/* AiLookout — design tokens, base, app shell, buttons, cards, badges.
   Plain CSS. Dark mode via prefers-color-scheme (guarded by :not([data-theme="light"]))
   and an explicit [data-theme="dark"]. Page-level components live in pages.css. */

@import url("https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap");

:root {
    --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

    --bg: #f5f7fa;
    --surface: #ffffff;
    --surface-2: #eef1f5;
    --surface-3: #e3e8ef;
    --border: #dde2ea;
    --border-strong: #c6cdd8;
    --text: #141a22;
    --text-2: #4b5563;
    --text-3: #6b7280;

    --accent: #0f766e;
    --accent-strong: #0b5f59;
    --accent-soft: #d8f1ee;
    --accent-ink: #ffffff;

    --vivid: #6366f1;
    --vivid-strong: #4f46e5;
    --vivid-soft: #e0e7ff;
    --grad: linear-gradient(135deg, #0f766e 0%, #2563eb 60%, #6366f1 100%);

    --ok: #15803d;        --ok-soft: #dcfce7;
    --warn: #b45309;      --warn-soft: #fef3c7;
    --bad: #b42318;       --bad-soft: #fee2e2;
    --info: #1d4ed8;      --info-soft: #dbeafe;
    --slate: #475569;     --slate-soft: #e2e8f0;
    --danger: var(--bad);

    --radius: 12px;
    --radius-sm: 8px;
    --radius-lg: 16px;
    --shadow-xs: 0 1px 2px rgba(16, 24, 40, 0.05);
    --shadow: 0 1px 2px rgba(16, 24, 40, 0.05), 0 2px 8px rgba(16, 24, 40, 0.06);
    --shadow-md: 0 4px 12px rgba(16, 24, 40, 0.08), 0 12px 32px rgba(16, 24, 40, 0.08);
    --shadow-lg: 0 12px 32px rgba(16, 24, 40, 0.14);
    --ring: 0 0 0 3px color-mix(in srgb, var(--accent) 28%, transparent);

    --gutter: 16px;
    --max: 1120px;
    --sidebar: 248px;
    --topbar: 56px;

    color-scheme: light;
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --bg: #0b0f15; --surface: #131922; --surface-2: #1b2330; --surface-3: #242e3c;
        --border: #273140; --border-strong: #364254;
        --text: #e6eaf0; --text-2: #b4bcc8; --text-3: #8a94a3;
        --accent: #2dd4bf; --accent-strong: #5eead4; --accent-soft: #10302e; --accent-ink: #06201e;
        --vivid: #818cf8; --vivid-strong: #a5b4fc; --vivid-soft: #1e1b4b;
        --grad: linear-gradient(135deg, #14b8a6 0%, #3b82f6 60%, #818cf8 100%);
        --ok: #4ade80; --ok-soft: #0d2f23;
        --warn: #fbbf24; --warn-soft: #3a2a0a;
        --bad: #f87171; --bad-soft: #3b1518;
        --info: #93c5fd; --info-soft: #0f1f3d;
        --slate: #cbd5e1; --slate-soft: #273242;
        --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.4);
        --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 2px 8px rgba(0, 0, 0, 0.3);
        --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4), 0 12px 32px rgba(0, 0, 0, 0.4);
        --shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.55);
        color-scheme: dark;
    }
}

:root[data-theme="dark"] {
    --bg: #0b0f15; --surface: #131922; --surface-2: #1b2330; --surface-3: #242e3c;
    --border: #273140; --border-strong: #364254;
    --text: #e6eaf0; --text-2: #b4bcc8; --text-3: #8a94a3;
    --accent: #2dd4bf; --accent-strong: #5eead4; --accent-soft: #10302e; --accent-ink: #06201e;
    --vivid: #818cf8; --vivid-strong: #a5b4fc; --vivid-soft: #1e1b4b;
    --grad: linear-gradient(135deg, #14b8a6 0%, #3b82f6 60%, #818cf8 100%);
    --ok: #4ade80; --ok-soft: #0d2f23;
    --warn: #fbbf24; --warn-soft: #3a2a0a;
    --bad: #f87171; --bad-soft: #3b1518;
    --info: #93c5fd; --info-soft: #0f1f3d;
    --slate: #cbd5e1; --slate-soft: #273242;
    --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 2px 8px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4), 0 12px 32px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.55);
    color-scheme: dark;
}

