/* ==========================================================================
   SauriBet — Design System
   Source de vérité unique des tokens visuels, partagée par le site public
   et le back-office admin. Palette dérivée du logo (bleu ciel + or).

   Doit être chargé APRÈS Bootstrap pour surcharger ses variables.
   ========================================================================== */

:root {
    /* ----------------------------------------------------------------------
       MARQUE — couleurs échantillonnées directement dans le logo
       ---------------------------------------------------------------------- */
    --brand-sky:        #2E8DED;  /* bleu ciel — accent principal */
    --brand-sky-light:  #4CACF3;
    --brand-sky-pale:   #E8F3FE;
    --brand-blue:       #0A4BB3;  /* bleu roi */
    --brand-navy:       #092E69;  /* bleu marine */
    --brand-navy-deep:  #051E4C;

    --brand-gold:       #F7D02F;  /* or — accent secondaire */
    --brand-gold-light: #F8E454;
    --brand-gold-pale:  #FEF8E0;
    --brand-amber:      #F3B216;  /* or profond */

    /* ----------------------------------------------------------------------
       ALIASES SÉMANTIQUES — c'est ce que le code applicatif consomme.
       Ne jamais utiliser une valeur hex en dur dans une vue : passer par ces
       variables, pour qu'un changement de charte reste un changement d'un seul fichier.
       ---------------------------------------------------------------------- */
    --primary:          var(--brand-sky);
    --primary-dark:     var(--brand-blue);
    --primary-light:    var(--brand-sky-light);
    --primary-pale:     var(--brand-sky-pale);
    --primary-rgb:      46, 141, 237;      /* DOIT rester synchronisé avec --primary */

    --secondary:        var(--brand-gold);
    --secondary-dark:   var(--brand-amber);
    --secondary-light:  var(--brand-gold-light);
    --secondary-pale:   var(--brand-gold-pale);
    --secondary-rgb:    247, 208, 47;      /* DOIT rester synchronisé avec --secondary */

    --dark:             var(--brand-navy);

    /* ----------------------------------------------------------------------
       ÉTATS — volontairement distincts de l'or de la marque, pour qu'un
       avertissement ne se confonde jamais avec un simple accent décoratif.
       ---------------------------------------------------------------------- */
    --success:      #0E9F6E;
    --success-pale: #E6F6F0;
    --warning:      #D97706;
    --warning-pale: #FDF1E3;
    --danger:       #E02424;
    --danger-pale:  #FDEAEA;
    --info:         var(--brand-sky);
    --info-pale:    var(--brand-sky-pale);

    /* ----------------------------------------------------------------------
       NEUTRES — légèrement biaisés vers le bleu pour s'accorder à l'accent.
       ⚠️ Contraste : gray-400 et au-dessous ne passent PAS le seuil WCAG AA
       pour du texte. Texte secondaire → gray-500 minimum. gray-400 et en
       dessous sont réservés aux bordures, séparateurs et états désactivés.
       ---------------------------------------------------------------------- */
    --gray-50:   #F5F8FC;
    --gray-100:  #EBF1F8;
    --gray-200:  #DBE4EF;
    --gray-300:  #C2CFE0;
    --gray-400:  #8D9DB3;   /* bordures / disabled uniquement */
    --gray-500:  #64748B;   /* plus petit gris admis pour du texte */
    --gray-600:  #4A5A70;
    --gray-700:  #334155;
    --gray-800:  #1E2C40;
    --gray-900:  #0F1B2D;

    --body-bg:   var(--gray-50);
    --surface:   #FFFFFF;
    --border:    var(--gray-200);

    --text-strong: var(--gray-900);
    --text:        var(--gray-700);
    --text-muted:  var(--gray-500);
    --text-on-brand: #FFFFFF;
    --text-on-gold:  var(--brand-navy);  /* l'or est clair : jamais de blanc dessus */

    /* ----------------------------------------------------------------------
       TYPOGRAPHIE
       Plus Jakarta Sans porte les titres (caractère), Inter porte le texte
       courant et les données (lisibilité, chiffres tabulaires).
       ---------------------------------------------------------------------- */
    --font-display: 'Plus Jakarta Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
    --font-body:    'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
    --font-mono:    ui-monospace, 'SF Mono', 'Cascadia Code', Consolas, monospace;

    /* Échelle typographique — ratio 1.2 (tierce mineure) */
    --text-xs:   0.75rem;    /* 12px */
    --text-sm:   0.875rem;   /* 14px */
    --text-base: 1rem;       /* 16px */
    --text-lg:   1.125rem;   /* 18px */
    --text-xl:   1.375rem;   /* 22px */
    --text-2xl:  1.75rem;    /* 28px */
    --text-3xl:  2.25rem;    /* 36px */
    --text-4xl:  3rem;       /* 48px */
    --text-5xl:  3.75rem;    /* 60px */

    --leading-tight:  1.15;
    --leading-snug:   1.35;
    --leading-normal: 1.6;

    --tracking-tight: -0.02em;
    --tracking-wide:  0.06em;

    /* ----------------------------------------------------------------------
       ESPACEMENT — base 4px
       ---------------------------------------------------------------------- */
    --space-1:  0.25rem;
    --space-2:  0.5rem;
    --space-3:  0.75rem;
    --space-4:  1rem;
    --space-5:  1.25rem;
    --space-6:  1.5rem;
    --space-8:  2rem;
    --space-10: 2.5rem;
    --space-12: 3rem;
    --space-16: 4rem;
    --space-20: 5rem;
    --space-24: 6rem;

    /* ----------------------------------------------------------------------
       RAYONS
       ---------------------------------------------------------------------- */
    --radius-sm:   6px;
    --radius-md:   10px;
    --radius-lg:   14px;
    --radius-xl:   20px;
    --radius-2xl:  28px;
    --radius-full: 999px;

    /* ----------------------------------------------------------------------
       OMBRES — teintées bleu marine plutôt que noir pur, pour rester
       dans la famille chromatique de la marque.
       ---------------------------------------------------------------------- */
    --shadow-xs: 0 1px 2px rgba(9, 46, 105, 0.06);
    --shadow-sm: 0 1px 3px rgba(9, 46, 105, 0.08), 0 1px 2px rgba(9, 46, 105, 0.04);
    --shadow-md: 0 4px 12px rgba(9, 46, 105, 0.08), 0 2px 4px rgba(9, 46, 105, 0.04);
    --shadow-lg: 0 12px 28px rgba(9, 46, 105, 0.10), 0 4px 8px rgba(9, 46, 105, 0.04);
    --shadow-xl: 0 24px 48px rgba(9, 46, 105, 0.14);

    --shadow-primary:   0 8px 24px rgba(var(--primary-rgb), 0.28);
    --shadow-secondary: 0 8px 24px rgba(var(--secondary-rgb), 0.32);

    /* ----------------------------------------------------------------------
       APLATS — pas de dégradés.
       Les surfaces de marque sont des couleurs pleines : c'est plus net, plus
       durable, et ça évite le rendu « générique » des dégradés multicolores.
       Le contraste vient de la juxtaposition bleu / or, pas d'une transition.
       ---------------------------------------------------------------------- */
    --surface-brand:      var(--brand-sky);
    --surface-brand-deep: var(--brand-navy);
    --surface-gold:       var(--brand-gold);

    /* ----------------------------------------------------------------------
       MOUVEMENT
       ---------------------------------------------------------------------- */
    --ease:        cubic-bezier(0.4, 0, 0.2, 1);
    --ease-out:    cubic-bezier(0.16, 1, 0.3, 1);
    --duration:    200ms;
    --duration-lg: 400ms;

    /* ----------------------------------------------------------------------
       SURCHARGES BOOTSTRAP — pour que les composants Bootstrap natifs
       (.btn-primary, .badge, .alert…) héritent de la marque sans réécriture.
       ---------------------------------------------------------------------- */
    --bs-primary:        var(--primary);
    --bs-primary-rgb:    var(--primary-rgb);
    --bs-secondary:      var(--secondary);
    --bs-secondary-rgb:  var(--secondary-rgb);
    --bs-success:        var(--success);
    --bs-warning:        var(--warning);
    --bs-danger:         var(--danger);
    --bs-info:           var(--info);
    --bs-body-color:     var(--text);
    --bs-body-bg:        var(--body-bg);
    --bs-body-font-family: var(--font-body);
    --bs-border-color:   var(--border);
    --bs-border-radius:  var(--radius-md);
    --bs-link-color:     var(--primary);
    --bs-link-color-rgb: var(--primary-rgb);
    --bs-link-hover-color: var(--primary-dark);
}

