/* ============================================================
   Swiftli Smart HR — Web-Demo
   App-Style: NavigationSplitView + DetailCard + Figtree
   Theme = system / light / dark, Default-Akzent = Blau
   ============================================================ */

:root {
  color-scheme: light dark;

  /* Default Akzent = Blau (wie in der App) */
  --accent: #007AFF;             /* SwiftUI .blue auf macOS */
  /* Soft/strong-Varianten leiten sich automatisch via color-mix ab —
     bleiben korrekt wenn der User den Akzent wechselt */
  --accent-soft: color-mix(in srgb, var(--accent) 15%, transparent);
  --accent-strong: color-mix(in srgb, var(--accent) 85%, transparent);

  /* Brand-Gradient — Default = Teal Depths (App-Default in Theme.swift). */
  --brand-gradient: linear-gradient(180deg, #0f2027 0%, #203a43 50%, #2c5364 100%);

  /* App-Layout */
  --banner-h: 44px;
  --topbar-h: 52px;
  --sidebar-w: 232px;
  --sidebar-rail-w: 56px;

  /* Corner-Radien (App nutzt 12pt durchgehend, 6pt für kleinere Items) */
  --radius-xs: 4px;
  --radius-sm: 6px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;

  /* Übergänge */
  --transition-fast: 0.15s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-normal: 0.25s cubic-bezier(0.4, 0, 0.2, 1);

  /* Tint-Intensität (entspricht uiTintIntensity Slider, default 0.5) */
  --tint-intensity: 0.5;
  --tint-amount: calc(var(--tint-intensity) * 0.30);

  /* Card-Opacity (entspricht cardOpacity Slider, default 1.0) */
  --card-opacity: 1.0;
}

/* ===== Light Theme (default — folgt Systemvorgabe) ===== */
:root,
:root[data-theme="light"] {
  --bg-window: #f2f2f7;          /* NSWindow-Background */
  --bg-content: #f7f7f7;         /* etwas heller für Main-Content */
  --bg-card-base: #ffffff;       /* card-base vor mix */

  /* DetailCard-Formel approximated:
     Color.cardBackground.mix(with: tint, by: 0.15).mix(with: black, by: 0.18)
     Wir nutzen color-mix() für die akzent-Beimischung,
     dann fallen wir auf eine konkretere darken-Kombination zurück. */
  --card-bg: color-mix(in srgb,
                color-mix(in srgb, var(--bg-card-base) 85%, var(--accent)) 82%,
                #000);

  --text-primary: #1d1d1f;       /* SwiftUI .primary auf Light */
  --text-secondary: #515154;     /* .secondary */
  --text-tertiary: #8e8e93;      /* .tertiary */

  --border-subtle: rgba(0, 0, 0, 0.08);   /* Color.cardBorder */
  --border-medium: rgba(0, 0, 0, 0.14);
  --hover-bg: rgba(0, 0, 0, 0.04);

  --shadow-card: 0 1px 2px rgba(0, 0, 0, 0.04), 0 2px 8px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 16px 48px rgba(0, 0, 0, 0.18);

  --sidebar-bg: rgba(255, 255, 255, 0.72);
  --topbar-bg: rgba(246, 246, 246, 0.88);
}

/* ===== Dark Theme — explizit oder via System ===== */
:root[data-theme="dark"] {
  --bg-window: #1e1e1e;
  --bg-content: #1e1e1e;
  --bg-card-base: #2e2e30;

  --card-bg: color-mix(in srgb,
                color-mix(in srgb, var(--bg-card-base) 85%, var(--accent)) 82%,
                #000);

  --text-primary: #f5f5f7;
  --text-secondary: #b8b8bd;
  --text-tertiary: #8e8e93;

  --border-subtle: rgba(255, 255, 255, 0.10);
  --border-medium: rgba(255, 255, 255, 0.18);
  --hover-bg: rgba(255, 255, 255, 0.06);

  --shadow-card: 0 1px 2px rgba(0, 0, 0, 0.3), 0 2px 8px rgba(0, 0, 0, 0.2);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 16px 48px rgba(0, 0, 0, 0.5);

  --sidebar-bg: rgba(28, 28, 30, 0.72);
  --topbar-bg: rgba(20, 20, 22, 0.88);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg-window: #1e1e1e;
    --bg-content: #1e1e1e;
    --bg-card-base: #2e2e30;
    --card-bg: color-mix(in srgb,
                  color-mix(in srgb, var(--bg-card-base) 85%, var(--accent)) 82%,
                  #000);
    --text-primary: #f5f5f7;
    --text-secondary: #b8b8bd;
    --text-tertiary: #8e8e93;
    --border-subtle: rgba(255, 255, 255, 0.10);
    --border-medium: rgba(255, 255, 255, 0.18);
    --hover-bg: rgba(255, 255, 255, 0.06);
    --shadow-card: 0 1px 2px rgba(0, 0, 0, 0.3), 0 2px 8px rgba(0, 0, 0, 0.2);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.35);
    --shadow-lg: 0 16px 48px rgba(0, 0, 0, 0.5);
    --sidebar-bg: rgba(28, 28, 30, 0.72);
    --topbar-bg: rgba(20, 20, 22, 0.88);
  }
}

/* ===== Reset + base ===== */
* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  /* Font-Stack mit Inter (SF-Pro-Lookalike) als primary, Figtree fallback */
  font-family: 'Inter var', 'Inter', -apple-system, BlinkMacSystemFont,
               'SF Pro Text', 'Figtree', 'Helvetica Neue', system-ui, sans-serif;
  font-optical-sizing: auto;
  font-feature-settings: 'cv11', 'ss01', 'ss03';  /* Inter stylistic sets — schweizer 1, runde a/g */
  background: var(--bg-window);
  color: var(--text-primary);
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
  position: relative;
}

/* App-Wide-Gradient — analog LoginGradient.appWideGradientOpacity in Theme.swift.
   Liegt unter allen Surfaces; sidebar/topbar/main sind translucent damit
   der Gradient durchscheint. Opacity-Default 0.18 (web etwas stärker als
   Mac wegen Browser-Gamma). User kann via Einstellungen wechseln. */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background: var(--brand-gradient);
  opacity: 0.18;
  pointer-events: none;
  z-index: 0;
}

