/*
 * Desktop-Layout (ab 960px Breite, geladen via media-Attribut in index.html).
 * Gleiche Funktionen wie die mobile Ansicht, nur breiter angeordnet:
 * Kopfzeile mit Logo, Anruf-Karte links, Anrufhistorie rechts,
 * Profil/Ruhezeiten als Karte mit Seitennavigation.
 */

:root {
  --page-bg: #f4f4f6;
  --surface: #ffffff;
  --surface-border: rgba(15, 22, 34, 0.06);
  --surface-shadow: 0 1px 2px rgba(15, 22, 34, 0.04), 0 12px 32px rgba(15, 22, 34, 0.06);
  --surface-radius: 20px;
  --hover: rgba(114, 48, 255, 0.05);
  --sidebar-w: 340px;
  --desktop-maxw: 1120px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --page-bg: #0a0a0a;
    --surface: #161616;
    --surface-border: rgba(255, 255, 255, 0.06);
    --surface-shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 12px 32px rgba(0, 0, 0, 0.35);
    --hover: rgba(165, 163, 255, 0.07);
  }
}

body {
  background: var(--page-bg);
}

button {
  cursor: pointer;
}

button:focus-visible,
a:focus-visible {
  outline: 2px solid rgba(114, 48, 255, 0.8);
  outline-offset: 2px;
}

/* ---------- Grundraster ---------- */

.app {
  max-width: var(--desktop-maxw);
  padding: 0 32px 48px;
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  grid-template-areas:
    "top top"
    "side main";
  column-gap: 28px;
  row-gap: 24px;
  align-content: start;
}

.is-logged-out .app {
  align-content: center;
}

/* ---------- Kopfzeile ---------- */

.topbar {
  grid-area: top;
  padding: 24px 0 18px;
  border-bottom: 1px solid var(--divider);
}

.brand {
  gap: 16px;
}

.brand__mark {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding-right: 16px;
  border-right: 1px solid var(--divider);
  color: #7230ff;
}

.brand__logo {
  width: 38px;
  height: 30px;
}

