/* ═══════════════════════════════════════════════════════════════
   KBR CONNECT – DESIGN TOKENS
   Alle Farben, Abstände und Schriften zentral definiert.
   Theme-Switch: document.documentElement.setAttribute('data-theme', 'light' | 'dark')
   ═══════════════════════════════════════════════════════════════ */

/* ── DARK THEME (Standard) ──────────────────────────────────── */
:root,
[data-theme="dark"] {

  /* Hintergründe */
  --bg:              #0f0f10;
  --surface:         #1a1a1d;
  --surface2:        #242428;
  --surface3:        #2e2e33;

  /* Rahmen */
  --border:          rgba(255, 255, 255, 0.07);
  --border2:         rgba(255, 255, 255, 0.13);

  /* Text */
  --text:            #f0ece6;
  --text-2:          #9e9b96;
  --text-3:          #5e5c59;

  /* Akzente */
  --accent-hot:      #f0a04b;   /* Orange – Primärakzent */
  --accent-hot-bg:   rgba(240, 160, 75, 0.12);
  --accent-hot-border: rgba(240, 160, 75, 0.30);

  /* Semantische Farben */
  --color-success:        #4caf7d;
  --color-success-bg:     rgba(76, 175, 125, 0.12);
  --color-success-border: rgba(76, 175, 125, 0.25);

  --color-warning:        #e8c84a;
  --color-warning-bg:     rgba(232, 200, 74, 0.12);
  --color-warning-border: rgba(232, 200, 74, 0.25);

  --color-danger:         #e05c5c;
  --color-danger-bg:      rgba(224, 92, 92, 0.12);
  --color-danger-border:  rgba(224, 92, 92, 0.20);

  --color-info:           #4a90d9;
  --color-info-bg:        rgba(74, 144, 217, 0.12);
  --color-info-border:    rgba(74, 144, 217, 0.30);

  /* Topbar / Navbars (mit Blur-Effekt) */
  --topbar-bg:       rgba(15, 15, 16, 0.92);
  --tabbar-bg:       rgba(15, 15, 16, 0.95);

  /* Schatten */
  --shadow-sm:       0 2px 8px rgba(0, 0, 0, 0.4);
  --shadow-md:       0 8px 24px rgba(0, 0, 0, 0.5);
  --shadow-lg:       0 20px 60px rgba(0, 0, 0, 0.6);

  /* Modals */
  --overlay-bg:      rgba(0, 0, 0, 0.75);

  /* Theme-Meta (für JS) */
  --theme-name:      "dark";
  color-scheme: dark;
}

/* ── LIGHT THEME ────────────────────────────────────────────── */
[data-theme="light"] {

  /* Hintergründe */
  --bg:              #f5f4f1;
  --surface:         #ffffff;
  --surface2:        #f0efe9;
  --surface3:        #e8e6df;

  /* Rahmen */
  --border:          rgba(0, 0, 0, 0.07);
  --border2:         rgba(0, 0, 0, 0.13);

  /* Text */
  --text:            #1a1917;
  --text-2:          #5a5854;
  --text-3:          #9a9894;

  /* Akzente – gleiche Markenwerte, leicht gesättigter für Hell */
  --accent-hot:      #d4782a;
  --accent-hot-bg:   rgba(212, 120, 42, 0.10);
  --accent-hot-border: rgba(212, 120, 42, 0.28);

  /* Semantische Farben */
  --color-success:        #2d8a5e;
  --color-success-bg:     rgba(45, 138, 94, 0.10);
  --color-success-border: rgba(45, 138, 94, 0.22);

  --color-warning:        #b8960a;
  --color-warning-bg:     rgba(184, 150, 10, 0.10);
  --color-warning-border: rgba(184, 150, 10, 0.22);

  --color-danger:         #c0392b;
  --color-danger-bg:      rgba(192, 57, 43, 0.10);
  --color-danger-border:  rgba(192, 57, 43, 0.18);

  --color-info:           #2471b8;
  --color-info-bg:        rgba(36, 113, 184, 0.10);
  --color-info-border:    rgba(36, 113, 184, 0.25);

  /* Topbar / Navbars */
  --topbar-bg:       rgba(245, 244, 241, 0.92);
  --tabbar-bg:       rgba(255, 255, 255, 0.96);

  /* Schatten */
  --shadow-sm:       0 2px 8px rgba(0, 0, 0, 0.08);
  --shadow-md:       0 8px 24px rgba(0, 0, 0, 0.10);
  --shadow-lg:       0 20px 60px rgba(0, 0, 0, 0.14);

  /* Modals */
  --overlay-bg:      rgba(0, 0, 0, 0.45);

  --theme-name:      "light";
  color-scheme: light;
}

