/* =========================================================
   SECURITY AUDIT THEME LAYER
   - Dark  = bestehende dunkle Basis bleibt führend
   - White = sauberes Light Theme mit echter Variablen-Mappung
   - RMM / SaaS kompatibel
   ========================================================= */

:root {
    --theme-sidebar-width: 260px;
}

html[data-theme="dark"] {
    color-scheme: dark;

    /* generische Mapping-Variablen für Module wie RMM */
    --bg-primary: #07111f;
    --bg-secondary: rgba(8, 16, 30, 0.78);
    --bg-tertiary: rgba(255,255,255,0.04);
    --text-color: #e5eef9;
    --text-muted: #91a4bf;
    --border: rgba(148,163,184,0.18);
    --primary: #38bdf8;
    --primary-strong: #2563eb;
    --primary-gradient: linear-gradient(135deg, #0ea5e9, #2563eb);
    --card-shadow: 0 20px 50px rgba(0,0,0,.35);
}

html[data-theme="white"] {
    color-scheme: light;

    --th-bg: #edf2f8;
    --th-bg-soft: #f7faff;
    --th-surface: #ffffff;
    --th-surface-2: #f8fbff;
    --th-text: #0f172a;
    --th-text-muted: #475569;
    --th-text-soft: #64748b;
    --th-border: #d7e2f0;
    --th-border-strong: #bfd0e6;
    --th-sidebar-bg: linear-gradient(180deg, #ffffff 0%, #f7fbff 100%);
    --th-sidebar-border: 1px solid #dbe4f0;
    --th-sidebar-shadow: 8px 0 26px rgba(15, 23, 42, 0.08);
    --th-nav-hover: rgba(37, 99, 235, 0.08);
    --th-nav-active-bg: linear-gradient(180deg, #eef4ff 0%, #dde9ff 100%);
    --th-nav-active-bar: linear-gradient(180deg, #2563eb, #60a5fa);
    --th-panel-bg: linear-gradient(180deg, rgba(255,255,255,.985) 0%, rgba(248,251,255,.985) 100%);
    --th-panel-shadow: 0 14px 34px rgba(15, 23, 42, 0.14);
    --th-input-bg: #ffffff;
    --th-primary: #2563eb;
    --th-primary-strong: #1d4ed8;
    --th-primary-soft: #e8f0ff;
    --th-mobile-bg: rgba(255,255,255,.95);
    --th-mobile-text: #0f172a;
    --th-overlay: rgba(15, 23, 42, 0.18);
    --th-ring: rgba(37, 99, 235, 0.18);

    /* entscheidend: generische Mapping-Variablen für alle Module */
    --bg-primary: #edf2f8;
    --bg-secondary: linear-gradient(180deg, rgba(255,255,255,.985) 0%, rgba(248,251,255,.985) 100%);
    --bg-tertiary: #f4f8fd;
    --text-color: #0f172a;
    --text-muted: #64748b;
    --border: #d7e2f0;
    --primary: #2563eb;
    --primary-strong: #1d4ed8;
    --primary-gradient: linear-gradient(135deg, #2563eb, #60a5fa);
    --card-shadow: 0 18px 40px rgba(15, 23, 42, 0.12);
}

html[data-theme="white"] body {
    background: var(--th-bg) !important;
    color: var(--th-text) !important;
}

html[data-theme="white"] body::before,
html[data-theme="white"] body::after {
    display: none !important;
}

html[data-theme="white"] .layout {
    min-height: 100vh !important;
    align-items: stretch !important;
}

html[data-theme="white"] .sidebar {
    width: var(--theme-sidebar-width) !important;
    height: 100vh !important;
    min-height: 100vh !important;
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    display: flex !important;
    flex-direction: column !important;
    overflow: hidden !important;
    background: var(--th-sidebar-bg) !important;
    border-right: var(--th-sidebar-border) !important;
    box-shadow: var(--th-sidebar-shadow) !important;
    z-index: 2000 !important;
}

html[data-theme="white"] .sidebar-top {
    flex: 1 1 auto !important;
    min-height: 0 !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    padding: 18px 14px !important;
}

html[data-theme="white"] .sidebar-bottom {
    flex: 0 0 auto !important;
    padding: 14px !important;
    border-top: 1px solid var(--th-border) !important;
    background: transparent !important;
}

html[data-theme="white"] .main {
    margin-left: var(--theme-sidebar-width) !important;
    min-width: 0 !important;
}

html[data-theme="white"] h1,
html[data-theme="white"] h2,
html[data-theme="white"] h3,
html[data-theme="white"] h4,
html[data-theme="white"] h5,
html[data-theme="white"] h6,
html[data-theme="white"] strong {
    color: var(--th-text) !important;
}

html[data-theme="white"] p,
html[data-theme="white"] li,
html[data-theme="white"] label,
html[data-theme="white"] td,
html[data-theme="white"] th,
html[data-theme="white"] span,
html[data-theme="white"] div {
    color: inherit;
}

html[data-theme="white"] a {
    color: var(--th-primary) !important;
}

html[data-theme="white"] a:hover {
    color: var(--th-primary-strong) !important;
}

html[data-theme="white"] .sidebar-logo-title,
html[data-theme="white"] .user-name {
    color: var(--th-text) !important;
}

html[data-theme="white"] .sidebar-logo-sub,
html[data-theme="white"] .user-role,
html[data-theme="white"] .user-company,
html[data-theme="white"] .nav-section-label,
html[data-theme="white"] .sidebar-legal a,
html[data-theme="white"] .theme-toggle-label,
html[data-theme="white"] .theme-toggle-copy {
    color: var(--th-text-soft) !important;
}

html[data-theme="white"] .sidebar-logo-img,
html[data-theme="white"] .user-avatar {
    background: linear-gradient(135deg, var(--th-primary), var(--th-primary-strong)) !important;
    color: #ffffff !important;
}

html[data-theme="white"] .nav-link {
    color: var(--th-text) !important;
    background: transparent !important;
}

html[data-theme="white"] .nav-link:hover {
    background: var(--th-nav-hover) !important;
}

html[data-theme="white"] .nav-link.active {
    color: var(--th-text) !important;
    background: var(--th-nav-active-bg) !important;
    box-shadow: inset 0 0 0 1px var(--th-border-strong) !important;
}

html[data-theme="white"] .nav-link.active::before {
    background: var(--th-nav-active-bar) !important;
    box-shadow: 0 0 12px rgba(37, 99, 235, 0.25) !important;
}

html[data-theme="white"] .sidebar-user {
    background: var(--th-primary-soft) !important;
    border: 1px solid var(--th-border) !important;
    border-radius: 14px !important;
    padding: 10px !important;
}

html[data-theme="white"] .tier-pill {
    background: var(--th-surface) !important;
    border: 1px solid var(--th-border) !important;
    box-shadow: none !important;
}

.theme-toggle {
    margin-top: 14px;
    padding-top: 12px;
    border-top: 1px solid rgba(148,163,184,.18);
}

.theme-toggle-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.theme-toggle-copy {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.theme-toggle-label {
    font-size: 12px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: #93a4bf;
}

.theme-toggle-state {
    font-size: 14px;
    font-weight: 700;
    color: #f8fafc;
}

html[data-theme="white"] .theme-toggle-state {
    color: var(--th-text) !important;
}

.theme-switch-toggle {
    position: relative;
    width: 56px;
    height: 32px;
    display: inline-flex;
    align-items: center;
    flex: 0 0 auto;
}

.theme-switch-toggle input {
    position: absolute;
    inset: 0;
    opacity: 0;
    margin: 0;
    cursor: pointer;
}

.theme-switch-slider {
    position: absolute;
    inset: 0;
    border-radius: 999px;
    background: linear-gradient(135deg, rgba(15,23,42,.82), rgba(30,41,59,.92));
    border: 1px solid rgba(148,163,184,.24);
    box-shadow: inset 0 1px 1px rgba(255,255,255,.04), 0 10px 20px rgba(2,8,23,.18);
    transition: background .22s ease, border-color .22s ease, box-shadow .22s ease;
}

.theme-switch-slider::before {
    content: "";
    position: absolute;
    top: 3px;
    left: 3px;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: linear-gradient(180deg, #ffffff 0%, #e2e8f0 100%);
    box-shadow: 0 3px 10px rgba(15,23,42,.22);
    transition: transform .22s ease;
}

.theme-switch-toggle input:checked + .theme-switch-slider {
    background: linear-gradient(135deg, #93c5fd, #2563eb);
    border-color: rgba(37,99,235,.42);
    box-shadow: 0 0 0 4px rgba(37,99,235,.10), 0 10px 24px rgba(37,99,235,.22);
}

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

.theme-switch-toggle input:focus-visible + .theme-switch-slider {
    outline: none;
    box-shadow: 0 0 0 4px rgba(37,99,235,.18);
}

html[data-theme="white"] .theme-switch-slider {
    background: linear-gradient(135deg, #dbeafe, #bfdbfe) !important;
    border-color: rgba(37,99,235,.22) !important;
}

html[data-theme="white"] input,
html[data-theme="white"] textarea,
html[data-theme="white"] select {
    background: var(--th-input-bg) !important;
    color: var(--th-text) !important;
    border: 1px solid var(--th-border-strong) !important;
    box-shadow: none !important;
}

html[data-theme="white"] input::placeholder,
html[data-theme="white"] textarea::placeholder {
    color: var(--th-text-soft) !important;
}

html[data-theme="white"] input:focus,
html[data-theme="white"] textarea:focus,
html[data-theme="white"] select:focus {
    outline: none !important;
    border-color: var(--th-primary) !important;
    box-shadow: 0 0 0 4px var(--th-ring) !important;
}

html[data-theme="white"] .btn-primary,
html[data-theme="white"] .neon-button,
html[data-theme="white"] .quiz-start-btn,
html[data-theme="white"] .sidebar-login-btn,
html[data-theme="white"] .sidebar-logout-btn,
html[data-theme="white"] .btn-small,
html[data-theme="white"] .btn-success {
    background: linear-gradient(135deg, var(--th-primary), var(--th-primary-strong)) !important;
    color: #fff !important;
    border: 1px solid var(--th-primary) !important;
}

html[data-theme="white"] .btn-secondary,
html[data-theme="white"] .btn-link {
    background: var(--th-surface) !important;
    color: var(--th-text) !important;
    border: 1px solid var(--th-border-strong) !important;
}

html[data-theme="white"] .btn-danger,
html[data-theme="white"] .neon-button-red {
    color: #fff !important;
}

html[data-theme="white"] .main-header,
html[data-theme="white"] .main-header-company,
html[data-theme="white"] .hero-card,
html[data-theme="white"] .stat-card,
html[data-theme="white"] .scan-card,
html[data-theme="white"] .quiz-card,
html[data-theme="white"] .action-card,
html[data-theme="white"] .kpi-card,
html[data-theme="white"] .level-card,
html[data-theme="white"] .dashboard-header,
html[data-theme="white"] .dashboard-wrapper,
html[data-theme="white"] .kpi-box,
html[data-theme="white"] .logs-panel,
html[data-theme="white"] .logs-card,
html[data-theme="white"] .filter-card,
html[data-theme="white"] .admin-wrapper,
html[data-theme="white"] .ds-shell,
html[data-theme="white"] .ds-panel,
html[data-theme="white"] .ds-content-card,
html[data-theme="white"] .ds-result-box,
html[data-theme="white"] .ds-card-layout,
html[data-theme="white"] .ds-card-wide,
html[data-theme="white"] .ds-stat-box,
html[data-theme="white"] .profile-card,
html[data-theme="white"] .card,
html[data-theme="white"] .box,
html[data-theme="white"] .panel,
html[data-theme="white"] .question-card,
html[data-theme="white"] .quiz-scenario-wrapper,
html[data-theme="white"] .scan-wrapper,
html[data-theme="white"] .security-stats,
html[data-theme="white"] .home-actions,
html[data-theme="white"] .answers-table,
html[data-theme="white"] .results-table,
html[data-theme="white"] .styled-table,
html[data-theme="white"] .pw-history-table {
    background: var(--th-panel-bg) !important;
    color: var(--th-text) !important;
    border: 1px solid var(--th-border) !important;
    box-shadow: var(--th-panel-shadow) !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
}

html[data-theme="white"] .main-header h1,
html[data-theme="white"] .main-header p,
html[data-theme="white"] .main-header-company span,
html[data-theme="white"] .main-header-company strong,
html[data-theme="white"] .hero-card h2,
html[data-theme="white"] .hero-sub,
html[data-theme="white"] .hero-desc,
html[data-theme="white"] .scan-title,
html[data-theme="white"] .scan-desc,
html[data-theme="white"] .scan-header,
html[data-theme="white"] .scan-examples,
html[data-theme="white"] .scan-examples span,
html[data-theme="white"] .stat-label,
html[data-theme="white"] .stat-desc,
html[data-theme="white"] .stat-source,
html[data-theme="white"] .action-card h2,
html[data-theme="white"] .action-card p {
    color: var(--th-text) !important;
}

html[data-theme="white"] .hero-sub,
html[data-theme="white"] .hero-desc,
html[data-theme="white"] .main-header p,
html[data-theme="white"] .scan-desc,
html[data-theme="white"] .stat-desc,
html[data-theme="white"] .stat-source,
html[data-theme="white"] .action-card p,
html[data-theme="white"] .scan-examples {
    color: var(--th-text-muted) !important;
}

html[data-theme="white"] .stat-value.red { color: #ef4444 !important; }
html[data-theme="white"] .stat-value.blue { color: #3b82f6 !important; }
html[data-theme="white"] .stat-value.yellow { color: #d97706 !important; }

html[data-theme="white"] .main-header::before,
html[data-theme="white"] .main-header::after,
html[data-theme="white"] .hero-card::before,
html[data-theme="white"] .hero-card::after,
html[data-theme="white"] .scan-card::before,
html[data-theme="white"] .scan-card::after,
html[data-theme="white"] .quiz-card::before,
html[data-theme="white"] .quiz-card::after,
html[data-theme="white"] .stat-card::before,
html[data-theme="white"] .stat-card::after,
html[data-theme="white"] .action-card::before,
html[data-theme="white"] .action-card::after,
html[data-theme="white"] .ps-hero::before,
html[data-theme="white"] .ps-hero::after {
    pointer-events: none !important;
    opacity: .12 !important;
}

html[data-theme="white"] table,
html[data-theme="white"] .logs-table,
html[data-theme="white"] .ds-table,
html[data-theme="white"] .quiz-table,
html[data-theme="white"] .user-table,
html[data-theme="white"] .answers-table,
html[data-theme="white"] .results-table,
html[data-theme="white"] .styled-table,
html[data-theme="white"] .pw-history-table {
    background: transparent !important;
    color: var(--th-text) !important;
}

html[data-theme="white"] .logs-table thead,
html[data-theme="white"] .ds-table thead,
html[data-theme="white"] .quiz-table thead,
html[data-theme="white"] .user-table thead,
html[data-theme="white"] .answers-table thead,
html[data-theme="white"] .results-table thead,
html[data-theme="white"] table thead {
    background: #eef4fb !important;
}

html[data-theme="white"] .logs-table th,
html[data-theme="white"] .logs-table td,
html[data-theme="white"] .ds-table th,
html[data-theme="white"] .ds-table td,
html[data-theme="white"] .quiz-table th,
html[data-theme="white"] .quiz-table td,
html[data-theme="white"] .user-table th,
html[data-theme="white"] .user-table td,
html[data-theme="white"] .answers-table th,
html[data-theme="white"] .answers-table td,
html[data-theme="white"] .results-table th,
html[data-theme="white"] .results-table td,
html[data-theme="white"] table th,
html[data-theme="white"] table td {
    border-bottom: 1px solid var(--th-border) !important;
    color: var(--th-text) !important;
    background: transparent !important;
}

html[data-theme="white"] .badge,
html[data-theme="white"] .pill,
html[data-theme="white"] .badge-pill,
html[data-theme="white"] .stats-pill {
    background: var(--th-primary-soft) !important;
    border: 1px solid var(--th-border-strong) !important;
    color: var(--th-primary) !important;
}

html[data-theme="white"] .login-overlay {
    background: radial-gradient(circle at 10% 0, rgba(37,99,235,.10), transparent 52%), linear-gradient(135deg, rgba(245,248,253,.74), rgba(232,239,249,.88)) !important;
    backdrop-filter: blur(2px) !important;
}

html[data-theme="white"] .login-card {
    background: rgba(255,255,255,.96) !important;
    border: 1px solid #dbe4f0 !important;
    box-shadow: 0 24px 54px rgba(15,23,42,.16) !important;
}

html[data-theme="white"] .login-title h1,
html[data-theme="white"] .login-title p,
html[data-theme="white"] .form-group label,
html[data-theme="white"] .login-footer,
html[data-theme="white"] .login-footer * {
    color: #0f172a !important;
}

html[data-theme="white"] .alert-error {
    background: #fee2e2 !important;
    border-color: #fecaca !important;
    color: #991b1b !important;
}

:root {
    --card-bg: var(--bg-secondary);
    --text-primary: var(--text-color);
    --border-color: var(--border);
    --text-muted: var(--text-muted);
    --input-bg: var(--bg-secondary);
    --soft-bg: var(--bg-tertiary);
    --accent-color: var(--primary);
    --btn-gradient: var(--primary-gradient);
    --terminal-bg: var(--bg-primary);
    --terminal-text: var(--text-color);
    --secondary-btn-bg: var(--bg-tertiary);
}

[data-theme="white"],
html[data-theme="white"] {
    --card-bg: var(--bg-secondary);
    --text-primary: var(--text-color);
    --border-color: var(--border);
    --text-muted: var(--text-muted);
    --input-bg: var(--th-input-bg);
    --soft-bg: var(--bg-tertiary);
    --accent-color: var(--primary);
    --btn-gradient: var(--primary-gradient);
    --terminal-bg: #f8fbff;
    --terminal-text: #0f172a;
    --secondary-btn-bg: #f4f8fd;
}

@media (max-width: 900px) {
    html[data-theme="white"] .main {
        margin-left: 0 !important;
        padding-top: 60px !important;
    }

    html[data-theme="white"] .sidebar {
        width: 280px !important;
        max-width: 88vw !important;
        transform: translateX(-100%) !important;
        transition: transform .3s cubic-bezier(.4,0,.2,1) !important;
    }

    html[data-theme="white"] .sidebar.open,
    html[data-theme="white"] .sidebar.active {
        transform: translateX(0) !important;
    }

    html[data-theme="white"] .sidebar-overlay {
        position: fixed !important;
        inset: 0 !important;
        opacity: 0 !important;
        pointer-events: none !important;
        z-index: 1500 !important;
        background: var(--th-overlay) !important;
    }

    html[data-theme="white"] .sidebar-overlay.active,
    html[data-theme="white"] .sidebar-overlay.open {
        opacity: 1 !important;
        pointer-events: auto !important;
    }

    html[data-theme="white"] .mobile-header {
        display: flex !important;
        align-items: center !important;
        justify-content: space-between !important;
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        right: 0 !important;
        height: 60px !important;
        padding: 0 16px !important;
        background: var(--th-mobile-bg) !important;
        color: var(--th-mobile-text) !important;
        border-bottom: 1px solid var(--th-border) !important;
        backdrop-filter: blur(12px) !important;
        z-index: 2100 !important;
    }

    html[data-theme="white"] .burger-btn {
        position: relative !important;
        z-index: 2101 !important;
        pointer-events: auto !important;
        color: var(--th-mobile-text) !important;
        border-color: var(--th-border) !important;
        background: rgba(255,255,255,.82) !important;
    }
}