body > * {
  position: relative;
  z-index: 1;
}

button {
  font-family: inherit;
  border: none;
  background: none;
  color: inherit;
  cursor: pointer;
}

input, textarea, select {
  font-family: inherit;
  background: var(--hover-bg);
  color: var(--text-primary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  outline: none;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

input:focus, textarea:focus, select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ===== Demo-Banner (global, oberhalb der Toolbar) ===== */
.demo-banner {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--banner-h);
  background: var(--brand-gradient);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  z-index: 200;
  padding: 0 16px;
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.18), 0 4px 12px rgba(0, 0, 0, 0.12);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.35);
}
.demo-banner-label {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: 0.18em;
  background: rgba(255, 255, 255, 0.22);
  padding: 4px 14px;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.4);
  line-height: 1;
}
.demo-banner-text {
  font-size: 13px;
  font-weight: 500;
  opacity: 0.95;
}
.demo-status-note {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin: 16px auto 24px;
  padding: 12px 20px;
  max-width: 720px;
  background: color-mix(in srgb, var(--accent) 10%, var(--surface));
  color: var(--text);
  border: 1px solid color-mix(in srgb, var(--accent) 25%, var(--border));
  border-radius: 12px;
  font-size: 13px;
  line-height: 1.4;
  text-align: center;
}
.demo-status-note i { color: var(--accent); font-size: 18px; flex-shrink: 0; }
@media (max-width: 720px) { .demo-status-note { font-size: 12px; padding: 10px 14px; margin: 12px 14px; } }
.demo-banner-back {
  position: absolute;
  left: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 32px;
  padding: 0 14px 0 10px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.18);
  color: white;
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  transition: background 0.15s;
  border: 1px solid rgba(255, 255, 255, 0.30);
}
.demo-banner-back:hover { background: rgba(255, 255, 255, 0.32); text-decoration: none; }
.demo-banner-back i { font-size: 16px; }
.demo-banner-back-label { white-space: nowrap; }

/* ===== Top Bar — macOS-Toolbar mit Liquid-Glass + Traffic-Lights ===== */
.topbar {
  position: fixed;
  top: var(--banner-h); left: 0; right: 0;
  height: var(--topbar-h);
  background: var(--topbar-bg);
  backdrop-filter: blur(30px) saturate(180%);
  -webkit-backdrop-filter: blur(30px) saturate(180%);
  display: flex;
  align-items: center;
  padding: 0 14px;
  gap: 10px;
  z-index: 100;
  border-bottom: 0.5px solid var(--border-subtle);
}

.topbar-left {
  display: flex;
  gap: 6px;
  align-items: center;
}