.brand__logo use {
  fill: none;
  stroke: currentColor;
  stroke-width: 3;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.brand__name {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.2px;
}

.section-title {
  font-size: 18px;
  font-weight: 600;
  color: var(--muted);
}

.profile-link {
  width: 40px;
  height: 40px;
  transition: box-shadow 0.2s ease, transform 0.1s ease;
}

.profile-link:hover {
  box-shadow: 0 0 0 3px rgba(114, 48, 255, 0.25), 0 6px 16px rgba(0, 0, 0, 0.08);
}

.is-account-open .profile-link {
  box-shadow: 0 0 0 3px rgba(114, 48, 255, 0.6);
}

/* ---------- Anmeldung ---------- */

.auth {
  grid-column: 1 / -1;
  flex: none;
  flex-direction: row;
  align-items: stretch;
  justify-self: center;
  width: min(880px, 100%);
  min-height: 460px;
  margin: 48px 0;
  padding: 0;
  gap: 0;
  background: var(--surface);
  border: 1px solid var(--surface-border);
  border-radius: 24px;
  box-shadow: var(--surface-shadow);
  overflow: hidden;
}

.auth__logo {
  flex: 1 1 50%;
  flex-direction: column;
  gap: 20px;
  transform: none;
  padding: 48px;
  color: #fff;
  background: linear-gradient(150deg, #7230ff 0%, #5420c9 100%);
}

.auth__logo::after {
  content: "Familienfenster";
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.3px;
}

.auth__logo .logo {
  width: 150px;
  filter: drop-shadow(0 10px 24px rgba(0, 0, 0, 0.25));
}

.auth__logo .logo use {
  stroke: #fff;
}

.auth__card {
  flex: 1 1 50%;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 48px;
  border: 0;
  border-radius: 0;
  background: transparent;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}

.auth__card::before {
  display: none;
}

.auth__title {
  font-size: 28px;
}

.auth__subtitle {
  margin-bottom: 24px;
  font-size: 15px;
}

.auth__submit:hover:not(:disabled) {
  background: rgba(114, 48, 255, 0.85);
}

/* ---------- Anruf-Karte (links) ---------- */

.bottom-glass-panel {
  grid-area: side;
  position: sticky;
  top: 24px;
  bottom: auto;
  left: auto;
  align-self: start;
  width: auto;
  max-width: none;
  padding: 28px;
  transform: none;
  background: var(--surface);
  border: 1px solid var(--surface-border);
  border-radius: var(--surface-radius);
  box-shadow: var(--surface-shadow);
  z-index: 1;
}

.bottom-glass-panel.is-hidden,
.is-call-active .bottom-glass-panel {
  transform: none;
}

.call-cta {
  gap: 24px;
}

.call-cta__intro {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.call-cta__logo {
  width: 64px;
  height: 50px;
  margin-bottom: 8px;
  color: #7230ff;
}

.call-cta__logo use {
  fill: none;
  stroke: currentColor;
  stroke-width: 2.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.call-cta__title {
  margin: 0;
  font-size: 22px;
  line-height: 1.25;
}

.call-cta__text {
  margin: 0;
  font-size: 14px;
  line-height: 1.5;
  color: var(--muted);
}

.call-now-btn {
  height: 52px;
  min-height: 52px;
  font-size: 16px;
  background: #34c759;
  border-color: transparent;
  box-shadow: 0 10px 24px rgba(52, 199, 89, 0.28);
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}

.call-now-btn:hover:not(.is-disabled) {
  background: #2fb852;
  box-shadow: 0 12px 28px rgba(52, 199, 89, 0.36);
}

/* ---------- Anrufhistorie (rechts) ---------- */

.history {
  grid-area: main;
  align-self: start;
  min-height: 240px;
  padding: 8px 0;
  background: var(--surface);
  border: 1px solid var(--surface-border);
  border-radius: var(--surface-radius);
  box-shadow: var(--surface-shadow);
  overflow: hidden;
}

/* Ohne Anruf-Karte (z. B. Geräte-Key fehlt) nimmt die Liste die volle Breite ein */
.app:has(> #call-action-wrap[hidden]) .history {
  grid-column: 1 / -1;
}

.row {
  padding: 16px 28px;
  transition: background 0.15s ease;
}

.row:hover {
  background: var(--hover);
}

.dnd-banner {
  margin: 12px 20px 8px;
}

.empty {
  padding: 16px 28px 20px;
}

.history__loading {
  justify-content: center;
  padding: 48px 28px;
}

.key-gate {
  max-width: 480px;
  margin: 0 auto;
  padding: 56px 28px;
  text-align: center;
}

.key-gate__title {
  font-size: 22px;
}

.key-gate__text {
  font-size: 15px;
  color: var(--muted);
}

.access-form__submit:hover {
  background: rgba(114, 48, 255, 0.85);
}

/* ---------- Profil & Ruhezeiten ---------- */

.account {
  grid-column: 1 / -1;
}

body:not(.is-account-open) .account {
  display: none;
}

.account__card {
  max-width: none;
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  grid-template-areas:
    "nav nav"
    "tabs panel";
  column-gap: 40px;
  row-gap: 8px;
  padding: 28px 32px 36px;
  background: var(--surface);
  border: 1px solid var(--surface-border);
  border-radius: var(--surface-radius);
  box-shadow: var(--surface-shadow);
}

.account__nav {
  grid-area: nav;
  margin-bottom: 8px;
}

.account__back {
  font-size: 14px;
}

.account__back:hover {
  text-decoration: underline;
}

.account__tabs {
  grid-area: tabs;
  align-self: start;
  grid-template-columns: 1fr;
  gap: 4px;
  margin: 0;
  padding: 0;
  background: transparent;
  border: 0;
}

.account__tab {
  text-align: left;
  padding: 12px 16px;
  font-size: 15px;
}

.account__tab:hover:not([aria-selected="true"]) {
  background: var(--hover);
  color: var(--text);
}

.account__panel {
  grid-area: panel;
  min-width: 0;
  padding-left: 40px;
  border-left: 1px solid var(--divider);
}

.account__panel > .account__heading {
  font-size: 24px;
  margin-bottom: 6px;
}

.account__subtitle {
  max-width: 620px;
  font-size: 15px;
}

#account-form {
  max-width: 480px;
}

.account__logout {
  justify-self: start;
  width: auto;
  padding: 10px 22px;
}

.account__logout:hover {
  background: rgba(0, 0, 0, 0.04);
}

/* Ruhezeiten: aktive Regeln links, neue Regel rechts */
.account__section--dnd {
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  column-gap: 32px;
  row-gap: 12px;
  align-items: start;
}

.account__section--dnd > .account__heading,
.account__section--dnd > .account__title,
.account__section--dnd > .account__subtitle {
  grid-column: 1 / -1;
}

.account__section--dnd > .account__heading {
  margin: 0;
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--muted);
}

.account__section--dnd > .account__title {
  margin: 0;
  font-size: 24px;
}

.account__section--dnd > .account__subtitle {
  margin-bottom: 12px;
}

.dnd-list--active {
  grid-column: 1;
  grid-row: 4 / span 2;
}

.dnd-list--new {
  grid-column: 2;
  grid-row: 4;
}

.account__form--dnd {
  grid-column: 2;
  grid-row: 5;
  padding: 18px;
  border: 1px solid var(--divider);
  border-radius: 16px;
}

.dnd-days__grid {
  grid-template-columns: repeat(7, minmax(0, 1fr));
}

.dnd-day {
  flex-direction: column;
  justify-content: center;
  padding: 6px 0;
}

.dnd-range {
  grid-template-columns: 1fr 1fr;
}

.dnd-range__field .account__input {
  width: 100%;
}

.dnd-save:hover {
  background: rgba(114, 48, 255, 0.85);
}

.dnd-list__delete:hover {
  background: rgba(255, 93, 48, 0.22);
}

@media (prefers-color-scheme: dark) {
  .account__logout:hover {
    background: rgba(255, 255, 255, 0.06);
  }
}

/* ---------- Anruf-Overlay ---------- */

.call-overlay__remote {
  object-fit: contain;
}

.call-overlay__ringing:not([hidden]) {
  display: grid;
  align-content: center;
  margin-top: 0;
}

.call-overlay__local-wrapper {
  width: 260px;
  height: 170px;
  right: 32px;
}

.call-overlay__local-wrapper[data-position="bottom-left"],
.call-overlay__local-wrapper[data-position="bottom-right"] {
  bottom: 150px;
}

.call-overlay__local-wrapper.relaxed[data-position="bottom-left"],
.call-overlay__local-wrapper.relaxed[data-position="bottom-right"] {
  bottom: 40px;
}

.call-overlay__controls {
  max-width: 420px;
}

.call-btn:hover {
  background: rgba(255, 255, 255, 0.22);
}

.call-btn--hangup:hover {
  background: #e5352b;
}

.device-volume__btn:hover {
  background: rgba(255, 255, 255, 0.22);
}

/* Kartenschatten nicht abschneiden (mobil nutzt overflow für die Slide-Animation) */
.is-account-open .account {
  overflow: visible;
}

@media (prefers-color-scheme: dark) {
  .brand__mark,
  .call-cta__logo {
    color: #a78bfa;
  }
}
