/* ============================================================
   Berichtsheft Online - Basis-Design (Phase 1)
   ============================================================ */

:root {
    --color-primary: #4f46e5;
    --color-primary-hover: #4338ca;
    --color-bg: #f4f5f9;
    --color-card: #ffffff;
    --color-text: #1e2130;
    --color-text-muted: #6b7280;
    --color-border: #e2e4ec;
    --color-error-bg: #fee2e2;
    --color-error-text: #b91c1c;
    --radius: 12px;
    --shadow: 0 4px 20px rgba(20, 20, 40, 0.06);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background: var(--color-bg);
    color: var(--color-text);
}

.center-page {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 24px;
    gap: 16px;
}

.landing-card,
.auth-card {
    background: var(--color-card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 40px;
    width: 100%;
    max-width: 440px;
}

.landing-card {
    text-align: center;
}

.landing-actions {
    display: flex;
    gap: 12px;
    margin-top: 24px;
    justify-content: center;
    flex-wrap: wrap;
}

h1 {
    font-size: 1.6rem;
    margin: 0 0 8px;
}

.subtitle {
    color: var(--color-text-muted);
    margin: 0 0 24px;
    font-size: 0.95rem;
}

.form-row {
    display: flex;
    gap: 12px;
}

.form-row .form-group {
    flex: 1;
}

.form-group {
    margin-bottom: 16px;
}

label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    margin-bottom: 6px;
    color: var(--color-text);
}

input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--color-border);
    border-radius: 8px;
    font-size: 0.95rem;
    transition: border-color 0.15s ease;
}

input:focus {
    outline: none;
    border-color: var(--color-primary);
}

.btn {
    display: inline-block;
    padding: 11px 20px;
    border-radius: 8px;
    font-weight: 600;
    font-size: 0.95rem;
    text-decoration: none;
    border: none;
    cursor: pointer;
    transition: background-color 0.15s ease, transform 0.05s ease;
}

.btn:active {
    transform: translateY(1px);
}

.btn-primary {
    background: var(--color-primary);
    color: #fff;
}

.btn-primary:hover {
    background: var(--color-primary-hover);
}

.btn-secondary {
    background: #eef0fb;
    color: var(--color-primary);
}

.btn-secondary:hover {
    background: #e0e3fa;
}

.btn-block {
    width: 100%;
    text-align: center;
}

.switch-link {
    text-align: center;
    margin-top: 20px;
    font-size: 0.9rem;
    color: var(--color-text-muted);
}

.switch-link a {
    color: var(--color-primary);
    text-decoration: none;
    font-weight: 600;
}

.error-box {
    background: var(--color-error-bg);
    color: var(--color-error-text);
    padding: 10px 14px;
    border-radius: 8px;
    font-size: 0.85rem;
    margin-bottom: 16px;
}

/* Responsive: Formularreihen auf kleinen Bildschirmen untereinander */
@media (max-width: 480px) {
    .form-row {
        flex-direction: column;
        gap: 0;
    }

    .auth-card,
    .landing-card {
        padding: 28px 22px;
    }
}

/* ============================================================
   App-Layout mit Sidebar (Phase 2: Dashboard und Folgeseiten)
   ============================================================ */

.app-layout {
    display: flex;
    min-height: 100vh;
}

/* --- Sidebar --- */

.sidebar {
    width: 260px;
    flex-shrink: 0;
    background: #ffffff;
    border-right: 1px solid var(--color-border);
    display: flex;
    flex-direction: column;
    padding: 20px 0;
}

.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px 20px;
}

.sidebar-logo {
    font-weight: 700;
    font-size: 1.05rem;
}

.sidebar-close-btn {
    display: none;
    background: none;
    border: none;
    font-size: 1.1rem;
    cursor: pointer;
    color: var(--color-text-muted);
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 0 12px;
    flex: 1;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: 8px;
    text-decoration: none;
    color: var(--color-text);
    font-size: 0.92rem;
    font-weight: 500;
    position: relative;
}

.nav-item:hover {
    background: var(--color-bg);
}

.nav-item.active {
    background: #eef0fb;
    color: var(--color-primary);
    font-weight: 700;
}

.nav-icon {
    font-size: 1.05rem;
    width: 20px;
    text-align: center;
}

