/* ARIS Web-App: dunkle Oberfläche, ein Akzent pro Farbthema (Blau, Grün, Rot). */

:root {
  --bg: #04060b;
  --bg-2: #0a0f1a;
  --surface: rgba(255, 255, 255, 0.04);
  --surface-2: rgba(255, 255, 255, 0.07);
  --border: rgba(255, 255, 255, 0.09);
  --text: #e9eef7;
  --muted: #8b95a8;
  --radius: 18px;
  --font: "Inter", "Segoe UI", system-ui, -apple-system, Roboto, "Noto Sans Arabic", "Noto Kufi Arabic", sans-serif;
}

/* Jedes Thema: Hauptfarbe, zweite Farbe für Verläufe, und ein Rot-Grün-Blau-Tripel für Leuchten. */
[data-theme="blue"] {
  --accent: #38b6ff;
  --accent-2: #7c5cff;
  --accent-rgb: 56, 182, 255;
  --accent-2-rgb: 124, 92, 255;
}
[data-theme="green"] {
  --accent: #2df5a8;
  --accent-2: #00c2d1;
  --accent-rgb: 45, 245, 168;
  --accent-2-rgb: 0, 194, 209;
}
[data-theme="red"] {
  --accent: #ff4d6d;
  --accent-2: #ff9f43;
  --accent-rgb: 255, 77, 109;
  --accent-2-rgb: 255, 159, 67;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
}

body {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  grid-template-columns: minmax(0, 1fr);
  min-height: 100dvh;
  overflow: hidden;
}

.backdrop {
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(60vmax 60vmax at 50% 30%, rgba(var(--accent-rgb), 0.16), transparent 60%),
    radial-gradient(50vmax 40vmax at 85% 90%, rgba(var(--accent-2-rgb), 0.12), transparent 60%),
    linear-gradient(180deg, var(--bg-2), var(--bg));
  transition: background 0.6s ease;
}
.backdrop::after {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.025) 1px, transparent 1px);
  background-size: 44px 44px;
  mask-image: radial-gradient(ellipse at 50% 40%, black 20%, transparent 75%);
}

