/* =========================================================
   CHANTIER PRO — feuille de style
   Emplacement : assets/css/style.css
   Design : moderne, sobre, mobile-first. Teal profond + neutres chauds.
   ========================================================= */

:root {
    /* Surfaces & encre */
    --bg:          oklch(0.985 0.006 210);
    --surface:     oklch(1 0 0);
    --surface-2:   oklch(0.975 0.008 215);
    --ink:         oklch(0.27 0.02 240);
    --ink-soft:    oklch(0.44 0.02 240);
    --muted:       oklch(0.58 0.02 240);
    --line:        oklch(0.91 0.008 230);
    --line-strong: oklch(0.85 0.01 230);

    /* Primaire (teal) */
    --primary:      oklch(0.55 0.098 205);
    --primary-ink:  oklch(0.40 0.088 205);
    --primary-soft: oklch(0.955 0.028 205);

    /* États */
    --success:      oklch(0.60 0.12 155);
    --success-soft: oklch(0.955 0.04 155);
    --warn:         oklch(0.70 0.12 68);
    --warn-soft:    oklch(0.96 0.045 80);
    --danger:       oklch(0.57 0.17 25);
    --danger-soft:  oklch(0.955 0.035 25);

    /* Accents par rôle */
    --role-promoteur: oklch(0.52 0.14 275);
    --role-gerant:    oklch(0.55 0.10 205);
    --role-macon:     oklch(0.62 0.13 55);
    --role-admin:     oklch(0.45 0.03 260);

    --radius:    14px;
    --radius-sm: 9px;
    --shadow:    0 1px 2px oklch(0.4 0.03 240 / .05), 0 10px 30px oklch(0.4 0.03 240 / .06);
    --shadow-sm: 0 1px 2px oklch(0.4 0.03 240 / .06), 0 4px 12px oklch(0.4 0.03 240 / .05);

    --font:    'Inter', system-ui, -apple-system, sans-serif;
    --display: 'Plus Jakarta Sans', var(--font);

    --header-h: 64px;
    --wrap: 1120px;
}

* { box-sizing: border-box; }

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

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

h1, h2, h3 { font-family: var(--display); color: var(--ink); margin: 0; line-height: 1.2; }
a { color: inherit; text-decoration: none; }

/* ---------- Barre supérieure ---------- */
.topbar {
    position: sticky; top: 0; z-index: 50;
    background: oklch(1 0 0 / .85);
    backdrop-filter: saturate(1.4) blur(8px);
    border-bottom: 1px solid var(--line);
}
.topbar__inner {
    max-width: var(--wrap); margin: 0 auto;
    height: var(--header-h);
    display: flex; align-items: center; gap: 16px;
    padding: 0 20px;
}
.brand { display: flex; align-items: center; gap: 10px; font-family: var(--display); font-weight: 800; letter-spacing: -.02em; }
.brand__mark {
    display: grid; place-items: center;
    width: 34px; height: 34px; border-radius: 10px;
    background: var(--primary); color: #fff;
}
.brand__mark i { width: 19px; height: 19px; }
.brand__name { font-size: 17px; }

.nav { margin-left: auto; display: flex; align-items: center; gap: 4px; }
.nav__link {
    display: inline-flex; align-items: center; gap: 8px;
    padding: 9px 14px; border-radius: 10px;
    color: var(--ink-soft); font-weight: 500; font-size: 14px;
    transition: background .18s ease, color .18s ease;
}
.nav__link i { width: 17px; height: 17px; }
.nav__link:hover { background: var(--surface-2); color: var(--ink); }
.nav__link.is-active { background: var(--primary-soft); color: var(--primary-ink); font-weight: 600; }

.nav__user {
    display: flex; align-items: center; gap: 10px;
    margin-left: 12px; padding-left: 14px;
    border-left: 1px solid var(--line);
}
.nav__name { font-size: 14px; font-weight: 500; color: var(--ink); }
.nav__logout {
    display: grid; place-items: center; width: 36px; height: 36px;
    border-radius: 9px; color: var(--muted);
    transition: background .18s, color .18s;
}
.nav__logout:hover { background: var(--danger-soft); color: var(--danger); }
.nav__logout i { width: 18px; height: 18px; }