/* ==========================================================================
   BASE
   ========================================================================== */

body {
    font-family: var(--font-body);
    color: var(--text);
    background-color: var(--body-bg);
    line-height: var(--leading-normal);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

h1, h2, h3, h4, h5, h6,
.display-1, .display-2, .display-3, .display-4 {
    font-family: var(--font-display);
    color: var(--text-strong);
    font-weight: 700;
    line-height: var(--leading-tight);
    letter-spacing: var(--tracking-tight);
    text-wrap: balance;
}

/* Les chiffres alignés en colonne (montants, soldes, tableaux) doivent
   toujours utiliser des chasses fixes, sinon les colonnes dansent. */
.tabular,
table td,
table th,
.amount,
.stat-value {
    font-variant-numeric: tabular-nums;
}

/* Accessibilité : un focus clavier toujours visible, dans la couleur de marque. */
:focus-visible {
    outline: 3px solid rgba(var(--primary-rgb), 0.5);
    outline-offset: 2px;
    border-radius: var(--radius-sm);
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

/* ==========================================================================
   COMPOSANTS PARTAGÉS
   ========================================================================== */

/* --- Boutons --- */
.btn {
    font-family: var(--font-body);
    font-weight: 600;
    border-radius: var(--radius-md);
    padding: 0.625rem 1.25rem;
    transition: transform var(--duration) var(--ease),
                box-shadow var(--duration) var(--ease),
                background-color var(--duration) var(--ease);
}

.btn-primary {
    background: var(--primary);
    border-color: transparent;
    color: var(--text-on-brand);
    box-shadow: var(--shadow-sm);
}

.btn-primary:hover,
.btn-primary:focus {
    background: var(--primary-dark);
    border-color: transparent;
    color: var(--text-on-brand);
    box-shadow: var(--shadow-md);
}

/* L'or est une couleur claire : le texte dessus est marine, jamais blanc. */
.btn-secondary,
.btn-gold {
    background: var(--secondary);
    border-color: transparent;
    color: var(--text-on-gold);
    box-shadow: var(--shadow-sm);
}

.btn-secondary:hover,
.btn-gold:hover {
    background: var(--secondary-dark);
    border-color: transparent;
    color: var(--text-on-gold);
    box-shadow: var(--shadow-md);
}

.btn-outline-primary {
    border-color: var(--primary);
    color: var(--primary);
    background: transparent;
}

.btn-outline-primary:hover {
    background: var(--primary);
    border-color: var(--primary);
    color: var(--text-on-brand);
}

/* --- Cartes --- */
.card,
.ds-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
}

/* --- Badges d'état --- */
.ds-badge {
    display: inline-flex;
    align-items: center;
    gap: var(--space-1);
    padding: 0.25rem 0.625rem;
    border-radius: var(--radius-full);
    font-size: var(--text-xs);
    font-weight: 600;
    line-height: 1.4;
    white-space: nowrap;
}

.ds-badge--success { background: var(--success-pale); color: var(--success); }
.ds-badge--warning { background: var(--warning-pale); color: var(--warning); }
.ds-badge--danger  { background: var(--danger-pale);  color: var(--danger); }
.ds-badge--info    { background: var(--info-pale);    color: var(--primary-dark); }
.ds-badge--neutral { background: var(--gray-100);     color: var(--gray-600); }

/* --- Champs de formulaire --- */
.form-control,
.form-select {
    border-radius: var(--radius-md);
    border-color: var(--border);
    padding: 0.625rem 0.875rem;
    font-family: var(--font-body);
    transition: border-color var(--duration) var(--ease),
                box-shadow var(--duration) var(--ease);
}

.form-control:focus,
.form-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(var(--primary-rgb), 0.12);
}

.form-label {
    font-weight: 600;
    font-size: var(--text-sm);
    color: var(--text-strong);
    margin-bottom: var(--space-2);
}

/* --- Étiquette de section (eyebrow) --- */
.ds-eyebrow {
    font-family: var(--font-body);
    font-size: var(--text-xs);
    font-weight: 700;
    letter-spacing: var(--tracking-wide);
    text-transform: uppercase;
    color: var(--primary);
}

/* --- Tableaux denses (admin) --- */
.ds-table-wrap {
    overflow-x: auto;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
}

.ds-table-wrap table {
    margin-bottom: 0;
}