/* ---------- Base ---------- */

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0; font-family: var(--font); font-size: 16px; line-height: 1.55;
    color: var(--text); background: var(--bg); overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 { margin: 0 0 0.5em; line-height: 1.2; font-weight: 600; letter-spacing: -0.01em; }
h1 { font-size: clamp(2rem, 5vw, 3.25rem); letter-spacing: -0.02em; }
h2 { font-size: clamp(1.5rem, 3vw, 2rem); }
h3 { font-size: 1.125rem; }
p { margin: 0 0 1em; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
img, svg { max-width: 100%; height: auto; display: block; }
ul { margin: 0; padding: 0; list-style: none; }
code { font-family: var(--mono); font-size: 0.9em; background: var(--surface-2); padding: 0.1em 0.4em; border-radius: 4px; }
button { font: inherit; color: inherit; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.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;
}
.skip-link {
    position: absolute; left: var(--gutter); top: -100px; z-index: 100;
    background: var(--accent); color: var(--accent-ink); padding: 8px 12px; border-radius: 6px;
}
.skip-link:focus { top: 8px; }

.container { width: 100%; max-width: var(--max); margin-inline: auto; padding-inline: var(--gutter); }

/* ---------- Buttons ---------- */

.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    padding: 9px 16px; border-radius: var(--radius-sm); border: 1px solid transparent;
    font: inherit; font-weight: 500; font-size: 0.925rem; line-height: 1.2;
    cursor: pointer; text-decoration: none; white-space: nowrap;
    transition: background 120ms ease, border-color 120ms ease, color 120ms ease, box-shadow 120ms ease, transform 120ms ease;
}
.btn:hover { text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: 0.55; cursor: not-allowed; transform: none; }
.btn svg { width: 16px; height: 16px; flex: none; }

.btn-primary { background: var(--accent); color: var(--accent-ink); box-shadow: var(--shadow-xs), inset 0 1px 0 rgba(255, 255, 255, 0.12); }
.btn-primary:hover { background: var(--accent-strong); box-shadow: var(--shadow); }
.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--border-strong); box-shadow: var(--shadow-xs); }
.btn-secondary:hover { border-color: var(--text-3); background: var(--surface-2); }
.btn-ghost { background: transparent; color: var(--text-2); padding-inline: 10px; }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }
.btn-danger { color: var(--bad); }
.btn-danger:hover { background: var(--bad-soft); color: var(--bad); }
.btn-lg { padding: 13px 24px; font-size: 1.05rem; }
.btn-sm { padding: 5px 10px; font-size: 0.85rem; }
.btn-icon { padding: 8px; width: 36px; height: 36px; border-radius: var(--radius-sm); }
.btn-icon svg { width: 18px; height: 18px; }

/* ---------- Brand ---------- */

.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--text); font-weight: 600; font-size: 1.05rem; }
.brand:hover { text-decoration: none; }
.brand svg { width: 28px; height: 28px; flex: none; }
/* Mark colours are fixed in BrandMark.razor (brand gradient tile, white mark) so they hold in both themes. */

/* ---------- App shell ---------- */

.app { min-height: 100vh; display: flex; font-size: 14px; }
.app h1 { font-size: 1.5rem; letter-spacing: -0.02em; }
.app h2 { font-size: 1.05rem; }
.app h3 { font-size: 0.95rem; }
.app-col { flex: 1; min-width: 0; display: flex; flex-direction: column; }