/* macOS Traffic-Light-Buttons */
.traffic-lights {
  display: inline-flex;
  gap: 8px;
  margin-right: 10px;
  align-items: center;
  padding: 0 4px;
}
.tl {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  display: inline-block;
  cursor: pointer;
  transition: filter 0.12s ease;
  position: relative;
  background: var(--tl-bg, #ddd);
  box-shadow: inset 0 0 0 0.5px rgba(0, 0, 0, 0.18);
}
.tl-close { --tl-bg: #ff5f57; }
.tl-min   { --tl-bg: #febc2e; }
.tl-max   { --tl-bg: #28c840; }
.traffic-lights:hover .tl {
  background: var(--tl-bg);
}
.traffic-lights:hover .tl::before {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 9px;
  font-weight: 700;
  color: rgba(0, 0, 0, 0.5);
  line-height: 12px;
}
.traffic-lights:hover .tl-close::before  { content: '×'; font-size: 11px; }
.traffic-lights:hover .tl-min::before    { content: '−'; }
.traffic-lights:hover .tl-max::before    { content: '+'; }

.topbar-search {
  flex: 1;
  max-width: 480px;
  margin: 0 auto;
  position: relative;
}

.topbar-search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 14px;
  color: var(--text-tertiary);
  pointer-events: none;
}

/* Uniform-Search-Field-Style: capsule pill, 32pt hoch (macOS-Toolbar-Größe) */
.topbar-search input {
  width: 100%;
  height: 32px;
  background: var(--hover-bg);
  border: 1px solid var(--border-subtle);
  border-radius: 999px;
  padding: 0 14px 0 32px;
  font-size: 13px;
  font-family: inherit;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}

.nav-btn {
  width: 26px;
  height: 26px;
  border-radius: 5px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  font-size: 15px;
  transition: all var(--transition-fast);
  background: transparent;
}
.nav-btn:hover { background: var(--hover-bg); color: var(--text-primary); }

.topbar-btn {
  width: 28px;
  height: 28px;
  border-radius: 5px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  font-size: 15px;
  transition: all var(--transition-fast);
}
.topbar-btn:hover { background: var(--hover-bg); color: var(--accent); }

.user-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 10px 4px 4px;
  background: var(--hover-bg);
  border: 1px solid var(--border-subtle);
  border-radius: 999px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-primary);
}

.user-avatar {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), color-mix(in srgb, var(--accent) 70%, transparent));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 600;
  color: white;
}

/* ===== Persistent Demo-Status-Bar (zwischen Topbar und App-Grid) ===== */
.demo-status-bar {
  position: fixed;
  top: calc(var(--banner-h) + var(--topbar-h));
  left: 0; right: 0;
  z-index: 99;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 8px 16px;
  background: color-mix(in srgb, var(--accent) 12%, var(--bg-content));
  color: var(--text-primary);
  font-size: 12.5px;
  line-height: 1.4;
  border-bottom: 1px solid var(--border-subtle);
  text-align: center;
  backdrop-filter: blur(10px) saturate(150%);
  -webkit-backdrop-filter: blur(10px) saturate(150%);
}
.demo-status-bar i { color: var(--accent); font-size: 16px; flex-shrink: 0; }

