/* ================================================================
   GOBOT ALL4CUSTOMER 2026 — Dashboard CSS v14
   Police : Outfit (Google Fonts)
================================================================ */

@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@400;500;600;700;800;900&display=swap');

:root {
    --navy:     #1e3a5f;
    --navy-lt:  #eef2f7;
    --navy-bd:  #b8cce0;
    --bg:       #f0f4f8;
    --surface:  #ffffff;
    --border:   #e2e8f0;
    --text:     #1a2535;
    --muted:    #64748b;
    --light:    #f8fafc;
    --teal:     #0d9488;
    --yellow:   #d97706;
    --green:    #16a34a;
    --blue:     #2563eb;
    --red:      #e11d48;
    --sb-w:     250px;
    --tb-h:     56px;
    --r:        12px;
    --sh:       0 1px 3px rgba(0,0,0,.07), 0 1px 2px rgba(0,0,0,.04);
    --sh-md:    0 6px 20px rgba(0,0,0,.10);
    --ease:     .22s ease;
    --f:        'Outfit', system-ui, sans-serif;
}

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

html { scroll-behavior: smooth; }

body {
    font-family: var(--f);
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
    font-weight: 400;
    line-height: 1.5;
    min-height: 100vh;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

/* ================================================================
   SIDEBAR
================================================================ */
.sidebar {
    position: fixed;
    top: 0; left: 0;
    width: var(--sb-w);
    height: 100vh;
    background: var(--surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    z-index: 500;
    overflow-y: auto;
    overflow-x: hidden;
    box-shadow: 2px 0 10px rgba(0,0,0,.06);
    /* Transition pour le collapse desktop */
    transition: width var(--ease), transform var(--ease), box-shadow var(--ease);
    will-change: transform;
}

/* Desktop : collapsed (width → 0) */
.sidebar.sb-collapsed {
    width: 0;
    overflow: hidden;
    border-right: none;
    box-shadow: none;
}

/* Mobile : slide depuis la gauche */
@media (max-width: 991px) {
    .sidebar {
        transform: translateX(-100%);
        width: var(--sb-w) !important;
        overflow-y: auto !important;
        box-shadow: none;
    }
    .sidebar.sb-open {
        transform: translateX(0);
        box-shadow: var(--sh-md);
    }
}

/* ── Overlay mobile ─────────────────────────── */
.sb-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.45);
    z-index: 499;
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
}
.sb-overlay.sb-overlay-on { display: block; }

/* ── Header sidebar ─────────────────────────── */
.sb-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 10px 12px 12px;
    background: #fff;
    border-bottom: 3px solid var(--navy);
    flex-shrink: 0;
    min-height: 70px;
}

.sb-mascot-wrap {
    flex-shrink: 0;
    width: 48px; height: 48px;
    border-radius: 10px;
    background: #f0f4f8;
    border: 2px solid var(--navy-bd);
    display: flex; align-items: center; justify-content: center;
    overflow: hidden;
}
.sb-mascot { width: 42px; height: 42px; object-fit: contain; display: block; }

.sb-titles { flex: 1; min-width: 0; }
.sb-title {
    font-size: 11.5px; font-weight: 800; color: var(--navy);
    text-transform: uppercase; letter-spacing: .05em; line-height: 1.35;
}
.sb-sub { font-size: 10px; font-weight: 500; color: var(--muted); margin-top: 2px; }