.badge-soon {
    margin-left: auto;
    font-size: 0.65rem;
    background: #f1f2f6;
    color: var(--color-text-muted);
    padding: 2px 7px;
    border-radius: 999px;
    font-weight: 600;
}

.sidebar-footer {
    padding: 12px;
    border-top: 1px solid var(--color-border);
    margin-top: 12px;
}

.sidebar-user {
    padding: 8px 12px 4px;
    font-size: 0.8rem;
    color: var(--color-text-muted);
    font-weight: 600;
}

.logout-item {
    color: #b91c1c;
}

.sidebar-overlay {
    display: none;
}

/* --- Hauptbereich --- */

.main-column {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.topbar {
    display: none;
    align-items: center;
    gap: 14px;
    padding: 14px 20px;
    background: #fff;
    border-bottom: 1px solid var(--color-border);
}

.topbar-menu-btn {
    background: none;
    border: none;
    font-size: 1.3rem;
    cursor: pointer;
}

.topbar-title {
    font-weight: 700;
}

.main-content {
    padding: 32px;
    max-width: 980px;
    width: 100%;
}

.main-content h1 {
    margin-bottom: 4px;
}

.main-content .subtitle {
    margin-bottom: 28px;
}

/* --- Statistik-Karten --- */

.stat-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
    margin-bottom: 28px;
}

.stat-card {
    background: var(--color-card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.stat-value {
    font-size: 1.9rem;
    font-weight: 700;
    color: var(--color-primary);
}

.stat-label {
    font-size: 0.85rem;
    color: var(--color-text-muted);
}

/* --- Panel (z.B. "Letzte Berichte") --- */

.panel {
    background: var(--color-card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 24px;
}

.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.panel-header h2 {
    font-size: 1.1rem;
    margin: 0;
}

.btn-sm {
    padding: 8px 14px;
    font-size: 0.85rem;
}

.empty-state {
    text-align: center;
    padding: 32px 16px;
    color: var(--color-text-muted);
    font-size: 0.95rem;
    line-height: 1.6;
}

.empty-state .muted {
    font-size: 0.85rem;
    opacity: 0.8;
}

/* --- "Kommt bald"-Platzhalterseiten --- */

.coming-soon {
    text-align: center;
    padding: 60px 20px;
    max-width: 480px;
    margin: 0 auto;
}

.coming-soon-icon {
    font-size: 2.6rem;
    margin-bottom: 12px;
}

.coming-soon h1 {
    margin-bottom: 10px;
}

.coming-soon .subtitle {
    margin-bottom: 24px;
}

/* --- Responsive: Sidebar wird zum mobilen Off-Canvas-Menue --- */

@media (max-width: 860px) {
    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        height: 100vh;
        transform: translateX(-100%);
        transition: transform 0.2s ease;
        z-index: 50;
        box-shadow: 0 0 24px rgba(0,0,0,0.15);
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .sidebar-close-btn {
        display: block;
    }

    .sidebar-overlay {
        display: none;
        position: fixed;
        inset: 0;
        background: rgba(15, 17, 30, 0.4);
        z-index: 40;
    }

    .sidebar-overlay.visible {
        display: block;
    }

    .topbar {
        display: flex;
    }

    .main-content {
        padding: 20px;
    }

    .stat-grid {
        grid-template-columns: 1fr;
    }
}

/* ============================================================
   Berichte, Editor, Kalender, Übersicht (Phase 3 + 4)
   ============================================================ */

.btn-danger {
    background: #fee2e2;
    color: #b91c1c;
}

.btn-danger:hover {
    background: #fecaca;
}

/* --- Filterleiste (Berichte-Übersicht) --- */

.filter-bar {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 20px;
}

.filter-bar input,
.filter-bar select {
    padding: 9px 12px;
    border: 1px solid var(--color-border);
    border-radius: 8px;
    font-size: 0.88rem;
    background: #fff;
}

.filter-bar input {
    flex: 1;
    min-width: 200px;
}

/* --- Berichte-Liste (Dashboard + Übersicht) --- */

.report-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.report-row {
    background: var(--color-card);
    border: 1px solid var(--color-border);
    border-radius: 10px;
    padding: 14px 18px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}

.report-row-date {
    font-weight: 600;
    font-size: 0.92rem;
}

.report-row-preview {
    color: var(--color-text-muted);
    font-size: 0.85rem;
    margin-top: 4px;
    max-width: 520px;
}

.report-row-meta {
    margin-top: 8px;
    display: flex;
    gap: 6px;
}

.tag {
    display: inline-block;
    background: #f1f2f6;
    color: var(--color-text-muted);
    font-size: 0.72rem;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 999px;
}

.tag-school {
    background: #e0e7ff;
    color: var(--color-primary);
}

.report-row-actions {
    display: flex;
    gap: 6px;
    flex-shrink: 0;
}

.muted {
    color: var(--color-text-muted);
    font-weight: 400;
}

/* --- Editor --- */

.editor-content .panel {
    margin-bottom: 16px;
}

.editor-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.save-status {
    font-size: 0.8rem;
    color: var(--color-text-muted);
}

.computed-hours {
    font-size: 0.85rem;
    color: var(--color-primary);
    font-weight: 600;
    margin: 4px 0 0;
}

.panel-subheading {
    font-size: 1rem;
    margin: 0 0 14px;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 600;
    cursor: pointer;
}

.checkbox-label input {
    width: auto;
}

.school-fields {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--color-border);
}

textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--color-border);
    border-radius: 8px;
    font-size: 0.95rem;
    font-family: inherit;
    resize: vertical;
}