/* ── GEMEINSAME STATISCHE TOKENS ────────────────────────────── */
:root {
  /* Abstände */
  --space-xs:   4px;
  --space-sm:   8px;
  --space-md:   16px;
  --space-lg:   24px;
  --space-xl:   32px;

  /* Radien */
  --radius-sm:  8px;
  --radius:     14px;
  --radius-lg:  20px;
  --radius-xl:  28px;
  --radius-full: 999px;

  /* Layout */
  --tab-h:      64px;
  --header-h:   56px;
  --app-max-w:  430px;

  /* Typografie */
  --font-display: 'Syne', sans-serif;
  --font-body:    'DM Sans', sans-serif;

  --text-xs:    10px;
  --text-sm:    12px;
  --text-base:  14px;
  --text-md:    16px;
  --text-lg:    18px;
  --text-xl:    24px;
  --text-2xl:   28px;
  --text-3xl:   36px;

  /* Übergänge */
  --transition-fast:   all 0.15s ease;
  --transition-base:   all 0.20s ease;
  --transition-slow:   all 0.35s ease;
}

/* ── BASIS-RESET ─────────────────────────────────────────────── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  min-height: 100dvh;
  overscroll-behavior: none;
  transition: background 0.3s ease, color 0.3s ease;
}

a { text-decoration: none; color: inherit; }
button { border: none; background: none; cursor: pointer; font-family: inherit; }
img { display: block; max-width: 100%; }

/* ── APP SHELL ───────────────────────────────────────────────── */
.app {
  max-width: var(--app-max-w);
  margin: 0 auto;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

/* ── TOPBAR ──────────────────────────────────────────────────── */
.topbar {
  position: sticky; top: 0; z-index: 100;
  height: var(--header-h);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 var(--space-md);
  background: var(--topbar-bg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
}

/* ── TABBAR ──────────────────────────────────────────────────── */
.tabbar {
  position: fixed; bottom: 0; left: 50%; transform: translateX(-50%);
  width: 100%; max-width: var(--app-max-w);
  height: var(--tab-h);
  background: var(--tabbar-bg);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border-top: 1px solid var(--border);
  z-index: 100;
  padding-bottom: env(safe-area-inset-bottom);
}
.tabs { display: flex; height: 100%; }
.tab {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 4px;
  color: var(--text-3); font-size: var(--text-xs); font-weight: 500;
  transition: var(--transition-base); position: relative;
}
.tab svg { width: 22px; height: 22px; stroke-width: 1.8; }
.tab.active { color: var(--accent-hot); }
.tab.active::before {
  content: ''; position: absolute; top: 0; left: 50%; transform: translateX(-50%);
  width: 28px; height: 2px;
  background: var(--accent-hot);
  border-radius: 0 0 3px 3px;
}
.tab:hover:not(.active) { color: var(--text-2); }

/* ── SCROLL AREA ─────────────────────────────────────────────── */
.scroll-area {
  flex: 1; overflow-y: auto;
  padding-bottom: calc(var(--tab-h) + var(--space-md));
}
.scroll-area::-webkit-scrollbar { display: none; }

/* ── SECTION LABELS ──────────────────────────────────────────── */
.section-head {
  padding: var(--space-lg) var(--space-md) var(--space-sm);
  display: flex; align-items: center; justify-content: space-between;
}
.section-head h2,
.list-label {
  font-family: var(--font-display);
  font-size: 11px; font-weight: 700;
  letter-spacing: 1.4px; text-transform: uppercase;
  color: var(--text-3);
}
.section-head a { font-size: var(--text-sm); color: var(--accent-hot); font-weight: 500; }

/* ── BUTTONS ─────────────────────────────────────────────────── */
.topbar-btn, .btn-back, .btn-close, .topbar-action {
  width: 36px; height: 36px;
  border-radius: var(--radius-sm);
  background: var(--surface);
  border: 1px solid var(--border2);
  display: flex; align-items: center; justify-content: center;
  color: var(--text-2); cursor: pointer;
  transition: var(--transition-base);
}
.topbar-btn:hover, .btn-back:hover, .btn-close:hover { background: var(--surface2); color: var(--text); }
.topbar-btn:hover { color: var(--accent-hot); }

/* ── ANIMATIONEN ─────────────────────────────────────────────── */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.4; }
}
@keyframes popIn {
  from { opacity: 0; transform: translateY(-8px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes sheetUp {
  from { transform: translateY(100%); }
  to   { transform: translateY(0); }
}
@keyframes overlayIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

/* ── BRAND ───────────────────────────────────────────────────── */
.brand { display: flex; align-items: center; gap: 10px; }
.brand-logo {
  width: 32px; height: 32px; border-radius: var(--radius-sm); object-fit: contain;
}
.brand-logo-fallback {
  width: 32px; height: 32px; border-radius: var(--radius-sm);
  background: var(--surface3);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-display); font-size: 13px; font-weight: 700;
  color: var(--text); letter-spacing: 0.5px;
}
.brand-name {
  font-family: var(--font-display); font-size: 17px; font-weight: 700;
  color: var(--text); letter-spacing: -0.3px;
}
.brand-name span { color: var(--accent-hot); }

/* ── AVATAR ──────────────────────────────────────────────────── */
.btn-profile {
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--surface2); border: 1.5px solid var(--border2);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-display); font-size: 13px; font-weight: 700;
  color: var(--text); cursor: pointer; position: relative;
  transition: var(--transition-base); overflow: hidden;
}
.btn-profile:hover { border-color: var(--accent-hot); }
.btn-profile img { width: 100%; height: 100%; object-fit: cover; }

