/* Globale Design-Token (Theme-Variablen) */
:root {
    --bg-primary: #f8f9fa;
    --bg-surface: #ffffff;
    --text-primary: #212529;
    --text-secondary: #6c757d;
    --color-primary: #4f46e5;      /* Modernes Indigo */
    --color-primary-hover: #4338ca;
    --color-danger: #ef4444;
    --border-color: #e5e7eb;
    --radius-md: 12px;
    --radius-sm: 8px;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
    --transition: all 0.2s ease-in-out;
}

/* Reset & Basis-Styles */
* { box-sizing: border-box; margin: 0; padding: 0; }
body { 
    font-family: 'Inter', system-ui, -apple-system, sans-serif; 
    background-color: var(--bg-primary); 
    color: var(--text-primary);
    line-height: 1.5;
}

/* --- Globaler fixierter Header --- */
.app-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 70px;
    background-color: var(--bg-surface);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 40px;
    /* WICHTIG: Der Header muss hoch genug liegen, um das Dropdown anzuzeigen */
    z-index: 1050; 
}
.header-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--color-primary);
}
.header-nav {
    display: flex;
    gap: 20px;
    align-items: center;
}
.header-nav-link {
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
    transition: var(--transition);
}
.header-nav-link:hover {
    color: var(--color-primary);
}

/* --- Layout Anpassung für fixierten Header --- */
.app-container {
    display: flex;
    min-height: 100vh;
    padding-top: 70px;
    /* WICHTIG: Darf den Header nicht überlagern */
    position: relative;
    z-index: 1; 
}

/* Sidebar Anpassung: Scrollt jetzt unabhängig unter dem Header */
.sidebar {
    width: 260px;
    background-color: var(--bg-surface);
    border-right: 1px solid var(--border-color);
    padding: 24px;
    display: flex;
    flex-direction: column;
    height: calc(100vh - 70px);
    position: sticky;
    top: 70px;
    /* WICHTIG: Höher als der Content, aber niedriger als der Header */
    z-index: 100; 
}

.sidebar-brand { font-size: 1.25rem; font-weight: 700; color: var(--color-primary); margin-bottom: 32px; }
.nav-menu { list-style: none; display: flex; flex-direction: column; gap: 8px; }
.nav-link {
    display: block;
    padding: 12px 16px;
    color: var(--text-secondary);
    text-decoration: none;
    font-weight: 500;
    border-radius: var(--radius-sm);
    transition: var(--transition);
}
.nav-link:hover, .nav-link.active {
    background-color: #f3f4f6;
    color: var(--color-primary);
}

/* Hauptinhalt */
.main-content { flex: 1; padding: 40px; max-width: 1200px; }

/* UI Komponenten */
.card {
    background-color: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 24px;
    box-shadow: var(--shadow-md);
}
h1 { font-size: 1.75rem; font-weight: 700; margin-bottom: 24px; }

