/* ══════════════════════════════════════════════════════════════════
   MAIC — Design Tokens (Material Design 3)
   ──────────────────────────────────────────────────────────────────
   Feuille de style partagée par tous les modules MAIC.
   À inclure en premier dans chaque page :
       <link rel="stylesheet" href="shared/maic-tokens.css">

   Source unique de vérité pour :
     • Couleurs (primary, surface, sémantiques)
     • Ombres d'élévation MD3
     • Rayons de coin
     • Typographies
     • Composants réutilisables (topbar, boutons, champs, snackbar…)
   ══════════════════════════════════════════════════════════════════ */

:root {
  /* ─── Couleurs primaires ─── */
  --md-primary:            #1a73e8;
  --md-primary-container:  #d2e3fc;
  --md-on-primary:         #ffffff;
  --md-on-primary-cont:    #041e49;
  --md-secondary:          #1967d2;
  --md-tertiary:           #006a6a;

  /* ─── Surfaces ─── */
  --md-surface:            #ffffff;
  --md-surface-variant:    #f1f3f4;
  --md-surface-container:  #f8f9fa;
  --md-surface-cont-high:  #f1f3f4;

  /* ─── Textes ─── */
  --md-on-surface:         #202124;
  --md-on-surface-var:     #5f6368;

  /* ─── Contours ─── */
  --md-outline:            #dadce0;
  --md-outline-variant:    #e8eaed;

  /* ─── Sémantiques ─── */
  --md-error:              #b3261e;
  --md-error-container:    #f9dedc;
  --md-success:            #1e8e3e;
  --md-success-container:  #e6f4ea;
  --md-warning:            #f9ab00;
  --md-warning-container:  #fef3cd;
  --md-info:               #1967d2;
  --md-info-container:     #d2e3fc;

  /* ─── Élévations ─── */
  --elev-1: 0 1px 2px rgba(60,64,67,.3),  0 1px 3px 1px rgba(60,64,67,.15);
  --elev-2: 0 1px 2px rgba(60,64,67,.3),  0 2px 6px 2px rgba(60,64,67,.15);
  --elev-3: 0 4px 8px 3px rgba(60,64,67,.15), 0 1px 3px rgba(60,64,67,.3);
  --elev-4: 0 6px 10px 4px rgba(60,64,67,.15), 0 2px 3px rgba(60,64,67,.3);

  /* ─── Rayons ─── */
  --radius-xs:   4px;
  --radius-s:    8px;
  --radius-m:   12px;
  --radius-l:   16px;
  --radius-xl:  28px;
  --radius-full: 50px;

  /* ─── Typographies ─── */
  --sans:    'Roboto', sans-serif;
  --display: 'Google Sans', sans-serif;
  --mono:    'Roboto Mono', monospace;

  /* ─── Z-index ─── */
  --z-topbar:    500;
  --z-drawer:    600;
  --z-modal:     800;
  --z-snackbar: 9999;
}

/* ══════════════════════════════════════════════════════════════════
   RESET minimal
   ══════════════════════════════════════════════════════════════════ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: var(--sans);
  background: var(--md-surface-container);
  color: var(--md-on-surface);
  font-size: 14px;
  line-height: 1.5;
  min-height: 100vh;
}

/* ══════════════════════════════════════════════════════════════════
   TOPBAR — barre d'application partagée
   ══════════════════════════════════════════════════════════════════ */
.maic-topbar {
  position: sticky; top: 0; z-index: var(--z-topbar);
  height: 64px; background: var(--md-surface);
  border-bottom: 1px solid var(--md-outline-variant);
  display: flex; align-items: center;
  padding: 0 16px 0 8px; gap: 12px;
  box-shadow: var(--elev-1);
}
.maic-topbar-logo {
  width: 36px; height: 36px; background: var(--md-primary);
  border-radius: var(--radius-s); flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  color: var(--md-on-primary);
}
.maic-topbar-brand {
  font-family: var(--display);
  font-size: 1.1rem; font-weight: 500;
  color: var(--md-on-surface);
}
.maic-topbar-divider {
  width: 1px; height: 22px;
  background: var(--md-outline);
}
.maic-topbar-sub {
  font-size: 13px;
  color: var(--md-on-surface-var);
}
.maic-topbar-spacer { flex: 1; }

