/* ═══════════════════════════════════════════════════════════════════
   CORE STYLES - Layout, Theme, Header
   ═══════════════════════════════════════════════════════════════════ */

:root {
  /* Fonts (geteilt mit Marketing-Website) */
  --font-display: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-body:    'DM Sans', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-mono:    'JetBrains Mono', 'Fira Code', monospace;
  --serif:        var(--font-display);
  --mono:         var(--font-mono);

  /* Farben (geteilt mit Marketing-Website) */
  --purple:       #a78bfa;
  --blue:         #60a5fa;
  --green:        #34d399;
  --amber:        #f59e0b;
  --red:          #f87171;
  --accent:       #7c3aed;
  --accent-blue:  #2563eb;
  --brand-red:    #e31903;

  --grad-cta:     linear-gradient(135deg, #7c3aed, #2563eb);
  --grad-main:    linear-gradient(135deg, #a78bfa, #60a5fa, #34d399);

  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 16px;
  --r-xl: 20px;

  /* Dark Mode – etwas heller */
  --bg:   #12151e;
  --bg1:  #12151e;
  --bg2:  #1a1f2b;
  --bg3:  #222938;
  --bg4:  #2a3346;
  --tx:   #e8e6e1;
  --txs:  rgba(232,230,225,.62);
  --txm:  rgba(232,230,225,.36);
  --border:      rgba(255,255,255,.10);
  --border2:     rgba(255,255,255,.18);
  --bsub:        #1c2333;
  --card-bg:     #161b25;
  --input-bg:    rgba(255,255,255,.05);
  --shadow:      0 4px 24px rgba(0,0,0,.35);
  --card-shadow: 0 4px 24px rgba(0,0,0,.35);
}

/* LIGHT MODE */
[data-theme="light"], html.light-mode {
  /* Light Mode – etwas dunkler/wärmer */
  --bg:   #ebeef4;
  --bg1:  #ebeef4;
  --bg2:  #f7f8fa;
  --bg3:  #e0e4ed;
  --bg4:  #d4d9e4;
  --tx:   #1a1d2e;
  --txs:  rgba(26,29,46,.62);
  --txm:  rgba(26,29,46,.38);
  --border:      rgba(0,0,0,.10);
  --border2:     rgba(0,0,0,.18);
  --bsub:        #e8ecf2;
  --card-bg:     #ffffff;
  --input-bg:    rgba(0,0,0,.03);
  --shadow:      0 4px 24px rgba(0,0,0,.07);
  --card-shadow: 0 4px 24px rgba(0,0,0,.07);
}

/* ── Transitions (smooth theme switch) ──────────────────────────── */
html {
  transition: background-color .25s ease, color .2s ease;
}
*, *::before, *::after {
  transition: background-color .2s ease, border-color .2s ease, box-shadow .2s ease;
}
/* Ausnahmen: Animationen, SVGs */
svg, svg *, canvas, [class*="animate"], .toast, .toast * {
  transition: none !important;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
body {
  font-family: var(--font-body);
  background: var(--bg1);
  color: var(--tx);
  font-size: 12px;
  line-height: 1.5;
  overflow: hidden;
}

/* ═══════════════════════════════════════════════════════
   SIDEBAR — Einheitliches System (alle 5 Module)
   ═══════════════════════════════════════════════════════ */
.sidebar-toolbar { padding: 10px 14px; border-bottom: 1px solid var(--border); display: flex; flex-direction: column; gap: 8px; }
.sidebar-search-row { display: flex; gap: 6px; align-items: center; }
.sidebar-search-input { flex: 1; min-width: 0; height: 32px; padding: 0 10px; font-size: 12px; font-family: inherit; border: 1px solid var(--border); border-radius: 8px; background: var(--bg2); color: var(--tx); outline: none; transition: border-color .15s; }
.sidebar-search-input:focus { border-color: var(--purple); }
.sidebar-new-btn { height: 32px; padding: 0 14px; font-size: 12px; font-weight: 600; font-family: inherit; background: var(--purple); color: #fff; border: none; border-radius: 8px; cursor: pointer; white-space: nowrap; flex-shrink: 0; display: flex; align-items: center; transition: opacity .15s; }
.sidebar-new-btn:hover { opacity: .85; }
.sidebar-filter-select { width: 100%; height: 32px; padding: 0 10px; font-size: 12px; font-family: inherit; border: 1px solid var(--border); border-radius: 8px; background: var(--bg2); color: var(--tx); cursor: pointer; outline: none; appearance: auto; transition: border-color .15s; }
.sidebar-filter-select:focus { border-color: var(--purple); }
.sidebar-filter-select.has-filter { border-color: var(--purple); }
.sidebar-checkbox-row { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--txs); cursor: pointer; user-select: none; }
.sidebar-checkbox-row input[type="checkbox"] { accent-color: var(--purple); cursor: pointer; }
.sidebar-count-bar { padding: 5px 14px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: center; background: var(--bg2); }
.sidebar-count-bar span { font-size: 11px; color: var(--txs); }

/* Listenelement: mit Avatar (Kontakte) */
.sidebar-item { display: flex; align-items: center; gap: 11px; padding: 10px 14px; border-bottom: 1px solid var(--border); cursor: pointer; transition: background .1s; }
.sidebar-item:last-child { border-bottom: none; }
.sidebar-item:hover { background: var(--bg2); }
.sidebar-item.active { background: rgba(167,139,250,.08); border-left: 2px solid var(--purple); padding-left: 12px; }
.sidebar-avatar { width: 34px; height: 34px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 600; flex-shrink: 0; color: #fff; }
.sidebar-icon-box { width: 34px; height: 34px; border-radius: 8px; background: var(--bg2); border: 1px solid var(--border); display: flex; align-items: center; justify-content: center; font-size: 16px; flex-shrink: 0; }
.sidebar-item-body { flex: 1; min-width: 0; }
.sidebar-item-name { font-size: 13px; font-weight: 600; color: var(--tx); display: flex; align-items: center; gap: 6px; overflow: hidden; }
.sidebar-item-sub { font-size: 11px; color: var(--txs); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-item-meta { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; flex-shrink: 0; }
.sidebar-item-meta-main { font-size: 12px; font-weight: 600; color: var(--tx); }
.sidebar-item-meta-sub { font-size: 11px; color: var(--txs); }

/* Listenelement: kein Avatar (Einheiten) */
.sidebar-item-flat { padding: 10px 14px; border-bottom: 1px solid var(--border); cursor: pointer; transition: background .1s; }
.sidebar-item-flat:last-child { border-bottom: none; }
.sidebar-item-flat:hover { background: var(--bg2); }
.sidebar-item-flat.active { background: rgba(167,139,250,.08); border-left: 2px solid var(--purple); padding-left: 12px; }
.sidebar-item-flat-name { font-size: 13px; font-weight: 600; color: var(--tx); display: flex; align-items: center; gap: 6px; }
.sidebar-item-flat-sub { font-size: 11px; color: var(--txs); margin-top: 3px; }

/* Listenelement: mit Dot (Aufgaben + Instandsetzungen) */
.sidebar-item-task { display: flex; align-items: flex-start; gap: 10px; padding: 10px 14px; border-bottom: 1px solid var(--border); cursor: pointer; transition: background .1s; }
.sidebar-item-task:last-child { border-bottom: none; }
.sidebar-item-task:hover { background: var(--bg2); }
.sidebar-item-task.active { background: rgba(167,139,250,.08); border-left: 2px solid var(--purple); padding-left: 12px; }
.sidebar-status-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; margin-top: 4px; }
.sidebar-status-dot.red { background: var(--red); }
.sidebar-status-dot.amber { background: var(--amber); }
.sidebar-status-dot.green { background: var(--green); }
.sidebar-status-dot.gray { background: var(--border2); }
.sidebar-task-prio { font-size: 11px; color: var(--txm); flex-shrink: 0; padding-top: 1px; min-width: 16px; text-align: right; }
.sidebar-item-badges { display: flex; gap: 4px; margin-top: 5px; flex-wrap: wrap; }

/* Skeleton + Empty */
@keyframes skeleton-shimmer { 0% { opacity: .5; } 50% { opacity: 1; } 100% { opacity: .5; } }
.skeleton-pulse { animation: skeleton-shimmer 1.4s ease-in-out infinite; }

/* Display-Font für Headlines */
h1, h2, h3, .nav-logo, .modal-title, .section-header,
.detail-header-name, .login-logo-text, .login-welcome {
  font-family: var(--font-display);
}

/* App Shell */
#app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  margin-left: 64px;
}

/* Header */
#topbar {
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  background: var(--bg1);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  z-index: 20;
  position: relative;
}
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 8px; margin-right: 8px; }
.topbar-logo { display: flex; gap: 9px; align-items: center; }




/* Hamburger Button (hidden on desktop) */
.hamburger {
  display: none;
  width: 40px;
  height: 40px;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  cursor: pointer;
  color: var(--tx);
}

.hamburger svg {
  width: 24px;
  height: 24px;
  pointer-events: none;
}

/* ── Left Nav Rail (desktop) ─────────────────────────────────────── */
#nav-rail {
  position: fixed;
  left: 0; top: 0;
  width: 64px;
  height: 100vh;
  background: var(--bg1);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  align-items: center;
  z-index: 100;
}

