/* ============================================================
   Teams Softphone – Kompakt – Stylesheet
   Disziplinierte Palette, ein Akzent für "Anrufen", klarer
   Rot-Ton für "Auflegen". Kein Dialpad – eigenständiges
   Statusfenster für den aktuellen Anruf.
   ============================================================ */

:root[data-theme="light"] {
  --bg: #f3f5f8;
  --surface: #ffffff;
  --surface-2: #eef1f6;
  --border: #dde2ea;
  --text: #1b2230;
  --text-dim: #6a7382;
  --accent: #1f9d6b;        /* Anruf-Grün  */
  --accent-press: #167a52;
  --danger: #d8453b;
  --danger-press: #b53329;
  --hold: #c8851a;
  --connected: #1f9d6b;
  --shadow: 0 1px 2px rgba(20, 30, 50, .06), 0 8px 24px rgba(20, 30, 50, .06);
  --key-shadow: 0 1px 0 rgba(0,0,0,.04), 0 2px 4px rgba(20,30,50,.10);
}

:root[data-theme="dark"] {
  --bg: #0f141c;
  --surface: #18202b;
  --surface-2: #212c39;
  --border: #2a3644;
  --text: #e7ecf3;
  --text-dim: #8b97a7;
  --accent: #2fb985;
  --accent-press: #25966b;
  --danger: #e25a50;
  --danger-press: #c7463d;
  --hold: #e0a132;
  --connected: #2fb985;
  --shadow: 0 1px 2px rgba(0,0,0,.4), 0 12px 32px rgba(0,0,0,.35);
  --key-shadow: 0 1px 0 rgba(0,0,0,.3), 0 2px 6px rgba(0,0,0,.4);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

/* --- Topbar --- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 22px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 650; letter-spacing: .2px; }
.brand .dot {
  width: 11px; height: 11px; border-radius: 50%;
  background: var(--accent); box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 22%, transparent);
}
.topbar-right { display: flex; align-items: center; gap: 12px; }
.user-name { color: var(--text-dim); font-size: 14px; }
.icon-btn {
  background: none; border: 1px solid var(--border); color: var(--text);
  width: 34px; height: 34px; border-radius: 8px; cursor: pointer; font-size: 16px;
}
.icon-btn:hover { background: var(--surface-2); }

/* --- Sprachumschalter in der Topbar --- */
.lang-switch {
  display: flex; align-items: center; gap: 2px;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 9px;
  padding: 2px;
}
.lang-btn {
  background: none; border: none; color: var(--text-dim); cursor: pointer;
  padding: 5px 9px; border-radius: 7px; font-size: 12px; font-weight: 700;
  letter-spacing: .3px;
}
.lang-btn:hover { color: var(--text); }
.lang-btn.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }

/* --- Layout --- */
.layout {
  display: grid; grid-template-columns: 1fr; gap: 22px;
  max-width: 720px; margin: 22px auto 28px; padding: 0;
}
.panel {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 16px; box-shadow: var(--shadow);
}

/* --- Statusfenster: aktueller Anruf --- */
.call-status-panel {
  max-width: 720px; margin: 28px auto 0; padding: 20px 22px;
  transition: box-shadow .15s ease, border-color .15s ease;
}
.call-status-head {
  display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px;
}
.call-status-head h2 {
  font-size: 12px; margin: 0; letter-spacing: 1px; text-transform: uppercase; color: var(--text-dim);
}
.call-timer {
  font-variant-numeric: tabular-nums; font-feature-settings: "tnum";
  font-weight: 700; color: var(--connected);
}
/* Aktiver/klingelnder Anruf: deutlich hervorgehoben (Fokus-Schatten) */
.call-status-panel.active,
.call-status-panel.ringing {
  border-color: color-mix(in srgb, var(--accent) 45%, var(--border));
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 16%, transparent), var(--shadow);
}

/* --- Statuszeile --- */
.state {
  text-align: center; font-size: 13px; font-weight: 600; letter-spacing: .4px;
  text-transform: uppercase; padding: 6px 0; color: var(--text-dim);
}
.state.connected { color: var(--connected); }
.state.hold { color: var(--hold); }
.state.error { color: var(--danger); }
.state.active { color: var(--accent); }
.peer { text-align: center; min-height: 22px; font-weight: 600; color: var(--text); font-size: 18px; }

/* --- Ruhezustand-Hinweis (Wahl nur über Verzeichnis) --- */
.idle-hint { text-align: center; color: var(--text-dim); font-size: 13.5px; margin-top: 16px; }

/* --- Video im Statusfenster --- */
.video-area {
  position: relative; margin-top: 16px; border-radius: 12px; overflow: hidden;
  background: #000; aspect-ratio: 16 / 9;
}
.remote-video { width: 100%; height: 100%; }
.remote-video video { width: 100%; height: 100%; object-fit: cover; }
.local-video {
  position: absolute; right: 10px; bottom: 10px; width: 26%; max-width: 160px;
  aspect-ratio: 16 / 9; border-radius: 8px; overflow: hidden;
  border: 2px solid var(--surface); box-shadow: var(--shadow);
}
.local-video video { width: 100%; height: 100%; object-fit: cover; }
/* Wenn nur das eigene Bild vorliegt (Gegenseite sendet noch kein Video),
   füllt die Vorschau die ganze Fläche statt als kleines PiP zu erscheinen. */
.video-area.local-only .local-video {
  position: static; width: 100%; max-width: none; aspect-ratio: auto;
  border: none; box-shadow: none; height: 100%;
}