textarea:focus {
    outline: none;
    border-color: var(--color-primary);
}

/* --- Kalender --- */

.calendar-nav {
    display: flex;
    gap: 8px;
}

.calendar-legend {
    display: flex;
    gap: 18px;
    font-size: 0.85rem;
    color: var(--color-text-muted);
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.calendar-weekdays {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    text-align: center;
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--color-text-muted);
    margin-bottom: 6px;
}

.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 6px;
}

.calendar-cell {
    background: var(--color-card);
    border: 1px solid var(--color-border);
    border-radius: 8px;
    min-height: 64px;
    padding: 8px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    text-decoration: none;
    color: var(--color-text);
    cursor: pointer;
    transition: border-color 0.15s ease;
}

.calendar-cell:hover {
    border-color: var(--color-primary);
}

.calendar-cell-empty {
    background: transparent;
    border: none;
    cursor: default;
}

.calendar-cell-today {
    border-color: var(--color-primary);
    border-width: 2px;
}

.calendar-day-number {
    font-size: 0.85rem;
    font-weight: 600;
}

.calendar-dot {
    align-self: flex-end;
    font-size: 0.9rem;
}

/* --- Übersicht (Jahr / Monat / KW Baum) --- */

.tree-year {
    margin-bottom: 10px;
}

.tree-year > summary {
    font-size: 1.15rem;
    font-weight: 700;
    cursor: pointer;
    padding: 10px 0;
}

.tree-months {
    padding-left: 16px;
}

.tree-month summary {
    font-weight: 600;
    cursor: pointer;
    padding: 8px 0;
}

.tree-weeks {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 6px 0 10px 16px;
}

.tree-week {
    text-decoration: none;
    color: var(--color-text);
    font-size: 0.9rem;
    padding: 6px 10px;
    border-radius: 6px;
}

.tree-week:hover {
    background: var(--color-bg);
    color: var(--color-primary);
}

/* --- Responsive Anpassungen für Phase 3/4 Seiten --- */

@media (max-width: 700px) {
    .calendar-grid,
    .calendar-weekdays {
        grid-template-columns: repeat(7, minmax(0, 1fr));
    }

    .calendar-cell {
        min-height: 48px;
        padding: 5px;
    }

    .report-row {
        flex-direction: column;
        align-items: flex-start;
    }

    .report-row-actions {
        width: 100%;
    }
}

/* ============================================================
   Dark Mode (Phase 6)
   Ueberschreibt die CSS-Variablen aus :root, sobald
   <html data-theme="dark"> gesetzt ist (siehe js/theme.js).
   ============================================================ */

:root[data-theme="dark"] {
    --color-primary: #818cf8;
    --color-primary-hover: #a5b4fc;
    --color-bg: #14151f;
    --color-card: #1c1d2b;
    --color-text: #e7e8f3;
    --color-text-muted: #9498b0;
    --color-border: #2f3145;
    --color-error-bg: #3a1a1a;
    --color-error-text: #f87171;
    --shadow: 0 4px 20px rgba(0, 0, 0, 0.45);
}

