/* =========================================================
   Haupria SMS — aligné sur STUDIO by Haupria
   Accent doré, gris chauds, Unbounded + DM Sans, dark par défaut
   ========================================================= */
:root, [data-theme="dark"] {
    --bg: #232328;
    --bg-raised: #2b2b30;
    --surface: #313136;        /* bg-card */
    --surface-2: #2b2b30;      /* bg-raised */
    --card-hover: #38383e;
    --border: #43434b;
    --border-light: #4d4d55;
    --ink: #f0f0f2;            /* text */
    --muted: #a0a0aa;          /* text-muted */
    --soft: #72727c;           /* text-dim */
    --primary: #c9a355;        /* accent */
    --primary-soft: rgba(201, 163, 85, .13);
    --primary-glow: rgba(201, 163, 85, .07);
    --ok: #4ade80;
    --ok-soft: rgba(22, 163, 74, .14);
    --bad: #f87171;
    --bad-soft: rgba(220, 38, 38, .14);
    --info: #c9a355;
    --track: #43434b;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, .12);
    --shadow: 0 8px 32px rgba(0, 0, 0, .25);
    --side-bg: #2b2b30;
    --side-hover: rgba(255, 255, 255, .04);
}

[data-theme="light"] {
    /* Blanc épuré */
    --bg: #f4f5f7;
    --bg-raised: #ffffff;
    --surface: #ffffff;
    --surface-2: #fafbfc;
    --card-hover: #f0f1f4;
    --border: #e5e7eb;
    --border-light: #d8dce2;
    --ink: #1a1a1c;
    --muted: #5b6270;
    --soft: #8a909c;
    --primary: #a58636;
    --primary-soft: rgba(165, 134, 54, .10);
    --primary-glow: rgba(165, 134, 54, .05);
    --ok: #16a34a;
    --ok-soft: rgba(22, 163, 74, .10);
    --bad: #dc2626;
    --bad-soft: rgba(220, 38, 38, .09);
    --info: #a58636;
    --track: #e8eaee;
    --shadow-sm: 0 1px 3px rgba(20, 30, 60, .06);
    --shadow: 0 10px 34px rgba(20, 30, 60, .10);
    --side-bg: #ffffff;
    --side-hover: rgba(0, 0, 0, .04);
}