/* Prominenter Disclaimer-Banner — höher kontrastiert als Info-Bar */
.demo-status-bar.demo-disclaimer {
  background: linear-gradient(90deg, color-mix(in srgb, #d97706 18%, var(--bg-content)) 0%, color-mix(in srgb, #d97706 8%, var(--bg-content)) 100%);
  border-bottom: 2px solid #d97706;
  font-size: 13px;
  font-weight: 500;
  padding: 10px 16px;
  color: var(--text-primary);
}
.demo-status-bar.demo-disclaimer i { color: #d97706; font-size: 18px; }
.demo-status-bar.demo-disclaimer strong { color: #d97706; font-weight: 700; }
:root { --status-bar-h: 36px; }
@media (max-width: 720px) {
  .demo-status-bar { font-size: 11.5px; padding: 7px 14px; gap: 8px; }
  :root { --status-bar-h: 38px; }
}

/* ===== App-Grid ===== */
.app-grid {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  height: 100vh;
  padding-top: calc(var(--banner-h) + var(--topbar-h) + var(--status-bar-h, 36px));
  background: transparent; /* gradient durch body::before sichtbar */
}

/* ===== Collapsed Sidebar (icon-rail mode) — App: sidebarExpanded == false ===== */
/* Wenn .sidebar.collapsed, schrumpft das Grid + alle Labels weg, nur Icons in
   centrierten 50x50 Round-Buttons (wie railButton im App-Code) */
.app-grid:has(.sidebar.collapsed) {
  grid-template-columns: var(--sidebar-rail-w) 1fr;
}
.sidebar.collapsed { padding: 4px 6px; }

.sidebar.collapsed .sidebar-header-text,
.sidebar.collapsed .nav-badge,
.sidebar.collapsed .sidebar-reorder-btn,
.sidebar.collapsed .sidebar-section-divider,
.sidebar.collapsed .sidebar-profile-text,
.sidebar.collapsed .sidebar-logout span {
  display: none !important;
}
/* nav-label wird zum Hover-Tooltip rechts vom Icon */
.sidebar.collapsed .nav-label {
  position: absolute;
  left: calc(100% + 10px);
  top: 50%;
  transform: translateY(-50%);
  background: #1a1a1a;
  color: white;
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 12.5px;
  font-weight: 500;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s;
  z-index: 200;
  box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}
.sidebar.collapsed .nav-item:hover .nav-label { opacity: 1; }

.sidebar.collapsed .sidebar-header {
  justify-content: center;
  padding: 4px 0 12px;
}
.sidebar.collapsed .sidebar-logo-btn {
  width: 38px;
  height: 38px;
  font-size: 18px;
  border-radius: 10px;
}

.sidebar.collapsed .nav-item {
  width: 44px;
  height: 44px;
  margin: 2px auto;
  padding: 0;
  border-radius: 12px;
  justify-content: center;
  gap: 0;
  position: relative;
}
.sidebar.collapsed .nav-icon {
  width: auto;
  font-size: 20px;
}
.sidebar.collapsed .sidebar-scroll { gap: 2px; }
.sidebar.collapsed .sidebar-pinned { gap: 2px; padding-top: 8px; border-top: 1px solid var(--border-subtle); margin-top: 8px; }

.sidebar.collapsed .sidebar-profile {
  justify-content: center;
  padding: 6px 0;
}
.sidebar.collapsed .sidebar-profile-avatar-wrap { margin: 0; }

.sidebar.collapsed .sidebar-logout {
  width: 44px;
  margin: 4px auto 0;
  padding: 6px 0;
  justify-content: center;
}
.sidebar.collapsed .sidebar-logout i { font-size: 16px; }

/* Smooth Animation beim Toggle */
.sidebar {
  transition: padding var(--transition-normal);
}
.app-grid {
  transition: grid-template-columns var(--transition-normal);
}

/* ===== Sidebar — Exakte App-Replikation aus DashboardView.swift ===== */

/* Sidebar als "schwebende" Card im Window — Höhe ist content-fit */
.sidebar {
  background:
    /* App-Wide: Color(.windowBackgroundColor) + LoginGradient.sidebarGradient + accent.opacity(tint*0.5) */
    linear-gradient(180deg,
      color-mix(in srgb, var(--accent) 12%, transparent) 0%,
      color-mix(in srgb, var(--accent) 6%, transparent) 50%,
      color-mix(in srgb, var(--accent) 8%, transparent) 100%),
    var(--sidebar-bg);
  backdrop-filter: blur(40px) saturate(180%);
  -webkit-backdrop-filter: blur(40px) saturate(180%);
  /* Card mit allen 4 Ecken gerundet — schwebt im Window */
  border-radius: 16px;
  /* OUTER padding rundherum */
  margin: 12px 0 20px 12px;
  padding: 4px 8px 4px 14px;
  display: flex;
  flex-direction: column;
  /* Content-fit Höhe — Sidebar so groß wie ihr Inhalt, nicht 100vh */
  align-self: start;
  max-height: calc(100vh - var(--topbar-h) - 32px);
  overflow: hidden;
  position: relative;
  box-shadow:
    0 8px 24px rgba(0, 0, 0, 0.12),
    inset 0 1px 0 color-mix(in srgb, white 8%, transparent);
  border: 0.5px solid var(--border-subtle);
}

/* sidebarHeader: Logo-Box + Firmenname + Untertitel (wie App `sidebarHeader`) */
.sidebar-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 4px 6px 16px;
}
.sidebar-logo-btn {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: color-mix(in srgb, white 10%, transparent);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-primary);
  font-size: 22px;
  cursor: pointer;
  flex-shrink: 0;
  transition: background var(--transition-fast);
}
.sidebar-logo-btn:hover {
  background: color-mix(in srgb, white 16%, transparent);
}
.sidebar-header-text { flex: 1; min-width: 0; }
.sidebar-company-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: -0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sidebar-company-sub {
  font-size: 11px;
  color: var(--text-secondary);
  margin-top: 2px;
}

/* Scrollbarer Bereich für Haupt-Nav */
.sidebar-scroll {
  display: flex;
  flex-direction: column;
  gap: 6px;
  overflow-y: auto;
  padding: 5px 0 8px;
  flex-shrink: 1;
  flex-grow: 0;
  min-height: 0;
}

.sidebar-pinned {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 0 0 4px;
}

/* Sidebar-Row — App-Specs: HStack spacing 14, padding h12 v9, fontSize 16, weight medium */
.nav-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 9px 12px;
  border-radius: 10px;
  color: var(--text-primary);
  font-size: 15px;
  font-weight: 500;
  letter-spacing: -0.01em;
  transition: background var(--transition-fast);
  position: relative;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-decoration: none;
}

/* App: SidebarHoverFeedback = white.opacity(0.08), 6pt corner */
.nav-item:hover {
  background: color-mix(in srgb, white 8%, transparent);
}

/* App: SelectedGlassModifier = .regularMaterial + .tint(.white.opacity(0.32)) in 10pt rect */
.nav-item.active {
  background: color-mix(in srgb, white 22%, transparent);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  color: var(--text-primary);
}

/* Phosphor-Icon — App: Image 18pt medium, frame width 26 */
.nav-icon {
  width: 26px;
  font-size: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  flex-shrink: 0;
  transition: color var(--transition-fast);
}

.nav-item.active .nav-icon { color: var(--text-primary); }
.nav-item:hover .nav-icon { color: var(--text-primary); }

.nav-label {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Badge für unread/pending counts — App: Capsule mit Color */
.nav-badge {
  font-size: 9px;
  font-weight: 700;
  color: white;
  padding: 2px 6px;
  border-radius: 999px;
  background: #ff3b30;
  flex-shrink: 0;
}
.nav-badge-orange { background: #ff9500; }
.nav-badge-red    { background: #ff3b30; }

/* "Anordnen"-Button — App: Image+Text gearshape, 11pt, secondary */
.sidebar-reorder-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  padding: 6px 12px;
  font-size: 11px;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  background: transparent;
  border: none;
  text-align: left;
  border-radius: 6px;
  transition: background var(--transition-fast);
}
.sidebar-reorder-btn:hover { background: color-mix(in srgb, white 6%, transparent); }
.sidebar-reorder-btn i { font-size: 12px; }

/* Section divider — App: Divider() */
.sidebar-section-divider {
  height: 0.5px;
  background: var(--border-subtle);
  margin: 8px 0;
}

/* Profile-Button am unteren Rand — App: profileNavButton */
.sidebar-profile {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 10px;
  margin-top: 6px;
  border-radius: 8px;
  cursor: pointer;
  text-decoration: none;
  color: var(--text-primary);
  transition: background var(--transition-fast);
}
.sidebar-profile:hover {
  background: color-mix(in srgb, white 10%, transparent);
}
.sidebar-profile-avatar-wrap {
  position: relative;
  width: 38px;
  height: 38px;
  flex-shrink: 0;
}
.sidebar-profile-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: color-mix(in srgb, white 12%, transparent);
  border: 2px solid;
  border-image: linear-gradient(135deg,
    color-mix(in srgb, white 60%, transparent),
    color-mix(in srgb, var(--accent) 40%, transparent)) 1;
  /* Fallback for browsers without border-image gradient */
  border-color: color-mix(in srgb, var(--accent) 50%, transparent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
}
.sidebar-profile-status {
  position: absolute;
  bottom: -1px;
  right: -1px;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: #34c759;
  border: 2px solid var(--bg-window);
}
.sidebar-profile-text { flex: 1; min-width: 0; }
.sidebar-profile-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: -0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sidebar-profile-role {
  font-size: 11px;
  color: var(--text-secondary);
  margin-top: 1px;
}

/* Logout-Button — App: rectangle.portrait.and.arrow.right, 12pt, secondary, full width */
.sidebar-logout {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 100%;
  padding: 6px 12px;
  margin-top: 4px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  background: transparent;
  border: none;
  border-radius: 6px;
  transition: background var(--transition-fast);
}
.sidebar-logout:hover {
  background: color-mix(in srgb, white 6%, transparent);
  color: var(--text-primary);
}
.sidebar-logout i { font-size: 13px; }

.nav-divider {
  height: 1px;
  background: var(--border-subtle);
  margin: 12px 6px;
}

.nav-section {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-tertiary);
  padding: 6px 10px 2px;
}

.sidebar-footer {
  margin-top: auto;
  padding: 10px 6px 4px;
}

.sidebar-hint {
  font-size: 10px;
  color: var(--text-tertiary);
  text-align: center;
  padding: 8px;
  background: var(--accent-soft);
  border-radius: var(--radius-sm);
  line-height: 1.4;
}

.sidebar-hint span {
  color: var(--accent);
  font-weight: 600;
}

/* ===== Main Content ===== */
.main {
  overflow-y: auto;
  background: transparent; /* gradient durchscheint, cards sitzen drauf */
  padding: 24px 28px 40px;
}

.loading {
  text-align: center;
  padding: 80px 0;
  color: var(--text-tertiary);
}

/* ===== Module Header (statt Brand-Gradient-Hero) ===== */
.module-header {
  margin-bottom: 24px;
}

.module-title {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.module-subtitle {
  font-size: 14px;
  color: var(--text-secondary);
  max-width: 720px;
  line-height: 1.5;
}

/* ===== DetailCard (das Haupt-Pattern in der App) — Liquid-Glass-Layering ===== */
.card {
  background: var(--card-bg);
  border: 0.5px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 16px;
  box-shadow:
    inset 0 1px 0 color-mix(in srgb, white 10%, transparent),  /* top-edge highlight */
    var(--shadow-card);
  transition: all var(--transition-fast);
  opacity: var(--card-opacity);
  position: relative;
}

.card:hover {
  border-color: color-mix(in srgb, var(--accent) 35%, var(--border-subtle));
  box-shadow:
    inset 0 1px 0 color-mix(in srgb, white 14%, transparent),
    0 1px 2px rgba(0, 0, 0, 0.06),
    0 4px 16px color-mix(in srgb, var(--accent) 18%, transparent);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 10px;
  margin-bottom: 14px;
  border-bottom: 1px solid var(--border-subtle);
}

.card-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
}

.card-subtitle {
  font-size: 12px;
  color: var(--text-tertiary);
  margin-bottom: 10px;
}

.card-action {
  font-size: 12px;
  color: var(--accent);
  cursor: pointer;
  font-weight: 500;
}
.card-action:hover { text-decoration: underline; }

.card-stat {
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text-primary);
}

/* Card-Grid (auto-fit) */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 14px;
}

