/* ==========================================================================
   RacingLubes — Espace service client
   Feuille de style unique, écrite à la main (aucune étape de build).
   Objectif : lisible par des personnes non techniques. Contrastes élevés,
   grandes zones cliquables, vocabulaire en français courant.
   ========================================================================== */

/* --- 1. Réinitialisation minimale ---------------------------------------- */

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

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    font-family: "IBM Plex Sans", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
    font-size: 16px;
    line-height: 1.55;
    color: var(--ink);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3, p, ul, ol, figure { margin: 0; }
ul, ol { padding: 0; list-style: none; }
img { max-width: 100%; height: auto; }
a { color: inherit; }

button, input, select, textarea { font: inherit; color: inherit; }

code, pre, .mono {
    font-family: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 0.94em;
}

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

/* --- 2. Jetons de couleur ------------------------------------------------- */

:root {
    --bg:            #f4f6f9;
    --surface:       #ffffff;
    --surface-2:     #f8fafc;
    --surface-3:     #eef2f7;

    --ink:           #14213a;   /* texte principal */
    --ink-2:         #475674;   /* texte secondaire */
    --ink-3:         #6b7a99;   /* texte discret */

    --line:          #dde4ee;
    --line-strong:   #c3cede;

    --brand:         #b8531a;   /* orange RacingLubes, assombri pour le contraste */
    --brand-ink:     #8f3f13;
    --brand-soft:    #fdf1e8;
    --brand-line:    #f0cdb2;

    --ok:            #14724a;
    --ok-soft:       #e6f5ee;
    --ok-line:       #b7e0cd;

    --warn:          #92600b;
    --warn-soft:     #fdf3e0;
    --warn-line:     #f0d9a8;

    --alert:         #b3261e;
    --alert-soft:    #fdeceb;
    --alert-line:    #f3c4c1;

    --info:          #1c5b96;
    --info-soft:     #e9f2fb;
    --info-line:     #bcd8f0;

    --focus:         #1c5b96;

    --radius:        12px;
    --radius-sm:     8px;
    --shadow:        0 1px 2px rgba(20, 33, 58, .06), 0 6px 18px rgba(20, 33, 58, .07);
    --shadow-sm:     0 1px 2px rgba(20, 33, 58, .07);
}

/* --- 3. Ossature de page -------------------------------------------------- */

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

.wrap { width: 100%; max-width: 1120px; margin: 0 auto; padding: 0 24px; }
.wrap-narrow { max-width: 780px; }

.topbar {
    position: sticky; top: 0; z-index: 30;
    background: var(--surface);
    border-bottom: 1px solid var(--line);
    box-shadow: var(--shadow-sm);
}
.topbar-in {
    display: flex; align-items: center; gap: 16px;
    min-height: 64px; padding-top: 10px; padding-bottom: 10px;
    flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; }
.brand-mark {
    width: 34px; height: 34px; flex: none;
    display: grid; place-items: center;
    border-radius: 9px;
    background: var(--brand-soft);
    border: 1px solid var(--brand-line);
    font-size: 18px;
}
.brand-name { font-weight: 700; letter-spacing: -.01em; }
.brand-sub { display: block; font-size: 12px; font-weight: 500; color: var(--ink-3); }

.topbar-nav { display: flex; gap: 4px; margin-left: 8px; flex-wrap: wrap; }
.topbar-nav a {
    padding: 7px 12px; border-radius: 8px;
    font-size: 14px; font-weight: 600; color: var(--ink-2); text-decoration: none;
}
.topbar-nav a:hover { background: var(--surface-3); color: var(--ink); }
.topbar-nav a[aria-current="page"] { background: var(--brand-soft); color: var(--brand-ink); }

.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 12px; }

.content { flex: 1; padding: 28px 0 64px; }

.page-head { margin-bottom: 20px; }
.page-title { font-size: 26px; font-weight: 700; letter-spacing: -.02em; }
.page-intro { margin-top: 6px; color: var(--ink-2); max-width: 70ch; }

/* --- 4. Boutons ----------------------------------------------------------- */

.btn {
    display: inline-flex; align-items: center; gap: 8px;
    padding: 9px 16px; min-height: 40px;
    border: 1px solid var(--line-strong); border-radius: 9px;
    background: var(--surface); color: var(--ink);
    font-size: 14px; font-weight: 600; text-decoration: none;
    cursor: pointer; transition: background .12s, border-color .12s, color .12s;
}
.btn:hover { background: var(--surface-3); border-color: var(--ink-3); }
.btn-primary {
    background: var(--brand); border-color: var(--brand); color: #fff;
}
.btn-primary:hover { background: var(--brand-ink); border-color: var(--brand-ink); }
.btn-sm { min-height: 32px; padding: 5px 11px; font-size: 13px; }
.btn-ghost { border-color: transparent; background: transparent; color: var(--ink-2); }
.btn-ghost:hover { background: var(--surface-3); color: var(--ink); }

