/* =================================================================
   Detective — app.css
   Fuenf Themes via CSS-Variablen + [data-theme]-Attribut auf <html>.
   Default: solarized (siehe <html data-theme="solarized"> im base.html)
   ================================================================= */

/* Palette D "Solarized Dark" — DEFAULT */
:root,
[data-theme="solarized"] {
    --bg: #002b36;
    --surface: #073642;
    --surface-2: #0d4651;
    --border: #2a4a51;
    --text: #93a1a1;
    --text-muted: #586e75;
    --accent: #b58900;
    --accent-hover: #cb4b16;
    --alert: #dc322f;
    --ok: #859900;
    --info: #268bd2;
    --badge-ok-bg: rgba(133, 153, 0, .18);
    --badge-warn-bg: rgba(181, 137, 0, .18);
    --badge-alert-bg: rgba(220, 50, 47, .18);
    --badge-info-bg: rgba(38, 139, 210, .18);
}

/* Palette A "Case File" */
[data-theme="case-file"] {
    --bg: #0f1115;
    --surface: #1a1d24;
    --surface-2: #22262f;
    --border: #2a2f3a;
    --text: #e5e7eb;
    --text-muted: #9ca3af;
    --accent: #d97706;
    --accent-hover: #f59e0b;
    --alert: #dc2626;
    --ok: #059669;
    --info: #2563eb;
    --badge-ok-bg: rgba(5, 150, 105, .15);
    --badge-warn-bg: rgba(217, 119, 6, .15);
    --badge-alert-bg: rgba(220, 38, 38, .15);
    --badge-info-bg: rgba(37, 99, 235, .15);
}

/* Palette B "Cold Case" */
[data-theme="cold-case"] {
    --bg: #0b1221;
    --surface: #141c2e;
    --surface-2: #1c253a;
    --border: #283040;
    --text: #e2e8f0;
    --text-muted: #94a3b8;
    --accent: #06b6d4;
    --accent-hover: #22d3ee;
    --alert: #ef4444;
    --ok: #10b981;
    --info: #3b82f6;
    --badge-ok-bg: rgba(16, 185, 129, .15);
    --badge-warn-bg: rgba(6, 182, 212, .15);
    --badge-alert-bg: rgba(239, 68, 68, .15);
    --badge-info-bg: rgba(59, 130, 246, .15);
}

/* Palette C "Evidence" */
[data-theme="evidence"] {
    --bg: #141414;
    --surface: #1f1f1f;
    --surface-2: #282828;
    --border: #2e2e2e;
    --text: #e5e5e5;
    --text-muted: #a3a3a3;
    --accent: #991b1b;
    --accent-hover: #b91c1c;
    --alert: #ef4444;
    --ok: #10b981;
    --info: #d97706;
    --badge-ok-bg: rgba(16, 185, 129, .15);
    --badge-warn-bg: rgba(153, 27, 27, .18);
    --badge-alert-bg: rgba(239, 68, 68, .15);
    --badge-info-bg: rgba(217, 119, 6, .15);
}

/* Palette E "Parchment" (Solarized Light) */
[data-theme="parchment"] {
    --bg: #fdf6e3;
    --surface: #eee8d5;
    --surface-2: #e4ddc6;
    --border: #d5cdb3;
    --text: #073642;
    --text-muted: #657b83;
    --accent: #b58900;
    --accent-hover: #cb4b16;
    --alert: #dc322f;
    --ok: #859900;
    --info: #268bd2;
    --badge-ok-bg: rgba(133, 153, 0, .18);
    --badge-warn-bg: rgba(181, 137, 0, .18);
    --badge-alert-bg: rgba(220, 50, 47, .18);
    --badge-info-bg: rgba(38, 139, 210, .18);
}

/* ─── base ─── */
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
    background: var(--bg);
    color: var(--text);
    font-family: system-ui, -apple-system, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    transition: background .2s, color .2s;
}
.mono { font-family: ui-monospace, 'JetBrains Mono', Menlo, Consolas, monospace; }
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); }
hr { border: 0; border-top: 1px solid var(--border); margin: 1rem 0; }

