/*
 * Feuille de style du dashboard.
 *
 * Écrite à la main et servie statiquement, sans Tailwind ni étape de build : `php artisan serve`
 * suffit à afficher le dashboard, sans `npm install` ni `npm run build` ni manifeste Vite à
 * régénérer avant chaque déploiement. Pour quelques écrans internes de consultation, la chaîne
 * d'assets coûterait plus cher qu'elle ne rapporte.
 *
 * Identité visuelle : interface sombre, accent orange, cartes arrondies posées sur un fond très
 * sombre. Le choix du sombre n'est pas décoratif -- c'est un écran de supervision qu'on laisse
 * ouvert toute la journée, souvent en second plan, et l'orange y ressort sans agresser.
 *
 * La couleur d'accent ne sert JAMAIS à dire l'état d'une imprimante : les couleurs sémantiques
 * (vert/ambre/rouge) sont réservées à ça. Un accent qui signifierait aussi "tout va bien" rendrait
 * l'écran illisible au premier coup d'œil, qui est précisément le moment qui compte.
 */

:root {
    color-scheme: dark;

    --bg: #0b0c0e;
    --surface: #16171a;
    --surface-raised: #1e2024;
    --surface-hover: #232529;
    --border: #292b30;
    --border-strong: #34373d;

    --text: #ecedef;
    --text-dim: #b4b7bd;
    --muted: #85888f;

    --accent: #f0562d;
    --accent-hover: #ff6a42;
    --accent-soft: #f0562d1f;
    --accent-contrast: #ffffff;

    /* Sémantique -- distincte de l'accent, et seule autorisée à qualifier un état. */
    --ok: #3ecf8e;
    --ok-bg: #11342650;
    --ok-text: #6fe0ab;
    --warn: #e8a33d;
    --warn-bg: #3a2a0f60;
    --warn-text: #f0be6b;
    --danger: #f2555a;
    --danger-bg: #3d171a60;
    --danger-text: #ff8a8e;
    --info-bg: #16283f60;
    --info-text: #7cb8f5;
    --busy-bg: #2a1f4260;
    --busy-text: #b79cf0;
    --neutral-bg: #24262b;
    --neutral-text: #a5a9b1;

    --radius: 14px;
    --radius-sm: 9px;

    --font: "Plus Jakarta Sans", "Segoe UI", system-ui, -apple-system, sans-serif;
    --font-mono: "JetBrains Mono", ui-monospace, "Cascadia Mono", Consolas, monospace;
}

* { box-sizing: border-box; }

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

a { color: inherit; }

h1, h2, h3 { margin: 0; letter-spacing: -0.015em; text-wrap: balance; }
h1 { font-size: 1.65rem; font-weight: 700; }
h2 { font-size: 1.15rem; font-weight: 600; }
h3 { font-size: 0.98rem; font-weight: 600; }

p { margin: 0; }

/* ---------------------------------------------------------------- structure */

.shell {
    display: grid;
    grid-template-columns: 244px 1fr;
    min-height: 100vh;
}

@media (max-width: 900px) {
    .shell { grid-template-columns: 1fr; }
}

.sidebar {
    background: var(--surface);
    border-right: 1px solid var(--border);
    padding: 22px 16px;
    display: flex;
    flex-direction: column;
    gap: 26px;
    position: sticky;
    top: 0;
    height: 100vh;
}

@media (max-width: 900px) {
    .sidebar { position: static; height: auto; }
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 700;
    font-size: 1.1rem;
    letter-spacing: -0.02em;
    text-decoration: none;
    padding: 0 8px;
}

.brand-mark {
    width: 30px;
    height: 30px;
    border-radius: 9px;
    background: var(--accent);
    color: var(--accent-contrast);
    display: grid;
    place-items: center;
    font-size: 15px;
    font-weight: 800;
    flex: none;
}

.brand .scope {
    display: block;
    font-size: 11px;
    font-weight: 500;
    color: var(--muted);
    letter-spacing: 0.02em;
}

.nav { display: flex; flex-direction: column; gap: 3px; }

.nav a {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 9px 12px;
    border-radius: var(--radius-sm);
    color: var(--text-dim);
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    transition: background 120ms ease, color 120ms ease;
}

