/* ============================================
   HIG-Layer – orientiert an den Apple Human Interface Guidelines
   Wird als letztes Stylesheet geladen und bündelt
   Querschnittsthemen: Typografie, Navigationsleiste,
   Fokus, Trefferflächen und reduzierte Bewegung.
   ============================================ */

/* ---------- Semantische Farben (hell) ---------- */
:root {
    --bg: #ffffff;
    --label: #1f2937;
    /* Akzent als Füllfläche mit weißer Schrift; --primary bleibt Text-/Akzentfarbe */
    --primary-fill: var(--primary);
    --primary-fill-hover: var(--primary-hover);
}

/* ---------- Typografie: Systemschrift, klare Grundfarbe ---------- */
body {
    font-family: var(--font-system);
    color: var(--label);
    background-color: var(--bg);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
    /* Kein horizontales Wackeln auf Mobile; clip statt hidden, damit sticky erhalten bleibt */
    overflow-x: clip;
}

/* ---------- Navigationsleiste: helles, transluzentes Material ---------- */
.navbar.navbar-therapy {
    position: sticky;
    top: 0;
    z-index: 1030;
    background-color: var(--bar-material, rgba(255, 255, 255, 0.82));
    -webkit-backdrop-filter: saturate(180%) blur(20px);
    backdrop-filter: saturate(180%) blur(20px);
    border-bottom: 1px solid var(--bar-separator, rgba(0, 0, 0, 0.08));
    box-shadow: none;
}

.navbar.navbar-therapy .navbar-brand,
.navbar.navbar-therapy .nav-link {
    color: var(--label) !important;
}

.navbar.navbar-therapy .nav-link:hover {
    color: var(--primary) !important;
    background-color: rgba(109, 40, 217, 0.08);
}

.navbar.navbar-therapy .nav-link.text-secondary {
    color: var(--text-muted) !important;
}

.navbar.navbar-therapy .btn-therapy-cta {
    color: #fff !important;
    background-color: var(--primary-fill);
    border-radius: var(--radius-full);
    padding-left: 1rem;
    padding-right: 1rem;
}

.navbar.navbar-therapy .btn-therapy-cta:hover {
    color: #fff !important;
    background-color: var(--primary-fill-hover);
}

.navbar.navbar-therapy .navbar-toggler {
    border: none;
    color: var(--label);
}

.navbar.navbar-therapy .navbar-toggler-icon {
    filter: none;
}

/* Umschalter Erscheinungsbild */
.navbar.navbar-therapy .theme-toggle .bi {
    font-size: 1.05rem;
}

.theme-menu {
    min-width: 10rem;
}

.theme-menu .dropdown-item {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    min-height: 40px;
}

/* Ausgewählte Einträge in Menüs (Erscheinungsbild, Sortierung) in der Akzentfarbe */
.dropdown-item.active,
.dropdown-item:active {
    background-color: var(--primary-fill);
    color: #fff;
}

/* Sticky-Sidebar unter der (jetzt ebenfalls sticky) Navigationsleiste halten */
.sidebar {
    top: 5rem;
}

/* ---------- Fokus: immer sichtbar für Tastaturnutzung ---------- */
a:focus-visible,
button:focus-visible,
summary:focus-visible,
[role="button"]:focus-visible,
.noUi-handle:focus-visible {
    outline: 3px solid rgba(109, 40, 217, 0.55);
    outline-offset: 2px;
    border-radius: 6px;
}

/* ---------- Trefferflächen: mind. 44 × 44 pt auf Touch-Geräten ---------- */
@media (pointer: coarse) {
    .navbar.navbar-therapy .nav-link,
    .navbar.navbar-therapy .navbar-toggler,
    .btn-add,
    .filter-toggle {
        min-height: 44px;
        display: inline-flex;
        align-items: center;
    }

    .navbar.navbar-therapy .navbar-toggler,
    .btn-add {
        min-width: 44px;
        justify-content: center;
    }

    /* Eingaben ≥ 16px verhindern das automatische Zoomen in iOS Safari */
    input,
    select,
    textarea,
    .form-control {
        font-size: 16px !important;
    }
}

/* ---------- Bewegung reduzieren, wenn vom System gewünscht ---------- */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }

    .heart-icon:hover,
    .merkliste:hover {
        transform: none;
    }
}

/* ============================================
   Dark Mode – aktiv über html[data-bs-theme="dark"].
   Das Skript in base.html setzt das Attribut nach Nutzerwahl
   (Hell/Dunkel) oder, falls keine Wahl, nach dem System.
   Farben angelehnt an die iOS-/macOS-Systemfarben
   (systemBackground, secondarySystemBackground, label, separator).
   ============================================ */