/* ─── authenticated layout ─── */
.shell { display: grid; grid-template-columns: 240px 1fr; grid-template-rows: 56px 1fr; min-height: 100vh; }
header.topbar {
    grid-column: 1 / 3;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    display: flex; align-items: center; padding: 0 1.25rem;
    gap: 1.5rem;
}
header.topbar .logo { font-family: ui-monospace, monospace; font-size: 1.1rem; letter-spacing: .25em; color: var(--accent); font-weight: 600; }
header.topbar .spacer { flex: 1; }
header.topbar .user { color: var(--text-muted); font-size: .85rem; }
header.topbar .user strong { color: var(--text); }

.theme-picker { display: flex; align-items: center; gap: .5rem; }
.theme-picker label { font-size: .7rem; letter-spacing: .1em; color: var(--text-muted); text-transform: uppercase; }
.theme-picker .btns { display: flex; gap: 4px; background: var(--bg); border: 1px solid var(--border); border-radius: 4px; padding: 2px; }
.theme-btn { background: transparent; color: var(--text-muted); border: 0; padding: 4px 10px; font-size: .78rem; cursor: pointer; border-radius: 3px; font-family: inherit; }
.theme-btn:hover { color: var(--text); }
.theme-btn.active { background: var(--accent); color: #fff; }

/* Hilfe-Button in der Topbar */
.help-btn {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-muted);
    padding: 4px 12px;
    border-radius: 4px;
    font-size: .78rem;
    cursor: pointer;
    font-family: inherit;
    letter-spacing: .02em;
}
.help-btn:hover { color: var(--accent); border-color: var(--accent); }
.help-btn span[aria-hidden] {
    display: inline-block;
    width: 14px; height: 14px;
    line-height: 14px;
    border-radius: 50%;
    background: var(--border);
    color: var(--text);
    font-weight: 600;
    font-size: .72rem;
    text-align: center;
    margin-right: 4px;
}
.help-btn:hover span[aria-hidden] { background: var(--accent); color: #fff; }

/* Modal-Overlay + Help-Box */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    display: none;
    align-items: flex-start;
    justify-content: center;
    z-index: 1000;
    padding: 3rem 1rem;
    overflow-y: auto;
    animation: fadeIn .15s ease-out;
}
.modal-overlay.open { display: flex; }
@keyframes fadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}

.modal-box {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1.75rem 2rem;
    max-width: 760px;
    width: 100%;
    max-height: calc(100vh - 6rem);
    overflow-y: auto;
    box-shadow: 0 12px 48px rgba(0,0,0,0.5);
    position: relative;
}
.modal-box .close {
    position: absolute;
    top: .5rem;
    right: .75rem;
    background: transparent;
    border: 0;
    color: var(--text-muted);
    font-size: 1.6rem;
    line-height: 1;
    cursor: pointer;
    padding: 4px 10px;
    border-radius: 4px;
}
.modal-box .close:hover { color: var(--accent); background: var(--surface); }

/* Toolbar oben im Modal (Drucken, Neues Fenster) */
.help-toolbar {
    position: absolute;
    top: .6rem;
    right: 3rem;
    display: flex;
    gap: .4rem;
    z-index: 2;
}
.help-toolbar-btn {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-muted);
    padding: 3px 10px;
    border-radius: 3px;
    font-size: .72rem;
    letter-spacing: .02em;
    cursor: pointer;
    font-family: inherit;
    text-decoration: none;
    line-height: 1.4;
}
.help-toolbar-btn:hover { color: var(--accent); border-color: var(--accent); }

/* Standalone-Hilfe-Seite (/help/<name>) */
body.help-standalone {
    padding: 2rem 1rem;
    background: var(--bg);
}
.help-standalone-wrap {
    max-width: 800px;
    margin: 0 auto;
}
.help-toolbar-bar {
    display: flex;
    gap: .5rem;
    align-items: center;
    margin-bottom: 1rem;
    padding-bottom: .75rem;
    border-bottom: 1px solid var(--border);
}
body.help-standalone .help-body {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 2rem 2.25rem;
}

