/* FILE: public/assets/css/dashboard.css
 *
 * The dashboard has to pass its own scanner, so the accessibility-relevant
 * choices are deliberate rather than incidental:
 *
 *  - :focus-visible is always drawn, never removed (WCAG 2.4.7 / 2.4.11)
 *  - body text is 16px minimum and reflows to 320px without horizontal scroll
 *    (WCAG 1.4.10)
 *  - severity is never signalled by colour alone — every badge carries a label
 *    (WCAG 1.4.1)
 *  - all foreground/background pairs below meet 4.5:1 in both schemes
 *  - prefers-reduced-motion is honoured (WCAG 2.3.3)
 *  - the skip link is visible on focus, not permanently hidden (WCAG 2.4.1)
 */

:root {
    color-scheme: light dark;

    --bg: #ffffff;
    --surface: #f6f7f9;
    --border: #d8dbe0;
    --fg: #16181d;
    --fg-muted: #5c6370;      /* 5.9:1 on --bg */
    --accent: #0b5cd5;        /* 6.3:1 on --bg */
    --accent-fg: #ffffff;
    --focus: #0b5cd5;

    --critical: #a4262c;
    --serious: #9a4d00;
    --moderate: #6b5300;
    --minor: #4a5058;
    --ok: #16652f;

    --radius: 6px;
    --gap: 1rem;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #14161a;
        --surface: #1c1f25;
        --border: #333842;
        --fg: #e9ebee;
        --fg-muted: #a4abb6;   /* 6.1:1 on --bg */
        --accent: #79aaff;     /* 7.2:1 on --bg */
        --accent-fg: #0d1117;
        --focus: #79aaff;

        --critical: #ff8a8f;
        --serious: #ffb066;
        --moderate: #e3c65c;
        --minor: #b3bac4;
        --ok: #6fd68a;
    }
}

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

body {
    margin: 0;
    background: var(--bg);
    color: var(--fg);
    font: 16px/1.6 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

/* ── Focus. Never remove this. ─────────────────────────────────────────── */
:focus-visible {
    outline: 3px solid var(--focus);
    outline-offset: 2px;
    border-radius: 2px;
}

/* Visible when focused; the WCAG failure is hiding it in both states. */
.skip-link {
    position: absolute;
    left: -9999px;
    top: 0;
    z-index: 100;
    padding: 0.75rem 1rem;
    background: var(--accent);
    color: var(--accent-fg);
    font-weight: 600;
}
.skip-link:focus {
    left: 0;
}

/* ── Layout ───────────────────────────────────────────────────────────── */
header {
    border-bottom: 1px solid var(--border);
    background: var(--surface);
}
header nav {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--gap);
    max-width: 76rem;
    margin: 0 auto;
    padding: 0.75rem 1rem;
}
.brand { font-weight: 700; text-decoration: none; color: var(--fg); }
header nav ul {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
    list-style: none;
    margin: 0;
    padding: 0;
    flex: 1;
}
header nav a { color: var(--fg); text-decoration: none; padding: 0.4rem 0.6rem; border-radius: var(--radius); }
header nav a:hover { background: var(--bg); text-decoration: underline; }
header nav a[aria-current="page"] { background: var(--bg); font-weight: 600; }

main {
    max-width: 76rem;
    margin: 0 auto;
    padding: 1.5rem 1rem 3rem;
}

footer {
    max-width: 76rem;
    margin: 0 auto;
    padding: 1.5rem 1rem;
    border-top: 1px solid var(--border);
    color: var(--fg-muted);
    font-size: 0.85rem;
}

h1 { font-size: 1.6rem; margin: 0 0 0.5rem; line-height: 1.25; }
h2 { font-size: 1.25rem; margin: 2rem 0 0.75rem; }
h3 { font-size: 1.05rem; margin: 1.25rem 0 0.5rem; }

a { color: var(--accent); }
.hint { color: var(--fg-muted); font-size: 0.875rem; margin: 0.25rem 0 0; }
.lede { color: var(--fg-muted); margin-top: 0; }