#nav-open { position: absolute; opacity: 0; pointer-events: none; }
.nav-toggle { display: inline-flex; }
.nav-toggle svg { width: 20px; height: 20px; }

.app-topbar {
    position: sticky; top: 0; z-index: 20; height: var(--topbar);
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    padding-inline: var(--gutter);
    background: color-mix(in srgb, var(--surface) 92%, transparent);
    backdrop-filter: blur(10px); border-bottom: 1px solid var(--border);
}
.app-topbar .left, .app-topbar .right { display: flex; align-items: center; gap: 10px; min-width: 0; }
.app-topbar .brand { font-size: 1rem; }
.app-topbar .crumbs { display: none; align-items: center; gap: 6px; color: var(--text-3); font-size: 0.875rem; }
.app-topbar .crumbs a { color: var(--text-2); }
.app-topbar form { display: inline; margin: 0; }
.user-chip { display: inline-flex; align-items: center; gap: 8px; min-width: 0; color: var(--text-2); font-size: 0.875rem; }
.user-chip .avatar {
    flex: none; width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center;
    background: var(--grad); color: #fff; font-weight: 600; font-size: 0.75rem; text-transform: uppercase;
}
.user-chip .email { display: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 240px; }

.sidebar {
    position: fixed; top: var(--topbar); bottom: 0; left: 0; z-index: 15;
    width: min(var(--sidebar), 85vw); display: flex; flex-direction: column;
    background: var(--surface); border-right: 1px solid var(--border);
    padding: 12px; overflow-y: auto;
    transform: translateX(-100%); transition: transform 180ms ease;
}
#nav-open:checked ~ .sidebar { transform: none; box-shadow: var(--shadow-lg); }
.sidebar-backdrop { display: none; position: fixed; inset: var(--topbar) 0 0 0; z-index: 14; background: rgba(8, 12, 20, 0.45); }
#nav-open:checked ~ .sidebar-backdrop { display: block; }

.sidebar-brand { display: none; align-items: center; gap: 10px; padding: 6px 10px 18px; }
.sidebar-brand .brand { font-size: 1.05rem; }
.sidebar-brand .tag {
    margin-left: auto; font-size: 0.65rem; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase;
    padding: 2px 7px; border-radius: 999px; background: var(--vivid-soft); color: var(--vivid-strong);
}

.sidebar-section { padding: 14px 12px 6px; font-size: 0.7rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-3); }
.sidebar-nav { display: grid; gap: 2px; }
.sidebar-nav a {
    position: relative; display: flex; align-items: center; gap: 10px; padding: 8px 12px;
    border-radius: var(--radius-sm); color: var(--text-2); font-weight: 500; font-size: 0.9rem;
    transition: background 120ms ease, color 120ms ease;
}
.sidebar-nav a svg { width: 18px; height: 18px; flex: none; opacity: 0.8; }
.sidebar-nav a:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.sidebar-nav a.active { background: var(--accent-soft); color: var(--accent-strong); font-weight: 600; }
.sidebar-nav a.active svg { opacity: 1; }
.sidebar-nav a.active::before {
    content: ""; position: absolute; left: -12px; top: 8px; bottom: 8px; width: 3px;
    border-radius: 0 3px 3px 0; background: var(--accent);
}
.sidebar-nav a .count {
    margin-left: auto; font-size: 0.7rem; font-weight: 600; padding: 1px 7px; border-radius: 999px;
    background: var(--surface-2); color: var(--text-3);
}
.sidebar-foot { margin-top: auto; padding-top: 12px; border-top: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.sidebar-foot .help { display: inline-flex; align-items: center; gap: 8px; padding: 8px 12px; border-radius: var(--radius-sm); color: var(--text-2); font-weight: 500; font-size: 0.875rem; }
.sidebar-foot .help:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.sidebar-foot .help svg { width: 18px; height: 18px; }

.app-main { flex: 1; min-width: 0; width: 100%; max-width: 1280px; margin-inline: auto; padding: 24px var(--gutter) 56px; }

.page-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-end; gap: 12px 16px; margin-bottom: 24px; }
.page-head h1 { margin: 0; }
.page-head p { margin: 4px 0 0; color: var(--text-2); max-width: 64ch; }
.page-head .actions { display: flex; flex-wrap: wrap; gap: 8px; }