.nav-toggle {
    display: none; margin-left: auto;
    background: var(--surface-2); border: 1px solid var(--line);
    border-radius: 10px; width: 42px; height: 42px;
    color: var(--ink); cursor: pointer;
    align-items: center; justify-content: center;
}
.nav-toggle i { width: 20px; height: 20px; }

/* ---------- Conteneur ---------- */
.container { max-width: var(--wrap); margin: 0 auto; padding: 32px 20px 64px; }

.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 26px; flex-wrap: wrap; }
.page-head h1 { font-size: clamp(22px, 4vw, 30px); letter-spacing: -.02em; }
.page-head p { margin: 6px 0 0; color: var(--muted); font-size: 14px; }

/* ---------- Chips / badges ---------- */
.chip {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 4px 11px; border-radius: 999px;
    font-size: 12px; font-weight: 600; line-height: 1.6;
}
.chip i { width: 13px; height: 13px; }
.chip--role[data-role="promoteur"] { background: oklch(0.52 0.14 275 / .12); color: var(--role-promoteur); }
.chip--role[data-role="gerant"]    { background: oklch(0.55 0.10 205 / .13); color: var(--role-gerant); }
.chip--role[data-role="macon"]     { background: oklch(0.62 0.13 55 / .16); color: oklch(0.48 0.13 55); }
.chip--role[data-role="admin"]     { background: oklch(0.45 0.03 260 / .12); color: var(--role-admin); }

.badge {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 4px 10px; border-radius: 999px;
    font-size: 12px; font-weight: 600;
}
.badge i { width: 13px; height: 13px; }
.badge--pending  { background: var(--warn-soft);    color: oklch(0.48 0.11 60); }
.badge--valid    { background: var(--success-soft); color: oklch(0.42 0.11 155); }

/* ---------- Cartes ---------- */
.panel {
    background: var(--surface); border: 1px solid var(--line);
    border-radius: var(--radius); box-shadow: var(--shadow-sm);
}
.panel__head {
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    padding: 18px 22px; border-bottom: 1px solid var(--line);
}
.panel__head h2 { font-size: 16px; }
.panel__body { padding: 22px; }

/* ---------- Grille de stats ---------- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 16px; margin-bottom: 28px; }
.stat {
    background: var(--surface); border: 1px solid var(--line);
    border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow-sm);
    display: flex; flex-direction: column; gap: 6px;
}
.stat__label { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; font-weight: 500; }
.stat__label i { width: 16px; height: 16px; }
.stat__value { font-family: var(--display); font-size: 26px; font-weight: 800; letter-spacing: -.02em; }
.stat__meta { font-size: 12.5px; color: var(--muted); }
.stat--accent { background: linear-gradient(160deg, var(--primary) 0%, var(--primary-ink) 100%); border-color: transparent; color: #fff; }
.stat--accent .stat__label, .stat--accent .stat__meta { color: oklch(1 0 0 / .82); }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 14px; }
table.data th {
    text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em;
    color: var(--muted); font-weight: 600; padding: 12px 14px; border-bottom: 1px solid var(--line);
    white-space: nowrap;
}
table.data td { padding: 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.data tr:last-child td { border-bottom: 0; }
table.data tbody tr { transition: background .14s; }
table.data tbody tr:hover { background: var(--surface-2); }
.cell-strong { font-weight: 600; }
.cell-muted { color: var(--muted); font-size: 13px; }
.cell-amount { font-variant-numeric: tabular-nums; font-weight: 600; white-space: nowrap; }
.row-actions { display: flex; gap: 6px; justify-content: flex-end; }

/* ---------- Boutons ---------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    padding: 10px 16px; border-radius: 10px; border: 1px solid transparent;
    font-family: var(--font); font-size: 14px; font-weight: 600; cursor: pointer;
    transition: transform .12s ease, background .18s, border-color .18s, color .18s;
    white-space: nowrap; text-decoration: none;
}
.btn i { width: 16px; height: 16px; }
.btn:active { transform: translateY(1px); }
.btn--primary { background: var(--primary); color: #fff; }
.btn--primary:hover { background: var(--primary-ink); }
.btn--ghost { background: var(--surface); border-color: var(--line-strong); color: var(--ink); }
.btn--ghost:hover { background: var(--surface-2); }
.btn--success { background: var(--success); color: #fff; }
.btn--success:hover { filter: brightness(.95); }
.btn--danger { background: var(--danger-soft); color: var(--danger); }
.btn--danger:hover { background: var(--danger); color: #fff; }
.btn--sm { padding: 7px 11px; font-size: 13px; border-radius: 9px; }
.btn--icon { padding: 8px; width: 36px; height: 36px; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }

.icon-btn {
    display: inline-grid; place-items: center; width: 34px; height: 34px;
    border-radius: 9px; border: 1px solid var(--line); background: var(--surface);
    color: var(--ink-soft); cursor: pointer; transition: background .16s, color .16s, border-color .16s;
}
.icon-btn i { width: 16px; height: 16px; }
.icon-btn:hover { background: var(--surface-2); color: var(--ink); }
.icon-btn--danger:hover { background: var(--danger); color: #fff; border-color: var(--danger); }

/* ---------- Formulaires ---------- */
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; }
/* Champ large : occupe 2 colonnes quand la grille en a plusieurs.
   Défini via classe (et non style inline) pour pouvoir le neutraliser en mobile. */
