/*
 * Fichier    : base.css
 * Rôle       : Variables CSS (couleurs, polices, espacements), reset box-sizing,
 *              styles html/body, scrollbar custom, thèmes dark et light complets
 * Emplacement: assets/css/base.css
 * Auteur     : RCBG
 * Projet     : Franck Emery v1.0.0
 */

/* ============================================================
   IMPORT POLICES (fallback  les polices principales sont
   charges via <link> dans le HTML pour la performance)
============================================================ */
@import url('https://fonts.googleapis.com/css2?family=Playfair+Display:ital,wght@0,400;0,600;0,700;1,400;1,600&family=DM+Sans:ital,opsz,wght@0,9..40,300;0,9..40,400;0,9..40,500;0,9..40,600;1,9..40,400&display=swap');


/* ============================================================
   THÈME SOMBRE (par défaut)
   Slecteur : html[data-theme="dark"] ou html (absence de thème)
============================================================ */
:root,
html[data-theme="dark"] {

  /*  Couleurs de fond  */
  --bg:            #0b0b12;        /* Fond principal  noir profond bleut */
  --bg2:           #111119;        /* Fond secondaire  cards, panels */
  --bg3:           #18181f;        /* Fond tertiaire  inputs, hover states */
  --bg4:           #1une27;        /* Fond quaternaire  sidebar, modals */
  --bg-glass:      rgba(17, 17, 25, 0.72);  /* Glassmorphism nav */
  --bg-overlay:    rgba(11, 11, 18, 0.85);  /* Overlays modals, lightbox */

  /*  Textes  */
  --text:          #eeeef5;        /* Texte principal */
  --text2:         #9898b8;        /* Texte secondaire  labels, sous-titres */
  --text3:         #5a5a78;        /* Texte tertiaire  placeholders, hints */
  --text-invert:   #0b0b12;        /* Texte sur fond clair (boutons primaires) */

  /*  Accent (remplac dynamiquement par ThemeManager)  */
  --accent:        #8b7cf8;        /* Couleur primaire d'accent */
  --accent2:       #a78bfa;        /* Variante légèrement plus claire */
  --accent-dim:    rgba(139, 124, 248, 0.12);  /* Fond teint accent */
  --accent-glow:   rgba(139, 124, 248, 0.30);  /* Lueur / box-shadow accent */
  --accent-strong: rgba(139, 124, 248, 0.55);  /* Focus ring, bordures actives */

  /*  Bordures & sparateurs  */
  --border:        rgba(255, 255, 255, 0.07);
  --border2:       rgba(255, 255, 255, 0.12);
  --border-accent: rgba(139, 124, 248, 0.35);

  /*  tats smantiques  */
  --success:       #34d399;
  --success-dim:   rgba(52, 211, 153, 0.12);
  --warning:       #fbbf24;
  --warning-dim:   rgba(251, 191, 36, 0.12);
  --danger:        #f87171;
  --danger-dim:    rgba(248, 113, 113, 0.12);
  --info:          #60a5fa;
  --info-dim:      rgba(96, 165, 250, 0.12);

  /*  Ombres  */
  --shadow-sm:     0 1px 3px rgba(0, 0, 0, 0.40);
  --shadow-md:     0 4px 16px rgba(0, 0, 0, 0.50);
  --shadow-lg:     0 8px 32px rgba(0, 0, 0, 0.60);
  --shadow-xl:     0 20px 60px rgba(0, 0, 0, 0.70);
  --shadow-accent: 0 4px 24px rgba(139, 124, 248, 0.28);

  /*  Icne thème  */
  --theme-icon-sun:  block;
  --theme-icon-moon: none;
}


/* ============================================================
   THÈME CLAIR
   Slecteur : html[data-theme="light"]
============================================================ */
html[data-theme="light"] {

  --bg:            #f5f5f9;
  --bg2:           #ffffff;
  --bg3:           #ededf4;
  --bg4:           #e6e6ef;
  --bg-glass:      rgba(245, 245, 249, 0.82);
  --bg-overlay:    rgba(245, 245, 249, 0.90);

  --text:          #1a1a2e;
  --text2:         #5c5c78;
  --text3:         #9898b0;
  --text-invert:   #ffffff;

  --accent:        #6d5ce8;
  --accent2:       #8b7cf8;
  --accent-dim:    rgba(109, 92, 232, 0.10);
  --accent-glow:   rgba(109, 92, 232, 0.22);
  --accent-strong: rgba(109, 92, 232, 0.45);

  --border:        rgba(0, 0, 0, 0.08);
  --border2:       rgba(0, 0, 0, 0.13);
  --border-accent: rgba(109, 92, 232, 0.30);

  --success:       #059669;
  --success-dim:   rgba(5, 150, 105, 0.10);
  --warning:       #d97706;
  --warning-dim:   rgba(217, 119, 6, 0.10);
  --danger:        #dc2626;
  --danger-dim:    rgba(220, 38, 38, 0.10);
  --info:          #2563eb;
  --info-dim:      rgba(37, 99, 235, 0.10);

  --shadow-sm:     0 1px 3px rgba(0, 0, 0, 0.08);
  --shadow-md:     0 4px 16px rgba(0, 0, 0, 0.10);
  --shadow-lg:     0 8px 32px rgba(0, 0, 0, 0.13);
  --shadow-xl:     0 20px 60px rgba(0, 0, 0, 0.16);
  --shadow-accent: 0 4px 24px rgba(109, 92, 232, 0.20);

  --theme-icon-sun:  none;
  --theme-icon-moon: block;
}