/* ── PROFIL POPUP ────────────────────────────────────────────── */
.profile-popup {
  position: absolute; top: calc(var(--header-h) - 8px); right: var(--space-md);
  width: 220px;
  background: var(--surface); border: 1px solid var(--border2);
  border-radius: var(--radius); box-shadow: var(--shadow-md);
  opacity: 0; pointer-events: none; transform: translateY(-8px) scale(0.97);
  transition: var(--transition-base); z-index: 200;
}
.profile-popup.open {
  opacity: 1; pointer-events: auto; transform: translateY(0) scale(1);
  animation: popIn .18s ease both;
}
.popup-header {
  padding: 14px 16px 12px;
  border-bottom: 1px solid var(--border);
  display: flex; flex-direction: column; gap: 2px;
}
.popup-name { font-size: 14px; font-weight: 600; color: var(--text); }
.popup-role { font-size: 11px; color: var(--text-3); }
.popup-menu { list-style: none; padding: 6px 0; }
.popup-menu li {
  padding: 10px 16px; font-size: 13px; color: var(--text-2);
  cursor: pointer; transition: var(--transition-fast);
  display: flex; align-items: center; gap: 10px;
}
.popup-menu li:hover { background: var(--surface2); color: var(--text); }
.popup-menu li.danger { color: var(--color-danger); }
.popup-menu li.danger:hover { background: var(--color-danger-bg); }

/* ── Avatar Badge ── */
    .avatar-wrap { position: relative; }
    .notif-badge {
      position: absolute; top: -3px; right: -3px;
      min-width: 16px; height: 16px; border-radius: var(--radius-full);
      background: var(--color-danger); border: 2px solid var(--bg);
      font-size: 9px; font-weight: 700; color: #fff;
      display: flex; align-items: center; justify-content: center;
      padding: 0 3px; line-height: 1;
    }

    /* ── Popup aktiviert_bis ── */
    .popup-aktiviert {
      padding: 10px 16px;
      border-top: 1px solid var(--border);
      font-size: 12px;
      display: flex; align-items: center; justify-content: space-between; gap: 8px;
    }
    .popup-aktiviert-label { color: var(--text-3); }
    .popup-aktiviert-val { font-weight: 600; }
    .popup-aktiviert-val.ok      { color: var(--color-success); }
    .popup-aktiviert-val.warning { color: var(--color-warning); }
    .popup-aktiviert-val.expired { color: var(--color-danger); }
    .btn-reaktivieren {
      width: calc(100% - 32px); margin: 0 16px 10px;
      padding: 9px; border-radius: var(--radius);
      background: var(--color-warning-bg);
      border: 1px solid var(--color-warning-border);
      color: var(--color-warning); font-size: 12px; font-weight: 600;
      cursor: pointer; transition: var(--transition-base);
    }
    .btn-reaktivieren:hover { background: var(--color-warning); color: #fff; }

/* ── NEWS KARUSSELL ──────────────────────────────────────────── */
.carousel-wrap { padding: var(--space-md) var(--space-md) 0; }
.carousel { position: relative; border-radius: var(--radius-lg); overflow: hidden; }
.slides { position: relative; }
.slide {
  display: none; border-radius: var(--radius-lg); overflow: hidden;
  background: var(--surface); border: 1px solid var(--border2);
  cursor: pointer;
}
.slide.active { display: block; animation: fadeUp .3s ease both; }
.slide-img { width: 100%; aspect-ratio: 16/9; object-fit: cover; }
.slide-img-placeholder {
  width: 100%; aspect-ratio: 16/9;
  background: linear-gradient(135deg, var(--surface2), var(--surface3));
  display: flex; align-items: center; justify-content: center;
}
.slide-img-placeholder svg { color: var(--text-3); opacity: .4; }
.slide-body { padding: 14px 16px 16px; }
.slide-title {
  font-family: var(--font-display); font-size: 16px; font-weight: 700;
  color: var(--text); line-height: 1.3; margin-bottom: 6px;
}
.slide-teaser { font-size: 13px; color: var(--text-2); line-height: 1.5; }
.slide-meta {
  margin-top: 10px; display: flex; align-items: center; gap: 12px;
  font-size: 11px; color: var(--text-3);
}
.slide-meta-item { display: flex; align-items: center; gap: 4px; }
.carousel-nav {
  padding: 10px var(--space-md) 0;
  display: flex; align-items: center; justify-content: space-between;
}
#newsDots { display: flex; gap: 6px; }
.dot {
  width: 6px; height: 6px; border-radius: var(--radius-full);
  background: var(--border2); border: none; cursor: pointer;
  transition: var(--transition-base); padding: 0;
}
.dot.active { width: 18px; background: var(--accent-hot); }
.nav-arrows { display: flex; gap: 6px; }
.nav-btn {
  width: 28px; height: 28px; border-radius: var(--radius-sm);
  background: var(--surface); border: 1px solid var(--border2);
  display: flex; align-items: center; justify-content: center;
  color: var(--text-2); cursor: pointer; transition: var(--transition-base);
}
.nav-btn:hover { background: var(--surface2); color: var(--text); }

/* ── SCHNELLZUGRIFF TILES ────────────────────────────────────── */
.tiles-grid {
  display: grid; grid-template-columns: repeat(4, 1fr);
  gap: var(--space-sm); padding: 0 var(--space-md);
}
.tile {
  display: flex; flex-direction: column; align-items: center;
  gap: 6px; padding: 12px 4px; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--border2);
  transition: var(--transition-base); cursor: pointer;
}
.tile:hover { background: var(--surface2); border-color: var(--accent-hot); transform: translateY(-2px); }
.tile-icon {
  width: 40px; height: 40px; border-radius: var(--radius-sm);
  background: var(--surface2);
  display: flex; align-items: center; justify-content: center;
  color: var(--accent-hot);
}
.tile-icon svg { width: 18px; height: 18px; stroke-width: 1.8; }
.tile-label { font-size: 10px; font-weight: 600; color: var(--text-2); text-align: center; }

