/* Theme-Variablen --------------------------------------------------------- */

:root {
  /* Dark theme ist Default, wird aber von .theme-light überschrieben */
  --bg: #020617;
  --bg-elevated: rgba(15, 23, 42, 0.9);
  --bg-elevated-soft: rgba(15, 23, 42, 0.7);
  --border-soft: rgba(148, 163, 184, 0.25);
  --accent: #38bdf8;
  --accent-soft: rgba(56, 189, 248, 0.15);
  --accent-strong: #0ea5e9;
  --text: #e5e7eb;
  --text-muted: #9ca3af;
  --danger: #f97373;
  --radius-lg: 16px;
  --radius-md: 10px;
  --radius-sm: 999px;
  --shadow-soft: 0 18px 45px rgba(15, 23, 42, 0.75);
}

:root.theme-dark {
  color-scheme: dark;
}

:root.theme-light {
  color-scheme: light;

  --bg: #f5f5f7;
  --bg-elevated: rgba(255, 255, 255, 0.92);
  --bg-elevated-soft: rgba(255, 255, 255, 0.9);
  --border-soft: rgba(210, 214, 220, 0.9);
  --accent: #0a84ff;
  --accent-soft: rgba(10, 132, 255, 0.12);
  --accent-strong: #0071e3;
  --text: #111827;
  --text-muted: #6b7280;
  --danger: #ff3b30;
  --shadow-soft: 0 18px 45px rgba(15, 23, 42, 0.1);
}

/* Reset / Basics ---------------------------------------------------------- */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
}

