/* ================================================================
   NAV.CSS - ZENTRALE NAVIGATIONS-STRUKTUR (MIT GLAS-OPTIK & MOBILE)
   ================================================================ */

/* ===== LIZENZ-BANNER (nicht wegklickbar) ===== */
.license-banner {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 9999;
  align-items: center;
  gap: 12px;
  padding: 12px 20px;
  font-size: 14px;
  font-weight: 500;
  color: #fff;
  box-shadow: 0 2px 12px rgba(0,0,0,.35);
}
.license-banner-icon { font-size: 18px; flex-shrink: 0; }
.license-banner-text { flex: 1; }
.license-banner-link a { color: #fff; text-decoration: underline; font-weight: 700; flex-shrink: 0; }
.license-banner-red { background: linear-gradient(90deg, #dc2626, #b91c1c); }
.license-banner-error { background: linear-gradient(90deg, #7c3aed, #6d28d9); }
.license-locked-link { cursor: not-allowed !important; }
.no-license-box {
  grid-column: 1 / -1;
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}
.no-license-box i { font-size: 48px; color: #dc2626; margin-bottom: 16px; }
.no-license-box h2 { color: var(--text-primary); margin: 0 0 8px; }
.no-license-box p { max-width: 480px; margin: 0 auto 20px; line-height: 1.6; }

/* ===== SIDEBAR ===== */
.sidebar-nav {
    width: 240px;
    min-height: 100vh;
    height: 100vh;
    box-sizing: border-box;
    position: sticky;
    top: 0;
    overflow-y: hidden;
    flex-shrink: 0;
    align-self: flex-start;
    padding: 16px 12px;
    z-index: 100;
    transition: background-color 0.2s ease;
    
    background: var(--bg-sidebar);
    border-right: 1px solid var(--divider-sidebar);
    display: flex;
    flex-direction: column;
}

/* ===== DARK MODE GLAS ===== */
[data-theme="dark"] .sidebar-nav {
    background: #0f172a;
    border-right: 1px solid rgba(255, 255, 255, 0.06);
}

/* ===== SCROLL-PERFORMANCE: backdrop-filter der Sidebar deaktivieren ===== */
/* dark.css laedt nach nav.css und setzt blur(12px) -> hier mit !important ueberschreiben,
   ohne dark.css selbst anzufassen. */
[data-theme="dark"] .sidebar-nav {
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    background: #0f172a !important;
}

[data-theme="light"] .sidebar-nav {
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
}

/* ===== LIGHT MODE GLAS ===== */
[data-theme="light"] .sidebar-nav {
    position: sticky;
    background: transparent;
    -webkit-border-right: 1px solid rgba(255, 255, 255, 0.12);
}

[data-theme="light"] .sidebar-nav::after {
    content: "";
    position: absolute;
    inset: 0;
    /* vertikaler Nav-Verlauf als Farbe */
    background: linear-gradient(180deg, #14b8a6 0%, #84cc16 100%);
    /* horizontal: links 100% deckend -> rechts 100% transparent */
    -webkit-mask-image: linear-gradient(90deg, #000 0%, #000 35%, transparent 100%);
    mask-image: linear-gradient(90deg, #000 0%, #000 35%, transparent 100%);
    pointer-events: none;
    z-index: 0;
}

[data-theme="light"] .sidebar-nav > * {
    position: relative;
    z-index: 1;
}

.sidebar-nav::-webkit-scrollbar {
    width: 4px;
}
.sidebar-nav::-webkit-scrollbar-track {
    background: transparent;
}
.sidebar-nav::-webkit-scrollbar-thumb {
    background: var(--divider-sidebar);
    border-radius: 4px;
}

/* ===== NAVIGATION LINKS CONTAINER ===== */
.sidebar-links {
    flex: 1;
    overflow-y: auto;
}

/* ===== LOGO ===== */
.sidebar-logo-container {
    margin-bottom: 24px;
    text-align: center;
    padding: 8px 0;
    flex-shrink: 0;
}

.sidebar-logo {
    max-width: 100%;
    max-height: 50px;
    object-fit: contain;
}

.cms-logo {
    font-size: 22px;
    font-weight: 700;
    letter-spacing: -0.5px;
    color: var(--text-sidebar-hover);
}

/* ===== NAVIGATION LINKS ===== */
.sidebar-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    border-radius: 8px;
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    margin-bottom: 2px;
    transition: background-color 0.15s ease, color 0.15s ease;
    color: var(--text-sidebar);
}

.sidebar-link:hover {
    background: var(--bg-sidebar-hover);
    color: var(--text-sidebar-hover);
}

.sidebar-link.active {
    background: var(--bg-sidebar-active);
    color: var(--text-sidebar-active);
    box-shadow: var(--shadow-sidebar-active);
}

.sidebar-link .icon {
    width: 22px;
    text-align: center;
    flex-shrink: 0;
    font-size: 16px;
}

.sidebar-link .label {
    flex: 1;
}

/* ===== KLAPPBARE KATEGORIEN (PARENT/CHILD) ===== */
.sidebar-group {
  display: block;
  margin: 6px 0;
}

.sidebar-group-toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 11px 16px;
  /* Verlauf wie im Admin-Bereich Header (Indigo) */
  background: linear-gradient(90deg, rgba(99,102,241,.22), rgba(99,102,241,.04));
  border: none;
  border-bottom: 2px solid #6366f1;
  color: var(--text-primary);
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  text-align: left;
  border-radius: 8px 8px 6px 6px;
  letter-spacing: .3px;
  /* dauerhaft wie "hover" - beim echten hover animiert zu durchgehend indigo */
  background-size: 200% 100%;
  background-position: 0% 0%;
  transition: background-position 0.35s ease, background 0.35s ease, box-shadow 0.2s ease;
  box-shadow: 0 3px 12px rgba(99, 102, 241, 0.22);
}

.sidebar-group-toggle .icon,
.sidebar-group-toggle .sidebar-group-caret {
  color: #818cf8;
}

.sidebar-group-toggle:hover {
  background: linear-gradient(90deg, #6366f1, #6366f1);
  background-size: 200% 100%;
  background-position: 100% 0%;
  color: #fff;
  box-shadow: 0 5px 16px rgba(99, 102, 241, 0.4);
}

.sidebar-group-toggle:hover .icon,
.sidebar-group-toggle:hover .sidebar-group-caret {
  color: #fff;
}

.sidebar-group-toggle .icon {
  width: 20px;
  text-align: center;
  flex-shrink: 0;
  font-size: 16px;
  opacity: 0.85;
}

.sidebar-group-toggle .label {
  flex: 1;
}

.sidebar-group-toggle .sidebar-group-caret {
  font-size: 12px;
  transition: transform 0.2s ease;
  opacity: 0.7;
}

.sidebar-group-toggle[aria-expanded="false"] .sidebar-group-caret {
  transform: rotate(-90deg);
}

.sidebar-group-items {
  /* Keine Einrueckung: verhindert haessliche Umbruche bei langen Labels */
}

.sidebar-sublink {
  padding: 9px 14px;
  font-size: 13px;
  font-weight: 400;
  opacity: 0.9;
  margin-bottom: 2px;
}

.sidebar-sublink.active {
  background: var(--bg-card-border);
  color: var(--text-primary);
}

/* ===== DIVIDER ===== */
.sidebar-divider {
    border: none;
    border-top: 2px solid var(--divider-sidebar);
    margin: 10px 12px;
    opacity: 1;
    height: 0;
    background: transparent;
    flex-shrink: 0;
}

/* ===== LOGOUT BUTTON ===== */
.sidebar-footer {
    margin-top: auto;
    padding-top: 12px;
    border-top: 2px solid var(--divider-sidebar);
    flex-shrink: 0;
}

.sidebar-footer .sidebar-link {
    margin-bottom: 0;
}

.sidebar-footer .sidebar-link.logout-link {
    color: var(--text-error);
    transition: background-color 0.15s ease;
}

.sidebar-footer .sidebar-link.logout-link:hover {
    color: var(--text-error);
    background: var(--bg-error);
    box-shadow: 0 0 20px rgba(255, 68, 68, 0.05);
}

.sidebar-footer .sidebar-link.logout-link .icon {
    color: var(--text-error);
    transition: color 0.3s ease;
}

.sidebar-footer .sidebar-link.logout-link:hover .icon {
    color: var(--text-error);
}

/* ================================================================
   DESKTOP (ab 769px)
   ================================================================ */
@media (min-width: 769px) {
    .sidebar-nav {
        width: 240px;
        padding: 16px 12px;
        position: sticky;
        left: 0;
    }
    .sidebar-nav .label {
        display: block !important;
        font-size: 14px;
    }
    .sidebar-nav .sidebar-link {
        gap: 12px;
        padding: 10px 14px;
    }
    .sidebar-nav .sidebar-link .icon {
        font-size: 16px;
        width: 22px;
    }
    .menu-toggle {
        display: none !important;
    }
    .sidebar-overlay {
        display: none !important;
    }
}

/* ================================================================
   TABLET (769px - 1199px)
   ================================================================ */
@media (max-width: 1199px) and (min-width: 769px) {
    .sidebar-nav {
        width: 200px;
        padding: 14px 10px;
    }
    .sidebar-nav .label {
        display: block !important;
        font-size: 13px;
    }
    .sidebar-nav .sidebar-link {
        gap: 10px;
        padding: 8px 12px;
    }
    .sidebar-nav .sidebar-link .icon {
        font-size: 15px;
        width: 20px;
    }
    .sidebar-logo-container {
        display: none;
    }
    .sidebar-divider {
        margin: 8px 8px;
    }
}

/* ================================================================
   MOBILE (unter 768px) - HAMBURGER MENÜ
   ================================================================ */
@media (max-width: 768px) {
    /* Sidebar als Overlay */
    .sidebar-nav {
        position: fixed;
        top: 0;
        left: -300px;
        width: 280px;
        height: 100vh;
        z-index: 9999;
        padding: 20px 16px;
        transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        box-shadow: 4px 0 30px rgba(0, 0, 0, 0.3);
        border-right: 1px solid var(--divider-sidebar);
    }
    
    .sidebar-nav.open {
        left: 0;
    }
    
    /* Labels in der mobilen Sidebar */
    .sidebar-nav .label {
        display: block !important;
        font-size: 14px;
    }
    
    .sidebar-nav .sidebar-link {
        gap: 12px;
        padding: 12px 14px;
        font-size: 15px;
    }
    
    .sidebar-nav .sidebar-link .icon {
        font-size: 20px;
        width: 28px;
    }
    
    .sidebar-logo-container {
        display: block;
        margin-bottom: 20px;
    }
    
    /* Overlay-Hintergrund */
    .sidebar-overlay {
        display: none;
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: 9998;
        -webkit-animation: overlayFade 0.3s ease;
    }
    
    .sidebar-overlay.active {
        display: block;
    }
    
    /* Hamburger-Button */
    .menu-toggle {
        display: flex !important;
        position: fixed;
        bottom: 20px;
        left: 50%;
        transform: translateX(-50%);
        z-index: 10000;
        width: 56px;
        height: 56px;
        border-radius: 28px;
        border: 1px solid var(--border-color);
        background: var(--bg-card);
        -webkit-color: var(--text-primary);
        font-size: 24px;
        cursor: pointer;
        align-items: center;
        justify-content: center;
        box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
        transition: all 0.2s ease;
    }
    
    .menu-toggle:hover {
        transform: scale(1.05);
        box-shadow: 0 6px 24px rgba(0, 0, 0, 0.18);
    }
    
    .menu-toggle:active {
        transform: scale(0.95);
    }
    
    /* Dark Mode Hamburger */
    [data-theme="dark"] .menu-toggle {
        background: var(--bg-sidebar);
        border-color: rgba(255, 255, 255, 0.08);
        color: var(--text-sidebar-hover);
    }
    
    /* Light Mode Hamburger */
    [data-theme="light"] .menu-toggle {
        background: var(--bg-card);
        border-color: rgba(0, 0, 0, 0.06);
        color: var(--text-primary);
    }
}

/* ================================================================
   MOBILE KLEIN (unter 480px)
   ================================================================ */
@media (max-width: 480px) {
    .sidebar-nav {
        width: 280px;
        left: -290px;
        padding: 16px 12px;
    }

    .sidebar-nav.open {
        left: 0;
    }

    .sidebar-nav .label {
        font-size: 14px;
    }

    .sidebar-nav .sidebar-link {
        padding: 10px 12px;
        font-size: 14px;
    }

    .sidebar-nav .sidebar-link .icon {
        font-size: 18px;
        width: 24px;
    }

    .menu-toggle {
        width: 52px;
        height: 52px;
        font-size: 20px;
        bottom: 16px;
        left: 50%;
        transform: translateX(-50%);
        border-radius: 26px;
    }
}

/* ================================================================
   ANIMATIONEN
   ================================================================ */
@keyframes overlayFade {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* ================================================================
   SCROLLBAR
   ================================================================ */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: var(--bg-body);
}
::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}