/* Centralisateur de logs BiNo — feuille de style unique, thème clair/sombre automatique. */

:root {
    --bg: #f4f5f8;
    --surface: #ffffff;
    --surface-2: #f0f1f5;
    --text: #1d2130;
    --muted: #6a7085;
    --border: #e1e3ea;
    --accent: #5b4bdb;
    --accent-soft: #ecebfd;
    --ok: #1f9d55;
    --ok-soft: #e3f6ea;
    --warn: #b7791f;
    --warn-soft: #fdf3e1;
    --error: #d64545;
    --error-soft: #fde8e8;
    --code-bg: #f6f7fa;
    --hit: #fff1c2;
    --radius: 10px;
    color-scheme: light;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #12141b;
        --surface: #1b1e27;
        --surface-2: #232733;
        --text: #e6e8ef;
        --muted: #9095a8;
        --border: #2d3140;
        --accent: #9d92ff;
        --accent-soft: #2a2750;
        --ok: #4cc97f;
        --ok-soft: #173325;
        --warn: #e5b04e;
        --warn-soft: #3a2e16;
        --error: #ff7373;
        --error-soft: #3d1c1f;
        --code-bg: #151821;
        --hit: #4a3f12;
        color-scheme: dark;
    }
}

* { box-sizing: border-box; }

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

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

code, pre { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 13px; }
code { overflow-wrap: anywhere; }

h1 { font-size: 22px; margin: 0 0 16px; line-height: 1.3; overflow-wrap: anywhere; }
h2 { font-size: 16px; margin: 0 0 12px; }

.muted { color: var(--muted); }
.small { font-size: 13px; }
.nowrap { white-space: nowrap; }
.num { text-align: right; font-variant-numeric: tabular-nums; }

/* ---------------------------------------------------------------- barre du haut */

.topbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px 24px;
    padding: 10px 24px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 10;
}

.brand { font-weight: 800; font-size: 18px; color: var(--text); }
.brand span { color: var(--accent); font-weight: 600; }

.topbar nav { display: flex; gap: 4px; flex-wrap: wrap; }
.topbar nav a { padding: 6px 12px; border-radius: 8px; color: var(--muted); font-weight: 500; }
.topbar nav a.active, .topbar nav a:hover { background: var(--accent-soft); color: var(--accent); text-decoration: none; }

.search { flex: 1 1 260px; }
.search input { width: 100%; }

.account { display: flex; align-items: center; gap: 12px; font-size: 13px; }
.account form { margin: 0; }

main { max-width: 1280px; margin: 0 auto; padding: 24px; }
main.narrow { max-width: 460px; padding-top: 12vh; }

/* ---------------------------------------------------------------- formulaires */

input, select, button {
    font: inherit;
    color: var(--text);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 7px 10px;
}

input:focus, select:focus { outline: 2px solid var(--accent); outline-offset: -1px; }

button, .button {
    display: inline-block;
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
    font-weight: 600;
    cursor: pointer;
}

button.secondary { background: var(--surface); color: var(--text); border-color: var(--border); }
button.link { background: none; border: 0; padding: 0; color: var(--accent); font-weight: 400; }
.button { padding: 7px 14px; border-radius: 8px; }

.stack { display: flex; flex-direction: column; gap: 14px; }
.stack label { display: flex; flex-direction: column; gap: 4px; font-weight: 500; }

.filters { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }

.alert { background: var(--error-soft); color: var(--error); padding: 10px 12px; border-radius: 8px; }
.notice { background: var(--ok-soft); color: var(--ok); padding: 10px 12px; border-radius: 8px; }

/* ---------------------------------------------------------------- cartes */

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px 20px;
    margin-bottom: 16px;
    overflow-x: auto;
}

.card.flush { padding: 0; }
.card.flush h2 { padding: 16px 20px 0; }
.alert-card { border-color: var(--error); }

.empty { color: var(--muted); padding: 20px; text-align: center; margin: 0; }

/* ---------------------------------------------------------------- badges */

.badge {
    display: inline-block;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .02em;
    text-transform: uppercase;
    padding: 2px 7px;
    border-radius: 999px;
    background: var(--surface-2);
    color: var(--muted);
    white-space: nowrap;
    vertical-align: middle;
}