/* ── Flash messages ───────────────────────────────────────────────────── */
.flash {
    max-width: 76rem;
    margin: 1rem auto 0;
    padding: 0.75rem 1rem;
    border-radius: var(--radius);
    border-left: 4px solid var(--accent);
    background: var(--surface);
}
.flash-error { border-left-color: var(--critical); }
.flash-success { border-left-color: var(--ok); }

/* ── Cards & stats ────────────────────────────────────────────────────── */
.grid {
    display: grid;
    gap: var(--gap);
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 15rem), 1fr));
}
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem;
}
.card h3 { margin-top: 0; }
.stat { font-size: 2rem; font-weight: 700; line-height: 1.1; display: block; }
.stat-label { color: var(--fg-muted); font-size: 0.85rem; }

/* ── Badges. Colour is reinforcement, never the sole cue. ─────────────── */
.badge {
    display: inline-block;
    padding: 0.15rem 0.5rem;
    border-radius: 999px;
    font-size: 0.78rem;
    font-weight: 600;
    border: 1px solid currentColor;
    white-space: nowrap;
}
.badge-critical { color: var(--critical); }
.badge-serious  { color: var(--serious); }
.badge-moderate { color: var(--moderate); }
.badge-minor    { color: var(--minor); }
.badge-open, .badge-in_progress { color: var(--accent); }
.badge-resolved { color: var(--ok); }
.badge-ignored, .badge-false_positive { color: var(--fg-muted); }

/* ── Tables. Wide content scrolls in its own box, never the page. ─────── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
caption { text-align: left; color: var(--fg-muted); padding-bottom: 0.5rem; font-size: 0.9rem; }
th, td { text-align: left; padding: 0.6rem 0.75rem; border-bottom: 1px solid var(--border); vertical-align: top; }
th { font-size: 0.82rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--fg-muted); }
tbody tr:hover { background: var(--surface); }

/* ── Forms ────────────────────────────────────────────────────────────── */
.field { margin-bottom: 1rem; }
label { display: block; font-weight: 600; margin-bottom: 0.25rem; }
input[type=text], input[type=email], input[type=password], input[type=url],
select, textarea {
    width: 100%;
    padding: 0.55rem 0.65rem;
    font: inherit;
    color: var(--fg);
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}
input[aria-invalid="true"] { border-color: var(--critical); border-width: 2px; }

button, .button {
    display: inline-block;
    padding: 0.55rem 1.1rem;
    font: inherit;
    font-weight: 600;
    color: var(--accent-fg);
    background: var(--accent);
    border: 1px solid transparent;
    border-radius: var(--radius);
    cursor: pointer;
    text-decoration: none;
}
button:hover, .button:hover { filter: brightness(1.1); }
.button-secondary { background: transparent; color: var(--accent); border-color: var(--border); }
.button-danger { background: var(--critical); color: #fff; }

/* Target size: 24x24 CSS px minimum (WCAG 2.5.8). */
button, .button, header nav a, .filters select { min-height: 2.25rem; }

.filters { display: flex; flex-wrap: wrap; gap: 0.75rem; align-items: end; margin-bottom: 1rem; }
.filters .field { margin-bottom: 0; }

/* ── Auth pages ───────────────────────────────────────────────────────── */
.auth-page { background: var(--surface); }
.auth-card {
    max-width: 26rem;
    margin: 3rem auto;
    padding: 2rem;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}
.auth-card h1 { font-size: 1.15rem; color: var(--fg-muted); }
.auth-card h2 { margin-top: 0; }
.logout button { background: transparent; color: var(--fg); border-color: var(--border); font-weight: 400; }

/* ── Code / captured markup ───────────────────────────────────────────── */
pre, code {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 0.85rem;
}
pre {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.75rem;
    overflow-x: auto;   /* the snippet scrolls, not the document */
}

.empty { text-align: center; padding: 3rem 1rem; color: var(--fg-muted); }

/* Visually hidden but available to assistive technology. */
.sr-only {
    position: absolute; width: 1px; height: 1px;
    padding: 0; margin: -1px; overflow: hidden;
    clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}