/* --- 5. Cartes et blocs --------------------------------------------------- */

.card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
}
.card-pad { padding: 20px 22px; }

.grid { display: grid; gap: 16px; }
@media (min-width: 720px) { .grid-2 { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 960px) { .grid-3 { grid-template-columns: repeat(3, 1fr); } }

.tile {
    display: block; text-decoration: none;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 22px;
    box-shadow: var(--shadow-sm);
    transition: border-color .12s, box-shadow .12s, transform .12s;
}
.tile:hover { border-color: var(--brand-line); box-shadow: var(--shadow); transform: translateY(-1px); }
.tile-title { font-size: 17px; font-weight: 700; letter-spacing: -.01em; }
.tile-text { margin-top: 8px; color: var(--ink-2); font-size: 15px; }
.tile-go { margin-top: 14px; display: inline-block; font-weight: 600; color: var(--brand-ink); font-size: 14px; }
.tile-primary { background: var(--brand-soft); border-color: var(--brand-line); }

/* --- 6. Messages d'état --------------------------------------------------- */

.notice {
    display: flex; gap: 12px; align-items: flex-start;
    padding: 14px 16px;
    border: 1px solid var(--line);
    border-left-width: 4px;
    border-radius: var(--radius-sm);
    background: var(--surface-2);
    font-size: 14.5px;
}
.notice-icon { font-size: 17px; line-height: 1.3; flex: none; }
.notice strong { font-weight: 700; }
.notice-ok    { background: var(--ok-soft);    border-color: var(--ok-line);    border-left-color: var(--ok); }
.notice-warn  { background: var(--warn-soft);  border-color: var(--warn-line);  border-left-color: var(--warn); }
.notice-alert { background: var(--alert-soft); border-color: var(--alert-line); border-left-color: var(--alert); }
.notice-info  { background: var(--info-soft);  border-color: var(--info-line);  border-left-color: var(--info); }
.notice p { margin-top: 3px; color: var(--ink-2); }
.notice code { background: rgba(255,255,255,.7); padding: 1px 5px; border-radius: 4px; }

/* --- 7. Onglets pays ------------------------------------------------------ */

.shopbar {
    display: flex; gap: 6px; flex-wrap: wrap;
    padding-bottom: 12px; margin-bottom: 18px;
    border-bottom: 1px solid var(--line);
}
.shoptab {
    display: inline-flex; align-items: center; gap: 8px;
    padding: 8px 14px; border-radius: 999px;
    border: 1px solid var(--line);
    background: var(--surface);
    font-size: 14px; font-weight: 600; color: var(--ink-2); text-decoration: none;
    white-space: nowrap;
}
.shoptab:hover { border-color: var(--line-strong); color: var(--ink); }
.shoptab[aria-current="page"] {
    background: var(--ink); border-color: var(--ink); color: #fff;
}
.shoptab .flag { font-size: 16px; }
.shoptab .n {
    min-width: 22px; padding: 1px 6px; border-radius: 999px;
    background: var(--surface-3); color: var(--ink-2);
    font-size: 12px; font-weight: 700; text-align: center;
}
.shoptab[aria-current="page"] .n { background: rgba(255,255,255,.22); color: #fff; }
.shoptab-empty { opacity: .55; }

/* --- 8. Sous-onglets (reçus / envoyés) ------------------------------------ */

.switch { display: inline-flex; padding: 4px; gap: 4px; background: var(--surface-3); border-radius: 10px; }
.switch a {
    padding: 7px 14px; border-radius: 7px;
    font-size: 14px; font-weight: 600; color: var(--ink-2); text-decoration: none;
}
.switch a:hover { color: var(--ink); }
.switch a[aria-current="page"] { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-sm); }

/* --- 9. Barre de filtres -------------------------------------------------- */

.toolbar {
    display: flex; gap: 10px; align-items: center; flex-wrap: wrap;
    margin: 18px 0 14px;
}
.chip {
    display: inline-flex; align-items: center; gap: 8px;
    padding: 8px 14px; min-height: 38px;
    border: 1px solid var(--line); border-radius: 999px;
    background: var(--surface); color: var(--ink-2);
    font-size: 14px; font-weight: 600; cursor: pointer;
    transition: background .12s, border-color .12s, color .12s;
}
.chip:hover { border-color: var(--line-strong); color: var(--ink); }
.chip[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: #fff; }
.chip .n {
    min-width: 22px; padding: 1px 6px; border-radius: 999px;
    background: var(--surface-3); color: var(--ink-2);
    font-size: 12px; font-weight: 700; text-align: center;
}
.chip[aria-pressed="true"] .n { background: rgba(255,255,255,.22); color: #fff; }

.search { position: relative; margin-left: auto; flex: 1 1 260px; max-width: 340px; }
.search input {
    width: 100%; padding: 9px 14px 9px 38px; min-height: 40px;
    border: 1px solid var(--line-strong); border-radius: 9px;
    background: var(--surface); font-size: 14.5px;
}
.search input::placeholder { color: var(--ink-3); }
.search-icon {
    position: absolute; left: 13px; top: 50%; transform: translateY(-50%);
    color: var(--ink-3); pointer-events: none; font-size: 15px;
}

/* --- 10. Liste des demandes ---------------------------------------------- */

.list { display: flex; flex-direction: column; gap: 10px; }

.req {
    background: var(--surface);
    border: 1px solid var(--line);
    border-left: 4px solid var(--line-strong);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}
.req[open] { box-shadow: var(--shadow); }
.req-lvl1 { border-left-color: var(--ok); }
.req-lvl2 { border-left-color: var(--warn); }
.req-lvl3 { border-left-color: var(--info); }
.req-lvl0 { border-left-color: var(--line-strong); }

.req > summary {
    list-style: none; cursor: pointer;
    padding: 14px 18px;
    display: grid; gap: 4px;
}
.req > summary::-webkit-details-marker { display: none; }
.req > summary:hover { background: var(--surface-2); }

.req-top { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.req-ref { font-weight: 700; letter-spacing: -.01em; }
.req-when { margin-left: auto; font-size: 13px; color: var(--ink-3); white-space: nowrap; }
.req-q {
    color: var(--ink-2); font-size: 14.5px;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.req-open { font-size: 13px; color: var(--ink-3); font-weight: 600; }
.req[open] .req-open::after { content: " ▴"; }
.req:not([open]) .req-open::after { content: " ▾"; }

.req-body { padding: 4px 18px 18px; display: grid; gap: 14px; border-top: 1px solid var(--line); }

.tag {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 3px 10px; border-radius: 999px;
    border: 1px solid var(--line);
    background: var(--surface-3);
    font-size: 12.5px; font-weight: 700; white-space: nowrap;
}
.tag-ok    { background: var(--ok-soft);    border-color: var(--ok-line);    color: var(--ok); }
.tag-warn  { background: var(--warn-soft);  border-color: var(--warn-line);  color: var(--warn); }
.tag-alert { background: var(--alert-soft); border-color: var(--alert-line); color: var(--alert); }
.tag-info  { background: var(--info-soft);  border-color: var(--info-line);  color: var(--info); }
.tag-mute  { background: var(--surface-3);  border-color: var(--line);       color: var(--ink-3); }
.tag-flag  { background: var(--surface); border-color: var(--line); color: var(--ink-2); }

.facts { display: flex; flex-wrap: wrap; gap: 8px 22px; font-size: 14px; }
.fact { display: flex; gap: 6px; }
.fact-k { color: var(--ink-3); }
.fact-v { font-weight: 600; }

.panel {
    background: var(--surface-2);
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    padding: 14px 16px;
}
.panel-title {
    font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em;
    color: var(--ink-3); margin-bottom: 7px;
}
.panel-quote { white-space: pre-wrap; font-size: 15px; }

.answer { background: var(--ok-soft); border-color: var(--ok-line); }
.answer-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 10px; }
.answer-title { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--ok); }
.answer-text {
    white-space: pre-wrap; font-family: inherit; font-size: 15px;
    background: var(--surface); border: 1px solid var(--ok-line); border-radius: var(--radius-sm);
    padding: 14px 16px; margin: 0;
}

.empty {
    padding: 56px 24px; text-align: center; color: var(--ink-2);
    background: var(--surface); border: 1px dashed var(--line-strong); border-radius: var(--radius);
}
.empty-title { font-size: 17px; font-weight: 700; color: var(--ink); }
.empty p { margin-top: 6px; }

/* --- 11. Tableau ---------------------------------------------------------- */

.table-scroll { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 14.5px; }
table.data th {
    text-align: left; padding: 10px 14px;
    font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-3);
    border-bottom: 1px solid var(--line);
}
table.data td { padding: 11px 14px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.data tr:last-child td { border-bottom: 0; }
table.data tbody tr:hover { background: var(--surface-2); }

/* --- 12. Connexion -------------------------------------------------------- */

.login-screen { min-height: 100vh; display: grid; place-items: center; padding: 32px 20px; }
.login-box { width: 100%; max-width: 400px; }
.login-head { text-align: center; margin-bottom: 22px; }
.login-mark {
    width: 56px; height: 56px; margin: 0 auto 14px;
    display: grid; place-items: center; font-size: 26px;
    background: var(--brand-soft); border: 1px solid var(--brand-line); border-radius: 16px;
}
.login-title { font-size: 21px; font-weight: 700; letter-spacing: -.01em; }
.login-sub { color: var(--ink-2); margin-top: 4px; }

.field { margin-bottom: 16px; }
.field label { display: block; font-size: 14px; font-weight: 600; margin-bottom: 6px; }
.field input {
    width: 100%; padding: 11px 14px; min-height: 44px;
    border: 1px solid var(--line-strong); border-radius: 9px;
    background: var(--surface); font-size: 15px;
}
.field input:focus { border-color: var(--focus); }

.foot-note { margin-top: 22px; text-align: center; font-size: 13px; color: var(--ink-3); }

/* --- 13. Utilitaires ------------------------------------------------------ */

.muted { color: var(--ink-3); }
.small { font-size: 13px; }
.strong { font-weight: 700; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.stack { display: grid; gap: 14px; }
.mt-1 { margin-top: 8px; }  .mt-2 { margin-top: 16px; } .mt-3 { margin-top: 24px; }
.mb-1 { margin-bottom: 8px; } .mb-2 { margin-bottom: 16px; } .mb-3 { margin-bottom: 24px; }
.hidden { display: none !important; }
.nowrap { white-space: nowrap; }

.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;
}

.link { color: var(--info); font-weight: 600; text-decoration: underline; text-underline-offset: 2px; }
.link:hover { color: var(--ink); }

@media (max-width: 640px) {
    .wrap { padding: 0 16px; }
    .page-title { font-size: 22px; }
    .req-when { margin-left: 0; }
    .search { margin-left: 0; max-width: none; }
}

@media print {
    .topbar, .toolbar, .shopbar, .switch, .btn { display: none !important; }
    .req { break-inside: avoid; box-shadow: none; }
    body { background: #fff; }
}

/* --- 14. Tickets : urgence SLA, actions, historique ----------------------- */

.req.sla-depasse       { border-left-color: var(--alert); }
.req.sla-bientot       { border-left-color: var(--warn); }
.req.sla-a_temps       { border-left-color: var(--ok); }
.req.sla-repondu_hors  { border-left-color: var(--warn); }
.req.sla-respecte      { border-left-color: var(--ok); }
.req.sla-clos,
.req.sla-sans_objet    { border-left-color: var(--line-strong); }

/* Le retard doit se voir sans lire : fond très légèrement teinté. */
.req.sla-depasse > summary { background: var(--alert-soft); }
.req.sla-depasse > summary:hover { background: #fbe0de; }

.actions {
    display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-start;
    padding-top: 12px; border-top: 1px dashed var(--line);
}
.actions form { margin: 0; }

details.act { position: relative; }
details.act > summary { list-style: none; cursor: pointer; }
details.act > summary::-webkit-details-marker { display: none; }
details.act[open] > summary { background: var(--surface-3); border-color: var(--ink-3); }

.act-form {
    margin-top: 10px; padding: 14px;
    display: grid; gap: 10px;
    background: var(--surface-2);
    border: 1px solid var(--line); border-radius: var(--radius-sm);
    min-width: min(460px, 90vw);
}
.act-form textarea {
    width: 100%; padding: 10px 12px;
    border: 1px solid var(--line-strong); border-radius: 8px;
    background: var(--surface); font-size: 14.5px; resize: vertical;
}
.act-form .btn { justify-self: start; }

select {
    padding: 8px 12px; min-height: 38px;
    border: 1px solid var(--line-strong); border-radius: 8px;
    background: var(--surface); font-size: 14px;
}

.timeline { margin-top: 10px; display: grid; gap: 10px; border-left: 2px solid var(--line); padding-left: 14px; }
.timeline li { position: relative; }
.timeline li::before {
    content: ""; position: absolute; left: -19px; top: 7px;
    width: 8px; height: 8px; border-radius: 999px;
    background: var(--surface); border: 2px solid var(--line-strong);
}

/* Tableau de suivi (responsable) : lignes compactes et lisibles. */
.kpi { display: grid; gap: 4px; }
.kpi-value { font-size: 30px; font-weight: 700; letter-spacing: -.02em; line-height: 1.1; }
.kpi-label { font-size: 13px; color: var(--ink-3); }
.kpi-hint  { font-size: 12.5px; color: var(--ink-2); }
.kpi-alert .kpi-value { color: var(--alert); }
.kpi-warn  .kpi-value { color: var(--warn); }
.kpi-ok    .kpi-value { color: var(--ok); }

.bar { height: 8px; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
.bar > span { display: block; height: 100%; border-radius: 999px; background: var(--info); }