:root[data-theme="dark"] input,
:root[data-theme="dark"] select,
:root[data-theme="dark"] textarea {
    background: #23253a;
    color: var(--color-text);
    border-color: var(--color-border);
}

:root[data-theme="dark"] .sidebar,
:root[data-theme="dark"] .topbar {
    background: var(--color-card);
}

:root[data-theme="dark"] .nav-item.active {
    background: #2a2c47;
}

:root[data-theme="dark"] .btn-secondary {
    background: #2a2c47;
    color: #c7cbf5;
}

:root[data-theme="dark"] .btn-secondary:hover {
    background: #343657;
}

:root[data-theme="dark"] .tag,
:root[data-theme="dark"] .badge-soon {
    background: #2a2c47;
    color: var(--color-text-muted);
}

:root[data-theme="dark"] .tag-school {
    background: #363a6b;
    color: #c7cbf5;
}

:root[data-theme="dark"] .success-box {
    background: #12321f;
    color: #6ee7a3;
}

:root[data-theme="dark"] .btn-danger {
    background: #3a1a1a;
    color: #f87171;
}

:root[data-theme="dark"] .btn-danger:hover {
    background: #4a2020;
}

/* ============================================================
   Neue Komponenten (Phase 6): success-box, Switch-Toggle,
   Einstellungen, Gefahrenzone, Rechts-Seiten (Datenschutz/Impressum)
   ============================================================ */

.success-box {
    background: #dcfce7;
    color: #15803d;
    padding: 10px 14px;
    border-radius: 8px;
    font-size: 0.85rem;
    margin-bottom: 16px;
}

.settings-panel {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.settings-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 16px 0;
    border-bottom: 1px solid var(--color-border);
}

.settings-row:last-child {
    border-bottom: none;
}

.settings-label {
    font-weight: 600;
    font-size: 0.95rem;
}

.settings-hint {
    font-size: 0.82rem;
    color: var(--color-text-muted);
    margin-top: 2px;
    max-width: 420px;
}

.settings-row select {
    padding: 8px 10px;
    border-radius: 8px;
    border: 1px solid var(--color-border);
    background: var(--color-card);
    color: var(--color-text);
}

/* Switch-Toggle */
.switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
    flex-shrink: 0;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.switch-slider {
    position: absolute;
    cursor: pointer;
    inset: 0;
    background: #d1d3e0;
    border-radius: 999px;
    transition: background-color 0.15s ease;
}

.switch-slider::before {
    content: "";
    position: absolute;
    height: 18px;
    width: 18px;
    left: 3px;
    top: 3px;
    background: white;
    border-radius: 50%;
    transition: transform 0.15s ease;
}

.switch input:checked + .switch-slider {
    background: var(--color-primary);
}

.switch input:checked + .switch-slider::before {
    transform: translateX(20px);
}

.danger-zone {
    border: 1px solid #fecaca;
}

:root[data-theme="dark"] .danger-zone {
    border-color: #4a2020;
}

.legal-links {
    text-align: center;
    font-size: 0.82rem;
    color: var(--color-text-muted);
    margin-top: 20px;
}

.legal-links a {
    color: var(--color-text-muted);
}

/* Datenschutz-/Impressum-Seiten */

.legal-card {
    background: var(--color-card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 40px;
    max-width: 680px;
    width: 100%;
    line-height: 1.6;
}

.legal-card h1 {
    margin-bottom: 20px;
}

.legal-card h2 {
    font-size: 1.05rem;
    margin: 24px 0 8px;
}

.legal-card p {
    color: var(--color-text-muted);
    font-size: 0.92rem;
    margin: 0 0 4px;
}

.template-notice {
    background: #fef9c3;
    color: #854d0e;
    padding: 14px 16px;
    border-radius: 8px;
    font-size: 0.85rem;
    margin-bottom: 20px;
    line-height: 1.5;
}

:root[data-theme="dark"] .template-notice {
    background: #3a3410;
    color: #fde68a;
}

/* ============================================================
   Druckansicht (Phase 5)
   ============================================================ */

@media print {
    .sidebar,
    .sidebar-overlay,
    .topbar,
    .filter-bar,
    .panel-header .editor-actions,
    .panel-header a.btn,
    .report-row-actions,
    #exportPdfBtn,
    #printBtn {
        display: none !important;
    }

    .app-layout {
        display: block;
    }

    .main-content {
        padding: 0;
        max-width: 100%;
    }

    .report-row {
        break-inside: avoid;
        border: 1px solid #ccc;
        box-shadow: none;
    }

    body {
        background: #fff;
        color: #000;
    }
}

