/*
 * Die App-Huelle nach der Bildvorlage: das Foto traegt die ganze Flaeche, die Seitenleiste liegt
 * als dunkles, **durchscheinendes** Panel darueber (in der Vorlage sieht man den Berg durch sie
 * hindurch), und der Mic-Schalter sitzt als Pille am unteren Ende der Seitenleiste — nicht als
 * schwebender Knopf in der Ecke wie in der vorherigen Fassung.
 */

/* --------------------------------------------------------------------- */
/* Szene: das Foto, sichtbar                                             */
/* --------------------------------------------------------------------- */

.scene {
  position: fixed;
  inset: 0;
  z-index: 0;
  background: var(--scene-image) center 32% / cover no-repeat;
  pointer-events: none;
}

/*
 * Nur zwei Baender, oben und unten — genau dort, wo Text direkt auf dem Foto steht (Uhr, Datum,
 * Wetter, Fusszeile). Die Bildmitte bleibt unangetastet: das ist der Unterschied zur vorherigen
 * Fassung, die das ganze Foto mit 72–86 % Deckkraft zugedeckt hatte. Beide Deckkraefte kommen
 * aus `ui/theme/palette.ts` und sind so klein wie der Textkontrast es zulaesst.
 */
.scene::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(
    180deg,
    var(--scrim-top) 0%,
    transparent 26%,
    transparent 68%,
    var(--scrim-bottom) 100%
  );
}

.app-shell {
  position: fixed;
  inset: 0;
  z-index: 1;
  display: flex;
  height: 100%;
}

/* --------------------------------------------------------------------- */
/* Seitenleiste                                                          */
/* --------------------------------------------------------------------- */

.sidebar {
  position: relative;
  flex: 0 0 var(--sidebar-width);
  width: var(--sidebar-width);
  display: flex;
  flex-direction: column;
  padding: 26px 0 20px;
  background: var(--bg-sidebar);
  backdrop-filter: blur(var(--glass-blur));
  -webkit-backdrop-filter: blur(var(--glass-blur));
  border-right: 1px solid var(--border);
  overflow: hidden;
  transition: width var(--motion-medium) var(--ease-standard);
}

.sidebar[data-collapsed="true"] {
  width: var(--sidebar-width-collapsed);
  flex-basis: var(--sidebar-width-collapsed);
}

.sidebar__head {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 0 22px;
  margin-bottom: 34px;
  min-height: 22px;
}

.sidebar__brand {
  display: flex;
  align-items: center;
  gap: 11px;
  min-width: 0;
  padding: 0;
}

.sidebar__emblem {
  flex: none;
  height: 17px;
  width: auto;
  color: var(--fg);
  opacity: 0.92;
}

.sidebar__name {
  font-weight: 400;
  letter-spacing: 0.26em;
  text-transform: uppercase;
  font-size: var(--text-xs);
  color: var(--fg);
  white-space: nowrap;
}

/* Der Einklapp-Schalter steht nicht in der Vorlage. Er bleibt trotzdem (die Funktion war
 * ausdruecklich zu erhalten), aber zurueckhaltend: erst beim Ueberfahren der Seitenleiste
 * sichtbar, damit er das ruhige Bild der Vorlage nicht stoert. */
.sidebar__collapse {
  margin-left: auto;
  flex: none;
  display: flex;
  color: var(--fg-faint);
  opacity: 0;
  transition: opacity var(--motion-fast) ease, color var(--motion-fast) ease;
}
.sidebar:hover .sidebar__collapse,
.sidebar__collapse:focus-visible {
  opacity: 1;
}
.sidebar__collapse svg {
  width: 15px;
  height: 15px;
}
.sidebar__collapse:hover {
  color: var(--fg);
}
.sidebar[data-collapsed="true"] .sidebar__collapse svg {
  transform: rotate(180deg);
}

.sidebar__nav {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
}

/*
 * Vollbreite Zeile mit Akzentbalken links — so macht es die Vorlage (kein eingerueckter,
 * abgerundeter Block wie in der vorherigen Fassung).
 */
.sidebar__link {
  position: relative;
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  padding: 13px 22px;
  font-size: var(--text-md);
  text-align: left;
  color: var(--fg-muted);
  white-space: nowrap;
  cursor: grab;
  transition: background var(--motion-fast) ease, color var(--motion-fast) ease;
}
.sidebar__link:active {
  cursor: grabbing;
}
.sidebar__link:hover {
  background: rgba(255, 255, 255, 0.04);
  color: var(--fg);
}
.sidebar__link--active {
  background: rgba(255, 255, 255, 0.055);
  color: var(--fg);
}
.sidebar__link--active::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 2px;
  background: var(--accent);
}

.sidebar__icon {
  flex: none;
  display: inline-flex;
  justify-content: center;
  width: 20px;
}
.sidebar__icon svg {
  width: 20px;
  height: 20px;
}

