/* =============================================
   A1W9 — Professional Dark Theme
   ============================================= */

:root {
    --sb-sidebar-width: 240px;
    --sb-topbar-height: 52px;
    --bg: #050914; /* Tiefer Weltraum */
    --surface: #070d1a; /* Sidebar, Topbar */
    --surface-2: #0d1528; /* Cards, Tiles */
    --surface-3: #111e33; /* Input, Hover */
    --border: #162040;
    --border-2: #1e3060;
    --accent: #3d6fd4; /* Sternenlicht Blau */
    --accent-light: #6fa3f7; /* Heller Sternenlicht */
    --accent-dim: rgba(61,111,212,0.12);
    --text: #e8f0ff; /* Kaltes Sternenweiß */
    --text-muted: #7a96b8;
    --text-faint: #2e4a6a;
    --text-active: #ffffff;
}

*, *::before, *::after {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background: var(--bg);
    color: var(--text);
}

.sb-body {
    display: flex;
    min-height: 100vh;
}

/* ---- Sidebar ---- */
.sb-sidebar {
    width: var(--sb-sidebar-width);
    background: var(--surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 100;
    transition: transform 0.25s ease;
}

.sb-sidebar-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 18px 20px;
    border-bottom: 1px solid var(--border);
}

.sb-logo-icon {
    font-size: 20px;
    color: var(--accent-light) !important;
}

.sb-logo-text {
    font-size: 14px;
    font-weight: 700;
    color: var(--text);
    letter-spacing: 0.10em;
    text-transform: uppercase;
}

.sb-nav {
    list-style: none;
    margin: 0;
    padding: 12px 0 8px;
    flex: 1;
    overflow-y: auto;
}

.sb-nav-item {
    margin: 1px 8px;
}

.sb-nav-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    color: var(--text-muted) !important;
    text-decoration: none !important;
    border-radius: 6px;
    font-size: 13px;
    transition: background 0.15s, color 0.15s;
}

    .sb-nav-link i {
        font-size: 17px;
        flex-shrink: 0;
        color: inherit !important;
    }

    .sb-nav-link:hover {
        background: var(--surface-3);
        color: var(--text) !important;
    }

    .sb-nav-link.active {
        background: var(--accent-dim);
        color: var(--text) !important;
        font-weight: 500;
    }

        .sb-nav-link.active i {
            color: var(--accent-light) !important;
        }

.sb-nav-divider {
    height: 1px;
    background: var(--border);
    margin: 6px 0;
}

.sb-nav-label {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.10em;
    color: var(--text-faint);
    padding: 8px 20px 3px;
    font-weight: 600;
}

.sb-sidebar-footer {
    padding: 10px 8px;
    border-top: 1px solid var(--border);
}

/* ---- Main ---- */
.sb-main {
    margin-left: var(--sb-sidebar-width);
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* ---- Topbar ---- */
.sb-topbar {
    height: var(--sb-topbar-height);
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    padding: 0 28px;
    gap: 12px;
    position: sticky;
    top: 0;
    z-index: 50;
}

.sb-page-title {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-faint);
    text-transform: uppercase;
    letter-spacing: 0.12em;
}

/* ---- Content ---- */
.sb-content {
    padding: 32px;
    flex: 1;
}

/* ---- Page Hero ---- */
.page-hero {
    margin-bottom: 28px;
}

    .page-hero h1, .page-hero h2 {
        color: var(--text);
        font-weight: 700;
    }

/* ---- Cards ---- */
.card {
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 10px;
    color: var(--text);
}

/* ---- Buttons ---- */
.btn-primary {
    background: #1a3a6e;
    border: 1px solid #2a5090;
    color: #a8c4f0;
    font-weight: 500;
}

    .btn-primary:hover {
        background: #1f4580;
        border-color: #3a60a8;
        color: #c0d8ff;
    }