.nav a:hover { background: var(--surface-hover); color: var(--text); }

.nav a.active {
    background: var(--accent-soft);
    color: var(--accent);
    font-weight: 600;
}

.nav svg { width: 17px; height: 17px; flex: none; }

.nav-label {
    font-size: 10.5px;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--muted);
    padding: 0 12px;
    margin-bottom: 6px;
}

.sidebar-foot {
    margin-top: auto;
    border-top: 1px solid var(--border);
    padding-top: 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.who {
    font-size: 12.5px;
    color: var(--muted);
    padding: 0 12px;
    word-break: break-word;
}

main {
    padding: 26px clamp(16px, 3vw, 34px) 60px;
    min-width: 0;
}

.page-head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 22px;
}

.subtitle { color: var(--muted); font-size: 13.5px; }

section { margin-bottom: 26px; }

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

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px 20px;
}

.card + .card { margin-top: 14px; }

.card-head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 14px;
}

/* ---------------------------------------------------------------- chiffres */

.stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 12px;
}

.stat {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 15px 17px;
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.stat .value {
    font-size: 1.7rem;
    font-weight: 700;
    letter-spacing: -0.03em;
    font-variant-numeric: tabular-nums;
}

.stat .label {
    font-size: 11.5px;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--muted);
}

.stat.accent .value { color: var(--accent); }
.stat.warn .value { color: var(--warn); }

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

.table-scroll { overflow-x: auto; }

table { width: 100%; border-collapse: collapse; }

th, td {
    text-align: left;
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

th {
    font-size: 10.5px;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--muted);
    white-space: nowrap;
}

tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: var(--surface-hover); }

td.num { font-variant-numeric: tabular-nums; white-space: nowrap; }
td.note { color: var(--muted); font-size: 13px; }

.empty {
    color: var(--muted);
    text-align: center;
    padding: 26px 12px;
    font-size: 13.5px;
}

/* --------------------------------------------------------------- pastilles */

.badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 3px 9px;
    border-radius: 999px;
    font-size: 11.5px;
    font-weight: 600;
    white-space: nowrap;
    line-height: 1.5;
}

.badge::before {
    content: "";
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
    flex: none;
}

.badge-plain::before { display: none; }

.badge-ok { background: var(--ok-bg); color: var(--ok-text); }
.badge-warn { background: var(--warn-bg); color: var(--warn-text); }
.badge-danger { background: var(--danger-bg); color: var(--danger-text); }
.badge-info { background: var(--info-bg); color: var(--info-text); }
.badge-busy { background: var(--busy-bg); color: var(--busy-text); }
.badge-neutral { background: var(--neutral-bg); color: var(--neutral-text); }

.status-cell { display: inline-flex; flex-wrap: wrap; align-items: baseline; gap: 4px 8px; }
.status-reason { font-size: 12px; color: var(--muted); }

/* --------------------------------------------------------------- boutons */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    padding: 9px 16px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-strong);
    background: var(--surface-raised);
    color: var(--text);
    font: inherit;
    font-size: 13.5px;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    transition: background 120ms ease, border-color 120ms ease;
}

.btn:hover { background: var(--surface-hover); border-color: var(--muted); }

.btn-primary {
    background: var(--accent);
    border-color: var(--accent);
    color: var(--accent-contrast);
}

.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }

.btn-small { padding: 6px 11px; font-size: 12.5px; }

.btn-link {
    background: none;
    border: none;
    color: var(--accent);
    padding: 0;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
}

.btn-block { width: 100%; }

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

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

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

.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }

.field label {
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.03em;
    color: var(--text-dim);
}

.field input, .field select {
    width: 100%;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-strong);
    background: var(--bg);
    color: var(--text);
    font: inherit;
    font-size: 14px;
}

.field input:focus, .field select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}

.field input::placeholder { color: var(--muted); }

.hint { font-size: 12px; color: var(--muted); }

.filters {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 12px;
}

.filters .field { margin-bottom: 0; min-width: 190px; }

.errors {
    background: var(--danger-bg);
    color: var(--danger-text);
    border: 1px solid var(--danger);
    border-radius: var(--radius-sm);
    padding: 10px 14px;
    margin-bottom: 16px;
    font-size: 13.5px;
}

