/* =========================================================
   🌑 THEME SYSTEM V2 (GLOBAL)
========================================================= */

/* =========================
   🌙 DARK (DEFAULT)
========================= */

:root {
    --bg-main: #020617;
    --bg-soft: #0b1220;
    --bg-card: rgba(6,12,26,0.85);

    --text-main: #f4f8ff;
    --text-soft: #c6d3ea;
    --text-muted: #8fa3c4;

    --border: rgba(148,163,184,0.2);

    --primary: #3b82f6;
    --primary-soft: rgba(59,130,246,0.12);

    --shadow: 0 20px 60px rgba(0,0,0,0.6);
}

/* =========================
   ☀️ LIGHT MODE
========================= */

body.light-mode {
    --bg-main: #f4f7fb;
    --bg-soft: #ffffff;
    --bg-card: rgba(255,255,255,0.85);

    --text-main: #0f172a;
    --text-soft: #334155;
    --text-muted: #64748b;

    --border: rgba(0,0,0,0.08);

    --primary: #2563eb;
    --primary-soft: rgba(37,99,235,0.12);

    --shadow: 0 20px 60px rgba(0,0,0,0.1);
}

/* =========================
   🌍 GLOBAL APPLY
========================= */

body {
    background: var(--bg-main);
    color: var(--text-main);
    transition: background 0.3s ease, color 0.3s ease;
}

/* Cards */
.card,
.status-card,
.issue-card {
    background: var(--bg-card);
    color: var(--text-main);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
}

/* Sidebar */
.sidebar {
    background: var(--bg-soft);
    border-right: 1px solid var(--border);
}

/* Nav */
.nav-link {
    color: var(--text-soft);
}

.nav-link.active {
    background: var(--primary-soft);
    color: var(--text-main);
}

/* Text */
h1, h2, h3 {
    color: var(--text-main);
}

p {
    color: var(--text-soft);
}

body.light-mode body,
body.light-mode * {
    color: var(--text-main) !important;
}

body.light-mode {
    background: var(--bg-main) !important;
}

/* FORCE CARDS THEME */
body.light-mode .card,
body.light-mode .hero-card,
body.light-mode .scan-card,
body.light-mode .quiz-card,
body.light-mode .stat-card,
body.light-mode .action-card,
body.light-mode .bsi-feed-card,
body.light-mode .bsi-feed-item {
    background: var(--bg-card) !important;
    color: var(--text-main) !important;
    border: 1px solid var(--border) !important;
}

body.light-mode .card {
    backdrop-filter: blur(10px);
    background: rgba(255,255,255,0.7);
}

/* =========================
   🔥 FIX: HEADER LIGHT MODE
========================= */