/* ---------- Cards ---------- */

.card {
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
    padding: 20px; box-shadow: var(--shadow);
}
.card h2 { margin-bottom: 6px; }
.card.pad-0 { padding: 0; overflow: hidden; }
.card .card-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 14px; }
.card .card-head h2 { margin: 0; }
.card .card-head.flush { padding: 14px 18px; margin: 0; border-bottom: 1px solid var(--border); }
.card-link { display: block; color: inherit; transition: transform 140ms ease, box-shadow 140ms ease, border-color 140ms ease; }
.card-link:hover { text-decoration: none; transform: translateY(-2px); box-shadow: var(--shadow-md); border-color: var(--border-strong); }
.card-grid { display: grid; gap: 16px; }

.empty {
    text-align: center; padding: 48px 24px; color: var(--text-2);
    border: 1px dashed var(--border-strong); border-radius: var(--radius); background: var(--surface);
}
.empty h2 { color: var(--text); margin: 16px 0 6px; }
.empty p { max-width: 48ch; margin: 0 auto 18px; }
.empty .row { justify-content: center; }
.empty-art { width: 160px; margin: 0 auto; }
.empty-art .a { stroke: var(--accent); }
.empty-art .v { stroke: var(--vivid); }
.empty-art .f { fill: var(--surface-2); stroke: var(--border-strong); }
.empty-art .g { fill: var(--accent-soft); }

/* ---------- Badges ---------- */

.badge {
    display: inline-flex; align-items: center; gap: 6px; padding: 2px 9px; border-radius: 999px;
    font-size: 0.75rem; font-weight: 600; line-height: 1.6; white-space: nowrap;
    background: var(--slate-soft); color: var(--slate); border: 1px solid transparent;
}
.badge .dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; flex: none; }
.badge-ok, .badge-sent, .badge-on { background: var(--ok-soft); color: var(--ok); }
.badge-healed, .badge-suspicious, .badge-warn { background: var(--warn-soft); color: var(--warn); }
.badge-broken, .badge-failed, .badge-loginrequired, .badge-bad { background: var(--bad-soft); color: var(--bad); }
.badge-new { background: var(--slate-soft); color: var(--slate); }
.badge-pending, .badge-info { background: var(--info-soft); color: var(--info); }
.badge-paused, .badge-off { background: var(--surface-2); color: var(--text-3); border-color: var(--border); }
.badge-accent, .badge-newitem { background: var(--accent-soft); color: var(--accent-strong); }
.badge-vivid { background: var(--vivid-soft); color: var(--vivid-strong); }

/* ---------- Alerts ---------- */

.alert-inline { display: inline-flex; align-items: center; gap: 6px; color: var(--bad); font-size: 0.875rem; font-weight: 500; }
.alert-inline.block, .msg {
    display: flex; gap: 8px; align-items: flex-start; margin: 0 0 16px; padding: 10px 14px;
    border-radius: var(--radius-sm); font-size: 0.9rem; font-weight: 500; border: 1px solid transparent;
}
.alert-inline.block, .msg-err { background: var(--bad-soft); color: var(--bad); border-color: color-mix(in srgb, var(--bad) 25%, transparent); }
.msg-ok { background: var(--ok-soft); color: var(--ok); border-color: color-mix(in srgb, var(--ok) 25%, transparent); }
.msg-info { background: var(--info-soft); color: var(--info); border-color: color-mix(in srgb, var(--info) 25%, transparent); }
.msg { margin: 12px 0 0; }