:root {
    --danger: var(--bad);
    --success: var(--ok);
    --radius: 10px;
    --radius-sm: 7px;
    --radius-lg: 14px;
    --sidebar-w: 260px;
    --font-head: 'Unbounded', sans-serif;
    --font-body: 'DM Sans', -apple-system, BlinkMacSystemFont, sans-serif;
    --grad: linear-gradient(135deg, #d4b66a 0%, #c9a355 100%);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
    margin: 0;
    font-family: var(--font-body);
    background: var(--bg);
    color: var(--ink);
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
    transition: background .2s, color .2s;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
.icon { flex: none; vertical-align: middle; }

h1, h2, h3, .brand-logo, .card-value, .donut span, .auth-card h1 {
    font-family: var(--font-head);
    font-weight: 800;
    letter-spacing: -.02em;
}
h1 { font-size: 1.5rem; margin: 0; }
h2 { font-size: 1.05rem; font-weight: 700; margin: 0 0 16px; }

/* ============ Layout : sidebar + contenu ============ */
body.app { display: flex; min-height: 100vh; }

.sidebar {
    width: var(--sidebar-w);
    flex: none;
    background: var(--side-bg);
    color: var(--ink);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    padding: 0;
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    overflow-y: auto;
    z-index: 20;
}
.sidebar-brand {
    display: flex; align-items: baseline; gap: 8px;
    padding: 24px 24px 20px;
    border-bottom: 1px solid var(--border);
}
.brand-logo { font-size: 1.2rem; font-weight: 800; color: var(--ink); letter-spacing: -.03em; }
.brand-logo .dot { color: var(--primary); }
.brand-sub { font-size: .7rem; color: var(--soft); font-weight: 500; }
.brand-mark { display: none; }

.nav-group-label { font-size: .7rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--soft); padding: 16px 24px 6px; }
.sidebar-nav { display: flex; flex-direction: column; gap: 2px; flex: 1; padding: 12px; overflow-y: auto; }
.nav-link {
    display: flex; align-items: center; gap: 12px;
    padding: 10px 16px; border-radius: var(--radius-sm);
    color: var(--muted); font-weight: 500; font-size: .875rem;
    width: 100%; border: none; background: none; cursor: pointer; text-align: left; font-family: inherit;
    transition: background .2s, color .2s;
}
.nav-link .icon { opacity: .55; }
.nav-link:hover { background: var(--side-hover); color: var(--ink); text-decoration: none; }
.nav-link.active { background: var(--primary-soft); color: var(--primary); }
.nav-link.active .icon { opacity: 1; }

.sidebar-foot { border-top: 1px solid var(--border); padding: 8px 12px; display: flex; flex-direction: column; gap: 2px; }
.sidebar-user { display: flex; align-items: center; gap: 10px; padding: 8px 12px 10px; }
.avatar { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 50%; background: var(--primary-soft); color: var(--primary); font-family: var(--font-head); font-weight: 700; font-size: .72rem; }
.sidebar-username { font-size: .85rem; color: var(--ink); font-weight: 600; overflow: hidden; }
.sidebar-username small { display: block; font-weight: 400; color: var(--soft); font-size: .72rem; }
.sidebar-foot .nav-link { padding: 7px 12px; font-size: .8rem; }
.nav-link.logout { color: var(--bad); }
.nav-link.logout:hover { background: var(--bad-soft); }

.app-main { flex: 1; min-width: 0; display: flex; flex-direction: column; margin-left: var(--sidebar-w); }
.page-head { padding: 28px 36px 0; }
.page-head h1 { display: flex; align-items: center; gap: 12px; }
.page-head-icon { display: grid; place-items: center; width: 38px; height: 38px; border-radius: var(--radius-sm); background: var(--primary-soft); color: var(--primary); }
.page-body { padding: 24px 36px 40px; max-width: none; width: 100%; }
.app-footer { margin-top: auto; padding: 20px 36px; color: var(--soft); font-size: .8rem; }

/* ============ Layout centré (connexion) ============ */
body.centered {
    display: grid; place-items: center;
    background: var(--bg);
    padding: 24px;
}
body.centered::before { content: ''; position: fixed; inset: 0; background: radial-gradient(600px 400px at 50% 30%, var(--primary-glow), transparent 70%); pointer-events: none; }
.centered-main { width: 100%; max-width: 400px; position: relative; }
.auth-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 36px 32px;
    box-shadow: var(--shadow);
}
.auth-logo { display: grid; place-items: center; width: 54px; height: 54px; border-radius: 14px; background: var(--primary-soft); color: var(--primary); margin: 0 auto 18px; }
.auth-card h1 { text-align: center; font-size: 1.4rem; }
.auth-card .subtitle { text-align: center; color: var(--muted); margin: 6px 0 24px; font-size: .9rem; }
.auth-card .btn { width: 100%; margin-top: 8px; }

/* ============ Cartes / panneaux ============ */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; margin-bottom: 24px; }
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 22px;
    box-shadow: var(--shadow-sm);
    transition: border-color .2s, transform .2s;
}
.card:hover { border-color: var(--border-light); }
.card-top { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.card-ico { display: grid; place-items: center; width: 40px; height: 40px; border-radius: var(--radius-sm); background: var(--primary-soft); color: var(--primary); }
.card-ico.green { background: var(--ok-soft); color: var(--ok); }
.card-label { color: var(--muted); font-size: .75rem; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; }
.card-value { font-size: 2rem; font-weight: 700; letter-spacing: -.02em; line-height: 1.1; color: var(--ink); }
.card-value.card-error { color: var(--bad); font-size: 1.1rem; }
.card-sub { color: var(--muted); font-size: .85rem; margin-top: 4px; }
.card.card-action { display: flex; flex-direction: column; gap: 10px; justify-content: center; }
.card.card-action .btn { width: 100%; }

.panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    margin-bottom: 20px;
    box-shadow: var(--shadow-sm);
}
.panel-title { display: flex; align-items: center; gap: 9px; }

