/* App-Rahmen (js/app-shell.js): feste Seitenleiste links + schlanke Kopfzeile.
   Aktiv nur auf Seiten mit <body class="has-shell"> (alle eingeloggten Seiten). */

/* Seitenleiste schmaler als früher (248 px): Navigation in UI-Schriftgröße 13 px, 34-px-Zeilen. */
body.has-shell { --sidebar-w: 216px; padding-left: var(--sidebar-w); }

/* ============ SEITENLEISTE ============ */
.app-sidebar {
  position: fixed; top: 0; left: 0; bottom: 0; width: var(--sidebar-w); z-index: 30;
  display: flex; flex-direction: column;
  background:
    radial-gradient(120% 40% at 0% 0%, rgba(var(--accent-rgb), 0.07), transparent 70%),
    linear-gradient(180deg, var(--bg-sidebar), var(--bg-black));
  border-right: 1px solid var(--border);
}
.sidebar-brand {
  display: flex; align-items: center; gap: 11px; height: var(--topbar-h); flex-shrink: 0;
  padding: 0 18px; font-weight: 700; font-size: 15px; letter-spacing: -0.01em;
}
.sidebar-brand .logo-mark { width: 26px; height: 26px; border-radius: 8px; }
.sidebar-brand .logo-mark svg { width: 15px; height: 15px; }

.sidebar-nav {
  display: flex; flex-direction: column; justify-content: flex-start; align-items: stretch; gap: 2px;
  max-width: none; margin: 0; padding: 10px 12px; flex: 1; overflow-y: auto;
}
/* Aktiver Eintrag: weiche Verlaufsfläche Cyan→transparent mit leuchtendem Verlaufsbalken
   am Rand – kein Rahmenkasten. */
.sidebar-link {
  position: relative; display: flex; align-items: center; gap: 10px; height: 34px; padding: 0 10px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary); font-size: 13px; font-weight: 500;
  transition: background .15s, color .15s;
}
.sidebar-link svg { width: 16px; height: 16px; flex-shrink: 0; color: var(--text-tertiary); transition: color .15s; }
.sidebar-link:hover { color: var(--text-primary); background: rgba(255,255,255,0.04); }
.sidebar-link:hover svg { color: var(--text-secondary); }
.sidebar-link.is-active {
  color: var(--text-primary); font-weight: 600;
  background: linear-gradient(90deg, rgba(var(--accent-rgb), 0.16), rgba(var(--accent-2-rgb), 0.05) 70%, transparent);
}
.sidebar-link.is-active svg { color: var(--accent); filter: drop-shadow(0 0 6px rgba(var(--accent-rgb), 0.55)); }
.sidebar-link.is-active::before {
  content: ''; position: absolute; left: -12px; top: 8px; bottom: 8px; width: 3px;
  border-radius: 0 3px 3px 0; background: linear-gradient(180deg, var(--accent), var(--accent-2));
  box-shadow: 0 0 12px rgba(var(--accent-rgb), 0.7);
}
.sidebar-link:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

/* Nutzerblock unten: Avatar (Initialen), Anzeigename, darunter Funktion bzw. E-Mail. Klick
   öffnet ein Menü nach oben (Einstellungen, Abmelden). Fehlt die KI, sitzt ein Warnpunkt am Avatar. */