html[data-bs-theme="dark"] {
    --bg: #000000;
    --label: #f5f5f7;
    --primary: #b9a2ff;
    --primary-hover: #cdbbff;
    --primary-light: rgba(167, 139, 250, 0.28);
    --primary-lighter: rgba(167, 139, 250, 0.16);
    --primary-muted: rgba(167, 139, 250, 0.38);
    --primary-fill: #7c3aed;
    --primary-fill-hover: #8b5cf6;
    --text-gray: #e5e5ea;
    --text-muted: #a1a1aa;
    --surface: #1c1c1e;
    --surface-elevated: #1c1c1e;
    --border: #38383a;
    --shadow-sm: none;
    --shadow-md: 0 1px 0 rgba(255, 255, 255, 0.04);
    --bar-material: rgba(28, 28, 30, 0.78);
    --bar-separator: rgba(255, 255, 255, 0.1);
}

html[data-bs-theme="dark"] .landing,
html[data-bs-theme="dark"] .auth-page {
    --landing-primary: #b9a2ff;
    --landing-primary-bg: rgba(167, 139, 250, 0.14);
    --landing-text: #f5f5f7;
    --landing-text-muted: #a1a1aa;
    --landing-surface: #1c1c1e;
    --landing-border: #38383a;
    --landing-shadow: none;
    --landing-shadow-lg: 0 0 0 1px rgba(255, 255, 255, 0.06);
    --auth-primary: #b9a2ff;
    --auth-primary-bg: rgba(167, 139, 250, 0.14);
    --auth-text: #f5f5f7;
    --auth-text-muted: #a1a1aa;
    --auth-border: #38383a;
    --auth-surface: #1c1c1e;
    --auth-shadow: none;
    --auth-shadow-lg: 0 0 0 1px rgba(255, 255, 255, 0.06);
}

/* Flächen mit Verlauf */
html[data-bs-theme="dark"] .landing-hero-bg,
html[data-bs-theme="dark"] .auth-page {
    background: linear-gradient(135deg, #1a1430 0%, #120e22 55%, #000 100%);
}
html[data-bs-theme="dark"] .landing-cta {
    background: linear-gradient(135deg, #1a1430 0%, #120e22 100%);
}
html[data-bs-theme="dark"] .landing-teaser {
    background: #0b0b0c;
}
html[data-bs-theme="dark"] .landing-hero-badge {
    background: rgba(167, 139, 250, 0.16);
}

/* Gefüllte Akzent-Schaltflächen: dunklerer Violett-Ton für weiße Schrift */
html[data-bs-theme="dark"] .btn-landing-cta,
html[data-bs-theme="dark"] .auth-card .btn-auth-primary,
html[data-bs-theme="dark"] .auth-section .btn-auth-primary,
html[data-bs-theme="dark"] .back-to-top-btn,
html[data-bs-theme="dark"] .merkliste,
html[data-bs-theme="dark"] .merkliste-drawer-count {
    background: var(--primary-fill);
    border-color: var(--primary-fill);
    color: #fff;
}
html[data-bs-theme="dark"] .btn-landing-cta:hover,
html[data-bs-theme="dark"] .auth-card .btn-auth-primary:hover,
html[data-bs-theme="dark"] .auth-section .btn-auth-primary:hover,
html[data-bs-theme="dark"] .back-to-top-btn:hover,
html[data-bs-theme="dark"] .merkliste:hover {
    background: var(--primary-fill-hover);
    color: #fff;
}
html[data-bs-theme="dark"] .btn-landing-cta *,
html[data-bs-theme="dark"] .btn-landing-cta .bi {
    color: #fff;
}

/* Tabelle */
html[data-bs-theme="dark"] .table {
    --bs-table-bg: transparent;
    --bs-table-color: var(--label);
}
html[data-bs-theme="dark"] .event-date-cell,
html[data-bs-theme="dark"] .session-dropdown-item,
html[data-bs-theme="dark"] .filter-checkbox span {
    color: var(--label);
}
html[data-bs-theme="dark"] .veranstalter,
html[data-bs-theme="dark"] .th-label i,
html[data-bs-theme="dark"] .filter-label-sub,
html[data-bs-theme="dark"] .filter-toggle {
    color: var(--text-muted);
}
html[data-bs-theme="dark"] .filter-toggle {
    background-color: transparent;
}

/* Status-Badges: getönte Flächen statt Pastell */
html[data-bs-theme="dark"] .badge-ort-online {
    background: rgba(48, 209, 88, 0.14);
    color: #4ade80;
    border-color: rgba(48, 209, 88, 0.3);
}
html[data-bs-theme="dark"] .badge-jederzeit {
    background: rgba(255, 69, 58, 0.14);
    color: #ff8a80;
    border-color: rgba(255, 69, 58, 0.3);
}

/* Filter-Sidebar */
html[data-bs-theme="dark"] .range-slider .noUi-horizontal .noUi-handle {
    background: #f5f5f7;
}
html[data-bs-theme="dark"] .range-slider .noUi-handle:active {
    border-color: #fff;
}

/* Auth-Meldungen */
html[data-bs-theme="dark"] .auth-card .alert-success {
    color: #4ade80;
}

html[data-bs-theme="dark"] .back-to-top-btn::after {
    background: rgba(58, 58, 60, 0.96);
}