body.light-mode .main-header {
    background: linear-gradient(135deg, #ffffff, #f1f5f9) !important;
    border: 1px solid rgba(0,0,0,0.08) !important;
    box-shadow: 0 10px 30px rgba(0,0,0,0.08) !important;
}

/* TEXT sauber dunkel */
body.light-mode .main-header h1 {
    color: #0f172a !important;
}

body.light-mode .main-header p {
    color: #475569 !important;
}

/* ORGANISATION BADGE */
body.light-mode .main-header-company {
    background: rgba(255,255,255,0.7) !important;
    border: 1px solid rgba(0,0,0,0.08) !important;
    color: #0f172a !important;
}

body.light-mode .main-header-company span {
    color: #64748b !important;
}

body.light-mode .main-header-company strong {
    color: #020617 !important;
}

/* =========================
   🔥 FIX: INPUT LIGHT MODE
========================= */

body.light-mode .scan-input-group input {
    background: rgba(255,255,255,0.9) !important;
    color: #0f172a !important;

    border: 1px solid rgba(0,0,0,0.08) !important;

    box-shadow: 
        0 4px 12px rgba(0,0,0,0.06),
        inset 0 0 0 1px rgba(255,255,255,0.4);
}

/* Placeholder */
body.light-mode .scan-input-group input::placeholder {
    color: #94a3b8 !important;
}

/* Focus State (wichtig für Premium Feeling) */
body.light-mode .scan-input-group input:focus {
    border-color: #2563eb !important;

    box-shadow:
        0 0 0 3px rgba(37,99,235,0.15),
        0 6px 20px rgba(0,0,0,0.08);
}

/* =========================
   🔥 REGISTER / LOGIN LIGHT MODE
========================= */

/* PAGE OVERLAY heller */
body.light-mode .login-overlay {
    background:
        radial-gradient(circle at 10% 0, rgba(37,99,235,0.12), transparent 55%),
        linear-gradient(135deg, rgba(255,255,255,0.85), rgba(240,245,255,0.95));
}

/* CARD */
body.light-mode .login-card {
    background: rgba(255,255,255,0.9) !important;
    border: 1px solid rgba(0,0,0,0.08) !important;
    box-shadow: 0 20px 50px rgba(0,0,0,0.08) !important;
}

/* TITLE */
body.light-mode .login-title h1 {
    color: #0f172a !important;
}

body.light-mode .login-title p {
    color: #475569 !important;
}

/* INPUTS */
body.light-mode .form-group input {
    background: rgba(255,255,255,0.95) !important;
    color: #0f172a !important;

    border: 1px solid rgba(0,0,0,0.08) !important;

    box-shadow:
        0 4px 12px rgba(0,0,0,0.05),
        inset 0 0 0 1px rgba(255,255,255,0.4);
}

/* PLACEHOLDER */
body.light-mode .form-group input::placeholder {
    color: #94a3b8 !important;
}

/* FOCUS */
body.light-mode .form-group input:focus {
    border-color: #2563eb !important;

    box-shadow:
        0 0 0 3px rgba(37,99,235,0.15),
        0 6px 20px rgba(0,0,0,0.08);
}

/* LABELS */
body.light-mode .form-group label {
    color: #334155 !important;
}

/* META */
body.light-mode .form-meta p {
    color: #64748b !important;
}

/* FOOTER */
body.light-mode .login-footer {
    color: #64748b !important;
}

/* LOGO sauber */
body.light-mode .login-logo {
    border: 1px solid rgba(0,0,0,0.08) !important;
    box-shadow: 0 4px 12px rgba(0,0,0,0.08) !important;
}

/* SECONDARY BUTTON */
body.light-mode .btn-secondary {
    color: #1e293b !important;
    border-color: rgba(0,0,0,0.12) !important;
}

body.light-mode .btn-secondary:hover {
    background: rgba(37,99,235,0.08) !important;
}

/* PRIMARY bleibt fancy aber heller */
body.light-mode .btn-primary {
    color: #1e3a8a !important;
    border-color: #2563eb !important;
}

/* STARTPAGE BUTTON (Gold) */
body.light-mode .btn-startpage {
    color: #111827 !important;
}

/* =========================
   🔥 SIDEBAR USER BADGE FIX
========================= */

/* Avatar (der Kreis mit Buchstaben) */
body.light-mode .user-avatar {
    background: linear-gradient(135deg, #e2e8f0, #cbd5f1) !important;
    color: #0f172a !important;

    border: 1px solid rgba(0,0,0,0.08) !important;

    box-shadow:
        0 4px 12px rgba(0,0,0,0.08),
        inset 0 0 0 1px rgba(255,255,255,0.4);
}

/* Name */
body.light-mode .user-name {
    color: #0f172a !important;
}

/* Rolle */
body.light-mode .user-role {
    color: #64748b !important;
}

/* Firma */
body.light-mode .user-company {
    color: #475569 !important;
}

/* =========================
   🔥 THEME TRANSITION EFFECT
========================= */

body.theme-switching {
    transition: all 0.4s ease;
}

/* Smooth Übergang für ALLES */
body,
.card,
.main-header,
.sidebar,
.scan-card,
.login-card,
input,
button {
    transition:
        background 0.35s ease,
        color 0.25s ease,
        border 0.25s ease,
        box-shadow 0.35s ease;
}

/* kleiner blur während switch */
body.theme-switching .main,
body.theme-switching .sidebar {
    filter: blur(6px);
    transform: scale(0.995);
}

/* =========================
   🔥 GLASS MORPH SYSTEM
========================= */

/* Basis Tokens */
body.light-mode {
    --glass-bg: rgba(255,255,255,0.6);
    --glass-border: rgba(255,255,255,0.4);
    --glass-shadow: rgba(0,0,0,0.08);
    --glass-blur: 14px;
}

body:not(.light-mode) {
    --glass-bg: rgba(15,23,42,0.55);
    --glass-border: rgba(56,189,248,0.25);
    --glass-shadow: rgba(0,0,0,0.6);
    --glass-blur: 16px;
}

/* UNIVERSAL GLASS */
.glass {
    background: var(--glass-bg);
    backdrop-filter: blur(var(--glass-blur));
    -webkit-backdrop-filter: blur(var(--glass-blur));

    border: 1px solid var(--glass-border);
    box-shadow:
        0 10px 40px var(--glass-shadow),
        inset 0 0 0 1px rgba(255,255,255,0.15);

    border-radius: 18px;
}

/* =========================
   APPLY GLASS AUTOMATISCH
========================= */

.main-header,
.scan-card,
.login-card,
.sidebar,
.card {
    background: var(--glass-bg) !important;
    backdrop-filter: blur(var(--glass-blur));
    border: 1px solid var(--glass-border) !important;
    box-shadow: 0 12px 40px var(--glass-shadow) !important;
}

/* Inputs auch Glass */
input {
    background: rgba(255,255,255,0.65);
    backdrop-filter: blur(8px);
}

/* =========================
   🔥 SMOOTH THEME TRANSITION
========================= */

body,
.main,
.sidebar,
.card,
.main-header,
.scan-card,
.login-card,
input,
button {
    transition:
        background 0.5s cubic-bezier(.4,0,.2,1),
        color 0.3s ease,
        border 0.3s ease,
        box-shadow 0.5s ease,
        backdrop-filter 0.5s ease;
}

/* =========================
   🔥 SWITCH FX
========================= */

body.theme-switching {
    animation: themePulse 0.6s ease;
}

@keyframes themePulse {
    0% {
        filter: brightness(1) blur(0px);
    }
    40% {
        filter: brightness(1.2) blur(6px);
    }
    100% {
        filter: brightness(1) blur(0px);
    }
}

body.theme-switching::before {
    content: "";
    position: fixed;
    inset: 0;
    z-index: 99998;

    background: linear-gradient(
        to bottom,
        rgba(255,255,255,0.4),
        rgba(255,255,255,0)
    );

    animation: themeWave 0.7s ease forwards;
    pointer-events: none;
}

@keyframes themeWave {
    0% {
        transform: translateY(-100%);
        opacity: 1;
    }
    100% {
        transform: translateY(100%);
        opacity: 0;
    }
}

/* =========================
   🔥 ULTRA THEME TOGGLE
========================= */

.theme-toggle {
    width: 64px;
    height: 34px;
    border: none;
    background: transparent;
    cursor: pointer;
    padding: 0;
}

/* Track */
.toggle-track {
    position: relative;
    width: 100%;
    height: 100%;
    border-radius: 999px;

    background: var(--glass-bg);
    backdrop-filter: blur(10px);

    border: 1px solid var(--glass-border);

    box-shadow:
        inset 0 2px 6px rgba(0,0,0,0.2),
        0 4px 14px rgba(0,0,0,0.25);

    transition: all 0.4s ease;
}

/* Glow Layer */
.toggle-glow {
    position: absolute;
    inset: 0;
    border-radius: 999px;

    background: radial-gradient(circle at center, rgba(56,189,248,0.25), transparent 70%);
    opacity: 0.4;

    transition: all 0.4s ease;
}

/* Thumb */
.toggle-thumb {
    position: absolute;
    top: 3px;
    left: 4px;

    width: 26px;
    height: 26px;

    border-radius: 50%;

    background: linear-gradient(135deg, #ffffff, #e2e8f0);

    display: flex;
    align-items: center;
    justify-content: center;

    font-size: 13px;

    box-shadow:
        0 4px 12px rgba(0,0,0,0.25),
        inset 0 0 0 1px rgba(255,255,255,0.6);

    transition: all 0.4s cubic-bezier(.4,0,.2,1);
}

/* Icons */
.toggle-thumb .icon {
    position: absolute;
    transition: all 0.3s ease;
}

.toggle-thumb .sun {
    opacity: 0;
    transform: scale(0.6);
}

.toggle-thumb .moon {
    opacity: 1;
    transform: scale(1);
}

/* =========================
   ☀️ LIGHT MODE STATE
========================= */

body.light-mode .toggle-thumb {
    transform: translateX(30px);
    background: linear-gradient(135deg, #fde68a, #facc15);
}

body.light-mode .toggle-glow {
    background: radial-gradient(circle at center, rgba(250,204,21,0.4), transparent 70%);
}

body.light-mode .toggle-thumb .sun {
    opacity: 1;
    transform: scale(1);
}

body.light-mode .toggle-thumb .moon {
    opacity: 0;
    transform: scale(0.6);
}

/* Hover Effekt */
.theme-toggle:hover .toggle-thumb {
    transform: scale(1.05);
}

body.light-mode .theme-toggle:hover .toggle-thumb {
    transform: translateX(30px) scale(1.05);
}

/* =========================
   🔥 LAYOUT FIX (WICHTIG)
========================= */

.layout,
.app-shell {
    display: flex;
}

/* Sidebar fix */
.sidebar {
    width: 260px;
    flex-shrink: 0;
}

/* Content daneben */
.main,
.content-area {
    flex: 1;
    margin-left: 260px; /* DAS IST DER KEY */
}

/* Falls doppelt → verhindern */
.app-shell .content-area {
    margin-left: 0;
}

/* Mobile fallback */
@media (max-width: 900px) {
    .main,
    .content-area {
        margin-left: 0;
    }

    .sidebar {
        position: fixed;
        transform: translateX(-100%);
    }

    .sidebar.active {
        transform: translateX(0);
    }
}

