/* ==========================================================================
   VigiCore — Interface
   Direction : signalétique de site sécurisé. Nuit de garde + ambre haute visibilité,
   typo Barlow (inspirée des panneaux routiers). L'ambre est réservé à ce qui est "en direct".
   ========================================================================== */

@font-face { font-family: "Barlow"; font-weight: 400; font-style: normal; font-display: swap; src: url("../fonts/barlow-latin-400-normal.woff2") format("woff2"); }
@font-face { font-family: "Barlow"; font-weight: 500; font-style: normal; font-display: swap; src: url("../fonts/barlow-latin-500-normal.woff2") format("woff2"); }
@font-face { font-family: "Barlow"; font-weight: 600; font-style: normal; font-display: swap; src: url("../fonts/barlow-latin-600-normal.woff2") format("woff2"); }
@font-face { font-family: "Barlow"; font-weight: 700; font-style: normal; font-display: swap; src: url("../fonts/barlow-latin-700-normal.woff2") format("woff2"); }
@font-face { font-family: "Barlow Semi Condensed"; font-weight: 600; font-style: normal; font-display: swap; src: url("../fonts/barlow-semi-condensed-latin-600-normal.woff2") format("woff2"); }
@font-face { font-family: "Barlow Semi Condensed"; font-weight: 700; font-style: normal; font-display: swap; src: url("../fonts/barlow-semi-condensed-latin-700-normal.woff2") format("woff2"); }

:root {
    --night: #141c28;
    --night-2: #1f2a3a;
    --night-3: #2c394c;
    --ink: #18202b;
    --steel: #566273;
    --steel-light: #9aa5b4;
    --concrete: #eceef1;
    --paper: #ffffff;
    --line: #d9dde3;
    --signal: #e9a820;
    --signal-soft: #fbf1d9;
    --alert: #b8352a;
    --alert-soft: #f8e4e1;
    --ok: #2e7a4d;
    --ok-soft: #e1f0e7;

    --font: "Barlow", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    --font-display: "Barlow Semi Condensed", "Barlow", system-ui, sans-serif;

    --r-panel: 8px;
    --r-control: 5px;
    --sidebar-w: 256px;
}

*, *::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.5;
    color: var(--ink);
    background: var(--concrete);
    -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { font-family: var(--font-display); font-weight: 700; line-height: 1.15; margin: 0; letter-spacing: -0.005em; }
p { margin: 0; }
a { color: inherit; }
.muted { color: var(--steel); }

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

.icon { width: 20px; height: 20px; flex: none; }

.skip {
    position: absolute; left: 12px; top: -60px; z-index: 100;
    background: var(--signal); color: var(--night); padding: 8px 14px; border-radius: var(--r-control); font-weight: 600;
}
.skip:focus { top: 12px; }

/* ---------- Boutons & champs ---------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    min-height: 46px; padding: 0 20px;
    font: 600 16px/1 var(--font);
    border: 1px solid transparent; border-radius: var(--r-control);
    cursor: pointer; text-decoration: none;
    transition: background-color .15s ease;
}
.btn--primary { background: var(--night); color: #fff; }
.btn--primary:hover { background: var(--night-3); }
.btn--block { width: 100%; }

.icon-btn {
    display: inline-grid; place-items: center;
    width: 38px; height: 38px; padding: 0;
    background: transparent; color: inherit;
    border: 0; border-radius: var(--r-control); cursor: pointer;
}
.icon-btn:hover { background: rgba(255, 255, 255, .08); }

.field { display: grid; gap: 6px; margin-bottom: 18px; }
.field > span { font-size: 14px; font-weight: 600; }
.field input {
    width: 100%; min-height: 46px; padding: 0 14px;
    font: 400 16px var(--font); color: var(--ink);
    background: var(--paper);
    border: 1px solid var(--line); border-radius: var(--r-control);
}
.field input:focus { border-color: var(--night); outline: 3px solid var(--signal-soft); outline-offset: 0; }
.field input::placeholder { color: var(--steel-light); }

/* ---------- Messages ---------- */
.flash {
    padding: 12px 16px; margin-bottom: 18px;
    border-left: 4px solid var(--steel); border-radius: var(--r-control);
    background: var(--paper); font-size: 15px;
}
.flash--error { border-color: var(--alert); background: var(--alert-soft); }
.flash--success { border-color: var(--ok); background: var(--ok-soft); }
.flash--info { border-color: var(--signal); background: var(--signal-soft); }
.flash--floating {
    position: fixed; top: 16px; right: 16px; z-index: 50; max-width: 360px;
    box-shadow: 0 6px 24px rgba(20, 28, 40, .18);
}

/* ==========================================================================
   Connexion — panneau "main courante"
   ========================================================================== */
