/* =========================================================
   Debian Befehlsübersicht – Stylesheet (v0.6.4)
   ========================================================= */

/* ---------- Farbdefinitionen (Dark Theme Standard) ---------- */
:root {
    --bg:#0b0f14;
    --panel:#10151d;
    --muted:#96a0ad;
    --text:#e8eef6;
    --accent:#7cd992;
    --green:#c6efce;
    --yellow:#fff2cc;
    --red:#ffd7d7;
    --chip:#1a2230;
    --border:#243043;
    --code:#0e141b;
}

/* =========================================================
   Modern Light Theme – clean, balanced contrast
   ========================================================= */
:root[data-theme="light"] {
    --bg: #f9fafc;
    --panel: #ffffff;
    --muted: #6c7380;
    --text: #1c2026;
    --accent: #2a7d4f;
    --green: #bde5c8;
    --yellow: #fff3b0;
    --red: #ffd0d0;
    --chip: #f0f1f3;
    --border: #d6dae1;
    --code: #f4f6f8;

    --shadow-soft: 0 2px 6px rgba(0,0,0,0.04);
    --shadow-hover: 0 4px 12px rgba(0,0,0,0.08);
}

:root[data-theme="light"] body {
    background: var(--bg);
    color: var(--text);
}

:root[data-theme="light"] header {
    background: linear-gradient(180deg, var(--bg) 0%, rgba(255,255,255,0.85) 100%);
    border-bottom: 1px solid var(--border);
    backdrop-filter: saturate(150%) blur(6px);
}

:root[data-theme="light"] table {
    background: var(--panel);
    box-shadow: var(--shadow-soft);
    border: 1px solid var(--border);
}

:root[data-theme="light"] tbody tr:hover {
    background: #f5f7fa;
}

:root[data-theme="light"] thead th {
    background: #f1f3f6;
    color: #1b1f24;
}

:root[data-theme="light"] .chip {
    background: #f7f8fa;
    border-color: var(--border);
}

:root[data-theme="light"] .btn {
    background: #ffffff;
    border-color: var(--border);
    box-shadow: var(--shadow-soft);
}
:root[data-theme="light"] .btn:hover {
    box-shadow: var(--shadow-hover);
}

:root[data-theme="light"] input[type="search"] {
    background: #fff;
    color: #1b1f24;
    border: 1px solid var(--border);
    box-shadow: inset 0 1px 2px rgba(0,0,0,0.04);
}

:root[data-theme="light"] code {
    background: var(--code);
    color: #111;
    border-color: #e1e5eb;
}

:root[data-theme="light"] footer {
    background: rgba(255,255,255,0.9);
    border-top: 1px solid var(--border);
    backdrop-filter: blur(4px);
}

:root[data-theme="light"] .vh-panel {
    background: var(--panel);
    color: var(--text);
    box-shadow: 0 12px 40px rgba(0,0,0,0.08);
    border: 1px solid var(--border);
}

:root[data-theme="light"] mark {
    background: color-mix(in oklch, var(--accent) 25%, transparent);
    color: var(--text);
}

/* ---------- sanfte Farbtransitions beim Themewechsel ---------- */
:root.theme-animate * {
    transition:
            background-color 180ms ease,
            color 180ms ease,
            border-color 180ms ease,
            box-shadow 180ms ease;
}
@media (prefers-reduced-motion: reduce) {
    :root.theme-animate * { transition: none !important; }
}

/* ---------- Smooth Theme Fade ---------- */
:root.theme-animate.theme-fade {
    transition: background-color 0.3s ease, color 0.3s ease;
}
:root.theme-animate.theme-fade body {
    transition: opacity 0.35s ease;
}
:root.theme-animate.theme-fade.theme-switching body {
    opacity: 0;
}

/* ---------- Global Reset ---------- */
* { box-sizing: border-box; }
body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font: 16px/1.45 system-ui, -apple-system, Segoe UI, Roboto, Ubuntu, Cantarell, Noto Sans, Helvetica, Arial, "Apple Color Emoji", "Segoe UI Emoji";
}