/* ============================================================
   VARIABLES GLOBALES INDPENDANTES DU THÈME
============================================================ */
:root {

  /*  Typographie  */
  --font-body:     'DM Sans', system-ui, -apple-system, sans-serif;
  --font-display:  'Playfair Display', Georgia, 'Times New Roman', serif;
  --font-mono:     'JetBrains Mono', 'Fira Code', 'Cascadia Code', monospace;

  /*  Tailles de police (chelle harmonique)  */
  --text-xs:    11px;
  --text-sm:    13px;
  --text-base:  15px;
  --text-md:    17px;
  --text-lg:    20px;
  --text-xl:    24px;
  --text-2xl:   30px;
  --text-3xl:   38px;
  --text-4xl:   48px;
  --text-5xl:   64px;
  --text-6xl:   88px;

  /*  Espacements (base 8px)  */
  --space-1:    4px;
  --space-2:    8px;
  --space-3:    12px;
  --space-4:    16px;
  --space-5:    20px;
  --space-6:    24px;
  --space-8:    32px;
  --space-10:   40px;
  --space-12:   48px;
  --space-16:   64px;
  --space-20:   80px;
  --space-24:   96px;
  --space-32:   128px;

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

  /*  Transitions  */
  --transition-fast:   150ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-base:   250ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow:   400ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-spring: 350ms cubic-bezier(0.34, 1.56, 0.64, 1);

  /*  Layout  */
  --max-width:      1200px;
  --nav-height-top: 70px;   /* Hauteur nav top au repos */
  --nav-height-sm:  58px;   /* Hauteur nav top au scroll */
  --sidebar-width:  220px;  /* Largeur sidebar (admin & nav-side) */
  --sidebar-collapsed: 64px;
  --content-padding: clamp(24px, 5vw, 80px);

  /*  Z-index stacking context  */
  --z-base:      1;
  --z-dropdown:  100;
  --z-sticky:    200;
  --z-nav:       300;
  --z-sidebar:   400;
  --z-overlay:   500;
  --z-modal:     600;
  --z-toast:     700;
  --z-tooltip:   800;
}


/* ============================================================
   RESET & BASE
============================================================ */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  hanging-punctuation: first last;
}

body {
  font-family: var(--font-body);
  font-size: var(--text-base);
  font-weight: 400;
  line-height: 1.65;
  color: var(--text);
  background-color: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
  transition:
    background-color var(--transition-slow),
    color var(--transition-slow);
}

/* Empche le scrollbar de causer un layout shift */
html {
  scrollbar-gutter: stable;
}

/*  lments de base  */
img,
video,
svg {
  display: block;
  max-width: 100%;
}

img {
  height: auto;
}

a {
  color: inherit;
  text-decoration: none;
}

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

button {
  cursor: pointer;
  background: none;
  border: none;
}

ul,
ol {
  list-style: none;
}

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-display);
  font-weight: 700;
  line-height: 1.2;
  color: var(--text);
  letter-spacing: -0.02em;
}

p {
  color: var(--text2);
}

strong,
b {
  font-weight: 600;
  color: var(--text);
}

em,
i {
  font-style: italic;
}

code,
kbd,
samp,
pre {
  font-family: var(--font-mono);
  font-size: 0.875em;
}

pre {
  overflow-x: auto;
}

hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: var(--space-8) 0;
}

::selection {
  background: var(--accent-dim);
  color: var(--accent2);
}


/* ============================================================
   SCROLLBAR PERSONNALISE
   (Webkit  Chrome, Safari, Edge)
============================================================ */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: var(--bg);
}

::-webkit-scrollbar-thumb {
  background: var(--border2);
  border-radius: var(--radius-full);
  transition: background var(--transition-base);
}

::-webkit-scrollbar-thumb:hover {
  background: var(--accent);
}

::-webkit-scrollbar-corner {
  background: var(--bg);
}

/* Firefox */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--border2) var(--bg);
}


/* ============================================================
   FOCUS VISIBLE  ACCESSIBILIT
============================================================ */
:focus {
  outline: none;
}

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


/* ============================================================
   BODY VARIANTS
============================================================ */

/* Corps de la page admin */
body.admin-body {
  background: var(--bg);
  overflow: hidden;  /* Le scroll est gr par .dashboard__main */
}


/* ============================================================
   UTILITAIRES DE BASE
============================================================ */

/* Masquer visuellement tout en restant accessible */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}

/* Masquer compltement */
[hidden] {
  display: none !important;
}

/* Overflow scroll mobile */
.scroll-x {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

/* Truncate texte */
.truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Empcher le retour  la ligne */
.nowrap {
  white-space: nowrap;
}

/* Dégradé texte accent (réutilisés partout) */
.text-gradient {
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent2) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}


/* ============================================================
   TRANSITIONS THÈME
   Appliques sur les lments qui changent de couleur
   lors du basculement dark/light
============================================================ */
body,
.nav-top,
.nav-side,
.sidebar,
.auth-card,
.modal__panel,
.form-input,
.form-textarea,
.form-select,
.stat-card,
.item-card,
.flash-banner {
  transition:
    background-color var(--transition-slow),
    border-color var(--transition-slow),
    color var(--transition-slow);
}