/* Kopfzeile */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: max(14px, env(safe-area-inset-top)) 20px 10px;
}
.brand { display: flex; align-items: baseline; gap: 14px; min-width: 0; }
.brand-name {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 0.32em;
  background: linear-gradient(90deg, var(--text), var(--accent));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.status { display: inline-flex; align-items: center; gap: 7px; font-size: 12px; color: var(--muted); white-space: nowrap; }
.status-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--muted);
  box-shadow: 0 0 0 0 transparent;
}
.status.online .status-dot { background: var(--accent); box-shadow: 0 0 10px rgba(var(--accent-rgb), 0.9); }
.status.offline .status-dot { background: #ff5c5c; }
.model-chip {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  padding: 3px 9px;
  border-radius: 999px;
  color: var(--accent);
  background: rgba(var(--accent-rgb), 0.1);
  border: 1px solid rgba(var(--accent-rgb), 0.3);
  white-space: nowrap;
}

.controls { display: flex; align-items: center; gap: 8px; }
.themes { display: flex; gap: 6px; padding: 6px 8px; border: 1px solid var(--border); border-radius: 999px; background: var(--surface); }
.theme-dot {
  width: 18px; height: 18px; border-radius: 50%; border: 0; padding: 0; cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.theme-dot[data-theme-choice="blue"] { background: linear-gradient(135deg, #38b6ff, #7c5cff); }
.theme-dot[data-theme-choice="green"] { background: linear-gradient(135deg, #2df5a8, #00c2d1); }
.theme-dot[data-theme-choice="red"] { background: linear-gradient(135deg, #ff4d6d, #ff9f43); }
.theme-dot[aria-checked="true"] { transform: scale(1.15); box-shadow: 0 0 0 2px var(--bg), 0 0 0 3.5px var(--text); }
.theme-dot:hover { transform: scale(1.12); }

.pill, .icon-btn {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease;
}
.pill { height: 32px; min-width: 44px; padding: 0 12px; font: 600 12px var(--font); letter-spacing: 0.08em; }
.pill.strong { background: var(--accent); color: #04060b; border-color: transparent; }
.icon-btn { width: 32px; height: 32px; display: grid; place-items: center; padding: 0; }
.icon-btn svg, .mic svg, .send svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.pill:hover, .icon-btn:hover { background: var(--surface-2); border-color: rgba(var(--accent-rgb), 0.5); }
#voice-toggle.muted .wave { opacity: 0.2; }

/* Dashboard: links Heute und System, in der Mitte der Orb, rechts Freigaben und Kosten */
.dash {
  display: grid;
  grid-template-columns: minmax(260px, 320px) minmax(0, 1fr) minmax(280px, 360px);
  gap: 24px;
  padding: 12px 24px max(20px, env(safe-area-inset-bottom));
  min-height: 0;
}
.col { display: flex; flex-direction: column; justify-content: center; gap: 14px; min-height: 0; overflow-y: auto; }
.center { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px; min-width: 0; min-height: 0; }
/* Die Leinwand liegt absolut im Rahmen: so bestimmt der Rahmen die Größe, nie die Leinwand selbst
   (sonst wächst sie sich mit dem ResizeObserver immer weiter auf). */
.orb-wrap { position: relative; width: 100%; flex: 1 1 0; min-height: 220px; max-height: 62vh; }
#orb { position: absolute; inset: 0; width: 100%; height: 100%; }
.orb-label {
  position: absolute;
  inset-inline: 0;
  text-align: center;
  bottom: 4%;
  font-size: 12px;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: rgba(var(--accent-rgb), 0.85);
  min-height: 1em;
}
/* Nur wenn Vorlesen aus ist: die letzte Antwort kurz unter dem Orb, sonst bekäme man sie gar nicht mit. */
.caption {
  margin: 0; max-width: 620px; text-align: center; color: var(--text); font-size: 15px; line-height: 1.5;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
  animation: rise 0.28s ease both;
}
.caption[hidden] { display: none; }
/* Wichtiger Hinweis (z. B. Mikro blockiert): ganz lesbar, nicht nach drei Zeilen abgeschnitten. */
.caption.notice {
  display: block; -webkit-line-clamp: unset; font-size: 14px; text-align: start;
  padding: 10px 14px; border-radius: 12px;
  border: 1px solid rgba(255, 159, 67, 0.45); background: rgba(255, 159, 67, 0.08);
}
/* iPhone: kein Dauer-Zuhören, darum kein „Hey ARIS“-Schalter. */
.tap-only #talk { display: none; }

.card {
  border: 1px solid rgba(var(--accent-rgb), 0.2);
  border-radius: 16px;
  padding: 14px 16px;
  background: rgba(8, 18, 40, 0.55);
  backdrop-filter: blur(10px);
  display: flex; flex-direction: column; gap: 10px;
  min-width: 0;
}
.card-title {
  margin: 0; display: flex; justify-content: space-between; align-items: center; gap: 8px;
  font-size: 11px; font-weight: 500; letter-spacing: 0.22em; text-transform: uppercase; color: var(--muted);
}
.card-title > :not(:first-child) { letter-spacing: 0.04em; text-transform: none; }
.mono { font-family: "JetBrains Mono", ui-monospace, Consolas, monospace; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.strong { font-weight: 600; }
.card p { margin: 0; }
.items { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; font-size: 13px; }
.items li { display: flex; gap: 12px; min-width: 0; }
.items .when { flex: none; width: 46px; font-size: 12px; color: var(--accent); font-family: "JetBrains Mono", ui-monospace, Consolas, monospace; }
.items .when.alarm-time { color: #2df5a8; }
.items .what { min-width: 0; overflow-wrap: anywhere; }
.items .empty { color: var(--muted); }
.decide { display: flex; gap: 8px; margin-top: 8px; }
.decide-btn {
  min-height: 32px; padding: 0 14px; border-radius: 10px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  font: 600 12px var(--font); cursor: pointer;
}
.decide-btn.yes { border-color: rgba(45, 245, 168, 0.55); color: #2df5a8; }
.decide-btn.no { border-color: rgba(255, 92, 92, 0.5); color: #ff7a7a; }
.decide-btn:hover { background: var(--surface-2); }
.decide-btn[disabled] { opacity: 0.45; cursor: not-allowed; }
.weather { display: flex; align-items: baseline; gap: 12px; }
.temp { font-size: 30px; font-weight: 500; line-height: 1; }
.rows { margin: 0; display: grid; grid-template-columns: auto 1fr; gap: 8px 12px; font-size: 13px; }
.rows dt { color: var(--muted); }
.rows dd { margin: 0; text-align: end; overflow-wrap: anywhere; }
.ok { color: #2df5a8; }
.warn { color: #f2b03d; }
.approvals { border-color: rgba(242, 176, 61, 0.4); background: rgba(242, 176, 61, 0.05); }
.approvals .card-title > :first-child { color: #f2b03d; }
.live { color: #2df5a8; font-size: 11px; }
.live::before { content: "● "; }
.costs { display: flex; flex-direction: column; gap: 12px; }
.cost { display: flex; flex-direction: column; gap: 4px; font-size: 13px; }
.cost .line { display: flex; justify-content: space-between; gap: 12px; }
.cost .line > :last-child { white-space: nowrap; text-align: end; }
.cost .sub { font-size: 12px; color: var(--muted); }
.track { height: 4px; border-radius: 2px; background: rgba(255, 255, 255, 0.08); overflow: hidden; }
.fill { height: 100%; border-radius: 2px; background: var(--accent); }
.music-row { display: flex; align-items: center; gap: 12px; font-size: 13px; }
.cover { width: 40px; height: 40px; flex: none; border-radius: 10px; background: linear-gradient(135deg, rgba(var(--accent-2-rgb), 0.6), var(--accent)); opacity: 0.5; }

.quick { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; }
.quick-btn {
  min-height: 40px; padding: 0 16px; border-radius: 12px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  font: 500 13px var(--font); cursor: pointer;
  transition: border-color 0.2s ease, background 0.2s ease;
}
.quick-btn:hover { border-color: rgba(var(--accent-rgb), 0.55); background: var(--surface-2); }
.quick-btn#q-call { border-color: rgba(var(--accent-rgb), 0.45); }
.quick-btn[disabled] { opacity: 0.45; cursor: not-allowed; }
.clock { font-family: "JetBrains Mono", ui-monospace, Consolas, monospace; font-size: 13px; color: var(--muted); white-space: nowrap; }
.history-btn { display: inline-flex; align-items: center; gap: 7px; letter-spacing: 0.02em; }
.history-btn svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.history-btn[aria-expanded="true"] { border-color: rgba(var(--accent-rgb), 0.6); color: var(--accent); }

.conversation {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 8px 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  mask-image: linear-gradient(180deg, transparent, black 40px);
  scroll-behavior: smooth;
}
/* Keine sichtbaren Scrollleisten: Scrollen geht weiter mit Mausrad, Touch und Tastatur. */
* { scrollbar-width: none; }
*::-webkit-scrollbar { display: none; width: 0; height: 0; }
/* Wenige Nachrichten stehen unten am Eingabefeld, nicht oben unter dem Orb. */
.conversation > :first-child { margin-top: auto; }
.bubble {
  max-width: 88%;
  padding: 10px 14px;
  border-radius: var(--radius);
  line-height: 1.5;
  font-size: 15px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  animation: rise 0.28s ease both;
}
.bubble.user {
  align-self: flex-end;
  background: linear-gradient(135deg, rgba(var(--accent-rgb), 0.22), rgba(var(--accent-2-rgb), 0.18));
  border: 1px solid rgba(var(--accent-rgb), 0.35);
  border-end-end-radius: 6px;
}
.bubble.assistant {
  align-self: flex-start;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.055), rgba(255, 255, 255, 0.03));
  border: 1px solid var(--border);
  border-inline-start: 2px solid rgba(var(--accent-rgb), 0.7);
  border-end-start-radius: 6px;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.25);
}
.bubble.thinking { color: var(--muted); }
.bubble.thinking::after { content: "…"; animation: blink 1.2s infinite; }
.bubble.error { border-color: rgba(255, 92, 92, 0.5); color: #ffb3b3; }

/* Eingabe */
.composer {
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: 640px;
  width: 100%;
  margin: 0;
  padding: 8px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(10, 14, 24, 0.75);
  backdrop-filter: blur(14px);
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.45), 0 0 0 1px rgba(var(--accent-rgb), 0.06) inset;
}
.composer:focus-within { border-color: rgba(var(--accent-rgb), 0.55); }
.composer input {
  flex: 1;
  min-width: 0;
  background: transparent;
  border: 0;
  outline: none;
  color: var(--text);
  font: 15px var(--font);
  padding: 8px 4px;
}
.composer input::placeholder { color: var(--muted); }
.mic, .send {
  flex: none;
  width: 44px; height: 44px;
  border-radius: 50%;
  border: 0;
  display: grid; place-items: center;
  cursor: pointer;
  color: #04060b;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  transition: transform 0.15s ease, box-shadow 0.2s ease, opacity 0.2s ease;
}
.send { background: var(--surface-2); color: var(--text); }
.mic:hover, .send:hover { transform: scale(1.06); }
.mic.listening { box-shadow: 0 0 0 6px rgba(var(--accent-rgb), 0.18), 0 0 28px rgba(var(--accent-rgb), 0.8); animation: pulse 1.4s infinite; }
.mic[disabled] { opacity: 0.35; cursor: not-allowed; }
.talk {
  flex: none;
  display: inline-flex; align-items: center; gap: 6px;
  height: 36px; padding: 0 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  font: 600 12px var(--font);
  cursor: pointer;
  transition: color 0.2s ease, background 0.2s ease, border-color 0.2s ease;
}
.talk svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; }
.talk:hover { color: var(--text); border-color: rgba(var(--accent-rgb), 0.5); }
.talk[aria-pressed="true"] {
  color: var(--accent);
  background: rgba(var(--accent-rgb), 0.12);
  border-color: rgba(var(--accent-rgb), 0.6);
  box-shadow: 0 0 18px rgba(var(--accent-rgb), 0.25);
}
[dir="rtl"] .send svg { transform: scaleX(-1); }

/* Verlauf und Aktionsprotokoll: Schubladen von rechts */
.log-panel, .history-panel {
  position: fixed;
  inset-block: 0;
  inset-inline-end: 0;
  width: min(380px, 92vw);
  background: rgba(8, 11, 19, 0.96);
  border-inline-start: 1px solid var(--border);
  backdrop-filter: blur(16px);
  transform: translateX(100%);
  transition: transform 0.3s ease;
  display: flex;
  flex-direction: column;
  z-index: 10;
}
[dir="rtl"] .log-panel, [dir="rtl"] .history-panel { transform: translateX(-100%); }
.log-panel.open, .history-panel.open { transform: translateX(0); }
.log-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 18px 8px; }
.log-head h2 { margin: 0; font-size: 15px; letter-spacing: 0.06em; }
.voice-pick { display: grid; gap: 6px; padding: 4px 18px 10px; font-size: 13px; color: var(--muted); }
.voice-pick select {
  width: 100%; padding: 8px 10px; border-radius: 10px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text); font: 14px var(--font);
}
.voice-pick select option { background: var(--bg-2); }
.log-list { list-style: none; margin: 0; padding: 8px 18px 24px; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; }
.log-item { padding: 10px 12px; border-radius: 12px; background: var(--surface); border: 1px solid var(--border); font-size: 13px; }
.log-item .row { display: flex; justify-content: space-between; gap: 8px; }
.log-item .tool { font-weight: 600; }
.log-item .time { color: var(--muted); font-size: 12px; }
.log-item .result { color: var(--muted); margin-top: 4px; }
.badge { display: inline-block; font-size: 11px; padding: 1px 8px; border-radius: 999px; border: 1px solid var(--border); margin-top: 6px; }
.badge.done { color: var(--accent); border-color: rgba(var(--accent-rgb), 0.45); }
.badge.dry_run { color: #ffd166; border-color: rgba(255, 209, 102, 0.45); }
.badge.error, .badge.rejected { color: #ff8a8a; border-color: rgba(255, 92, 92, 0.45); }
.badge.needs_approval { color: #c7a6ff; border-color: rgba(199, 166, 255, 0.45); }

/* Zugangscode */
dialog {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-2);
  color: var(--text);
  padding: 22px;
  width: min(360px, 90vw);
}
dialog::backdrop { background: rgba(0, 0, 0, 0.6); backdrop-filter: blur(4px); }
dialog h2 { margin: 0 0 6px; font-size: 17px; }
dialog p { margin: 0 0 14px; color: var(--muted); font-size: 14px; }
dialog input {
  width: 100%; padding: 10px 12px; margin-bottom: 14px; border-radius: 10px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text); font: 15px var(--font);
}

@keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes blink { 50% { opacity: 0.2; } }
@keyframes pulse { 50% { box-shadow: 0 0 0 10px rgba(var(--accent-rgb), 0.06), 0 0 34px rgba(var(--accent-rgb), 0.9); } }

/* Schmaler Bildschirm (Laptop klein): Spalten schmaler */
@media (max-width: 1200px) {
  .dash { grid-template-columns: minmax(230px, 270px) minmax(0, 1fr) minmax(250px, 300px); gap: 16px; padding-inline: 16px; }
  .talk #talk-label { display: none; }
  .quick { gap: 8px; }
  .quick-btn { padding: 0 11px; font-size: 12px; }
  .model-chip { display: none; }
}
@media (max-width: 1000px) {
  .clock { display: none; }
}

/* Handy und Tablet: alles untereinander, die Seite scrollt */
@media (max-width: 900px) {
  html, body { height: auto; }
  body { overflow-y: auto; grid-template-rows: auto auto; }
  .dash { display: flex; flex-direction: column; gap: 14px; padding: 4px 16px max(20px, env(safe-area-inset-bottom)); }
  .dash > *, .col > * { flex: none; }
  .center { order: -1; }
  .orb-wrap { flex: none; height: min(46vh, 90vw); max-height: none; }
  .col { overflow: visible; justify-content: flex-start; }
  .dash > .col:first-child { order: 1; }
}
@media (max-width: 560px) {
  .topbar { padding-inline: 14px; }
  .brand-name { font-size: 18px; }
  .status, .model-chip, .clock { display: none; }
  #talk-label { display: none; }
  .talk { width: 36px; padding: 0; justify-content: center; }
  .controls { gap: 5px; }
  .themes { gap: 5px; padding: 5px 6px; }
  .theme-dot { width: 15px; height: 15px; }
  .pill { min-width: 34px; padding: 0 9px; }
  .history-btn span { display: none; }
  .icon-btn { width: 30px; height: 30px; }
  .quick-btn { flex: 1 1 40%; }
  .bubble { max-width: 90%; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* Mit „warte“ unterbrochene Antwort: nur leise angezeigt */
.bubble.interrupted { opacity: 0.45; }

/* Wecker klingelt */
.alarm {
  position: fixed; top: 72px; left: 50%; transform: translateX(-50%); z-index: 30;
  display: flex; align-items: center; gap: 12px; padding: 10px 12px 10px 16px;
  max-width: calc(100vw - 32px);
  background: rgba(8, 12, 22, 0.94); border: 1px solid rgba(var(--accent-rgb), 0.6); border-radius: 999px;
  box-shadow: 0 0 40px rgba(var(--accent-rgb), 0.35);
  animation: alarm-pulse 1.2s ease-in-out infinite;
}
.alarm[hidden] { display: none; }
.alarm-icon { font-size: 20px; }
.alarm-label { font-weight: 600; }
@keyframes alarm-pulse { 50% { box-shadow: 0 0 70px rgba(var(--accent-rgb), 0.6); } }
@media (prefers-reduced-motion: reduce) { .alarm { animation: none; } }