.badge-level-warning { background: var(--warn-soft); color: var(--warn); }
.badge-level-error, .badge-level-critical, .badge-level-alert, .badge-level-emergency { background: var(--error-soft); color: var(--error); }
.badge-status-open { background: var(--error-soft); color: var(--error); }
.badge-status-resolved { background: var(--ok-soft); color: var(--ok); }
.badge-interface { background: var(--accent-soft); color: var(--accent); }
.badge-interface-eleve { background: #e0f2fe; color: #0369a1; }
.badge-interface-parent { background: #fce7f3; color: #be185d; }
.badge-interface-professeur { background: #dcfce7; color: #15803d; }
.badge-interface-admin { background: #fef3c7; color: #b45309; }

@media (prefers-color-scheme: dark) {
    .badge-interface-eleve { background: #0c2d44; color: #7dd3fc; }
    .badge-interface-parent { background: #401a30; color: #f9a8d4; }
    .badge-interface-professeur { background: #133321; color: #86efac; }
    .badge-interface-admin { background: #3b2c0c; color: #fcd34d; }
}

/* ---------------------------------------------------------------- tableaux */

table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; }
th, td { padding: 10px 14px; border-bottom: 1px solid var(--border); vertical-align: top; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: var(--surface-2); }

.issue-badges { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 4px; }
.issue-title { font-weight: 600; color: var(--text); overflow-wrap: anywhere; }

.crumbs td { padding: 6px 10px; }
.crumbs tr.level-warning td { background: var(--warn-soft); }
.crumbs tr.level-error td, .crumbs tr.level-critical td { background: var(--error-soft); }

.incidents tr.ongoing td { background: var(--error-soft); }

/* ---------------------------------------------------------------- tableau de bord */

.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; margin-bottom: 16px; }

.tile {
    background: var(--surface);
    border: 1px solid var(--border);
    border-left: 5px solid var(--muted);
    border-radius: var(--radius);
    padding: 12px 14px;
}

.tile.ok { border-left-color: var(--ok); }
.tile.down { border-left-color: var(--error); background: var(--error-soft); }
.tile-label { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; font-weight: 600; }
.tile-value { font-size: 20px; font-weight: 700; }
.tile.ok .tile-value { color: var(--ok); }
.tile.down .tile-value { color: var(--error); }
.tile-meta { font-size: 12px; color: var(--muted); margin-top: 4px; }
.small-tile .tile-value { font-size: 15px; }

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 18px; color: var(--text); }
.kpi:hover { text-decoration: none; border-color: var(--accent); }
.kpi strong { display: block; font-size: 28px; }
.kpi span { color: var(--muted); font-size: 13px; }

.histogram { display: flex; align-items: flex-end; gap: 3px; height: 140px; padding-bottom: 18px; }
.histogram .bar { flex: 1; height: 100%; position: relative; }
.histogram .total, .histogram .errors { position: absolute; bottom: 0; left: 0; right: 0; height: calc(var(--h, 0) * 1%); border-radius: 3px 3px 0 0; }
.histogram .total { background: var(--accent-soft); }
.histogram .errors { background: var(--error); opacity: .75; }
.histogram .hour { position: absolute; bottom: -18px; left: 0; right: 0; text-align: center; font-size: 10px; color: var(--muted); }

.checks { display: flex; gap: 3px; flex-wrap: wrap; }
.check { width: 14px; height: 28px; border-radius: 3px; background: var(--ok); }
.check.down { background: var(--error); }

/* ---------------------------------------------------------------- détail d'un problème */

.crumb { margin: 0 0 8px; }

.issue-header { margin-bottom: 20px; }
.issue-header h1 { margin: 8px 0; }

.stats { display: flex; flex-wrap: wrap; gap: 28px; margin: 14px 0; }
.stats strong { display: block; font-size: 20px; }
.stats span { color: var(--muted); font-size: 12px; }

.actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }

.issue-layout { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 16px; align-items: start; }
.occurrences { position: sticky; top: 76px; max-height: calc(100vh - 100px); overflow-y: auto; }
.occurrences li a { display: block; padding: 8px 20px; color: var(--text); border-top: 1px solid var(--border); }
.occurrences li a:hover { background: var(--surface-2); text-decoration: none; }
.occurrences li.selected a { background: var(--accent-soft); }

@media (max-width: 900px) {
    .issue-layout { grid-template-columns: minmax(0, 1fr); }
    .occurrences { position: static; max-height: 320px; }
    main { padding: 16px; }
    .topbar { padding: 10px 16px; }
}

.facts { display: grid; grid-template-columns: max-content 1fr; gap: 8px 20px; margin: 0; }
.facts dt { color: var(--muted); font-size: 13px; padding-top: 1px; }
.facts dd { margin: 0; overflow-wrap: anywhere; }

@media (max-width: 560px) {
    .facts { grid-template-columns: 1fr; gap: 2px; }
    .facts dd { margin-bottom: 8px; }
}

.reference { background: var(--warn-soft); color: var(--warn); padding: 2px 6px; border-radius: 6px; font-weight: 700; }

.exception-message { font-size: 16px; font-weight: 600; white-space: pre-wrap; overflow-wrap: anywhere; }

pre.code {
    background: var(--code-bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 10px 0;
    margin: 6px 0 0;
    overflow-x: auto;
    line-height: 1.55;
}

pre.code > span { display: block; padding: 0 12px; }
pre.code:not(:has(> span)) { padding: 10px 12px; white-space: pre-wrap; overflow-wrap: anywhere; }
pre.code .hit { background: var(--hit); font-weight: 700; }
pre.code .ln { display: inline-block; width: 4ch; margin-right: 12px; text-align: right; color: var(--muted); user-select: none; }

.stack-trace { display: flex; flex-direction: column; gap: 12px; margin-top: 12px; }
.frame-head { font-size: 13px; }

details.vendor summary { cursor: pointer; color: var(--muted); font-size: 13px; }
ol.frames { margin: 6px 0 0; padding-left: 22px; font-size: 13px; }

ul.plain { list-style: none; margin: 0; padding: 0; }
ul.plain li { padding: 4px 0; }

details.raw summary { cursor: pointer; font-weight: 600; }

.pager { display: flex; gap: 4px; flex-wrap: wrap; }
.pager a { padding: 4px 10px; border-radius: 6px; background: var(--surface); border: 1px solid var(--border); }
.pager a.active { background: var(--accent); color: #fff; border-color: var(--accent); }

.qr { width: 220px; max-width: 100%; background: #fff; border-radius: 8px; margin: 8px 0; }
.qr svg { display: block; width: 100%; height: auto; }
.secret { font-size: 15px; letter-spacing: .08em; }

/* ---------------------------------------------------------------- petits écrans */

@media (max-width: 640px) {
    th, td { padding: 8px 10px; }
    .issues th:nth-child(3), .issues td:nth-child(3) { display: none; }
    .issues th:nth-child(2), .issues td:nth-child(2) { width: 1%; }
    .incidents th:nth-child(5), .incidents td:nth-child(5),
    .incidents th:nth-child(4), .incidents td:nth-child(4) { display: none; }
    .histogram .bar:not(:nth-child(3n)) .hour { visibility: hidden; }
    .search { order: 3; flex-basis: 100%; }
    .stats { gap: 16px; }
}