/* ============ Formulaires ============ */
.form label, .form-inline label { display: block; font-weight: 500; font-size: .8rem; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; margin-bottom: 16px; }
label > .hint { font-weight: 400; text-transform: none; letter-spacing: 0; }
input, textarea, select {
    width: 100%;
    padding: 10px 14px;
    margin-top: 7px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font: inherit; font-size: .875rem;
    color: var(--ink);
    background: var(--bg);
    transition: border-color .2s;
}
[data-theme="light"] input, [data-theme="light"] textarea, [data-theme="light"] select { background: #fff; }
input::placeholder, textarea::placeholder { color: var(--soft); }
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--primary); }
textarea { resize: vertical; }
.hint { display: block; color: var(--soft); font-size: .8rem; margin-top: 5px; text-transform: none; letter-spacing: 0; }

.form-inline { display: flex; flex-wrap: wrap; gap: 14px; align-items: flex-end; }
.form-inline label { margin-bottom: 0; }
.form-inline input, .form-inline select { width: auto; min-width: 170px; margin-top: 6px; }

/* ============ Boutons ============ */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    padding: 10px 20px;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    font-family: var(--font-body); font-size: .875rem; font-weight: 500;
    cursor: pointer;
    transition: all .25s;
}
.btn:hover { text-decoration: none; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { filter: brightness(1.1); transform: translateY(-1px); }
.btn-ghost { background: transparent; color: var(--muted); border-color: var(--border); }
.btn-ghost:hover { border-color: var(--soft); color: var(--ink); }
.btn-danger { background: transparent; color: var(--bad); border-color: var(--bad); }
.btn-danger:hover { background: var(--bad); color: #fff; }
.btn-sm { padding: 6px 14px; font-size: .8rem; }

/* ============ Tableaux ============ */
.table-wrap { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow-sm); }
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: 13px 18px; text-align: left; }
.table thead th { color: var(--soft); font-size: .72rem; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; border-bottom: 1px solid var(--border); }
.table tbody tr { border-bottom: 1px solid var(--border); }
.table tbody tr:last-child { border-bottom: none; }
.table tbody tr:hover td { background: var(--side-hover); }
.table td.mono { font-variant-numeric: tabular-nums; }
.table form { margin: 0; }
.empty { color: var(--soft); text-align: center; padding: 28px; }