.sidebar[data-collapsed="true"] .sidebar__name,
.sidebar[data-collapsed="true"] .sidebar__label {
  display: none;
}
.sidebar[data-collapsed="true"] .sidebar__link {
  justify-content: center;
  padding: 13px 0;
}
.sidebar[data-collapsed="true"] .sidebar__head {
  justify-content: center;
  padding: 0 12px;
}

.sidebar__foot {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 16px 16px 0;
}

/* --------------------------------------------------------------------- */
/* Mic-Pille (Punkt 6) — in der Vorlage unten in der Seitenleiste        */
/* --------------------------------------------------------------------- */

.mic-dock {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 6px 6px 14px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.03);
}

.mic-dock__wave {
  flex: none;
  display: inline-flex;
  align-items: flex-end;
  gap: 2px;
  height: 16px;
  color: var(--fg-muted);
}

.mic-dock__wave span {
  display: block;
  width: 2px;
  border-radius: 1px;
  background: currentcolor;
  height: 5px;
  opacity: 0.75;
}

.mic-dock__label {
  flex: 1;
  min-width: 0;
  font-size: var(--text-sm);
  color: var(--fg-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.mic-button {
  position: relative;
  flex: none;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.05);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--fg-muted);
  transition: color var(--motion-fast) ease, border-color var(--motion-fast) ease;
}
.mic-button:hover {
  color: var(--fg);
}
.mic-button svg {
  width: 15px;
  height: 15px;
  position: relative;
  z-index: 1;
}

.mic-button__ring {
  position: absolute;
  inset: -1px;
  border-radius: 50%;
  border: 1px solid var(--fg-muted);
  opacity: 0;
}

/*
 * Die sechs Zustaende (Punkt 6): unterschieden ueber Form, Bewegungsruhe und Deckkraft — nie
 * ueber Farbe, nie ueber Leuchten. Die Wellenbalken links tragen die Bewegung, der Ring die
 * Form.
 */
.sidebar[data-agent-state="listening"] .mic-dock__wave span {
  animation: wave-breathe 1.9s var(--ease-standard) infinite;
}
.sidebar[data-agent-state="listening"] .mic-dock__wave span:nth-child(2) {
  animation-delay: 0.18s;
}
.sidebar[data-agent-state="listening"] .mic-dock__wave span:nth-child(3) {
  animation-delay: 0.36s;
}
.sidebar[data-agent-state="listening"] .mic-dock__wave span:nth-child(4) {
  animation-delay: 0.54s;
}
.sidebar[data-agent-state="listening"] .mic-dock__wave span:nth-child(5) {
  animation-delay: 0.72s;
}
.sidebar[data-agent-state="listening"] .mic-button,
.sidebar[data-agent-state="speaking"] .mic-button,
.sidebar[data-agent-state="executing"] .mic-button {
  color: var(--fg);
  border-color: var(--fg-muted);
}
.sidebar[data-agent-state="listening"] .mic-button__ring {
  opacity: 0.55;
  animation: mic-breathe var(--motion-slow) var(--ease-standard) infinite;
}
.sidebar[data-agent-state="thinking"] .mic-button__ring {
  opacity: 0.5;
  border-style: dashed;
  animation: mic-rotate 3.4s linear infinite;
}
.sidebar[data-agent-state="speaking"] .mic-dock__wave span {
  animation: wave-speak 0.9s var(--ease-standard) infinite;
}
.sidebar[data-agent-state="speaking"] .mic-dock__wave span:nth-child(2) {
  animation-delay: 0.1s;
}
.sidebar[data-agent-state="speaking"] .mic-dock__wave span:nth-child(3) {
  animation-delay: 0.2s;
}
.sidebar[data-agent-state="speaking"] .mic-dock__wave span:nth-child(4) {
  animation-delay: 0.3s;
}
.sidebar[data-agent-state="speaking"] .mic-dock__wave span:nth-child(5) {
  animation-delay: 0.4s;
}
.sidebar[data-agent-state="executing"] .mic-button__ring {
  opacity: 0.7;
  border-width: 2px;
  border-top-color: transparent;
  animation: mic-rotate 1.2s linear infinite;
}
.sidebar[data-agent-state="complete"] .mic-button__ring {
  opacity: 0.85;
  border-color: var(--fg);
}

@keyframes wave-breathe {
  0%,
  100% {
    height: 4px;
    opacity: 0.5;
  }
  50% {
    height: 14px;
    opacity: 0.95;
  }
}

@keyframes wave-speak {
  0%,
  100% {
    height: 3px;
  }
  50% {
    height: 16px;
  }
}

@keyframes mic-breathe {
  0%,
  100% {
    transform: scale(1);
    opacity: 0.25;
  }
  50% {
    transform: scale(1.16);
    opacity: 0.6;
  }
}