/* --- Eingehender Anruf: inline im Statusfenster --- */
.incoming-inline { text-align: center; margin-top: 16px; animation: pop .18s ease; }
.incoming-label { font-size: 12px; letter-spacing: 1px; text-transform: uppercase; color: var(--text-dim); }
.incoming-actions { display: flex; gap: 12px; justify-content: center; margin-top: 12px; }
@keyframes pop { from { transform: scale(.94); opacity: 0; } to { transform: scale(1); opacity: 1; } }

/* --- Aktionsleiste im Gespräch: bewusst nur "Auflegen" --- */
.call-controls {
  display: flex; justify-content: center; margin-top: 18px;
}
.call-controls .btn { min-width: 160px; }
.hidden { display: none !important; }

.btn {
  border: 1px solid var(--border); background: var(--surface-2); color: var(--text);
  padding: 11px 14px; border-radius: 11px; font-size: 14px; font-weight: 600;
  cursor: pointer; transition: background .15s ease, transform .06s ease;
}
.btn:hover { background: var(--surface); }
.btn:active { transform: translateY(1px); }
.btn.small { padding: 11px 8px; }
.btn.ghost.on { background: var(--accent); color: #fff; border-color: transparent; }

.btn.primary { background: var(--accent); color: #fff; border-color: transparent; }
.btn.primary:hover { background: var(--accent-press); }
.btn.call { background: var(--accent); color: #fff; border-color: transparent; }
.btn.call:hover { background: var(--accent-press); }
.btn.danger { background: var(--danger); color: #fff; border-color: transparent; }
.btn.danger:hover { background: var(--danger-press); }

/* --- Verzeichnis --- */
.directory-panel { padding: 18px 18px 8px; display: flex; flex-direction: column; }
.dir-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.dir-head h2 { font-size: 15px; margin: 0; letter-spacing: .3px; }
.search {
  flex: 1; max-width: 396px; padding: 9px 12px; border-radius: 10px;
  border: 1px solid var(--border); background: var(--surface-2); color: var(--text);
}
.search:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.directory { overflow-y: auto; max-height: 60vh; }
.dir-row {
  display: grid; grid-template-columns: auto 1fr auto; gap: 12px; align-items: center;
  padding: 10px 6px; border-bottom: 1px solid var(--border);
}
.dir-row:last-child { border-bottom: none; }
.avatar {
  width: 38px; height: 38px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: color-mix(in srgb, var(--accent) 16%, transparent);
  color: var(--accent); font-weight: 700; font-size: 13px;
}
.dir-name { font-weight: 600; }
.dir-sub { font-size: 12.5px; color: var(--text-dim); }
.dir-actions { display: flex; gap: 6px; }
.btn-call {
  border: 1px solid var(--border); background: var(--surface-2); color: var(--text);
  padding: 9px 18px; border-radius: 13.5px; font-size: 18.75px; font-weight: 600; cursor: pointer;
}
.btn-call:hover { background: var(--accent); color: #fff; border-color: transparent; }
.btn-call.ghost:hover { background: var(--surface); color: var(--text); border-color: var(--border); }
.empty { color: var(--text-dim); font-size: 14px; padding: 8px 4px; }

/* --- Anmeldezustand --- */
#app.signed-out .layout,
#app.signed-out .call-status-panel,
#app.signed-out #btn-signout { display: none; }
#app:not(.signed-out) #btn-signin,
#app:not(.signed-out) .signin-hint { display: none; }
.signin-hint { text-align: center; color: var(--text-dim); margin-top: 60px; }

/* --- Toasts --- */
.toasts { position: fixed; right: 18px; bottom: 18px; display: flex; flex-direction: column; gap: 10px; z-index: 60; }
.toast {
  background: var(--surface); border: 1px solid var(--border); color: var(--text);
  padding: 12px 16px; border-radius: 11px; box-shadow: var(--shadow); max-width: 340px;
  opacity: 0; transform: translateY(8px); transition: opacity .25s ease, transform .25s ease;
  border-left: 3px solid var(--text-dim); font-size: 14px;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast.success { border-left-color: var(--accent); }
.toast.error { border-left-color: var(--danger); }
.toast.info { border-left-color: var(--text-dim); }

/* --- Responsiv --- */
@media (max-width: 820px) {
  .layout, .call-status-panel { padding-left: 16px; padding-right: 16px; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

/* --- Presence (Status) --- */
.presence-dot {
  position: relative; display: inline-block;
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--pres, #8a8886);
  box-shadow: 0 0 0 2px var(--surface); vertical-align: middle;
}
.presence-dot.lg { width: 15px; height: 15px; box-shadow: 0 0 0 3px var(--surface); }
.presence-dot.dnd::after {
  content: ""; position: absolute; top: 50%; left: 22%; right: 22%;
  height: 2px; transform: translateY(-50%); background: #fff; border-radius: 1px;
}

.avatar-wrap { position: relative; width: 38px; height: 38px; flex: none; }
.avatar-wrap .presence-dot { position: absolute; right: -2px; bottom: -2px; }
.presence-label { font-size: 12px; font-weight: 600; margin-top: 1px; }

/* Verzeichniszeile: Avatar-Spalte etwas breiter für den größeren Punkt */
.dir-row { grid-template-columns: 40px 1fr auto; }

/* --- Statusanzeige in der Topbar (fest "Online", nicht änderbar) --- */
.status-indicator {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--surface-2); border: 1px solid var(--border); color: var(--text);
  padding: 7px 12px; border-radius: 10px; font-size: 13.5px; font-weight: 600;
}
#app.signed-out .status-indicator { display: none; }

/* --- Splash Screen (nur aktiv, wenn SPLASH_SCREEN_URL konfiguriert ist) --- */
.splash-overlay {
  position: fixed; inset: 0; z-index: 200; background: #000;
}
.splash-frame { width: 100%; height: 100%; border: 0; display: block; }