.rail-logo {
  width: 34px; height: 34px;
  border-radius: 8px;
  background: var(--grad-cta);
  color: #fff;
  font-weight: 800;
  font-size: 16px;
  display: flex; align-items: center; justify-content: center;
  margin: 9px 0 6px;
  flex-shrink: 0;
  user-select: none;
}

.rail-sep { width: 32px; height: 1px; background: var(--border); margin: 4px 0; flex-shrink: 0; }

.rail-item {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 9px 0;
  gap: 3px;
  cursor: pointer;
  border: none;
  border-left: 3px solid transparent;
  background: transparent;
  color: var(--txm);
  transition: background 0.13s, color 0.13s, border-color 0.13s;
  flex-shrink: 0;
}

.rail-item:hover { background: var(--bg2); color: var(--tx); }
.rail-item.active { background: var(--bg2); border-left-color: var(--amber); color: var(--amber); }
.rail-icon { font-size: 17px; line-height: 1; }
.rail-label { font-size: 8.5px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.4px; }

.rail-bottom { margin-top: auto; width: 100%; display: flex; flex-direction: column; align-items: center; padding-bottom: 8px; }

/* Mobile Navigation Menu */
.mobile-nav {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 200px;
  height: 100vh;
  background: var(--bg1);
  z-index: 1001;
  flex-direction: column;
  box-shadow: 2px 0 20px rgba(0,0,0,0.25);
  transform: translateX(-100%);
  transition: transform 0.25s ease;
}