/* ══════════════════════════════════════════════════════════════════
   BOUTONS ICÔNE
   ══════════════════════════════════════════════════════════════════ */
.maic-icon-btn {
  width: 40px; height: 40px;
  border-radius: 50%; border: none;
  background: transparent; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  color: var(--md-on-surface-var);
  transition: background .15s;
}
.maic-icon-btn:hover {
  background: rgba(26,115,232,.08);
  color: var(--md-primary);
}
/* Boutons retour / accueil (auto-injectés sur les pages secondaires) */
.maic-back-btn,
.maic-home-btn {
  background: rgba(0,0,0,.04);
  color: var(--md-on-surface);
  margin-right: 2px;
}
.maic-back-btn:hover,
.maic-home-btn:hover {
  background: var(--md-primary);
  color: #fff;
}
.maic-nav-back-wrap {
  margin-right: 8px;
}
.maic-avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--md-primary-container);
  color: var(--md-on-primary-cont);
  font-family: var(--display);
  font-weight: 500; font-size: 14px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
}

/* ══════════════════════════════════════════════════════════════════
   BOUTONS
   ══════════════════════════════════════════════════════════════════ */
.maic-btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 8px; border: none; cursor: pointer;
  padding: 10px 24px; border-radius: var(--radius-full);
  font-family: var(--display); font-size: 14px; font-weight: 500;
  transition: all .15s;
  text-decoration: none;
}
.maic-btn:disabled { opacity: .5; cursor: not-allowed; }

.maic-btn-filled {
  background: var(--md-primary); color: var(--md-on-primary);
  box-shadow: var(--elev-1);
}
.maic-btn-filled:hover:not(:disabled) { box-shadow: var(--elev-2); }

.maic-btn-tonal {
  background: var(--md-primary-container);
  color: var(--md-on-primary-cont);
}
.maic-btn-tonal:hover:not(:disabled) {
  background: #bcd2f5;
}

.maic-btn-outlined {
  background: transparent;
  color: var(--md-primary);
  border: 1px solid var(--md-outline);
}
.maic-btn-outlined:hover:not(:disabled) {
  background: rgba(26,115,232,.08);
  border-color: var(--md-primary);
}

.maic-btn-text {
  background: transparent;
  color: var(--md-primary);
  padding: 10px 12px;
}
.maic-btn-text:hover:not(:disabled) {
  background: rgba(26,115,232,.08);
}

/* ══════════════════════════════════════════════════════════════════
   CHAMPS DE FORMULAIRE
   ══════════════════════════════════════════════════════════════════ */
.maic-field { margin-bottom: 16px; }
.maic-field-label {
  display: block;
  font-size: 12px; font-weight: 500;
  color: var(--md-on-surface-var);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: .05em;
}
.maic-field-label .req { color: var(--md-error); margin-left: 2px; }

.maic-input,
.maic-select,
.maic-textarea {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--md-outline);
  border-radius: var(--radius-s);
  background: var(--md-surface);
  color: var(--md-on-surface);
  font-family: var(--sans);
  font-size: 14px;
  transition: border-color .15s, box-shadow .15s;
}
.maic-input:focus,
.maic-select:focus,
.maic-textarea:focus {
  outline: none;
  border-color: var(--md-primary);
  box-shadow: 0 0 0 3px rgba(26,115,232,.12);
}
.maic-textarea { min-height: 80px; resize: vertical; }

.maic-helper {
  font-size: 12px;
  color: var(--md-on-surface-var);
  margin-top: 4px;
}
.maic-helper-error { color: var(--md-error); }

/* ══════════════════════════════════════════════════════════════════
   CARTES
   ══════════════════════════════════════════════════════════════════ */