/* Admin Dashboard Erweiterungen */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 24px;
    margin-bottom: 32px;
}
.stat-card {
    background-color: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 24px;
    box-shadow: var(--shadow-sm);
}
.stat-label { font-size: 0.875rem; color: var(--text-secondary); font-weight: 500; }
.stat-value { font-size: 1.75rem; font-weight: 700; color: var(--text-primary); margin-top: 4px; }
.stat-trend { font-size: 0.8125rem; margin-top: 8px; font-weight: 600; }
.trend-up { color: #10b981; } /* Grün */

/* Daten-Tabellen */
.table-responsive { width: 100%; overflow-x: auto; margin-top: 16px; }
.admin-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
    font-size: 0.9375rem;
}
.admin-table th {
    background-color: #f9fafb;
    padding: 12px 16px;
    color: var(--text-secondary);
    font-weight: 600;
    border-bottom: 1px solid var(--border-color);
}
.admin-table td {
    padding: 16px;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-primary);
}
.admin-table tr:hover { background-color: #f9fafb; }

/* Status Badges */
.badge {
    display: inline-block;
    padding: 4px 8px;
    font-size: 0.75rem;
    font-weight: 600;
    border-radius: 9999px;
}
.badge-admin { background-color: #e0e7ff; color: #4338ca; }
.badge-user { background-color: #f3f4f6; color: #374151; }

/* --- Header Drop-Down System --- */
.dropdown {
    position: relative;
    display: inline-block;
    cursor: pointer;
}

/* Der Container, der standardmäßig unsichtbar ist */
.dropdown-menu {
    display: none;
    position: absolute;
    right: 0;
    top: 100%; 
    background-color: var(--bg-surface);
    min-width: 160px;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 8px 0;
    z-index: 1100;
    /* ENTFERNT: margin-top: 8px; (Das hat die physikalische Lücke erzeugt!) */
}

/* SENIOR-TRICK: Wir nutzen ein unsichtbares ::before-Element, um eine Brücke 
   zwischen Header und Menü zu bauen. So bleibt der Hover-Zustand aktiv! */
.dropdown-menu::before {
    content: "";
    position: absolute;
    top: -12px; /* Schließt die Lücke von 12 Pixeln nach oben unsichtbar */
    left: 0;
    right: 0;
    height: 12px;
    background: transparent; /* Unsichtbare Brücke */
}

/* Links innerhalb des Drop-Downs */
.dropdown-item {
    color: var(--text-primary);
    padding: 10px 16px;
    text-decoration: none;
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    transition: var(--transition);
}

.dropdown-item:hover {
    background-color: #f3f4f6;
    color: var(--color-primary);
}

/* Senior-Trick: Blendet das Menü ein, wenn die Maus über das .dropdown-Element fährt */
.dropdown:hover .dropdown-menu,
.dropdown-menu:hover {
    display: block;
}


/* Optionaler kleiner Pfeil neben dem Namen */
.dropdown-trigger::after {
    content: " ▾";
    font-size: 0.8rem;
    color: var(--text-secondary);
}

/* --- Interner Dashboard Header --- */
.dashboard-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background-color: var(--bg-surface);
    padding: 20px 24px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
    margin-bottom: 32px; /* Abstand zum darauffolgenden Statistik-Grid */
}
.dashboard-title-area h2 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
}
.dashboard-title-area p {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-top: 4px;
}
.dashboard-actions {
    display: flex;
    gap: 12px;
}
.btn-action {
    padding: 10px 16px;
    font-size: 0.875rem;
    font-weight: 600;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
}
.btn-action-primary {
    background-color: var(--color-primary);
    color: white;
    border: none;
}
.btn-action-primary:hover { background-color: var(--color-primary-hover); }
.btn-action-secondary {
    background-color: transparent;
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}
.btn-action-secondary:hover { background-color: #f9fafb; }




/* --- Media Query für Smartphones und Tablets (max-width: 768px) --- */
@media screen and (max-width: 768px) {
    /* 1. Header anpassen */
    .app-header {
        height: 60px;
        padding: 0 16px;
        z-index: 2000; /* Auf dem Handy extrem hoch ansetzen für das Burger-Icon */
    }
    .header-title {
        font-size: 1rem; /* Kleinere Schrift auf Mobilgeräten */
    }
    .header-nav-link {
        display: none; /* Unwichtige Header-Links auf dem Handy ausblenden */
    }

    /* 2. Layout von Nebeneinander (Flex) auf Untereinander (Block) umstellen */
    .app-container {
        padding-top: 60px;
        display: block;
    }

    /* 3. Die Sidebar wird oben als horizontales Menü fixiert */
    .sidebar {
        position: fixed !important;
        top: 60px;
        left: -260px; /* Startet versteckt */
        width: 260px;
        height: calc(100vh - 60px);
        /* WICHTIG: Muss über dem Content liegen, aber unter dem Header-Balken */
        z-index: 1500 !important; 
        transition: left 0.3s ease-in-out;
    }
    .sidebar-brand {
        display: none; /* Logo in der mobilen Sidebar ausblenden, da es im Header steht */
    }
    .nav-menu {
        flex-direction: row; /* Links nebeneinander statt untereinander */
        justify-content: space-around; /* Gleichmäßige Verteilung */
        gap: 0;
    }
    .nav-link {
        padding: 8px 12px;
        font-size: 0.85rem;
    }

    /* 4. Hauptinhalt nimmt jetzt die volle Breite ein */
    .main-content {
        padding: 16px;
        width: 100%;
    }

    /* 5. Interne Dashboard-Header neu anordnen (Untereinander statt nebeneinander) */
    .dashboard-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 16px;
        padding: 16px;
        margin-bottom: 20px;
    }
    .dashboard-actions {
        width: 100%;
        justify-content: stretch;
    }
    .btn-action {
        flex: 1; /* Buttons nehmen mobil gleich viel Platz ein */
        text-align: center;
        justify-content: center;
    }

    /* 6. Statistik-Karten werden einspaltig */
    .stats-grid {
        grid-template-columns: 1fr; /* Zwingt die Karten untereinander */
        gap: 16px;
        margin-bottom: 24px;
    }
    .stat-card {
        padding: 16px;
    }

    /* 7. Grid-Formulare brechen sauber in eine Spalte um */
    div[style*="display: grid"] {
        grid-template-columns: 1fr !important; /* Überschreibt das 2-Spalten-Grid der Formulare */
        gap: 16px !important;
    }

    /* 8. UI Karten-Abstände minimieren */
    .card {
        padding: 16px;
    }
}

/* ==========================================================================
   BURGER-MENÜ SYSTEM (Reines CSS)
   ========================================================================== */

/* Auf dem Desktop standardmäßig alles verstecken */
.mobile-burger-container {
    display: none;
}

@media screen and (max-width: 768px) {
    /* 1. Burger-Container im Header einblenden */
    .mobile-burger-container {
        display: block;
        position: relative;
        z-index: 2100; /* Höher als alles andere im Header, damit der Klick durchgeht */
    }

    /* Die tatsächliche Checkbox unsichtbar machen */
    .burger-checkbox {
        display: none;
    }

    /* Das optische Burger-Icon (3 Querstriche) stylen */
    .burger-label {
        display: flex;
        flex-direction: column;
        justify-content: space-between;
        width: 24px;
        height: 18px;
        cursor: pointer;
        z-index: 1200;
        position: relative;
    }

    .burger-label span {
        display: block;
        height: 2px;
        width: 100%;
        background-color: var(--text-primary);
        border-radius: 9px;
        transition: all 0.3s ease-in-out;
    }

    /* 2. Die Sidebar mobil als Flyout-Menü von links deklarieren */
    .sidebar {
        position: fixed !important;
        top: 60px;
        left: -260px; /* Startposition: Komplett außerhalb des linken Bildschirmrands */
        width: 260px;
        height: calc(100vh - 60px);
        z-index: 999;
        box-shadow: 10px 0 15px -3px rgba(0, 0, 0, 0.05);
        transition: left 0.3s ease-in-out; /* Schiebe-Animation */
        display: flex !important;
        flex-direction: column;
    }

    /* Die Navigationslinks in der mobilen Sidebar wieder untereinander anordnen */
    .nav-menu {
        flex-direction: column !important;
        gap: 12px;
    }

    /* 3. DIE CSS-MAGIE: Wenn die Checkbox AKTIV (:checked) ist... */
    
    /* ...schiebe die Sidebar flüssig ins Bild hinein (left: 0) */
    .burger-checkbox:checked ~ .app-container .sidebar,
    #burger-toggle:checked ~ .app-container .sidebar {
        left: 0;
    }

    /* ...und verwandle das Burger-Icon in ein schickes Schließen-X */
    .burger-checkbox:checked + .burger-label span:nth-child(1) {
        transform: translateY(8px) rotate(45deg);
    }
    .burger-checkbox:checked + .burger-label span:nth-child(2) {
        opacity: 0; /* Mittlerer Strich verschwindet */
    }
    .burger-checkbox:checked + .burger-label span:nth-child(3) {
        transform: translateY(-8px) rotate(-45deg);
    }
}