.mobile-nav.open {
  transform: translateX(0);
}

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

.mobile-nav-close {
  background: transparent;
  border: none;
  font-size: 24px;
  cursor: pointer;
  color: var(--tx);
}

.mobile-nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  background: transparent;
  border: none;
  border-left: 3px solid transparent;
  text-align: left;
  font-size: 15px;
  color: var(--tx);
  cursor: pointer;
  transition: 0.13s;
  width: 100%;
}

.mobile-nav-item:hover {
  background: var(--bg2);
}

.mobile-nav-item.active {
  background: var(--bg3);
  border-left-color: var(--amber);
  color: var(--amber);
  font-weight: 600;
}

.mobile-nav-item span:first-child {
  font-size: 20px;
  width: 28px;
  text-align: center;
}

/* Mobile Overlay */
.mobile-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,0.5);
  z-index: 1000;
}

/* ═══════════════════════════════════════════════════════════════════
   MODULE SYSTEM
   ═══════════════════════════════════════════════════════════════════ */

#modules {
  flex: 1;
  overflow: hidden;
  position: relative;
}

/* Module Base */
.module {
  display: none; /* Versteckt by default */
  flex-direction: row;
  height: 100%;
  width: 100%;
  position: absolute;
  top: 0;
  left: 0;
}

.module.active {
  display: flex; /* Nur aktives Modul sichtbar */
}

/* Module Sidebar */
.module-sidebar {
  width: 260px;
  flex-shrink: 0;
  border-right: 1px solid var(--border);
  background: var(--bg1);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Module Main */
.module-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg1);
}

/* Module Main - Empty State */
.module-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--txm);
  font-size: 13px;
}

/* ═══════════════════════════════════════════════════════════════════
   MOBILE RESPONSIVE
   ═══════════════════════════════════════════════════════════════════ */

@media (max-width: 767px) {
  #topbar {
    height: 56px;
    padding: 0 12px;
  }

  /* Hide rail, show hamburger + logo, show mobile drawer */
  #nav-rail { display: none; }
  #app { margin-left: 0; }
  /* topbar-logo already always visible */

  .hamburger {
    display: flex !important;
  }

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

  .mobile-nav {
    display: flex !important;
  }

  .module {
    flex-direction: column;
  }

  .module-sidebar {
    width: 100%;
    max-height: 40vh;
    min-height: 180px;
    border-right: none;
    border-bottom: none;
    overflow-y: auto;
    background: var(--bg1);
  }

  .module-main {
    flex: 1;
    overflow-y: auto;
    background: var(--bg2);
    border-top: 1px solid var(--border);
  }
}

/* ═══════════════════════════════════════════════════════════════════
   LIGHT MODE – spezifische Anpassungen
   ═══════════════════════════════════════════════════════════════════ */

[data-theme="light"] #nav-rail {
  box-shadow: 0 0 0 1px var(--border);
}

[data-theme="light"] .module-sidebar {
  box-shadow: 1px 0 0 0 var(--border);
}

[data-theme="light"] .kontakt-item,
[data-theme="light"] .hw-item,
[data-theme="light"] .list-item {
  box-shadow: 0 1px 2px rgba(0,0,0,.04);
}

[data-theme="light"] .modal-box,
[data-theme="light"] .user-menu {
  box-shadow: var(--shadow);
}

/* Gradient-Buttons bleiben in beiden Modi gleich */
[data-theme="light"] .hwd-save-btn,
[data-theme="light"] .login-btn {
  color: #fff;
}

/* Badges/Chips: dunklere Schrift im Light Mode */
[data-theme="light"] .chip {
  color: var(--tx);
}

/* Input-Felder */
[data-theme="light"] input,
[data-theme="light"] select,
[data-theme="light"] textarea {
  background: var(--input-bg);
  border-color: var(--border2);
}

[data-theme="light"] input:focus,
[data-theme="light"] select:focus,
[data-theme="light"] textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(124,58,237,.15);
}