body {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "SF Pro Text",
    "Segoe UI", sans-serif;
  font-size: 14px;
  color: var(--text);
  background: radial-gradient(circle at top, #0f172a 0, #020617 55%, #000 100%);
}

/* App Shell --------------------------------------------------------------- */

.app-shell {
  width: 100%;
  max-width: 1320px;
  margin: 8px auto 40px;
  padding: 8px 14px 10px;
  border-radius: 16px;
  background: radial-gradient(
      circle at top left,
      rgba(56, 189, 248, 0.14),
      transparent 46%
    ),
    rgba(15, 23, 42, 0.96);
  border: 1px solid rgba(148, 163, 184, 0.28);
  box-shadow: var(--shadow-soft);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* Top Bar ----------------------------------------------------------------- */

.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 14px;
  border-radius: 16px;
  background: linear-gradient(
    135deg,
    rgba(15, 23, 42, 0.9),
    rgba(15, 23, 42, 0.7)
  );
  border: 1px solid rgba(148, 163, 184, 0.4);
  backdrop-filter: blur(18px);
}

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

.brand-logo {
  width: 32px;
  height: 32px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at top left, #38bdf8, #0f172a);
  font-weight: 700;
  letter-spacing: 0.04em;
  color: white;
  font-size: 18px;
}

.brand-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.brand-title {
  font-size: 15px;
  font-weight: 600;
}

.brand-subtitle {
  font-size: 12px;
  color: var(--text-muted);
}

.top-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

/* Pills & Buttons --------------------------------------------------------- */

.pill {
  display: inline-flex;
  align-items: center;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 11px;
  border: 1px solid rgba(148, 163, 184, 0.4);
}

.pill-grey {
  background: rgba(15, 23, 42, 0.9);
  color: var(--text-muted);
}

.pill-strong {
  background: rgba(15, 23, 42, 0.9);
  border-color: rgba(56, 189, 248, 0.7);
  color: var(--accent-strong);
}

button {
  font-family: inherit;
}

.btn-primary,
.btn-secondary {
  border-radius: 999px;
  padding: 7px 14px;
  border: 1px solid transparent;
  cursor: pointer;
  font-size: 13px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
  color: #0b1120;
  font-weight: 600;
  border-color: rgba(125, 211, 252, 0.8);
}

.btn-primary:hover {
  filter: brightness(1.06);
}

.btn-secondary {
  background: rgba(15, 23, 42, 0.9);
  border-color: rgba(148, 163, 184, 0.6);
  color: var(--text);
}

.btn-secondary:hover {
  border-color: rgba(148, 163, 184, 0.9);
}

/* Layout ------------------------------------------------------------------ */

.layout {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.panel {
  border-radius: 18px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-soft);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.panel-header h2 {
  margin: 0;
  font-size: 14px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #e5e7eb;
}

.panel-subtitle {
  margin: 4px 0 0;
  font-size: 12px;
  color: var(--text-muted);
}

.panel-chat {
  flex: 1.1;
  min-height: 360px;
}

.panel-modules {
  flex: 1;
  min-height: 360px;
}

/* Chat Tabs --------------------------------------------------------------- */

.chat-tabs {
  display: inline-flex;
  gap: 4px;
  padding: 4px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.9);
  border: 1px solid rgba(148, 163, 184, 0.4);
}

.chat-tab {
  border-radius: 999px;
  border: none;
  background: transparent;
  padding: 4px 10px;
  font-size: 12px;
  cursor: pointer;
  color: var(--text-muted);
}

.chat-tab.active {
  background: rgba(56, 189, 248, 0.14);
  color: var(--accent-strong);
}

/* Chat Log & Messages ----------------------------------------------------- */

.chat-log {
  margin-top: 10px;
  flex: 1;
  min-height: 180px;
  max-height: 360px;
  overflow-y: auto;
  padding: 10px;
  border-radius: 12px;
  background: radial-gradient(
      circle at top left,
      rgba(15, 23, 42, 0.96),
      rgba(15, 23, 42, 0.9)
    );
  border: 1px solid rgba(31, 41, 55, 0.9);
}

.chat-empty-state {
  font-size: 13px;
  color: var(--text-muted);
  padding: 8px 4px;
}

.chat-message {
  display: flex;
  margin-bottom: 8px;
}

.chat-message-bubble {
  max-width: 100%;
  padding: 8px 10px;
  border-radius: 10px;
  font-size: 13px;
}

.chat-message-user .chat-message-bubble {
  margin-left: auto;
  border-bottom-right-radius: 2px;
  background: linear-gradient(
    135deg,
    rgba(56, 189, 248, 0.16),
    rgba(37, 99, 235, 0.16)
  );
  border: 1px solid rgba(56, 189, 248, 0.5);
}

.chat-message-assistant .chat-message-bubble {
  margin-right: auto;
  border-bottom-left-radius: 2px;
  background: rgba(15, 23, 42, 0.95);
  border: 1px solid rgba(31, 41, 55, 0.95);
}

.chat-message-author {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 2px;
}

.chat-message-content {
  white-space: pre-wrap;
}

/* Chat Form --------------------------------------------------------------- */

.chat-form {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 8px;
}

.chat-input {
  width: 100%;
  resize: vertical;
  min-height: 72px;
  max-height: 160px;
  border-radius: 12px;
  border: 1px solid rgba(31, 41, 55, 0.95);
  background: rgba(15, 23, 42, 0.98);
  color: var(--text);
  padding: 8px 10px;
  font-family: inherit;
  font-size: 13px;
}

.chat-input:focus {
  outline: none;
  border-color: rgba(56, 189, 248, 0.75);
  box-shadow: 0 0 0 1px rgba(56, 189, 248, 0.5);
}

.chat-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  justify-content: flex-end;
  flex-wrap: wrap;
}

.chat-hints {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--text-muted);
  flex-wrap: wrap;
  gap: 6px;
}

.chat-hints code {
  padding: 1px 6px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.9);
  border: 1px solid rgba(148, 163, 184, 0.4);
}

/* Module Tabs ------------------------------------------------------------- */

.module-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.integration-tab {
  border-radius: 999px;
  border: 1px solid rgba(148, 163, 184, 0.4);
  background: rgba(15, 23, 42, 0.95);
  padding: 5px 11px;
  font-size: 12px;
  cursor: pointer;
  color: var(--text-muted);
}

.integration-tab.active {
  border-color: rgba(56, 189, 248, 0.9);
  background: rgba(15, 23, 42, 0.98);
  color: var(--accent-strong);
}

.modules-content {
  margin-top: 10px;
}

.integration-panel {
  display: none;
}

.integration-panel.active {
  display: block;
}

/* Module Cards ------------------------------------------------------------ */

.module-card {
  border-radius: 14px;
  padding: 10px 12px;
  background: radial-gradient(
      circle at top left,
      rgba(15, 23, 42, 0.98),
      rgba(15, 23, 42, 0.92)
    );
  border: 1px solid var(--border-soft);
}

.module-card-header {
  margin-bottom: 8px;
}