/* Help-Content-Typografie */
.help-body h2 { font-size: 1.15rem; margin: 0 0 .5rem; color: var(--text); }
.help-body h3 { font-size: .95rem; margin: 1.5rem 0 .5rem; color: var(--accent); border-bottom: 1px solid var(--border); padding-bottom: .3rem; }
.help-body p.lead { color: var(--text); font-size: .92rem; margin-bottom: 1rem; }
.help-body p { margin: .5rem 0; color: var(--text-muted); font-size: .88rem; line-height: 1.55; }
.help-body dl { margin: .75rem 0; }
.help-body dt { font-weight: 600; color: var(--text); margin-top: .85rem; font-size: .88rem; }
.help-body dd { margin: .25rem 0 .5rem; color: var(--text-muted); padding-left: 1rem; border-left: 2px solid var(--border); font-size: .86rem; line-height: 1.55; }
.help-body ul, .help-body ol { margin: .5rem 0 .75rem 1.4rem; color: var(--text-muted); font-size: .88rem; }
.help-body li { margin: .2rem 0; }
.help-body code { background: var(--surface); color: var(--accent); padding: 1px 6px; border-radius: 3px; font-family: ui-monospace, monospace; font-size: .82rem; }
.help-body strong { color: var(--text); }
.help-body .help-meta { margin-top: 1.5rem; padding-top: .75rem; border-top: 1px dashed var(--border); color: var(--text-muted); font-size: .75rem; }

/* ============================================================
   Print-Stylesheet — nur der Hilfe-Inhalt wird gedruckt,
   Farben auf schwarz-auf-weiss invertiert (spart Tinte,
   laesst sich auch bei Solarized Dark/Case File drucken).
   Greift sowohl im Modal (main-app) als auch auf der
   standalone /help/<name>-Seite.
   ============================================================ */
@media print {
    /* Topbar, Sidebar, Main-Content, Footer komplett ausblenden */
    body {
        background: white !important;
        color: black !important;
    }
    header.topbar, aside.sidebar, main.content, footer.foot {
        display: none !important;
    }
    /* Standalone-Seite: Toolbar ausblenden (Drucken-Button gehoert nicht aufs Papier) */
    .help-toolbar-bar, .help-toolbar, .modal-box .close {
        display: none !important;
    }
    /* Overlay kollabieren */
    .modal-overlay {
        position: static !important;
        display: block !important;
        background: white !important;
        padding: 0 !important;
        overflow: visible !important;
        animation: none !important;
    }
    .modal-box, body.help-standalone .help-body {
        background: white !important;
        border: none !important;
        box-shadow: none !important;
        max-width: none !important;
        max-height: none !important;
        overflow: visible !important;
        padding: 0 !important;
    }
    .help-standalone-wrap {
        max-width: none !important;
    }
    /* Typografie: saubere schwarze Schrift */
    .help-body h2, .help-body h3 {
        color: black !important;
        border-bottom: 1px solid #444 !important;
        padding-bottom: .25rem;
        page-break-after: avoid;
    }
    .help-body p, .help-body dd, .help-body li, .help-body dt {
        color: black !important;
    }
    .help-body strong { color: black !important; }
    .help-body code {
        background: #f0f0f0 !important;
        color: black !important;
        border: 1px solid #ddd;
        padding: 0 3px;
    }
    .help-body a {
        color: black !important;
        text-decoration: underline;
    }
    /* URL hinter Links zeigen — nuetzlich auf Papier */
    .help-body a[href^="http"]::after {
        content: " (" attr(href) ")";
        font-size: .82em;
        color: #555 !important;
        font-weight: normal;
    }
    .help-body .help-meta {
        border-top: 1px solid #999 !important;
        color: #555 !important;
    }
    /* Seiten-Umbrueche: Sektionen nicht mitten trennen */
    .help-body dl, .help-body ul, .help-body ol {
        page-break-inside: avoid;
    }
}

aside.sidebar {
    background: var(--surface);
    border-right: 1px solid var(--border);
    padding: 1rem 0;
    overflow-y: auto;
}
aside.sidebar .group { padding: .85rem 1.25rem .35rem; font-size: .7rem; letter-spacing: .15em; color: var(--text-muted); text-transform: uppercase; }
aside.sidebar a.nav { display: block; padding: .55rem 1.25rem; color: var(--text); border-left: 2px solid transparent; }
aside.sidebar a.nav:hover { background: var(--surface-2); color: var(--accent); }
aside.sidebar a.nav.active { background: var(--surface-2); color: var(--accent); border-left-color: var(--accent); }
aside.sidebar a.nav .count { float: right; color: var(--text-muted); font-size: .75rem; }

main.content { padding: 1.5rem 1.75rem; overflow-y: auto; }