.btn-outline-primary {
    border-color: var(--border-2);
    color: var(--accent-light);
}

    .btn-outline-primary:hover {
        background: var(--accent-dim);
        border-color: var(--accent-light);
        color: var(--accent-light);
    }

.btn-link.sb-toggle {
    color: var(--text-muted) !important;
    box-shadow: none !important;
    text-decoration: none !important;
}

    .btn-link.sb-toggle:hover {
        color: var(--text) !important;
    }

/* ---- Tiles ---- */
.sb-tile {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 32px 16px 24px;
    text-align: center;
    transition: background 0.15s, border-color 0.15s;
    gap: 14px;
    cursor: pointer;
}

    .sb-tile:hover {
        background: var(--surface-3);
        border-color: var(--border-2);
    }

.sb-tile-icon {
    width: 52px;
    height: 52px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--accent-dim);
    border: 1px solid rgba(96,165,250,0.18);
}

    .sb-tile-icon i {
        font-size: 26px;
        color: var(--accent-light) !important;
    }

.sb-tile-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted);
}

/* Tile-Varianten */
.sb-tile-primary .sb-tile-icon {
    background: rgba(96,165,250,0.10);
    border-color: rgba(96,165,250,0.20);
}

    .sb-tile-primary .sb-tile-icon i {
        color: #60a5fa !important;
    }

.sb-tile-success .sb-tile-icon {
    background: rgba(52,211,153,0.10);
    border-color: rgba(52,211,153,0.20);
}

    .sb-tile-success .sb-tile-icon i {
        color: #34d399 !important;
    }

.sb-tile-warning .sb-tile-icon {
    background: rgba(251,191,36,0.10);
    border-color: rgba(251,191,36,0.20);
}

    .sb-tile-warning .sb-tile-icon i {
        color: #fbbf24 !important;
    }

.sb-tile-info .sb-tile-icon {
    background: rgba(56,189,248,0.10);
    border-color: rgba(56,189,248,0.20);
}

    .sb-tile-info .sb-tile-icon i {
        color: #38bdf8 !important;
    }

.sb-tile-danger .sb-tile-icon {
    background: rgba(248,113,113,0.10);
    border-color: rgba(248,113,113,0.20);
}

    .sb-tile-danger .sb-tile-icon i {
        color: #f87171 !important;
    }

.sb-tile-purple .sb-tile-icon {
    background: rgba(167,139,250,0.10);
    border-color: rgba(167,139,250,0.20);
}

    .sb-tile-purple .sb-tile-icon i {
        color: #a78bfa !important;
    }

/* ---- Stat Cards ---- */
.sb-stat-card {
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 16px;
    text-align: center;
}

    .sb-stat-card i {
        font-size: 22px;
        display: block;
        margin-bottom: 6px;
        color: var(--accent-light);
    }

.sb-stat-val {
    font-size: 22px;
    font-weight: 700;
    color: var(--text);
}

.sb-stat-lbl {
    font-size: 12px;
    color: var(--text-faint);
}

/* ---- AI Bar ---- */
.sb-ai-bar {
    display: flex;
    align-items: center;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 10px 16px;
}

    .sb-ai-bar:focus-within {
        border-color: var(--accent-light);
    }

    .sb-ai-bar input {
        background: transparent;
        color: var(--text);
        outline: none;
        box-shadow: none !important;
    }

        .sb-ai-bar input::placeholder {
            color: var(--text-faint);
        }

    .sb-ai-bar i {
        color: var(--accent-light) !important;
    }

/* ---- AI Chat ---- */
.sb-ai-container {
    display: flex;
    flex-direction: column;
    height: calc(100vh - var(--sb-topbar-height) - 56px);
    max-width: 800px;
}

.sb-ai-messages {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 16px;
    padding: 8px 0 16px;
}

.sb-ai-message {
    display: flex;
    gap: 12px;
    align-items: flex-start;
}

.sb-ai-message--user {
    flex-direction: row-reverse;
}