/* ---------- Header ---------- */
header {
    position: sticky;
    top: 0;
    background: linear-gradient(180deg,var(--bg),rgba(11,15,20,.85));
    backdrop-filter:saturate(140%) blur(6px);
    z-index: 10;
    border-bottom:1px solid var(--border);
}
.wrap { max-width:1200px; margin:0 auto; padding:20px; }
h1 { font-size:clamp(20px,3.2vw,28px); margin:0 0 6px; }
.muted { color:var(--muted); }

/* ---------- Suche + Controls ---------- */
.bar {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 12px;
    align-items: center;
}
.bar input[type="search"] {
    grid-column: 1 / -1;
    width: 100%;
    min-height: 48px;
    padding: 14px 16px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: #0d131a;
    color: var(--text);
    font-size: 16px;
}
.controls {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
}
.chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    border: 1px solid var(--border);
    background: var(--chip);
    border-radius: 999px;
    font-size: 13px;
}
.btn {
    border: 1px solid var(--border);
    background: var(--chip);
    color: var(--text);
    padding: 8px 12px;
    border-radius: 10px;
    cursor: pointer;
}
.btn:hover { filter: brightness(1.05); }

/* ---------- Tabelle ---------- */
.table-wrap {
    overflow: auto;
    max-height: 70vh;
    border-radius: 14px;
}
table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 14px;
    overflow: hidden;
}
thead th {
    position: sticky;
    top: 0;
    background: #0f1520;
    border-bottom: 1px solid var(--border);
    text-align: left;
    padding: 12px;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    z-index: 5;
}
tbody td {
    padding: 12px;
    border-bottom: 1px solid #152034;
    vertical-align: top;
}
tbody tr:hover { background:#0f1624; }

/* ---------- Code & Badges ---------- */
code {
    background: var(--code);
    padding: .15rem .35rem;
    border-radius: 6px;
    border: 1px solid #152034;
}
.badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 8px;
    border-radius: 999px;
    font-weight: 600;
    font-size: 13px;
}
.b-green { background: var(--green); color: #103915; }
.b-yellow { background: var(--yellow); color: #5a4d00; }
.b-red { background: var(--red); color: #5a0000; }

/* ---------- Sticky Legend ---------- */
.sticky-legend { display: flex; gap: 10px; flex-wrap: wrap; }

/* ---------- Keyboard Badge ---------- */
.kbd {
    border: 1px solid var(--border);
    background: #0d131a;
    border-radius: 8px;
    padding: 2px 6px;
    font-variant: tabular-nums;
}

/* ---------- Footer ---------- */
footer {
    border-top: 1px solid var(--border);
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--bg);
    backdrop-filter: blur(6px);
    padding: 10px 20px;
    z-index: 20;
}
footer .wrap {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 0;
}
.small { font-size: 13px; }

/* ---------- Highlight ---------- */
mark {
    background: color-mix(in oklch, var(--accent) 40%, transparent);
    color: var(--text);
    border-radius: 3px;
    padding: 0 2px;
}

/* =========================================================
   Version-History Modal
   ========================================================= */
.vh-overlay{
    position: fixed;
    inset: 0;
    z-index: 60;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    background: rgba(4,8,12,0.6);
    backdrop-filter: blur(4px) saturate(120%);
    transition: opacity 0.25s ease, visibility 0s linear 0.25s;
}
.vh-overlay.is-open{
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transition: opacity 0.25s ease, visibility 0s;
}
.vh-panel{
    width: min(880px, 96%);
    max-height: 86vh;
    overflow: auto;
    background: var(--panel);
    color: var(--text);
    border-radius: 12px;
    border: 1px solid var(--border);
    box-shadow: 0 12px 40px rgba(2,6,12,0.6);
    transform: scale(0.96);
    opacity: 0;
    transition: transform 0.25s ease, opacity 0.25s ease;
    will-change: transform, opacity;
}
.vh-overlay.is-open .vh-panel{
    transform: scale(1);
    opacity: 1;
}
.vh-header{
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 18px 20px;
    border-bottom: 1px solid var(--border);
}
.vh-header h2{ margin: 0; font-size: 18px; }
.vh-close{
    background: transparent;
    border: 0;
    font-size: 26px;
    line-height: 1;
    color: var(--muted);
    cursor: pointer;
    padding: 6px;
    border-radius: 6px;
}
.vh-body{ padding: 16px 20px; }
.vh-intro{ margin: 0 0 12px; color: var(--muted); font-size: 14px; }
.vh-list{ list-style: none; margin: 0; padding: 0; display: block; }
.vh-item{ padding: 12px 0; }
.vh-item + .vh-item{
    border-top: 1px dashed rgba(255,255,255,0.06);
    padding-top: 12px;
}
.vh-meta{ display: flex; gap: 12px; align-items: baseline; margin-bottom: 6px; flex-wrap: wrap; }
.vh-version{ font-weight: 700; font-size: 15px; }
.vh-date{ font-size: 13px; color: var(--muted); }
.vh-notes{ font-size: 14px; color: var(--text); white-space: pre-wrap; }
.vh-footer{
    padding: 12px 20px;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}
.vh-btn-close{
    background: transparent;
    border: 1px solid var(--border);
    padding: 8px 12px;
    border-radius: 8px;
    cursor: pointer;
    color: var(--text);
}
.vh-badge{
    display:inline-block;
    padding:2px 8px;
    border-radius:999px;
    font-size:12px;
    font-weight:700;
    background:color-mix(in oklch,var(--accent) 25%,transparent);
    color:var(--text);
    border:1px solid color-mix(in oklch,var(--accent) 45%,transparent);
}
.vh-item.vh-current .vh-version{ text-decoration: underline; }

.vh-notes-list{
    margin: 6px 0 4px 20px;
    padding: 0;
}
.vh-notes-list li{
    margin: 4px 0;
    line-height: 1.5;
}

@media (max-width:600px){
    .vh-panel{ width:100%; height:100%; max-height:100vh; border-radius:0; }
}

/* =========================================================
   Header Layout mit Theme Switch rechts vom Titel
   ========================================================= */
.header-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap; /* bei schmalen Screens untereinander */
}

.header-top h1 {
    margin: 0;
    font-size: clamp(20px, 3.2vw, 28px);
}

/* Theme Toggle Button optisch etwas dezenter */
.btn-theme {
    padding: 6px 10px;
    font-size: 15px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

.btn-theme .theme-icon {
    font-size: 1.1rem;
    transition: transform 0.3s ease;
}

.btn-theme:hover .theme-icon {
    transform: rotate(20deg);
}

/* === Sticky Table Header – Fix === */
.table-wrap{
    position: relative;
    overflow: auto;
    max-height: 70vh;       /* ggf. anpassen */
    border-radius: 14px;
}

/* Header wirklich an den oberen Rand der Scrollbox pinnen */
#tbl thead th{
    position: sticky;
    top: 0;                 /* <— wichtig: nicht 74px */
    z-index: 5;             /* über Zellen */
    /* sRGB-Fallback-Hintergründe – nicht transparent, damit Text beim Scrollen lesbar bleibt */
    background: #0f1520;
}
:root[data-theme="light"] #tbl thead th{
    background: #f1f3f6;
}