/* ─── typography ─── */
h1 { font-size: 1.35rem; font-weight: 600; margin-bottom: .25rem; }
h1 .sub { display: block; font-size: .8rem; font-weight: 400; color: var(--text-muted); margin-top: .2rem; }
h2 { font-size: 1.05rem; font-weight: 600; margin: 2rem 0 .75rem; color: var(--text); }
h3 { font-size: .95rem; font-weight: 600; margin-bottom: .5rem; color: var(--text); }

/* ─── tiles ─── */
.tiles { display: grid; grid-template-columns: repeat(5, 1fr); gap: .75rem; margin-top: 1.25rem; }
.tile { background: var(--surface); border: 1px solid var(--border); border-radius: 6px; padding: .85rem 1rem; }
.tile .k { font-size: .7rem; letter-spacing: .1em; text-transform: uppercase; color: var(--text-muted); }
.tile .v { font-family: ui-monospace, monospace; font-size: 1.4rem; margin-top: .35rem; }
.tile.ok    .v { color: var(--ok); }
.tile.warn  .v { color: var(--accent); }
.tile.alert .v { color: var(--alert); }
.tile .s { font-size: .75rem; color: var(--text-muted); margin-top: .2rem; }

/* ─── table ─── */
table { width: 100%; border-collapse: collapse; margin-top: .5rem; background: var(--surface); border: 1px solid var(--border); border-radius: 6px; overflow: hidden; }
thead th { text-align: left; padding: .55rem .85rem; background: var(--surface-2); color: var(--text-muted); font-size: .75rem; letter-spacing: .05em; text-transform: uppercase; font-weight: 500; border-bottom: 1px solid var(--border); }
tbody td { padding: .55rem .85rem; border-bottom: 1px solid var(--border); font-size: .88rem; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: var(--surface-2); }
td.mono { font-family: ui-monospace, monospace; font-size: .82rem; }
td.num  { text-align: right; font-family: ui-monospace, monospace; }

/* ─── badges ─── */
.badge { display: inline-block; padding: 2px 8px; border-radius: 3px; font-size: .7rem; font-weight: 500; letter-spacing: .05em; }
.badge.ok    { background: var(--badge-ok-bg);    color: var(--ok); }
.badge.warn  { background: var(--badge-warn-bg);  color: var(--accent); }
.badge.alert { background: var(--badge-alert-bg); color: var(--alert); }
.badge.info  { background: var(--badge-info-bg);  color: var(--info); }

/* ─── cards ─── */
.split { display: grid; grid-template-columns: 2fr 1fr; gap: 1rem; margin-top: 1rem; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 6px; padding: 1rem 1.25rem; }
.card .note { color: var(--text-muted); font-size: .82rem; }

footer.foot { padding: 1rem 1.75rem; color: var(--text-muted); font-size: .75rem; border-top: 1px solid var(--border); margin-top: 2rem; }

/* ─── login page (standalone layout) ─── */
body.login-page { display: flex; align-items: center; justify-content: center; background: var(--bg); }
.login-box {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 2rem;
    width: 340px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.4);
}
.login-box .logo {
    font-family: ui-monospace, monospace;
    font-size: 1.25rem;
    letter-spacing: .3em;
    color: var(--accent);
    text-align: center;
    display: block;
    margin-bottom: 1.5rem;
    font-weight: 600;
}
.login-box label {
    display: block;
    font-size: .75rem;
    letter-spacing: .1em;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-top: .75rem;
    margin-bottom: .3rem;
}
.login-box input[type="text"],
.login-box input[type="password"] {
    width: 100%;
    padding: .55rem .75rem;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--text);
    font-family: inherit;
    font-size: .95rem;
}
.login-box input:focus { outline: none; border-color: var(--accent); }
.login-box button {
    width: 100%;
    margin-top: 1.25rem;
    padding: .65rem;
    background: var(--accent);
    color: #fff;
    border: 0;
    border-radius: 4px;
    font-weight: 500;
    font-size: .9rem;
    cursor: pointer;
    letter-spacing: .05em;
}
.login-box button:hover { background: var(--accent-hover); }
.login-box .error {
    margin-top: 1rem;
    padding: .5rem .75rem;
    background: var(--badge-alert-bg);
    color: var(--alert);
    border-radius: 4px;
    font-size: .85rem;
}
.login-box .hint {
    margin-top: 1rem;
    font-size: .72rem;
    color: var(--text-muted);
    text-align: center;
}