.sb-ai-avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--surface-3);
    color: var(--text-faint);
    flex-shrink: 0;
    border: 1px solid var(--border);
    font-size: 16px;
}

.sb-ai-message--assistant .sb-ai-avatar {
    background: var(--accent-dim);
    color: var(--accent-light);
    border-color: rgba(96,165,250,0.25);
}

.sb-ai-bubble {
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 10px 14px;
    font-size: 14px;
    line-height: 1.6;
    max-width: 75%;
    white-space: pre-wrap;
    color: var(--text);
}

.sb-ai-message--user .sb-ai-bubble {
    background: var(--accent-dim);
    border-color: rgba(96,165,250,0.20);
}

.sb-ai-input-area {
    border-top: 1px solid var(--border);
    padding-top: 16px;
}

/* ---- Login ---- */
.sb-login-body {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg);
}

.sb-login-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 40px 36px;
    width: 100%;
    max-width: 400px;
}

.sb-login-header {
    text-align: center;
    margin-bottom: 28px;
}

.sb-login-icon {
    font-size: 40px;
    color: var(--accent-light);
}

/* ---- Logout ---- */
.sb-nav-logout {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    border-radius: 6px;
    font-size: 13px;
    color: var(--text-muted);
    background: transparent;
    border: none;
    cursor: pointer;
    width: 100%;
    transition: background 0.15s, color 0.15s;
}

    .sb-nav-logout:hover {
        background: rgba(61,111,212,0.10);
        color: var(--text-muted);
    }

    .sb-nav-logout i {
        font-size: 17px;
        color: inherit !important;
    }

/* ---- Bottom Nav ---- */
.sb-bottom-nav {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 60px;
    background: var(--surface);
    border-top: 1px solid var(--border);
    z-index: 200;
    padding-bottom: env(safe-area-inset-bottom);
}

.sb-bottom-nav-inner {
    display: flex;
    height: 60px;
    align-items: stretch;
}

.sb-bottom-nav-link {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    color: var(--text-faint) !important;
    text-decoration: none !important;
    font-size: 10px;
    font-weight: 500;
    transition: color 0.15s;
    -webkit-tap-highlight-color: transparent;
}

    .sb-bottom-nav-link i {
        font-size: 20px;
        color: inherit !important;
    }

    .sb-bottom-nav-link.active {
        color: var(--accent-light) !important;
    }

    .sb-bottom-nav-link:active {
        background: var(--surface-2);
    }

/* ---- PWA Banner ---- */
.pwa-install-banner {
    position: fixed;
    bottom: 68px;
    left: 12px;
    right: 12px;
    background: var(--surface);
    border: 1px solid var(--border-2);
    border-radius: 12px;
    padding: 14px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
}

    .pwa-install-banner i {
        font-size: 24px;
        color: var(--accent-light) !important;
        flex-shrink: 0;
    }

    .pwa-install-banner .pwa-text {
        flex: 1;
    }

        .pwa-install-banner .pwa-text strong {
            display: block;
            font-size: 13px;
            color: var(--text);
        }

        .pwa-install-banner .pwa-text span {
            font-size: 11px;
            color: var(--text-faint);
        }

/* ---- Overlay ---- */
#sb-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.6);
    z-index: 99;
}

    #sb-overlay.show {
        display: block;
    }

/* ---- Mobile Topbar ---- */
.sb-topbar-mobile {
    display: none;
    height: 52px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    align-items: center;
    padding: 0 16px;
    gap: 12px;
    position: sticky;
    top: 0;
    z-index: 50;
}

.sb-toggle {
    display: none;
}

/* ---- Alerts ---- */
.alert-danger {
    background: rgba(220,38,38,0.08) !important;
    border-color: rgba(220,38,38,0.25) !important;
    color: #fca5a5 !important;
}