/* ============================================================
   Neue Startseite mit Übersicht und Vorschau
   ============================================================ */

.landing-body {
    background: var(--color-bg);
}

.landing-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 32px;
    max-width: 1100px;
    margin: 0 auto;
}

.landing-logo {
    font-weight: 700;
    font-size: 1.1rem;
}

.landing-nav {
    display: flex;
    gap: 10px;
}

.hero {
    text-align: center;
    padding: 50px 24px 30px;
    max-width: 700px;
    margin: 0 auto;
}

.hero h1 {
    font-size: 2.1rem;
    margin: 0 0 14px;
}

.hero-subtitle {
    color: var(--color-text-muted);
    font-size: 1.05rem;
    line-height: 1.6;
    margin-bottom: 28px;
}

.hero-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
    flex-wrap: wrap;
}

/* --- Vorschau-Mockup (rein dekorativ, keine echten Daten) --- */

.preview-section {
    display: flex;
    justify-content: center;
    padding: 10px 24px 50px;
}

.preview-frame {
    background: var(--color-card);
    border-radius: 14px;
    box-shadow: var(--shadow);
    width: 100%;
    max-width: 820px;
    overflow: hidden;
    border: 1px solid var(--color-border);
}

.preview-topbar {
    display: flex;
    gap: 6px;
    padding: 12px 16px;
    border-bottom: 1px solid var(--color-border);
}

.preview-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--color-border);
}

.preview-body {
    display: flex;
    min-height: 220px;
}

.preview-sidebar {
    width: 150px;
    flex-shrink: 0;
    border-right: 1px solid var(--color-border);
    padding: 14px 10px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.preview-nav-item {
    font-size: 0.72rem;
    padding: 7px 8px;
    border-radius: 6px;
    color: var(--color-text-muted);
}

.preview-nav-active {
    background: #eef0fb;
    color: var(--color-primary);
    font-weight: 700;
}

:root[data-theme="dark"] .preview-nav-active {
    background: #2a2c47;
}

.preview-main {
    flex: 1;
    padding: 18px;
}

.preview-stats {
    display: flex;
    gap: 10px;
    margin-bottom: 14px;
}

.preview-stat {
    flex: 1;
    background: var(--color-bg);
    border-radius: 8px;
    padding: 10px;
    font-size: 0.7rem;
    color: var(--color-text-muted);
}

.preview-stat span {
    display: block;
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--color-primary);
}

.preview-list-row {
    height: 30px;
    border-radius: 8px;
    background: var(--color-bg);
    margin-bottom: 8px;
}

.preview-list-row.short {
    width: 60%;
}

/* --- Funktionsübersicht --- */

.features-section {
    max-width: 1000px;
    margin: 0 auto;
    padding: 20px 24px 60px;
}

.features-heading {
    text-align: center;
    font-size: 1.4rem;
    margin-bottom: 28px;
}

.features-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 18px;
}

.feature-card {
    background: var(--color-card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 22px;
}

.feature-icon {
    font-size: 1.6rem;
    margin-bottom: 10px;
}

.feature-card h3 {
    font-size: 1rem;
    margin: 0 0 8px;
}

.feature-card p {
    font-size: 0.85rem;
    color: var(--color-text-muted);
    line-height: 1.5;
    margin: 0;
}

/* --- Download-Bereich (Platzhalter für spätere App) --- */

.download-section {
    padding: 0 24px 60px;
}

.download-card {
    max-width: 800px;
    margin: 0 auto;
    background: var(--color-card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 28px 30px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    flex-wrap: wrap;
}

.download-card h2 {
    font-size: 1.1rem;
    margin: 0 0 6px;
}

.download-card .subtitle {
    margin: 0;
    max-width: 480px;
}

.download-card .btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.landing-footer {
    padding: 20px 24px 40px;
}

/* --- Responsive --- */

@media (max-width: 760px) {
    .features-grid {
        grid-template-columns: 1fr;
    }

    .preview-sidebar {
        display: none;
    }

    .hero h1 {
        font-size: 1.6rem;
    }

    .landing-header {
        flex-direction: column;
        gap: 12px;
        text-align: center;
    }
}