.sidebar-foot { position: relative; flex-shrink: 0; border-top: 1px solid var(--border); }
.sidebar-foot .foot-btn { font-family: inherit; }
.foot-btn {
  display: flex; align-items: center; gap: 11px; width: calc(100% - 16px); margin: 8px; padding: 9px 10px;
  border-radius: var(--radius-md);
  background: none; border: none; cursor: pointer; text-align: left; color: inherit; transition: background .12s;
}
.foot-btn:hover, .foot-btn[aria-expanded="true"] { background: rgba(255,255,255,0.04); }
.foot-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.sidebar-foot .avatar {
  position: relative; width: 32px; height: 32px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  background: var(--accent-grad); color: var(--accent-ink);
  font-size: 11.5px; font-weight: 700; letter-spacing: 0.02em;
  box-shadow: 0 0 12px rgba(var(--accent-rgb), 0.25);
}
.sidebar-foot.is-bad .avatar::after {
  content: ''; position: absolute; right: -3px; top: -3px; width: 10px; height: 10px; border-radius: 50%;
  background: var(--warn); border: 2px solid var(--bg-sidebar);
}
.foot-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.foot-name { font-size: 13px; font-weight: 600; color: var(--text-primary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.foot-sub { font-size: 11px; color: var(--text-tertiary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.foot-chev svg { width: 15px; height: 15px; display: block; color: var(--text-tertiary); transition: transform .15s; }
.foot-btn[aria-expanded="true"] .foot-chev svg { transform: rotate(180deg); }

.foot-menu {
  position: absolute; left: 10px; right: 10px; bottom: calc(100% + 6px); z-index: 50; padding: 5px;
  background: var(--bg-raised); border: 1px solid var(--border-strong); border-radius: var(--radius-md);
  box-shadow: 0 20px 48px rgba(0,0,0,0.55);
}
.foot-menu[hidden] { display: none; }
.foot-menu-head { display: flex; flex-direction: column; gap: 2px; padding: 8px 10px 9px; border-bottom: 1px solid var(--border); margin-bottom: 4px; }
.foot-menu-head b { font-size: 12.5px; }
.foot-menu-head span { font-size: 11px; color: var(--text-tertiary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.foot-menu-item {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 10px; border-radius: var(--radius-sm);
  background: none; border: none; cursor: pointer; text-align: left; color: var(--text-primary); font-size: 13px; font-family: inherit;
}
.foot-menu-item[hidden] { display: none; }
.foot-menu-item svg { width: 15px; height: 15px; flex-shrink: 0; color: var(--text-tertiary); }
.foot-menu-item:hover, .foot-menu-item:focus-visible { background: rgba(255,255,255,0.06); outline: none; }
.foot-menu-item.is-warn, .foot-menu-item.is-warn svg { color: var(--warn); }
.foot-menu-sep { height: 1px; margin: 4px 2px; background: var(--border); }

/* ============ KOPFZEILE ============ */
header.app-topbar { background: var(--bg-chrome); backdrop-filter: blur(14px); border-bottom: 1px solid var(--border); }
header.app-topbar nav {
  max-width: none; height: var(--topbar-h); padding: 0 28px; gap: 16px;
}
.topbar-crumbs { display: flex; align-items: center; gap: 10px; min-width: 0; font-size: 15px; font-weight: 600; letter-spacing: -0.01em; }
.topbar-crumbs a { color: var(--text-tertiary); font-weight: 500; }
.topbar-crumbs a:hover { color: var(--text-primary); }
.topbar-crumbs .sep { color: var(--text-tertiary); opacity: .6; }
.topbar-crumbs .current { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

body.has-shell main { padding: 24px 0 64px; }
/* "Zurück zur Übersicht" übernimmt im Rahmen die Brotkrume in der Kopfzeile. */

/* ============ SCHMAL: Seitenleiste nur mit Icons ============ */
@media (max-width: 900px) {
  body.has-shell { --sidebar-w: 60px; }
  .app-sidebar .sidebar-label { display: none; }
  .sidebar-brand { justify-content: center; padding: 0; }
  .sidebar-nav { padding: 12px 8px; }
  .sidebar-link { justify-content: center; padding: 11px 0; }
  .sidebar-link.is-active::before { left: -8px; }
  .foot-btn { justify-content: center; padding: 8px 0; margin: 8px 4px; width: calc(100% - 8px); }
  .foot-menu { right: auto; width: 240px; left: 8px; }
}

@media print {
  .app-sidebar { display: none; }
  body.has-shell { padding-left: 0; }
}