/* ---- Bootstrap Overrides ---- */
.form-control, .form-select {
    background: var(--surface-2);
    border: 1px solid var(--border);
    color: var(--text);
    border-radius: 7px;
}

    .form-control:focus, .form-select:focus {
        background: var(--surface-2);
        border-color: var(--accent-light);
        color: var(--text);
        box-shadow: 0 0 0 3px rgba(96,165,250,0.12);
    }

    .form-control::placeholder {
        color: var(--text-faint);
    }

.form-label {
    color: var(--text-muted);
    font-size: 13px;
    font-weight: 500;
}

.table {
    color: var(--text);
}

    .table > :not(caption) > * > * {
        background-color: transparent;
        border-bottom-color: var(--border);
        color: var(--text);
    }

/* ---- Responsive ---- */
@media (min-width: 768px) and (max-width: 1024px) {
    :root {
        --sb-sidebar-width: 200px;
    }
}

@media (max-width: 767px) {
    .sb-sidebar {
        transform: translateX(-100%);
    }

        .sb-sidebar.show {
            transform: translateX(0);
        }

    .sb-main {
        margin-left: 0;
    }

    .sb-topbar {
        display: none;
    }

    .sb-topbar-mobile {
        display: flex;
    }

    .sb-bottom-nav {
        display: block;
    }

    .sb-toggle {
        display: flex;
    }

    .sb-content {
        padding: 16px 12px 76px;
    }

    .sb-ai-container {
        height: calc(100vh - 52px - 60px);
    }
}

/* ---- Logo Image ---- */
.sb-logo-img {
    height: 32px;
    width: auto;
    object-fit: contain;
    display: block;
}

/* Login Card — schwarz damit Logo-Glow sichtbar */
.sb-login-card {
    background: #000 !important;
    border-color: #1e2d4a !important;
}

.sb-login-header {
    background: #000;
    margin: -40px -36px 24px;
    padding: 32px 36px 24px;
    border-radius: 14px 14px 0 0;
}

/* Sidebar Header — schwarz damit Logo-Glow sichtbar */
.sb-sidebar-header {
    background: #000;
    justify-content: center;
    padding: 12px 16px;
    border-bottom: 1px solid #0f1e35;
    min-height: 60px;
}

.sb-logo-img {
    height: 38px;
    width: auto;
    object-fit: contain;
    display: block;
}

/* ---- Universum Hintergrund ---- */
body {
    background: radial-gradient(ellipse at 20% 50%, rgba(61,111,212,0.04) 0%, transparent 50%), radial-gradient(ellipse at 80% 20%, rgba(111,61,212,0.04) 0%, transparent 50%), radial-gradient(ellipse at 60% 80%, rgba(61,160,212,0.03) 0%, transparent 40%), #050914;
}

.sb-content {
    background-image: radial-gradient(1px 1px at 15% 25%, rgba(200,220,255,0.4) 0%, transparent 100%), radial-gradient(1px 1px at 45% 10%, rgba(200,220,255,0.3) 0%, transparent 100%), radial-gradient(1px 1px at 70% 40%, rgba(200,220,255,0.5) 0%, transparent 100%), radial-gradient(1px 1px at 85% 70%, rgba(200,220,255,0.3) 0%, transparent 100%), radial-gradient(1px 1px at 30% 80%, rgba(200,220,255,0.4) 0%, transparent 100%), radial-gradient(1px 1px at 55% 60%, rgba(200,220,255,0.2) 0%, transparent 100%), radial-gradient(1px 1px at 90% 15%, rgba(200,220,255,0.4) 0%, transparent 100%), radial-gradient(1px 1px at 10% 55%, rgba(200,220,255,0.3) 0%, transparent 100%), radial-gradient(1.5px 1.5px at 65% 90%, rgba(200,220,255,0.5) 0%, transparent 100%), radial-gradient(1px 1px at 40% 45%, rgba(200,220,255,0.2) 0%, transparent 100%);
}

/* Tile hover mit kosmischem Glow */
.sb-tile:hover {
    border-color: rgba(111,163,247,0.25);
    box-shadow: 0 0 20px rgba(61,111,212,0.08);
}