/* ===== Buttons ===== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius-md);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-fast);
  border: 1px solid transparent;
  background: var(--hover-bg);
  color: var(--text-primary);
  font-family: inherit;
}

.btn:hover { background: color-mix(in srgb, var(--hover-bg) 50%, var(--accent-soft)); }

.btn-primary {
  background: var(--accent);
  color: white;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
}
.btn-primary:hover {
  background: color-mix(in srgb, var(--accent) 88%, white);
  box-shadow: 0 2px 6px color-mix(in srgb, var(--accent) 40%, transparent);
}

.btn-secondary {
  background: var(--hover-bg);
  color: var(--text-primary);
  border: 1px solid var(--border-subtle);
}
.btn-secondary:hover { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }

.btn-bordered {
  background: transparent;
  border: 1px solid var(--border-medium);
  color: var(--text-primary);
}
.btn-bordered:hover { border-color: var(--accent); color: var(--accent); }

.btn-icon {
  width: 32px;
  height: 32px;
  padding: 0;
  border-radius: var(--radius-sm);
  justify-content: center;
}

/* ===== Tables ===== */
.table-wrap {
  background: var(--card-bg);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  overflow: hidden;
  margin-bottom: 18px;
  box-shadow: var(--shadow-card);
}

table {
  width: 100%;
  border-collapse: collapse;
}