.sb-close {
    flex-shrink: 0;
    width: 32px; height: 32px;
    border-radius: 8px;
    background: var(--navy);
    border: none; color: #fff;
    font-size: 17px; font-weight: 700; font-family: var(--f);
    display: flex; align-items: center; justify-content: center;
    cursor: pointer; transition: background var(--ease);
    line-height: 1;
}
.sb-close:hover { background: #162d4a; }

/* ── Section label ──────────────────────────── */
.sb-section-label {
    font-size: 10px; font-weight: 700;
    letter-spacing: .12em; text-transform: uppercase;
    color: var(--muted); padding: 14px 16px 5px; flex-shrink: 0;
}

/* ── Nav ────────────────────────────────────── */
.sb-nav { padding: 2px 10px 6px; flex-shrink: 0; }
.sb-link {
    display: flex; align-items: center; gap: 9px;
    padding: 9px 12px; border-radius: 8px;
    color: var(--muted); text-decoration: none;
    font-size: 13.5px; font-weight: 500;
    transition: all .18s; margin-bottom: 2px; white-space: nowrap;
}
.sb-link i { font-size: 15px; flex-shrink: 0; }
.sb-link:hover  { background: var(--light); color: var(--text); }
.sb-link.active { background: var(--navy-lt); color: var(--navy); font-weight: 700; }

/* ── Day stats ──────────────────────────────── */
.sb-day {
    display: flex; align-items: center; justify-content: space-between;
    padding: 9px 16px; border-left: 3px solid transparent;
    flex-shrink: 0; transition: all .18s; gap: 8px;
}
.sb-day:hover { background: var(--light); }
.sb-day.today { border-left-color: var(--navy); background: var(--navy-lt); }

.sb-day-left  { display: flex; flex-direction: column; min-width: 0; }
.sb-day-right { display: flex; flex-direction: column; align-items: flex-end; flex-shrink: 0; }
.sb-day-label { font-size: 9px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.sb-day-date  { font-size: 13px; font-weight: 600; color: var(--text); }
.sb-day-count { font-size: 22px; font-weight: 800; color: var(--navy); line-height: 1; }
.sb-day-unit  { font-size: 9px; color: var(--muted); }

.sb-empty { padding: 8px 16px; font-size: 11px; color: var(--muted); font-style: italic; }

/* ── Total ──────────────────────────────────── */
.sb-total {
    margin-top: auto; padding: 14px 16px;
    border-top: 1px solid var(--border);
    background: var(--navy-lt); flex-shrink: 0;
}
.sb-total-label {
    display: block; font-size: 9px; font-weight: 700;
    text-transform: uppercase; letter-spacing: .1em;
    color: var(--muted); margin-bottom: 4px;
}
.sb-total-row { display: flex; align-items: baseline; gap: 6px; }
.sb-total-num  { font-size: 40px; font-weight: 900; color: var(--navy); line-height: 1; }
.sb-total-unit { font-size: 13px; color: var(--muted); font-weight: 500; }

/* ================================================================
   MAIN WRAP
================================================================ */
.main-wrap {
    margin-left: var(--sb-w);
    min-height: 100vh;
    display: flex; flex-direction: column;
    transition: margin-left var(--ease);
}
.main-wrap.sb-collapsed { margin-left: 0; }

@media (max-width: 991px) {
    .main-wrap { margin-left: 0 !important; }
}

/* ================================================================
   TOPBAR
================================================================ */
.topbar {
    height: var(--tb-h);
    padding: 0 20px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    display: flex; align-items: center; justify-content: space-between;
    position: sticky; top: 0; z-index: 400;
    box-shadow: var(--sh); flex-shrink: 0; gap: 12px;
}

.topbar-left  { display: flex; align-items: center; gap: 10px; min-width: 0; flex: 1; overflow: hidden; }
.topbar-right { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }

.sb-toggle {
    flex-shrink: 0; width: 38px; height: 38px;
    border-radius: 9px; background: var(--navy);
    border: none; color: #fff;
    font-size: 22px; font-weight: 700; font-family: var(--f);
    line-height: 1; display: flex; align-items: center; justify-content: center;
    cursor: pointer; transition: background var(--ease);
}
.sb-toggle:hover { background: #162d4a; }

.topbar-text { min-width: 0; overflow: hidden; }
.topbar-title {
    font-size: 16px; font-weight: 800; color: var(--text);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis; letter-spacing: -.2px;
}
.topbar-sub {
    font-size: 11px; color: var(--muted);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 1px;
}

.live-pill {
    display: inline-flex; align-items: center; gap: 6px;
    background: #f0fdf4; border: 1.5px solid #86efac;
    color: var(--green); font-size: 11px; font-weight: 700;
    padding: 4px 11px; border-radius: 20px; letter-spacing: .04em; white-space: nowrap;
}
.live-dot {
    width: 7px; height: 7px; border-radius: 50%;
    background: var(--green); flex-shrink: 0; animation: blink 1.5s infinite;
}
@keyframes blink { 0%,100%{opacity:1;transform:scale(1);} 50%{opacity:.35;transform:scale(.65);} }
.topbar-date { font-size: 12px; font-weight: 500; color: var(--muted); white-space: nowrap; }

/* ================================================================
   MAIN CONTENT
================================================================ */
.main-content { flex: 1; padding: 20px; }

/* ================================================================
   GLASS CARD
================================================================ */
.glass-card {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--r); padding: 20px; box-shadow: var(--sh);
}
.card-heading {
    display: flex; align-items: center; gap: 7px;
    font-size: 11px; font-weight: 700; letter-spacing: .08em;
    text-transform: uppercase; color: var(--muted); margin-bottom: 16px;
}
.card-link {
    margin-left: auto; font-size: 12px; font-weight: 600;
    color: var(--muted); text-decoration: none; transition: color var(--ease); white-space: nowrap;
}
.card-link:hover { color: var(--navy); }

/* ================================================================
   MINI CARDS GOBOT (fractions)
================================================================ */
.gobot-cards {
    display: grid;
    grid-template-columns: 1.1fr 1fr 1fr 1fr 1fr;
    gap: 12px; margin-bottom: 16px;
}

.gc {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--r); padding: 14px 14px 12px;
    display: flex; align-items: flex-start; gap: 10px;
    box-shadow: var(--sh); position: relative; overflow: hidden;
    transition: box-shadow var(--ease), transform var(--ease);
    animation: fadeUp .4s ease both;
}
.gc:hover { box-shadow: var(--sh-md); transform: translateY(-2px); }
.gc::before {
    content: ''; position: absolute; top: 0; left: 0; right: 0;
    height: 3px; background: var(--ac); border-radius: var(--r) var(--r) 0 0;
}
.gc-total  { --ac: var(--navy); animation-delay:.05s; }
.gc-green  { --ac: #16a34a;     animation-delay:.10s; }
.gc-orange { --ac: #d97706;     animation-delay:.15s; }
.gc-blue   { --ac: var(--blue); animation-delay:.20s; }
.gc-red    { --ac: #e11d48;     animation-delay:.25s; }

.gc-icon {
    width: 34px; height: 34px; border-radius: 8px;
    background: color-mix(in srgb, var(--ac) 10%, white);
    border: 1px solid color-mix(in srgb, var(--ac) 20%, white);
    display: flex; align-items: center; justify-content: center;
    font-size: 16px; flex-shrink: 0; margin-top: 2px;
}
.gc-body { flex: 1; min-width: 0; }
.gc-fraction { display: flex; align-items: baseline; gap: 3px; line-height: 1; margin-bottom: 5px; }
.gc-num  { font-size: 28px; font-weight: 900; color: var(--ac); letter-spacing: -1px; }
.gc-sep  { font-size: 18px; font-weight: 400; color: var(--muted); margin: 0 1px; }
.gc-den  { font-size: 16px; font-weight: 600; color: var(--muted); }
.gc-label { font-size: 11px; font-weight: 600; color: var(--text); line-height: 1.3; }
.gc-pct   { font-size: 11px; font-weight: 500; color: var(--muted); margin-top: 2px; }

/* ================================================================
   DASHBOARD LAYOUT
================================================================ */
.dashboard-upper {
    display: grid;
    /* La colonne export ne peut pas être plus grande que 300px
       mais se réduit jusqu'à 220px si besoin, le graphe prend le reste */
    grid-template-columns: 1fr minmax(220px, 300px);
    gap: 16px; margin-bottom: 16px;
}
.chart-container { position: relative; height: 200px; }

.export-buttons { display: flex; gap: 10px; margin-bottom: 14px; }
.btn-export {
    flex: 1; display: inline-flex; align-items: center; justify-content: center;
    gap: 7px; padding: 10px 12px; border-radius: 9px;
    font-weight: 600; font-size: 13px; text-decoration: none;
    cursor: pointer; transition: all var(--ease); white-space: nowrap;
}
.btn-export-csv   { background: #f0fdfa; border: 1px solid #99f6e4; color: var(--teal); }
.btn-export-csv:hover   { background: #ccfbf1; box-shadow: var(--sh); }
.btn-export-excel { background: #fffbeb; border: 1px solid #fde68a; color: var(--yellow); }
.btn-export-excel:hover { background: #fef3c7; box-shadow: var(--sh); }

.recap-box { background: var(--light); border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; }
.recap-box-title { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin-bottom: 9px; }
.recap-row { display: flex; align-items: center; gap: 8px; padding: 5px 0; border-bottom: 1px solid #f1f5f9; }
.recap-row:last-child { border-bottom: none; }
.recap-dot { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; }
.recap-lbl { flex: 1; font-size: 12px; font-weight: 500; color: var(--text); }
.recap-val { font-size: 12px; font-weight: 700; color: var(--text); white-space: nowrap; }

/* ================================================================
   VISITOR CARDS (5 derniers)
================================================================ */
.visitors-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(270px,1fr)); gap: 10px; }
.visitor-card {
    display: flex; align-items: center; gap: 12px;
    background: var(--light); border: 1px solid var(--border);
    border-radius: 10px; padding: 12px 14px;
    transition: all var(--ease); animation: fadeUp .4s ease both;
}
.visitor-card:nth-child(1){animation-delay:.1s}
.visitor-card:nth-child(2){animation-delay:.2s}
.visitor-card:nth-child(3){animation-delay:.3s}
.visitor-card:nth-child(4){animation-delay:.4s}
.visitor-card:nth-child(5){animation-delay:.5s}
.visitor-card:hover { box-shadow: var(--sh-md); border-color: var(--navy-bd); }

.visitor-num {
    width: 26px; height: 26px; border-radius: 50%;
    background: #e2e8f0; display: flex; align-items: center; justify-content: center;
    font-size: 11px; font-weight: 700; color: var(--muted); flex-shrink: 0;
}
.visitor-info { flex: 1; min-width: 0; }
.visitor-name { font-size: 13.5px; font-weight: 700; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.visitor-meta { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 4px; }
.visitor-day-badge {
    flex-shrink: 0; background: var(--navy-lt); border: 1px solid var(--navy-bd);
    color: var(--navy); font-size: 11px; font-weight: 600;
    padding: 3px 9px; border-radius: 20px; white-space: nowrap;
}

.vtag { display: inline-flex; align-items: center; gap: 4px; font-size: 10.5px; font-weight: 600; padding: 2px 8px; border-radius: 20px; white-space: nowrap; }
.vtag i { font-size: 9px; }
.vtag-green { background: #f0fdf4; border: 1px solid #bbf7d0; color: #16a34a; }
.vtag-gray  { background: #f1f5f9; border: 1px solid #e2e8f0; color: #64748b; }
.vtag-blue  { background: #eff6ff; border: 1px solid #bfdbfe; color: #2563eb; }
.vtag-red   { background: #fff1f2; border: 1px solid #fecdd3; color: #e11d48; }

/* ================================================================
   TABLE VISITEURS
================================================================ */
.filter-bar {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--r); padding: 14px 16px; margin-bottom: 16px;
    display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; box-shadow: var(--sh);
}
.filter-group { display: flex; flex-direction: column; gap: 4px; }
.filter-group label { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }

.form-control-dark,
.form-select-dark {
    background: var(--light); border: 1.5px solid var(--border);
    border-radius: 8px; color: var(--text); font-family: var(--f);
    font-size: 13px; padding: 7px 12px;
    transition: border-color .2s, box-shadow .2s; min-width: 150px;
}
.form-control-dark:focus, .form-select-dark:focus {
    outline: none; border-color: var(--navy);
    box-shadow: 0 0 0 3px rgba(30,58,95,.08); background: #fff;
}
.btn-filter {
    background: var(--navy); border: none; border-radius: 8px; color: #fff;
    font-size: 13px; font-weight: 600; font-family: var(--f); padding: 8px 16px;
    cursor: pointer; transition: background var(--ease); display: inline-flex; align-items: center; gap: 6px;
}
.btn-filter:hover { background: #162d4a; }
.btn-reset {
    background: transparent; border: 1px solid var(--border); border-radius: 8px;
    color: var(--muted); font-size: 13px; font-family: var(--f); padding: 7px 12px;
    cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; gap: 6px;
    transition: all var(--ease);
}
.btn-reset:hover { color: var(--text); background: var(--light); }

/* Table desktop */
.table-desktop { display: block; }
.table-mobile  { display: none; }

.visitors-table { width: 100%; border-collapse: separate; border-spacing: 0; }
.visitors-table thead th {
    font-size: 10px; text-transform: uppercase; letter-spacing: .1em;
    font-weight: 700; color: var(--muted); padding: 9px 14px;
    border-bottom: 2px solid var(--border); background: var(--light); white-space: nowrap;
}
.visitors-table tbody tr { transition: background .13s; }
.visitors-table tbody tr:hover { background: var(--light); }
.visitors-table tbody td { padding: 11px 14px; font-size: 13px; color: var(--text); border-bottom: 1px solid #f1f5f9; vertical-align: middle; }

/* Cards mobile pour la table visiteurs */
.mobile-visitor-card {
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
}
.mobile-visitor-card:last-child { border-bottom: none; }
.mvc-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; margin-bottom: 8px; }
.mvc-name  { font-size: 14px; font-weight: 700; color: var(--text); }
.mvc-email { font-size: 11px; color: var(--muted); margin-top: 2px; }
.mvc-right { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; flex-shrink: 0; }
.mvc-date  { font-size: 11px; color: var(--muted); white-space: nowrap; }
.mvc-badges { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 6px; }
.mvc-besoins { font-size: 12px; color: var(--muted); font-style: italic; border-top: 1px solid #f1f5f9; padding-top: 6px; margin-top: 4px; }

.yn-badge { display: inline-flex; align-items: center; gap: 4px; font-size: 11px; font-weight: 600; padding: 3px 9px; border-radius: 20px; }
.yn-oui { background: #f0fdf4; border: 1px solid #bbf7d0; color: #16a34a; }
.yn-non { background: #f1f5f9; border: 1px solid #e2e8f0; color: #64748b; }

.source-badge { display: inline-flex; align-items: center; gap: 5px; font-size: 11px; font-weight: 600; padding: 3px 9px; border-radius: 20px; text-transform: capitalize; }
.source-whatsapp { background: #f0fdf4; border: 1px solid #bbf7d0; color: #16a34a; }
.source-manual   { background: #eff6ff; border: 1px solid #bfdbfe; color: #2563eb; }
.source-api      { background: #fffbeb; border: 1px solid #fde68a; color: #d97706; }

.pagination-wrapper { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 10px; padding: 12px 16px; }
.pagination-info { font-size: 12px; color: var(--muted); }

/* ================================================================
   EMPTY STATE
================================================================ */
.empty-state { text-align: center; padding: 40px 20px; color: var(--muted); }
.empty-state i { font-size: 36px; display: block; margin-bottom: 10px; color: #cbd5e1; }
.empty-state p { font-size: 13px; }

/* ================================================================
   ANIMATIONS
================================================================ */
@keyframes fadeUp { from{opacity:0;transform:translateY(10px);} to{opacity:1;transform:translateY(0);} }

/* ================================================================
   SCROLLBAR
================================================================ */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 3px; }

/* ================================================================
   RESPONSIVE COMPLET
================================================================ */

/* Grand écran avec sidebar ouverte (~1050–1280px de contenu) */
@media (max-width: 1400px) {
    /* Les 5 cards Gobot passent sur 3 colonnes dès que l'espace est serré */
    .gobot-cards { grid-template-columns: 1fr 1fr 1fr; }
}

/* Tablette large : graphe + export empilés */
@media (max-width: 1100px) {
    .dashboard-upper { grid-template-columns: 1fr; }
    .gobot-cards { grid-template-columns: 1fr 1fr 1fr; }
}

/* Tablette (768–991px) */
@media (max-width: 991px) {
    .dashboard-upper { grid-template-columns: 1fr; }
    .gobot-cards { grid-template-columns: 1fr 1fr; }
    .topbar-date { display: none; }
    .topbar { padding: 0 16px; }
}

/* Mobile large (576–767px) */
@media (max-width: 767px) {
    .main-content { padding: 12px; }
    .gobot-cards { grid-template-columns: 1fr 1fr; gap: 8px; }
    .visitors-grid { grid-template-columns: 1fr; }
    .filter-bar { flex-direction: column; align-items: stretch; }
    .form-control-dark, .form-select-dark { min-width: 100%; width: 100%; }
    .export-buttons { flex-direction: row; }
    /* Passer en cards mobile pour la table visiteurs */
    .table-desktop { display: none; }
    .table-mobile  { display: block; }
}

/* Mobile (max 575px) */
@media (max-width: 575px) {
    .main-content { padding: 10px; }
    .gobot-cards { grid-template-columns: 1fr 1fr; gap: 8px; }
    .gc { padding: 12px 10px 10px; gap: 8px; }
    .gc-icon { width: 28px; height: 28px; font-size: 13px; }
    .gc-num { font-size: 22px; }
    .gc-den { font-size: 13px; }
    .gc-label { font-size: 10px; }
    .topbar-title { font-size: 14px; }
    .topbar-sub { display: none; }
    .topbar { padding: 0 10px; }
    .sb-toggle { width: 34px; height: 34px; font-size: 19px; }
    .export-buttons { gap: 8px; }
    .glass-card { padding: 14px; }
    .visitors-grid { grid-template-columns: 1fr; }
}

/* Très petit (max 380px) */
@media (max-width: 380px) {
    .gobot-cards { grid-template-columns: 1fr 1fr; gap: 6px; }
    .gc-num { font-size: 20px; }
    .gc-label { font-size: 9.5px; }
    .main-content { padding: 8px; }
}