.errors ul { margin: 0; padding-left: 18px; }

.flash {
    border-radius: var(--radius-sm);
    padding: 11px 15px;
    margin-bottom: 18px;
    font-size: 13.5px;
    border: 1px solid transparent;
}

.flash-success { background: var(--ok-bg); color: var(--ok-text); border-color: var(--ok); }
.flash-error { background: var(--danger-bg); color: var(--danger-text); border-color: var(--danger); }

/* ---------------------------------------------------------------- connexion */

.auth-page {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.auth-bar {
    padding: 20px clamp(16px, 4vw, 40px);
    border-bottom: 1px solid var(--border);
}

.auth-wrap {
    flex: 1;
    display: grid;
    place-items: center;
    padding: clamp(24px, 6vw, 64px) 16px;
}

.auth-cols {
    width: 100%;
    max-width: 940px;
    display: grid;
    gap: 18px;
    grid-template-columns: 1fr;
}

@media (min-width: 860px) {
    .auth-cols { grid-template-columns: 1fr 1fr; gap: 26px; }
}

.auth-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: clamp(22px, 3vw, 32px);
}

/* La colonne d'inscription est le chemin secondaire : plus discrète, sans être cachée. */
.auth-card.secondary { background: transparent; }

.auth-card h1 { margin-bottom: 6px; }
.auth-card .subtitle { margin-bottom: 20px; }

.auth-foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-top: 18px;
}

/* ----------------------------------------------------------------- devices */

/*
 * Un poste et ses imprimantes forment un bloc : l'imprimante n'existe que derrière la machine qui
 * la déclare, et son état dépend d'abord de celui du poste. Les séparer obligerait à faire le
 * rapprochement de tête.
 */
.device {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}

.device + .device { margin-top: 14px; }

.device-head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px 14px;
    padding: 15px 18px;
    background: var(--surface-raised);
    border-bottom: 1px solid var(--border);
}

.device-name {
    font-weight: 650;
    font-size: 15px;
    display: flex;
    align-items: center;
    gap: 9px;
    min-width: 0;
}

.device-meta {
    margin-left: auto;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 14px;
    font-size: 12.5px;
    color: var(--muted);
}

.device-body { padding: 4px 0; }

.printer-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 14px;
    padding: 9px 18px;
    border-bottom: 1px solid var(--border);
}

.device-body .printer-row:last-child { border-bottom: none; }

.printer-name { min-width: 0; word-break: break-word; }

.printer-row .right { margin-left: auto; display: flex; align-items: center; gap: 10px; }

.printer-id {
    font-family: var(--font-mono);
    font-size: 11.5px;
    color: var(--muted);
    word-break: break-all;
}

/* Un poste déconnecté garde ses imprimantes affichées, mais en retrait : ce sont les dernières
   connues, pas un état vérifié. Les masquer donnerait l'impression d'avoir perdu la config. */
.device.is-off .device-body { opacity: 0.62; }

.device-empty { padding: 16px 18px; color: var(--muted); font-size: 13.5px; }

/* ---------------------------------------------------------------- divers */

.pagination { display: flex; gap: 8px; align-items: center; margin-top: 16px; font-size: 13.5px; }

.callout {
    border: 1px dashed var(--border-strong);
    border-radius: var(--radius);
    padding: 18px 20px;
    color: var(--text-dim);
    font-size: 14px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.callout code {
    font-family: var(--font-mono);
    font-size: 12.5px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 2px 6px;
}

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

/* ---------------------------------------------------------------------------
   Écran Intégration — valeurs à recopier

   Un jeton ou une commande curl se lit caractère par caractère et se sélectionne
   à la souris : d'où la police à chasse fixe, le retour à la ligne forcé (une
   barre de défilement horizontale rend la sélection pénible) et le contraste
   suffisant pour distinguer 0 de O, 1 de l.
   --------------------------------------------------------------------------- */
.token {
    margin: 12px 0 0;
    padding: 12px 14px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    font-family: ui-monospace, "JetBrains Mono", "Cascadia Mono", Consolas, monospace;
    font-size: 12.5px;
    line-height: 1.6;
    color: var(--text);
    white-space: pre-wrap;
    word-break: break-all;
    user-select: all;
}