/* Optional: dezenter Schatten, wenn die Tabelle scrollt */
.table-wrap.is-stuck #tbl thead th{
    box-shadow: 0 1px 0 0 var(--border), 0 6px 10px rgba(0,0,0,.08);
}

/* === Sticky Table Header: finaler Fix === */

/* 1) Die Scrollbox: hier scrollen, damit sticky daran haftet */
.table-wrap{
    position: relative;
    overflow: auto;
    max-height: 70vh;             /* nach Bedarf anpassen */
    border-radius: 14px;
}

/* 2) table darf NICHT clippen, sonst bricht sticky */
table#tbl{
    overflow: visible !important;  /* statt hidden */
    border-radius: 14px;           /* Optik bleibt */
}

/* 3) Header wirklich kleben lassen */
#tbl thead th{
    position: sticky;
    top: 0;                        /* an Oberkante der Scrollbox */
    z-index: 5;
    background: #0f1520;           /* solider Hintergrund für Lesbarkeit */
}
:root[data-theme="light"] #tbl thead th{
    background: #f1f3f6;
}

/* 4) Optional: Schatten, wenn die Scrollbox nach unten gescrollt ist */
.table-wrap.is-stuck #tbl thead th{
    box-shadow: 0 1px 0 0 var(--border), 0 6px 10px rgba(0,0,0,.08);
}