.badge { display: inline-block; padding: 3px 10px; border-radius: 20px; font-size: .7rem; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.badge-count { background: var(--primary-soft); color: var(--primary); }
.badge-ok { background: var(--ok-soft); color: var(--ok); }
.badge-stop { background: var(--bad-soft); color: var(--bad); }

.pagination { display: flex; align-items: center; gap: 12px; justify-content: center; margin-top: 18px; color: var(--muted); font-size: .9rem; }

/* Email complet (screenshot, image très haute) — affichée en entier, on déroule la page */
.email-preview { max-width: 640px; border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; background: #fff; box-shadow: var(--shadow-sm); }
.email-preview img { width: 100%; height: auto; display: block; }

/* Canal (SMS / Email) */
.chan { display: inline-flex; align-items: center; gap: 7px; font-weight: 600; color: var(--muted); }
.chan .chan-ico { display: grid; place-items: center; width: 26px; height: 26px; border-radius: 7px; background: var(--primary-soft); color: var(--primary); }

/* ============ Donuts ============ */
.report-donuts { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 16px; margin-bottom: 20px; }
.donut-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 24px; box-shadow: var(--shadow-sm); text-align: center; }
.donut-card h3 { font-size: .85rem; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; margin: 0 0 18px; font-family: var(--font-body); }
.donut { width: 150px; height: 150px; border-radius: 50%; margin: 0 auto; display: grid; place-items: center;
         background: conic-gradient(var(--donut-color) calc(var(--pct) * 1%), var(--track) 0); }
.donut::before { content: ""; grid-area: 1/1; width: 110px; height: 110px; border-radius: 50%; background: var(--surface); }
.donut span { grid-area: 1/1; font-size: 1.6rem; font-weight: 700; color: var(--ink); }
.donut-legend { display: flex; justify-content: center; gap: 28px; margin-top: 18px; }
.donut-legend div { text-align: center; }
.donut-legend .n { font-size: 1.3rem; font-weight: 700; display: block; font-family: var(--font-head); }
.donut-legend .l { font-size: .75rem; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }

/* ============ Flash ============ */
.flash { padding: 13px 16px; border-radius: var(--radius-sm); margin-bottom: 18px; font-weight: 500; font-size: .9rem; border: 1px solid transparent; }
.flash-success { background: var(--ok-soft); color: var(--ok); border-color: var(--ok); }
.flash-error { background: var(--bad-soft); color: var(--bad); border-color: var(--bad); }
.flash-info { background: var(--primary-soft); color: var(--primary); border-color: var(--primary); }

/* ============ Divers ============ */
.bar { background: var(--track); border-radius: 6px; height: 8px; overflow: hidden; }
.bar > span { display: block; background: var(--primary); height: 100%; }
.shortcuts { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.shortcuts li a { display: flex; align-items: center; gap: 10px; padding: 11px 14px; border-radius: var(--radius-sm); color: var(--ink); font-weight: 500; font-size: .9rem; }
.shortcuts li a:hover { background: var(--side-hover); text-decoration: none; }
.shortcuts .chev { margin-left: auto; color: var(--soft); }
.muted { color: var(--muted); }
.section-gap { margin-top: 24px; }

/* Barre mobile (masquée en bureau) */
.mobile-topbar { display: none; }
.nav-overlay { display: none; }
.burger {
    display: inline-flex; flex-direction: column; justify-content: center; gap: 4px;
    width: 40px; height: 40px; padding: 9px; border: 1px solid var(--border);
    border-radius: var(--radius-sm); background: var(--surface); cursor: pointer;
}
.burger span { display: block; height: 2px; border-radius: 2px; background: var(--ink); transition: .2s; }

@media (max-width: 820px) {
    /* La sidebar devient un tiroir coulissant */
    .sidebar {
        position: fixed; top: 0; left: 0; z-index: 60;
        width: 82%; max-width: 300px; height: 100vh;
        transform: translateX(-100%); transition: transform .25s ease;
        box-shadow: 0 0 40px rgba(0,0,0,.35);
    }
    body.nav-open .sidebar { transform: translateX(0); }
    .nav-overlay {
        position: fixed; inset: 0; z-index: 55;
        background: rgba(0,0,0,.45); opacity: 0; pointer-events: none; transition: opacity .25s;
    }
    body.nav-open .nav-overlay { display: block; opacity: 1; pointer-events: auto; }
    body.nav-open { overflow: hidden; }
    .app-main { margin-left: 0; }

    .mobile-topbar {
        display: flex; align-items: center; gap: 12px;
        position: sticky; top: 0; z-index: 40;
        padding: 12px 16px; background: var(--surface); border-bottom: 1px solid var(--border);
    }
    .mobile-topbar .brand-logo { font-size: 1.1rem; }

    .page-head { padding: 18px 18px 0; }
    .page-head h1 { font-size: 1.4rem; }
    .page-body, .app-footer { padding-left: 18px; padding-right: 18px; }
    .cards { grid-template-columns: 1fr; }
    .table-wrap { overflow-x: auto; }
}