th, td {
  text-align: left;
  padding: 10px 14px;
  font-size: 13px;
}

th {
  background: var(--hover-bg);
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border-subtle);
}

tr {
  border-top: 1px solid var(--border-subtle);
  transition: background var(--transition-fast);
}
tr:first-child { border-top: none; }
tr:hover { background: var(--hover-bg); }

/* ===== Badges (StatusBadge-Stil — Capsule, klein) ===== */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 600;
  background: var(--hover-bg);
  color: var(--text-secondary);
}

.badge-green, .badge-success {
  background: rgba(52, 199, 89, 0.18);
  color: #28a745;
}
.badge-orange, .badge-warning {
  background: rgba(255, 149, 0, 0.18);
  color: #d57c00;
}
.badge-red, .badge-danger {
  background: rgba(255, 59, 48, 0.18);
  color: #d92929;
}
.badge-gold, .badge-accent {
  background: var(--accent-soft);
  color: var(--accent);
}
.badge-info {
  background: var(--accent-soft);
  color: var(--accent);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .badge-green, :root:not([data-theme="light"]) .badge-success { color: #4ade80; }
  :root:not([data-theme="light"]) .badge-orange, :root:not([data-theme="light"]) .badge-warning { color: #fbbf24; }
  :root:not([data-theme="light"]) .badge-red, :root:not([data-theme="light"]) .badge-danger { color: #f87171; }
}

:root[data-theme="dark"] .badge-green, :root[data-theme="dark"] .badge-success { color: #4ade80; }
:root[data-theme="dark"] .badge-orange, :root[data-theme="dark"] .badge-warning { color: #fbbf24; }
:root[data-theme="dark"] .badge-red, :root[data-theme="dark"] .badge-danger { color: #f87171; }

/* ===== Forms ===== */
.form-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 12px;
}

.form-row label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary);
  letter-spacing: 0.02em;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

/* ===== Sheets / Modals (presentationBackground glass) ===== */
.sheet-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(0);
  transition: background var(--transition-fast), backdrop-filter var(--transition-fast);
}

.sheet-backdrop.sheet-in {
  background: rgba(0, 0, 0, 0.36);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.sheet {
  background: var(--card-bg);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 720px;
  max-height: 86vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
  transform: scale(0.97) translateY(8px);
  opacity: 0;
  transition: transform 0.22s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.18s;
}

.sheet-backdrop.sheet-in .sheet { transform: scale(1) translateY(0); opacity: 1; }

.sheet-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-subtle);
}

.sheet-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
}

.sheet-close {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--hover-bg);
  font-size: 18px;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--transition-fast);
}
.sheet-close:hover { background: rgba(255, 59, 48, 0.18); color: #d92929; }

.sheet-body {
  padding: 16px 20px;
  overflow-y: auto;
  flex: 1;
}

.sheet-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  padding: 12px 20px;
  border-top: 1px solid var(--border-subtle);
  background: var(--hover-bg);
}