/* ── EVENTS ──────────────────────────────────────────────────── */
.events-list { display: flex; flex-direction: column; gap: var(--space-sm); padding: 0 var(--space-md); }
.event-card {
  display: flex; align-items: center; gap: 14px;
  padding: 14px; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--border2);
  transition: var(--transition-base);
}
.event-card:hover { background: var(--surface2); transform: translateX(3px); }
.event-date-badge {
  min-width: 44px; height: 48px; border-radius: var(--radius-sm);
  background: var(--accent-hot-bg); border: 1px solid var(--accent-hot-border);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
}
.event-date-badge .day { font-family: var(--font-display); font-size: 18px; font-weight: 800; color: var(--accent-hot); line-height: 1; }
.event-date-badge .month { font-size: 9px; font-weight: 700; text-transform: uppercase; color: var(--accent-hot); opacity: .7; }
.event-info { flex: 1; }
.event-title { font-size: 14px; font-weight: 600; color: var(--text); }
.event-meta { font-size: 11px; color: var(--text-3); margin-top: 3px; display: flex; align-items: center; gap: 4px; }
.event-arrow { color: var(--text-3); }

/* ── BEREICHS-GRID ───────────────────────────────────────────── */
.dept-grid {
  display: grid; grid-template-columns: repeat(3, 1fr);
  gap: var(--space-sm); padding: 0 var(--space-md);
}
.dept-card {
  border-radius: var(--radius); padding: 16px 12px;
  background: var(--surface); border: 1px solid var(--border2);
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  transition: var(--transition-base);
}
.dept-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-sm); border-color: var(--dept-color, var(--border2)); }
.dept-icon { font-size: 28px; }
.dept-name { font-size: 11px; font-weight: 600; color: var(--text-2); text-align: center; }

/* ── THEME TOGGLE BUTTON (für Account-Einstellungen) ─────────── */
.theme-toggle {
  display: flex; align-items: center; gap: var(--space-sm);
  padding: 10px var(--space-md);
  background: var(--surface);
  border: 1px solid var(--border2);
  border-radius: var(--radius);
  cursor: pointer;
  transition: var(--transition-base);
  color: var(--text-2);
  font-size: var(--text-sm); font-weight: 500;
  font-family: var(--font-body);
  width: 100%;
}
.theme-toggle:hover { background: var(--surface2); color: var(--text); }
.theme-toggle-icon { font-size: 16px; }