.auth { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); min-height: 100vh; }

.auth__brand {
    display: flex; flex-direction: column; justify-content: center; gap: 36px;
    padding: 56px clamp(32px, 6vw, 88px);
    background: var(--night); color: #e6eaf0;
}
.auth__logo { display: flex; align-items: center; gap: 10px; color: #fff; font: 700 22px var(--font-display); }
.auth__logo .icon { width: 28px; height: 28px; color: var(--signal); }
.auth__pitch { font: 600 clamp(28px, 3.2vw, 40px)/1.12 var(--font-display); color: #fff; max-width: 17ch; }

.logbook { list-style: none; margin: 0; padding: 0; max-width: 460px; }
.logbook__row {
    position: relative;
    display: grid; grid-template-columns: 58px 1fr; gap: 14px;
    padding: 0 0 18px 0;
}
.logbook__row::before {            /* fil du temps */
    content: ""; position: absolute; left: 70px; top: 8px; bottom: -8px;
    width: 1px; background: var(--night-3);
}
.logbook__row:last-child::before { display: none; }
.logbook__row::after {             /* repère */
    content: ""; position: absolute; left: 66px; top: 6px;
    width: 9px; height: 9px; border-radius: 50%;
    background: var(--night); border: 2px solid var(--steel-light);
}
.logbook__row time {
    font-weight: 600; font-variant-numeric: tabular-nums;
    color: var(--signal);
}
.logbook__row > span { display: grid; padding-left: 16px; color: var(--steel-light); font-size: 15px; }
.logbook__row strong { color: #fff; font-weight: 600; }
.logbook__row.is-alert::after { border-color: var(--alert); background: var(--alert); }
.logbook__row.is-alert strong { color: #ffb3aa; }

/* Unique animation orchestrée : la main courante s'écrit ligne après ligne */
@media (prefers-reduced-motion: no-preference) {
    .auth__brand .logbook__row { opacity: 0; animation: log-in .45s ease-out forwards; }
    .auth__brand .logbook__row:nth-child(1) { animation-delay: .15s; }
    .auth__brand .logbook__row:nth-child(2) { animation-delay: .45s; }
    .auth__brand .logbook__row:nth-child(3) { animation-delay: .75s; }
    .auth__brand .logbook__row:nth-child(4) { animation-delay: 1.05s; }
    .auth__brand .logbook__row:nth-child(5) { animation-delay: 1.35s; }
}
@keyframes log-in { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

.auth__panel { display: grid; place-items: center; padding: 48px 24px; background: var(--paper); }
.auth__form { width: 100%; max-width: 380px; }
.auth__form h1 { font-size: 34px; margin-bottom: 8px; }
.auth__form .muted { margin-bottom: 28px; }
.auth__form h1 + .flash, .auth__form h1 + .field { margin-top: 28px; }
.auth__company { font-weight: 600; color: var(--steel); margin-bottom: 4px; }
.auth__switch { display: inline-block; margin-top: 18px; font-size: 15px; color: var(--steel); }
.auth__switch:hover { color: var(--ink); }

@media (max-width: 860px) {
    .auth { grid-template-columns: 1fr; }
    .auth__brand { padding: 32px 24px; gap: 20px; }
    .auth__brand .logbook { display: none; }
    .auth__pitch { font-size: 24px; max-width: none; }
    .auth__panel { place-items: start center; }
}

/* Code personnel d'accès */
.code-chip {
    display: inline-block; padding: 1px 8px; margin-left: 2px;
    background: var(--signal-soft); border: 1px solid #efd9a0; border-radius: 4px;
    font-weight: 700; letter-spacing: .06em; color: var(--ink); font-variant-numeric: tabular-nums;
    user-select: all;
}
.auth__hint { margin-top: 14px; font-size: 14px; color: var(--steel); }
.page-note { margin-top: 16px; font-size: 15px; }

/* ---------- Pages d'erreur ---------- */
.error-page { max-width: 480px; margin: 18vh auto 0; padding: 0 24px; }
.error-page__code { font: 700 64px/1 var(--font-display); color: var(--signal); font-variant-numeric: tabular-nums; }
.error-page h1 { font-size: 30px; margin: 10px 0; }
.error-page .muted { margin-bottom: 28px; }

/* ==========================================================================
   Espace société
   ========================================================================== */
.is-app { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); min-height: 100vh; }

.sidebar {
    position: sticky; top: 0; height: 100vh;
    display: flex; flex-direction: column;
    padding: 20px 14px;
    background: var(--night); color: #c9d1dc;
}
.sidebar__brand { display: flex; align-items: center; gap: 10px; padding: 4px 10px; color: #fff; font: 700 20px var(--font-display); }
.sidebar__brand .icon { width: 24px; height: 24px; color: var(--signal); }
.sidebar__company {
    margin: 18px 0 20px; padding: 10px 12px;
    background: var(--night-2); border-radius: var(--r-control);
    font-weight: 600; color: #fff;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.nav { display: grid; gap: 2px; }
.nav__item {
    display: flex; align-items: center; gap: 12px;
    min-height: 42px; padding: 0 12px;
    border-radius: var(--r-control);
    text-decoration: none; font-weight: 500; font-size: 15px;
}
a.nav__item:hover { background: var(--night-2); color: #fff; }
.nav__item.is-active { background: var(--night-2); color: #fff; box-shadow: inset 3px 0 0 var(--signal); }
.nav__item.is-soon { color: #6f7b8c; cursor: default; }
.nav__item small { margin-left: auto; font-size: 12px; color: #6f7b8c; }

.sidebar__user {
    display: flex; align-items: center; gap: 10px;
    margin-top: auto; padding-top: 16px;
    border-top: 1px solid var(--night-2);
}
.sidebar__user form { margin: 0 0 0 auto; }
.sidebar__who { display: grid; min-width: 0; line-height: 1.25; }
.sidebar__who strong { color: #fff; font-weight: 600; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar__who small { color: var(--steel-light); font-size: 13px; }
.avatar {
    display: grid; place-items: center; flex: none;
    width: 36px; height: 36px; border-radius: 50%;
    background: var(--night-3); color: #fff; font-weight: 600; font-size: 14px;
}

.main { min-width: 0; }
.topbar {
    display: flex; align-items: center; gap: 12px;
    height: 64px; padding: 0 32px;
    background: var(--paper); border-bottom: 1px solid var(--line);
}
.topbar__title { font-size: 22px; }
.topbar__clock { margin-left: auto; font-weight: 600; font-variant-numeric: tabular-nums; color: var(--steel); }
.topbar__menu { display: none; color: var(--ink); }
.topbar__menu:hover { background: var(--concrete); }
.main > .flash { margin: 20px 32px 0; }

.content { padding: 32px; max-width: 1240px; }

.greeting { margin-bottom: 24px; }
.greeting h2 { font-size: 30px; margin-bottom: 4px; }

/* Bandeau de situation : une seule surface, séparée par des filets */
.status-strip {
    display: grid; grid-template-columns: repeat(4, minmax(0, 1fr));
    margin-bottom: 24px;
    background: var(--paper); border: 1px solid var(--line); border-radius: var(--r-panel);
}
.status-strip__item { display: grid; gap: 2px; padding: 20px 24px; border-left: 1px solid var(--line); }
.status-strip__item:first-child { border-left: 0; }
.status-strip__value { font: 700 36px/1 var(--font-display); font-variant-numeric: tabular-nums; }
.status-strip__label { color: var(--steel); font-size: 15px; }
.status-strip__item.is-live .status-strip__label::before {
    content: ""; display: inline-block; width: 8px; height: 8px; margin-right: 8px;
    border-radius: 50%; background: var(--signal); vertical-align: 1px;
}

.split { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); gap: 24px; align-items: start; }
.panel { background: var(--paper); border: 1px solid var(--line); border-radius: var(--r-panel); padding: 24px; }
.panel__title { font-size: 20px; margin-bottom: 18px; }

/* Étapes de mise en route (vraie séquence → numérotée) */
.steps { list-style: none; margin: 0; padding: 0; counter-reset: step; }
.steps__item {
    position: relative; display: grid; gap: 2px;
    padding: 0 0 18px 48px; counter-increment: step;
}
.steps__item:last-child { padding-bottom: 0; }
.steps__item::before {
    content: counter(step);
    position: absolute; left: 0; top: -2px;
    display: grid; place-items: center; width: 30px; height: 30px;
    border: 1.5px solid var(--line); border-radius: 50%;
    font-weight: 600; font-size: 14px; color: var(--steel);
}
.steps__item strong { font-weight: 600; }
.steps__item span { color: var(--steel); font-size: 15px; }
.steps__item.is-done::before { content: "✓"; background: var(--ok); border-color: var(--ok); color: #fff; }

/* Main courante — variante claire pour le tableau de bord */
.logbook--light .logbook__row::before { background: var(--line); }
.logbook--light .logbook__row::after { background: var(--paper); border-color: var(--steel-light); }
.logbook--light .logbook__row time { color: var(--ink); }
.logbook--light .logbook__row > span { color: var(--steel); }
.logbook--light .logbook__row strong { color: var(--ink); }

.logbook--light .logbook__row.is-alert strong { color: var(--alert); }

/* ---------- Responsive espace société ---------- */
.scrim { display: none; }

@media (max-width: 1100px) {
    .split { grid-template-columns: 1fr; }
    .status-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .status-strip__item:nth-child(3) { border-left: 0; }
    .status-strip__item:nth-child(n+3) { border-top: 1px solid var(--line); }
}

@media (max-width: 860px) {
    .is-app { grid-template-columns: 1fr; }
    .sidebar {
        position: fixed; inset: 0 auto 0 0; z-index: 40;
        width: min(var(--sidebar-w), 86vw);
        transform: translateX(-100%);
        transition: transform .2s ease;
    }
    .is-menu-open .sidebar { transform: none; }
    .is-menu-open .scrim { display: block; position: fixed; inset: 0; z-index: 30; background: rgba(20, 28, 40, .45); }
    .topbar { padding: 0 16px; }
    .topbar__menu { display: inline-grid; }
    .content { padding: 20px 16px; }
    .main > .flash { margin: 16px 16px 0; }
}


/* ==========================================================================
   Équipe, formulaires, tableaux
   ========================================================================== */
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.auth__links { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; }

.field__help { font-size: 14px; color: var(--steel); }
.field__error { font-size: 14px; font-weight: 600; color: var(--alert); }
.field.has-error input { border-color: var(--alert); }
.field input[readonly] { background: var(--concrete); color: var(--steel); }
fieldset.field { border: 0; padding: 0; margin: 0 0 18px; min-width: 0; }
fieldset.field legend { font-size: 14px; font-weight: 600; padding: 0; margin-bottom: 6px; }

.btn--ghost {
    min-height: 36px; padding: 0 12px; font-size: 14px;
    background: var(--paper); color: var(--ink); border-color: var(--line);
}
.btn--ghost:hover { background: var(--concrete); }
.btn--danger { color: var(--alert); }
.btn--danger:hover { background: var(--alert-soft); border-color: var(--alert-soft); }

.page-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.back-link { display: inline-block; margin-bottom: 16px; font-size: 15px; color: var(--steel); }
.back-link::before { content: "‹ "; }

.table-wrap { overflow-x: auto; background: var(--paper); border: 1px solid var(--line); border-radius: var(--r-panel); }
.table { width: 100%; border-collapse: collapse; font-size: 15px; }
.table th {
    text-align: left; font-weight: 600; font-size: 14px; color: var(--steel);
    padding: 12px 16px; border-bottom: 1px solid var(--line); background: #f7f8fa; white-space: nowrap;
}
.table td { padding: 14px 16px; border-bottom: 1px solid var(--line); vertical-align: top; }
.table tr:last-child td { border-bottom: 0; }
.table strong { font-weight: 600; }
.table__sub { display: block; color: var(--steel); font-size: 14px; margin-top: 2px; }
.table tr.is-off td { color: var(--steel-light); }
.table__actions { text-align: right; white-space: nowrap; }
.table__actions form { display: inline-block; margin: 0 0 0 6px; }

.badge {
    display: inline-flex; align-items: center; gap: 6px;
    font-size: 14px; font-weight: 600; white-space: nowrap;
}
.badge::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.badge--ok { color: var(--ok); }
.badge--wait { color: #9a6b00; }
.badge--wait::before { background: var(--signal); }
.badge--alert { color: var(--alert); }
.badge--off { color: var(--steel-light); }

.panel--form { max-width: 640px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.choices { display: grid; gap: 8px; }
.choice {
    display: flex; gap: 12px; align-items: flex-start;
    padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--r-control); cursor: pointer;
}
.choice:has(input:checked) { border-color: var(--night); box-shadow: inset 3px 0 0 var(--signal); }
.field .choice input[type="radio"] { width: 18px; height: 18px; min-height: 0; padding: 0; margin: 2px 0 0; flex: none; accent-color: var(--night); }
.choice span { display: grid; font-size: 14px; color: var(--steel); }
.choice strong { font-size: 15px; font-weight: 600; color: var(--ink); }
.form-foot { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; padding-top: 8px; }
.form-foot .muted { font-size: 14px; max-width: 36ch; }

.steps__item a { color: inherit; text-decoration-color: var(--signal); text-underline-offset: 3px; }

@media (max-width: 860px) {
    .form-grid { grid-template-columns: 1fr; }
    .table thead { display: none; }
    .table, .table tbody, .table tr, .table td { display: block; }
    .table tr { padding: 12px 16px; border-bottom: 1px solid var(--line); }
    .table tr:last-child { border-bottom: 0; }
    .table td { padding: 4px 0; border: 0; }
    .table__actions { text-align: left; padding-top: 8px !important; }
    .table__actions form { margin: 0 6px 0 0; }
}

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