.maic-card {
  background: var(--md-surface);
  border-radius: var(--radius-l);
  box-shadow: var(--elev-1);
  padding: 20px;
}
.maic-card-title {
  font-family: var(--display);
  font-size: 16px; font-weight: 500;
  margin-bottom: 12px;
  display: flex; align-items: center; gap: 8px;
}

/* ══════════════════════════════════════════════════════════════════
   CHIPS / TAGS
   ══════════════════════════════════════════════════════════════════ */
.maic-chip {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 4px 12px;
  border-radius: var(--radius-full);
  background: var(--md-surface-variant);
  color: var(--md-on-surface);
  font-size: 12px; font-weight: 500;
  font-family: var(--display);
}
.maic-chip-primary { background: var(--md-primary-container); color: var(--md-on-primary-cont); }
.maic-chip-success { background: var(--md-success-container); color: #0f5723; }
.maic-chip-warning { background: var(--md-warning-container); color: #704c00; }
.maic-chip-error   { background: var(--md-error-container);   color: #78160c; }

/* ══════════════════════════════════════════════════════════════════
   SNACKBAR / TOAST
   ══════════════════════════════════════════════════════════════════ */
.maic-snackbar {
  position: fixed;
  bottom: 24px; left: 50%;
  transform: translateX(-50%) translateY(120px);
  background: #323232;
  color: #fff;
  padding: 12px 20px;
  border-radius: var(--radius-s);
  box-shadow: var(--elev-3);
  font-size: 14px;
  opacity: 0;
  transition: transform .3s cubic-bezier(.4,0,.2,1), opacity .3s;
  z-index: var(--z-snackbar);
  white-space: nowrap;
  display: flex; align-items: center; gap: 12px;
  max-width: 90vw;
}
.maic-snackbar.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}
.maic-snackbar.success { background: var(--md-success); }
.maic-snackbar.error   { background: var(--md-error); }
.maic-snackbar.warning { background: #704c00; }
.maic-snackbar .material-icons-round { font-size: 18px; }

/* ══════════════════════════════════════════════════════════════════
   MODAL
   ══════════════════════════════════════════════════════════════════ */
.maic-modal-overlay {
  position: fixed; inset: 0;
  background: rgba(32,33,36,.5);
  display: none;
  align-items: center; justify-content: center;
  z-index: var(--z-modal);
  padding: 20px;
}
.maic-modal-overlay.show { display: flex; }
.maic-modal {
  background: var(--md-surface);
  border-radius: var(--radius-xl);
  box-shadow: var(--elev-3);
  max-width: 560px; width: 100%;
  max-height: 90vh; overflow: auto;
  padding: 24px;
}
.maic-modal-title {
  font-family: var(--display);
  font-size: 18px; font-weight: 500;
  margin-bottom: 16px;
}
.maic-modal-actions {
  display: flex; justify-content: flex-end; gap: 8px;
  margin-top: 24px;
}

/* ══════════════════════════════════════════════════════════════════
   UTILITAIRES
   ══════════════════════════════════════════════════════════════════ */
.maic-divider {
  height: 1px;
  background: var(--md-outline-variant);
  margin: 12px 0;
}
.maic-spacer-xs { height: 4px; }
.maic-spacer-s  { height: 8px; }
.maic-spacer-m  { height: 16px; }
.maic-spacer-l  { height: 24px; }
.maic-spacer-xl { height: 40px; }

.maic-mono { font-family: var(--mono); }
.maic-display { font-family: var(--display); }

.maic-text-muted     { color: var(--md-on-surface-var); }
.maic-text-primary   { color: var(--md-primary); }
.maic-text-error     { color: var(--md-error); }
.maic-text-success   { color: var(--md-success); }

/* ══════════════════════════════════════════════════════════════════
   SCROLLBAR
   ══════════════════════════════════════════════════════════════════ */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--md-outline);
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover { background: var(--md-on-surface-var); }

/* ══════════════════════════════════════════════════════════════════
   RESPONSIVE
   ══════════════════════════════════════════════════════════════════ */
@media (max-width: 768px) {
  .maic-topbar { padding: 0 8px; }
  .maic-topbar-sub { display: none; }
}