.module-card-title {
  font-size: 13px;
  font-weight: 600;
}

.module-card-subtitle {
  font-size: 12px;
  margin-top: 2px;
  color: var(--text-muted);
}

.module-card-body {
  font-size: 13px;
}

/* Threads / Sidebar ------------------------------------------------------ */

.thread-sidebar {
  width: 220px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px;
  border-radius: 12px;
  background: rgba(15, 23, 42, 0.92);
  border: 1px solid var(--border-soft);
}

.thread-button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 10px;
  background: transparent;
  color: var(--text);
  border: none;
  cursor: pointer;
  font-size: 13px;
  text-align: left;
}

.thread-button:hover {
  background: rgba(56, 189, 248, 0.06);
}

.thread-button.active {
  background: rgba(56, 189, 248, 0.12);
  color: var(--accent-strong);
}

.thread-delete {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  border-radius: 8px;
}

.thread-delete:hover {
  color: var(--danger);
  background: rgba(255, 255, 255, 0.02);
}

/* Knowledge / Drive / Slides lists --------------------------------------- */

.knowledge-list,
.drive-list,
.slides-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.knowledge-list li,
.drive-list li,
.slides-list li {
  padding: 8px 10px;
  border-radius: 8px;
  background: rgba(15, 23, 42, 0.96);
  border: 1px solid rgba(31, 41, 55, 0.95);
  font-size: 13px;
  color: var(--text);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.drive-header,
.slides-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
  font-size: 13px;
  color: var(--text-muted);
}


/* Kalender-Styles --------------------------------------------------------- */

.calendar-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
  flex-wrap: wrap;
}

.calendar-range-toggle {
  display: inline-flex;
  gap: 3px;
  padding: 2px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.95);
  border: 1px solid rgba(148, 163, 184, 0.5);
}

.calendar-range-toggle button {
  border: none;
  background: transparent;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 11px;
  cursor: pointer;
  opacity: 0.8;
  color: var(--text-muted);
}

.calendar-range-toggle button.active {
  background: rgba(56, 189, 248, 0.14);
  opacity: 1;
  color: var(--accent-strong);
}

.calendar-status {
  font-size: 11px;
  color: var(--text-muted);
}

.calendar-events {
  list-style: none;
  margin: 0;
  margin-top: 4px;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.calendar-event {
  display: flex;
  gap: 8px;
  padding: 6px 8px;
  border-radius: 10px;
  background: rgba(15, 23, 42, 0.96);
  border: 1px solid rgba(31, 41, 55, 0.95);
}

.calendar-event-time {
  min-width: 5.2rem;
  font-size: 11px;
  font-weight: 500;
  color: var(--text-muted);
}

.calendar-event-main {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.calendar-event-title {
  font-size: 13px;
  font-weight: 500;
}

.calendar-event-meta {
  font-size: 11px;
  color: var(--text-muted);
}

/* Settings / Selfcheck ---------------------------------------------------- */

.settings-section {
  margin-bottom: 14px;
}

.settings-section-header {
  margin-bottom: 6px;
}

.settings-section-title {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
}

.settings-section-subtitle {
  font-size: 12px;
  color: var(--text-muted);
}

.settings-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}

#selfcheck-status {
  font-size: 12px;
  color: var(--text-muted);
}

.selfcheck-log {
  margin: 0;
  padding: 8px;
  border-radius: 10px;
  background: rgba(15, 23, 42, 0.98);
  border: 1px solid rgba(31, 41, 55, 1);
  font-size: 11px;
  max-height: 180px;
  overflow-y: auto;
}

/* Theme Toggle ------------------------------------------------------------ */

.theme-toggle {
  display: inline-flex;
  gap: 4px;
  padding: 4px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.9);
  border: 1px solid rgba(148, 163, 184, 0.5);
}

.theme-choice {
  border-radius: 999px;
  border: none;
  background: transparent;
  padding: 3px 10px;
  font-size: 12px;
  cursor: pointer;
  color: var(--text-muted);
}

.theme-choice.active {
  background: rgba(56, 189, 248, 0.16);
  color: var(--accent-strong);
}

/* Responsive -------------------------------------------------------------- */

@media (min-width: 880px) {
  .layout {
    flex-direction: row;
  }

  .panel-chat,
  .panel-modules {
    min-height: 480px;
  }
}