.field--wide { grid-column: span 2; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field label { font-size: 13px; font-weight: 600; color: var(--ink-soft); }
.field .hint { font-size: 12px; color: var(--muted); }
.input, .select, textarea.input {
    width: 100%; max-width: 100%; padding: 11px 13px; border-radius: 10px;
    border: 1px solid var(--line-strong); background: var(--surface);
    font-family: var(--font); font-size: 16px; color: var(--ink);
    transition: border-color .16s, box-shadow .16s;
}
.input:focus, .select:focus, textarea.input:focus {
    outline: none; border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-soft);
}
textarea.input { resize: vertical; min-height: 78px; }
.form-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 22px; flex-wrap: wrap; }

/* ---------- Lignes d'articles (livraison) ---------- */
.lignes { display: flex; flex-direction: column; gap: 10px; }
.ligne {
    display: grid; grid-template-columns: 2.4fr 1fr .8fr 1.3fr auto; gap: 10px; align-items: end;
    padding: 12px; border: 1px dashed var(--line-strong); border-radius: var(--radius-sm);
    background: var(--surface-2);
}
.ligne .field label { font-size: 11.5px; }
.ligne__remove {
    display: grid; place-items: center; width: 40px; height: 42px;
    border-radius: 9px; border: 1px solid var(--line-strong); background: var(--surface);
    color: var(--muted); cursor: pointer;
}
.ligne__remove:hover { background: var(--danger); color: #fff; border-color: var(--danger); }

/* ---------- Info-verrou ---------- */
.locked-note {
    display: inline-flex; align-items: center; gap: 7px;
    color: var(--muted); font-size: 13px;
}
.locked-note i { width: 15px; height: 15px; }

/* ---------- État vide ---------- */
.empty {
    text-align: center; padding: 56px 20px; color: var(--muted);
}
.empty i { width: 40px; height: 40px; color: var(--line-strong); }
.empty h3 { margin: 14px 0 4px; color: var(--ink-soft); font-size: 16px; }

/* ---------- Détail / mini-liste ---------- */
.mini-list { margin: 0; padding: 0; list-style: none; font-size: 13px; }
.mini-list li { display: flex; justify-content: space-between; gap: 12px; padding: 3px 0; color: var(--ink-soft); }
.mini-list li span:last-child { font-variant-numeric: tabular-nums; }

/* ---------- Page de connexion ---------- */
.auth {
    min-height: 100vh; display: grid; grid-template-columns: 1.05fr .95fr;
}
.auth__aside {
    background: linear-gradient(155deg, var(--primary) 0%, var(--primary-ink) 100%);
    color: #fff; padding: 56px; display: flex; flex-direction: column; justify-content: space-between;
    position: relative; overflow: hidden;
}
.auth__aside::after {
    content: ''; position: absolute; right: -80px; bottom: -80px;
    width: 320px; height: 320px; border-radius: 50%;
    background: oklch(1 0 0 / .08);
}
.auth__brand { display: flex; align-items: center; gap: 12px; font-family: var(--display); font-weight: 800; font-size: 20px; }
.auth__brand .brand__mark { background: oklch(1 0 0 / .18); }
.auth__pitch h2 { font-size: 30px; letter-spacing: -.02em; max-width: 15ch; color: #fff; }
.auth__pitch p { color: oklch(1 0 0 / .82); max-width: 40ch; margin-top: 12px; }
.auth__roles { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 22px; }
.auth__roles span {
    display: inline-flex; align-items: center; gap: 7px;
    background: oklch(1 0 0 / .12); padding: 7px 13px; border-radius: 999px; font-size: 13px; font-weight: 500;
}
.auth__main { display: grid; place-items: center; padding: 40px 24px; }
.auth__card { width: 100%; max-width: 380px; }
.auth__card h1 { font-size: 24px; margin-bottom: 6px; }
.auth__card > p { color: var(--muted); margin: 0 0 26px; font-size: 14px; }
.auth__form { display: flex; flex-direction: column; gap: 16px; }
.auth__hint { margin-top: 22px; padding: 14px; border-radius: var(--radius-sm); background: var(--surface-2); border: 1px solid var(--line); font-size: 12.5px; color: var(--muted); }
.auth__hint b { color: var(--ink-soft); }

/* ---------- Pied de page ---------- */
.footer { text-align: center; padding: 28px; color: var(--muted); font-size: 13px; }

/* ---------- Utilitaires ---------- */
.stack-lg { display: flex; flex-direction: column; gap: 24px; }
.flex-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.text-muted { color: var(--muted); }

/* =========================================================
   RESPONSIVE — mobile first : le menu devient un tiroir
   ========================================================= */
@media (max-width: 860px) {
    .nav-toggle { display: inline-flex; }
    .nav {
        position: fixed; inset: var(--header-h) 0 auto 0;
        flex-direction: column; align-items: stretch; gap: 4px;
        background: var(--surface); border-bottom: 1px solid var(--line);
        padding: 12px; margin: 0; box-shadow: var(--shadow);
        transform: translateY(-140%); opacity: 0; pointer-events: none;
        transition: transform .28s cubic-bezier(.22,1,.36,1), opacity .2s;
    }
    .nav.open { transform: translateY(0); opacity: 1; pointer-events: auto; }
    .nav__link { padding: 12px 14px; }
    .nav__user { margin: 6px 0 0; padding: 12px 4px 4px; border-left: 0; border-top: 1px solid var(--line); justify-content: space-between; }
    .auth { grid-template-columns: 1fr; }
    .auth__aside { display: none; }
    .ligne { grid-template-columns: 1fr 1fr; }
    .ligne__remove { grid-column: 1 / -1; width: 100%; }
    .row-actions { flex-wrap: wrap; }
}

/* Formulaires : une seule colonne + champ large neutralisé sous 640px */
@media (max-width: 640px) {
    .form-grid { grid-template-columns: 1fr; }
    .field--wide { grid-column: auto; }
    .page-head .btn { width: 100%; }
    .form-actions { flex-direction: column-reverse; }
    .form-actions .btn { width: 100%; }
    /* Barre d'actions de formulaire (Annuler / Enregistrer) empilée proprement */
    .panel__head .btn { flex: 1; }
}

@media (max-width: 520px) {
    .container { padding: 22px 14px 56px; }
    .panel__body { padding: 16px; }
    .stat__value { font-size: 23px; }
    .ligne { grid-template-columns: 1fr; }
}