/* ==========================================================================
   PRINT STYLES (Wird nur beim Drucken/PDF-Export aktiv)
   ========================================================================== */
@media print {
    /* 1. Unnötige UI-Elemente komplett ausblenden */
    .app-header, 
    .sidebar, 
    .dashboard-actions,
    .admin-table th:last-child, /* Blendit die "Aktion"-Spalte in der Tabelle aus */
    .admin-table td:last-child,
    .dashboard-header { 
        display: none !important; 
    }

    /* 2. Layout-Beschränkungen für das Papier aufheben */
    body {
        background-color: #fff !important;
        color: #000 !important;
        font-size: 12pt;
    }

    .app-container {
        padding-top: 0 !important; /* Fixierten Header-Abstand entfernen */
        display: block !important;
    }

    .main-content {
        padding: 0 !important;
        margin: 0 !important;
        max-width: 100% !important;
        width: 100% !important;
    }

    /* 3. Dashboard-Header und Karten für den Druck optimieren */
    .dashboard-header {
        border: none !important;
        box-shadow: none !important;
        padding: 0 0 20px 0 !important;
        border-bottom: 2px solid #000 !important;
        margin-bottom: 30px !important;
    }

    .card, .stat-card {
        border: 1px solid #ccc !important;
        box-shadow: none !important;
        page-break-inside: avoid; /* Verhindert unschöne Seitenumbrüche mitten in einer Karte */
    }
}