/* Blazor error bar (template behaviour, restyled) */
#blazor-error-ui {
    display: none; position: fixed; left: 0; right: 0; bottom: 0; z-index: 1000;
    padding: 12px var(--gutter); background: var(--bad); color: #fff; box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2);
}
#blazor-error-ui a { color: #fff; text-decoration: underline; margin-left: 8px; }
#blazor-error-ui .dismiss { cursor: pointer; position: absolute; right: var(--gutter); top: 12px; }

/* ---------- Responsive ---------- */

@media (min-width: 640px) {
    .card-grid { grid-template-columns: repeat(2, 1fr); }
    .user-chip .email { display: block; }
}

@media (min-width: 900px) {
    :root { --gutter: 24px; }
    .card-grid { grid-template-columns: repeat(4, 1fr); }
    .nav-toggle, .app-topbar .brand { display: none; }
    .app-topbar .crumbs { display: flex; }
    .sidebar {
        position: sticky; top: 0; height: 100vh; flex: none; width: var(--sidebar);
        transform: none; padding: 16px 12px 12px;
    }
    .sidebar-brand { display: flex; }
    #nav-open:checked ~ .sidebar { box-shadow: none; }
    .sidebar-backdrop, #nav-open:checked ~ .sidebar-backdrop { display: none; }
    .app-main { padding: 32px 32px 64px; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { transition: none !important; animation: none !important; }
}

/* ======================================================================
   Public layout chrome (header, nav, footer) shared by landing, guide and account pages.
   Landing/guide content styles live in public.css.
   ====================================================================== */

.site-header {
    position: sticky; top: 0; z-index: 20;
    background: color-mix(in srgb, var(--bg) 88%, transparent);
    backdrop-filter: blur(10px); border-bottom: 1px solid var(--border);
}
.site-header .container { display: flex; align-items: center; justify-content: space-between; height: 64px; gap: 12px; }
.site-nav { display: flex; align-items: center; gap: 8px; }
.site-nav .nav-links { display: none; gap: 4px; margin-right: 12px; }
.site-nav .nav-links a { color: var(--text-2); padding: 8px 12px; border-radius: 6px; font-weight: 500; font-size: 0.95rem; }
.site-nav .nav-links a:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.site-main { min-height: 60vh; }
.site-footer { border-top: 1px solid var(--border); padding: 40px 0 32px; color: var(--text-3); font-size: 0.9rem; }
.site-footer .container { display: flex; flex-wrap: wrap; gap: 16px 32px; justify-content: space-between; align-items: center; }
.site-footer nav { display: flex; flex-wrap: wrap; gap: 8px 20px; }
.site-footer a { color: var(--text-2); }

@media (min-width: 900px) {
    .site-nav .nav-links { display: flex; }
}

/* Blazor focuses the page h1 after navigation for screen readers; no visible ring for that. */
h1:focus, h1:focus-visible { outline: none; }

/* Background-checker status in the top bar. */
.sched-pill { display: inline-flex; align-items: center; gap: 7px; height: 28px; padding: 0 11px; border-radius: 999px;
  font-size: 12px; font-weight: 600; border: 1px solid var(--border); background: var(--surface); color: var(--text-2); white-space: nowrap; }
.sched-pill .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--text-3); }
.sched-running .dot { background: var(--ok); box-shadow: 0 0 0 3px var(--ok-soft); animation: sched-pulse 2.4s ease-in-out infinite; }
.sched-degraded { color: var(--warn); border-color: transparent; background: var(--warn-soft); }
.sched-degraded .dot { background: var(--warn); }
.sched-stalled { color: var(--bad); border-color: transparent; background: var(--bad-soft); }
.sched-stalled .dot { background: var(--bad); }
@keyframes sched-pulse { 0%, 100% { opacity: 1; } 50% { opacity: .45; } }
@media (prefers-reduced-motion: reduce) { .sched-running .dot { animation: none; } }
@media (max-width: 720px) { .sched-pill .label { display: none; } .sched-pill { padding: 0 9px; } }