@media (max-width: 640px) {
  .app-shell {
    margin: 0;
    border-radius: 0;
  }

  .top-bar {
    flex-direction: column;
    align-items: flex-start;
  }

  .chat-log {
    max-height: 260px;
  }
}

/* --- LIGHT THEME OVERRIDES (Apple-Style) --------------------------------- */

:root.theme-light body {
  background: radial-gradient(circle at top, #e5f0ff 0, #f5f5f7 50%, #f1f5f9 100%);
}

:root.theme-light .app-shell {
  background: linear-gradient(
      135deg,
      rgba(255, 255, 255, 0.9),
      rgba(248, 250, 252, 0.98)
    );
  border-color: rgba(209, 213, 219, 0.9);
}

:root.theme-light .top-bar {
  background: rgba(255, 255, 255, 0.82);
  border-color: rgba(209, 213, 219, 0.9);
}

:root.theme-light .pill-grey {
  background: rgba(248, 250, 252, 0.96);
  color: var(--text-muted);
}


:root.theme-light .pill-strong {
  background: rgba(239, 246, 255, 0.96);
  color: var(--accent-strong);
  border-color: rgba(129, 199, 255, 0.9);
}

:root.theme-light .pill {
  background: rgba(248, 250, 252, 0.98);
  border-color: rgba(209, 213, 219, 0.9);
  color: var(--text-muted);
}

:root.theme-light .btn-secondary {
  background: rgba(243, 244, 246, 0.98);
  border-color: rgba(209, 213, 219, 1);
  color: var(--text);
}

:root.theme-light .btn-secondary:hover {
  border-color: rgba(148, 163, 184, 1);
}

:root.theme-light .chat-hints code {
  background: rgba(248, 250, 252, 0.98);
  border-color: rgba(209, 213, 219, 0.9);
}

:root.theme-light .panel {
  background: var(--bg-elevated);
}

:root.theme-light .chat-log {
  background: linear-gradient(
    180deg,
    rgba(255, 255, 255, 0.92),
    rgba(248, 250, 252, 0.96)
  );
  border-color: rgba(209, 213, 219, 0.9);
}

:root.theme-light .chat-message-assistant .chat-message-bubble {
  background: rgba(255, 255, 255, 0.98);
  border-color: rgba(209, 213, 219, 0.9);
}

:root.theme-light .chat-message-user .chat-message-bubble {
  background: linear-gradient(
    135deg,
    rgba(10, 132, 255, 0.16),
    rgba(37, 99, 235, 0.1)
  );
  border-color: rgba(10, 132, 255, 0.45);
}

:root.theme-light .chat-input {
  background: rgba(255, 255, 255, 0.98);
  border-color: rgba(209, 213, 219, 1);
}

:root.theme-light .chat-input:focus {
  border-color: rgba(10, 132, 255, 0.8);
  box-shadow: 0 0 0 1px rgba(10, 132, 255, 0.4);
}

:root.theme-light .chat-tabs {
  background: rgba(248, 250, 252, 0.98);
  border-color: rgba(209, 213, 219, 0.9);
}

:root.theme-light .module-card {
  background: linear-gradient(
    135deg,
    rgba(255, 255, 255, 0.98),
    rgba(248, 250, 252, 0.98)
  );
  border-color: rgba(209, 213, 219, 0.9);
}

:root.theme-light .integration-tab {
  background: rgba(248, 250, 252, 0.98);
  border-color: rgba(209, 213, 219, 0.9);
}

:root.theme-light .integration-tab.active {
  background: rgba(239, 246, 255, 1);
  border-color: rgba(10, 132, 255, 0.7);
}

:root.theme-light .calendar-range-toggle {
  background: rgba(248, 250, 252, 0.98);
  border-color: rgba(209, 213, 219, 0.9);
}

:root.theme-light .calendar-event {
  background: rgba(255, 255, 255, 0.98);
  border-color: rgba(209, 213, 219, 0.9);
}

:root.theme-light .selfcheck-log {
  background: rgba(255, 255, 255, 0.98);
  border-color: rgba(209, 213, 219, 0.9);
}

:root.theme-light .theme-toggle {
  background: rgba(248, 250, 252, 0.98);
  border-color: rgba(209, 213, 219, 0.9);
}

:root.theme-light .theme-choice.active {
  background: rgba(10, 132, 255, 0.14);
}