/* ===== Utility ===== */
.flex { display: flex; gap: 12px; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.flex-center { display: flex; justify-content: center; align-items: center; }
.gap-sm { gap: 6px; } .gap-md { gap: 12px; } .gap-lg { gap: 18px; }
.mt-sm { margin-top: 6px; } .mt-md { margin-top: 12px; } .mt-lg { margin-top: 18px; }
.mb-sm { margin-bottom: 6px; } .mb-md { margin-bottom: 12px; } .mb-lg { margin-bottom: 18px; }
.text-secondary { color: var(--text-secondary); }
.text-tertiary { color: var(--text-tertiary); }
.text-accent { color: var(--accent); }
.font-mono { font-family: 'SF Mono', Menlo, Consolas, monospace; }
.hidden { display: none !important; }

/* ===== Scrollbar (subtle, App-Style) ===== */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-subtle); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--border-medium); }

/* ===== Mobile / Tablet Visibility Helpers ===== */
.mobile-only { display: none; }
.desktop-only { display: inline-flex; }

.sidebar-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.36);
  backdrop-filter: blur(6px);
  z-index: 90;
  display: none;
  opacity: 0;
  transition: opacity var(--transition-fast);
}
.sidebar-backdrop.show { display: block; opacity: 1; }

/* ===== Tablet (≤ 980px) ===== */
@media (max-width: 980px) {
  :root { --sidebar-w: 220px; }
  .topbar-search { margin: 0 8px; }
  .main { padding: 18px 18px 32px; }
  .module-title { font-size: 24px; }
  .form-grid { grid-template-columns: 1fr; }
}