@keyframes mic-rotate {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

.sidebar[data-collapsed="true"] .mic-dock {
  padding: 6px;
  justify-content: center;
}
.sidebar[data-collapsed="true"] .mic-dock__wave,
.sidebar[data-collapsed="true"] .mic-dock__label {
  display: none;
}

/* --------------------------------------------------------------------- */
/* Verbindungsstatus ("System Online" in der Vorlage)                    */
/* --------------------------------------------------------------------- */

.sidebar__status {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 0 8px;
  font-size: var(--text-2xs);
  color: var(--fg-muted);
  cursor: pointer;
  background: none;
  width: 100%;
  text-align: left;
}
.sidebar__status:hover {
  color: var(--fg);
}

.sidebar__dot {
  flex: none;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--fg-faint);
}
.sidebar__dot[data-status="open"] {
  background: var(--state-complete);
}
.sidebar__dot[data-status="connecting"] {
  background: var(--state-awaiting);
}
.sidebar__dot[data-status="closed"] {
  background: var(--state-error);
}

.sidebar__status-chevron {
  margin-left: auto;
  width: 12px;
  height: 12px;
  color: var(--fg-faint);
}
.sidebar[data-collapsed="true"] .sidebar__status {
  justify-content: center;
  padding: 0;
}
.sidebar[data-collapsed="true"] .sidebar__status-chevron {
  display: none;
}

/* --------------------------------------------------------------------- */
/* Ansichts-Auslass                                                      */
/* --------------------------------------------------------------------- */

#view-outlet {
  flex: 1 1 auto;
  min-width: 0;
  position: relative;
  overflow-y: auto;
  height: 100%;
}

/* --------------------------------------------------------------------- */
/* Hinweis-Toast                                                         */
/* --------------------------------------------------------------------- */

/* --------------------------------------------------------------------- */
/* Eingabezeile für einen neuen Auftrag (`ui/compose.ts`)                 */
/* --------------------------------------------------------------------- */

.composer {
  position: fixed;
  right: 28px;
  bottom: 28px;
  z-index: 45;
  width: min(420px, calc(100vw - 56px));
  padding: 16px 18px 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.composer__head {
  display: flex;
  align-items: center;
  gap: 12px;
}

.composer__title {
  font-size: var(--text-xs);
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--fg-muted);
}

.composer__close {
  margin-left: auto;
  display: inline-flex;
  color: var(--fg-faint);
}
.composer__close svg {
  width: 15px;
  height: 15px;
}
.composer__close:hover {
  color: var(--fg);
}

.composer__input {
  width: 100%;
  resize: vertical;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.04);
  color: var(--fg);
  font: inherit;
  font-size: var(--text-sm);
  line-height: 1.5;
}

.composer__row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.composer__status {
  flex: 1;
  min-width: 0;
  font-size: var(--text-xs);
  color: var(--fg-faint);
}
.composer__status[data-kind="error"] {
  color: var(--state-error);
}

.composer__send {
  padding: 8px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: var(--text-sm);
  color: var(--fg);
}
.composer__send:hover:not(:disabled) {
  border-color: var(--accent);
  color: var(--accent);
}
.composer__send:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.composer__replies:empty {
  display: none;
}

.composer__reply {
  margin: 0 0 8px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.04);
  font-size: var(--text-sm);
  color: var(--fg);
  white-space: pre-wrap;
}
.composer__reply--ask {
  color: var(--state-awaiting);
  white-space: normal;
}

.composer__question {
  margin: 0 0 10px;
}

.composer__choices {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.composer__choice {
  flex: 1 1 auto;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: var(--text-sm);
  text-align: left;
  color: var(--fg);
}
.composer__choice:hover {
  border-color: var(--state-awaiting);
  color: var(--state-awaiting);
}

.composer__live {
  margin: 0 0 8px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border-left: 2px solid var(--state-awaiting);
  background: rgba(255, 255, 255, 0.04);
  font-size: var(--text-sm);
  color: var(--fg);
  white-space: pre-wrap;
}

/* --------------------------------------------------------------------- */
/* Fokus-Modus                                                           */
/* --------------------------------------------------------------------- */

body[data-focus="on"] .sidebar,
body[data-focus="on"] .cockpit__grid,
body[data-focus="on"] .band,
body[data-focus="on"] .weather {
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--motion-medium) var(--ease-standard);
}

body[data-focus="on"] .cockpit__clock {
  left: 50%;
  transition: left var(--motion-medium) var(--ease-standard);
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 40px;
  transform: translateX(-50%);
  z-index: 50;
  max-width: min(440px, calc(100vw - 48px));
  padding: 11px 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-panel-solid);
  box-shadow: var(--shadow-card);
  font-size: var(--text-sm);
  color: var(--fg);
}

@media (max-width: 860px) {
  .sidebar {
    width: var(--sidebar-width-collapsed);
    flex-basis: var(--sidebar-width-collapsed);
  }
  .sidebar__name,
  .sidebar__label,
  .mic-dock__wave,
  .mic-dock__label,
  .sidebar__status-chevron {
    display: none;
  }
  .sidebar__link {
    justify-content: center;
    padding: 13px 0;
  }
  .sidebar__head {
    justify-content: center;
    padding: 0 12px;
  }
  .mic-dock {
    padding: 6px;
    justify-content: center;
  }
  .sidebar__status {
    justify-content: center;
    padding: 0;
  }
}