/* ===== iPad Portrait (≤ 1024px, ≥ 761px): force icon-rail sidebar ===== */
@media (min-width: 761px) and (max-width: 1024px) {
  .app-grid { grid-template-columns: var(--sidebar-rail-w) 1fr; }
  .sidebar { padding: 4px 6px; overflow-x: hidden; }
  .sidebar-header-text,
  .nav-label,
  .nav-badge,
  .sidebar-reorder-btn,
  .sidebar-section-divider,
  .sidebar-profile-text,
  .sidebar-logout span { display: none; }
  .sidebar-header { justify-content: center; padding: 8px 4px; }
  .sidebar-logo-btn { justify-content: center; }
  .nav-item { justify-content: center; padding: 11px 6px; }
  .nav-icon { margin: 0; }
  .sidebar-profile { justify-content: center; padding: 8px 4px; }
  .topbar-search { max-width: 360px; }

  /* Demo-Banner kompakter auf iPad */
  .demo-banner { gap: 10px; padding: 0 12px; }
  .demo-banner-label { font-size: 14px; padding: 3px 10px; letter-spacing: 0.14em; }
  .demo-banner-text { font-size: 11.5px; }
  .demo-banner-back { height: 28px; padding: 0 10px 0 8px; font-size: 12px; }
  .demo-banner-back i { font-size: 14px; }

  /* Demo-Status-Bar kompakter */
  .demo-status-bar { font-size: 11.5px; padding: 7px 14px; gap: 8px; line-height: 1.4; }

  /* Main padding etwas reduzieren */
  .main { padding: 18px 20px 32px; }
}

/* ===== Mobile (≤ 720px) ===== */
@media (max-width: 720px) {
  :root {
    --banner-h: 36px;
    --topbar-h: 48px;
    --sidebar-w: 78vw;
  }
  .demo-banner-label { font-size: 16px; padding: 3px 10px; }
  .demo-banner-text { font-size: 11px; }

  .mobile-only { display: inline-flex; }
  .desktop-only { display: none !important; }

  .topbar { padding: 0 10px; }
  .topbar-left { gap: 4px; }
  .topbar-search { margin: 0 8px; max-width: none; }
  .topbar-search input { height: 32px; padding: 0 12px; font-size: 13px; }
  .topbar-right { gap: 4px; }

  .app-grid { grid-template-columns: 1fr; }

  .sidebar {
    position: fixed;
    top: calc(var(--banner-h) + var(--topbar-h));
    left: 0;
    bottom: 0;
    width: var(--sidebar-w);
    max-width: 320px;
    z-index: 100;
    transform: translateX(-100%);
    transition: transform var(--transition-normal);
    box-shadow: var(--shadow-lg);
  }
  .sidebar.open { transform: translateX(0); }

  .main { padding: 14px 12px 28px; width: 100%; }
  .module-title { font-size: 22px; }
  .module-subtitle { font-size: 13px; }

  .card { padding: 14px; border-radius: var(--radius-md); }
  .card-grid { gap: 10px; }
  .form-row { flex-direction: column; }
  .form-grid { grid-template-columns: 1fr; }

  /* Tabellen scrollbar */
  .table-wrap { overflow-x: auto; }
  table { min-width: 540px; }

  /* Bottom-Sheet auf Mobile */
  .sheet {
    margin-top: auto;
    width: 100%;
    max-width: none;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    max-height: 90vh;
  }
  .sheet-backdrop { align-items: flex-end; }

  /* Touch-Targets */
  .nav-btn, .topbar-btn { width: 36px; height: 36px; font-size: 18px; }
  .btn { padding: 10px 16px; }
  .nav-item { padding: 11px 12px; font-size: 14px; }
}

@media (max-width: 600px) {
  .demo-banner-back-label { display: none; }
  .demo-banner-back { padding: 0; width: 32px; }
}

@media (max-width: 380px) {
  .module-title { font-size: 20px; }
  .card-stat { font-size: 22px; }
  .demo-banner-text { display: none; }
}

/* ===== Reduced motion ===== */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ===== Print ===== */
@media print {
  .sidebar, .topbar, .sidebar-backdrop, .guide-overlay { display: none; }
  .main { padding: 0; }
  body { background: white; color: black; }
  .card { box-shadow: none; border-color: #ccc; }
}

/* ===== Touch (iPad / iPhone): bigger hit-areas, no hover-transforms ===== */
@media (hover: none) {
  .nav-btn, .topbar-btn { min-width: 44px; min-height: 44px; }
  .nav-item { min-height: 44px; }
  .btn { min-height: 44px; padding: 10px 18px; }
  .topbar-search input { height: 40px; }
  .card:hover { transform: none; }
  .topbar-btn:hover { background: transparent; color: var(--text-2); }
}
