/* ===== AXIIS DESIGN SYSTEM — CODE COULEUR OFFICIEL ===== */
:root {
  /* Famille 1 — Identité de marque (Violet) */
  --color-brand-primary: #7C3AED;   /* Axiis Violet — logo, sidebar active, nav, focus ring, liens */
  --color-brand-light:   #A855F7;   /* Violet Light — hover nav, dégradé brand */
  --color-brand-mist:    #EDE9FE;   /* Violet Mist — badges plan, tinted bg, selected rows */

  /* Famille 2 — Action (usage strictement limité : 1 CTA teal par vue) */
  --color-action-primary: #0A7A70;  /* Axiis Teal — CTA principal uniquement */
  --color-action-hover:   #0D9488;  /* Teal Mid — hover CTA principal */
  --color-action-mist:    #CCFBF1;  /* Teal Mist — fond tags succès, toasts confirmation */

  /* Famille 3 — Neutres structurels */
  --color-surface-page:   #F8FAFC;  /* Fond de page global (le plus bas) */
  --color-surface-card:   #FFFFFF;  /* Cards, panels, modales, inputs, dropdowns */
  --color-border-default: #E2E8F0;  /* Bordures cards, séparateurs, outline inputs repos */
  --color-border-strong:  #CBD5E1;  /* Bordures hover, focus input, séparateurs tableaux */
  --color-text-primary:   #0F172A;  /* Ink — titres, labels, corps */
  --color-text-secondary: #64748B;  /* Slate — sous-titres, descriptions, labels form */
  --color-text-hint:      #94A3B8;  /* Muted — placeholders, icônes inactives, disabled */

  /* Famille 4 — Sémantiques (feedback système) */
  --color-semantic-success: #16A34A;
  --color-semantic-warning: #D97706;
  --color-semantic-error:   #DC2626;

  /* Aliases pratiques pour le code */
  --bg:         var(--color-surface-page);
  --bg-card:    var(--color-surface-card);
  --bg-hover:   #F1F5F9;
  --border:     var(--color-border-default);
  --border-s:   var(--color-border-strong);
  --primary:    var(--color-brand-primary);
  --primary-h:  var(--color-brand-light);
  --action:     var(--color-action-primary);
  --action-h:   var(--color-action-hover);
  --text:       var(--color-text-primary);
  --text-muted: var(--color-text-secondary);
  --text-hint:  var(--color-text-hint);
  --success:    var(--color-semantic-success);
  --warning:    var(--color-semantic-warning);
  --danger:     var(--color-semantic-error);
  --radius:     0.375rem;
  --radius-lg:  0.75rem;
  --shadow:     0 1px 3px rgba(0,0,0,.08), 0 4px 16px rgba(0,0,0,.06);
  --shadow-md:  0 4px 24px rgba(0,0,0,.1);
}

/* ===== RESET ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; scroll-behavior: smooth; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
img, svg { display: block; }
button { cursor: pointer; font-family: inherit; }
input, select, textarea { font-family: inherit; }

/* ===== TYPOGRAPHY ===== */
h1 { font-size: 1.875rem; font-weight: 700; color: var(--text); }
h2 { font-size: 1.5rem;   font-weight: 600; color: var(--text); }
h3 { font-size: 1.25rem;  font-weight: 600; color: var(--text); }
h4 { font-size: 1rem;     font-weight: 600; color: var(--text); }
p  { color: var(--text-muted); }
small { font-size: 0.8rem; color: var(--text-hint); }

/* ===== ICONS ===== */
.icon { display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; }
.icon img, .icon svg { width: 1em; height: 1em; }
.icon-sm { font-size: 14px; } .icon-md { font-size: 18px; } .icon-lg { font-size: 24px; }

/* ===== BOUTONS =====
   Règle design system :
   - btn-action  = Teal  (#0A7A70) → CTA principal, 1 seul par vue, font-weight 600 min 14px
   - btn-primary = Violet outline → CTAs secondaires
   - btn-brand   = Violet plein  → nav active, logo, badges
*/
.btn {
  display: inline-flex; align-items: center; gap: .4rem;
  padding: .5rem 1rem; border-radius: var(--radius);
  font-size: .875rem; font-weight: 500;
  border: 1px solid transparent;
  transition: background .15s, opacity .15s, box-shadow .15s;
  white-space: nowrap;
}
.btn:disabled { opacity: .45; pointer-events: none; }

/* CTA principal — TEAL (1 seul par vue) */
.btn-primary {
  background: var(--action); color: #fff;
  font-weight: 600; font-size: .9rem;
}
.btn-primary:hover { background: var(--action-h); }

/* Secondaire — Violet outline */
.btn-secondary {
  background: transparent;
  border-color: var(--primary); color: var(--primary);
}
.btn-secondary:hover { background: var(--color-brand-mist); }

/* Tertiaire — neutre */
.btn-outline {
  background: transparent; border-color: var(--border); color: var(--text);
}
.btn-outline:hover { background: var(--bg-hover); border-color: var(--border-s); }

.btn-ghost {
  background: transparent; color: var(--text-muted); border: none;
}
.btn-ghost:hover { background: var(--bg-hover); color: var(--text); }

.btn-danger { background: var(--danger); color: #fff; font-weight: 600; }
.btn-danger:hover { opacity: .85; }

.btn-brand { background: var(--primary); color: #fff; font-weight: 500; }
.btn-brand:hover { background: var(--primary-h); }

.btn-sm  { padding: .3rem .7rem;  font-size: .8rem; }
.btn-lg  { padding: .75rem 1.5rem; font-size: 1rem; }
.btn-full { width: 100%; justify-content: center; }
.btn-icon { padding: .4rem; }

/* Spinner */
.btn .spinner { animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== FORM ELEMENTS ===== */
.form-group { display: flex; flex-direction: column; gap: .4rem; }
.form-label { font-size: .875rem; font-weight: 500; color: var(--text); }
.form-input {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  padding: .55rem .85rem; font-size: .875rem;
  transition: border-color .15s, box-shadow .15s;
  width: 100%;
}
.form-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(124,58,237,.12); /* violet à ~30% opacité */
}
.form-input::placeholder { color: var(--text-hint); }
.form-input.error { border-color: var(--danger); }
.form-error { font-size: .8rem; color: var(--danger); }
.form-hint  { font-size: .8rem; color: var(--text-hint); }

/* ===== CARD ===== */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  box-shadow: var(--shadow);
}
.card-header { margin-bottom: 1rem; }
.card-title  { font-size: 1rem; font-weight: 600; color: var(--text); }
.card-desc   { font-size: .8rem; color: var(--text-muted); margin-top: .2rem; }

/* ===== BADGE ===== */
.badge {
  display: inline-flex; align-items: center; gap: .25rem;
  padding: .2rem .6rem; border-radius: 999px;
  font-size: .75rem; font-weight: 500;
}
.badge-success { background: var(--color-action-mist);           color: var(--success); }
.badge-warning { background: rgba(217,119,6,.12);                color: var(--warning); }
.badge-danger  { background: rgba(220,38,38,.1);                 color: var(--danger);  }
.badge-info    { background: rgba(124,58,237,.1);                color: var(--primary); }
.badge-default { background: var(--bg-hover); color: var(--text-muted); }
.badge-brand   { background: var(--color-brand-mist);            color: var(--primary); }

/* ===== TABLE ===== */
.table-wrap { overflow-x: auto; border-radius: var(--radius-lg); }
.table { width: 100%; border-collapse: collapse; font-size: .875rem; }
.table th {
  text-align: left; padding: .65rem .85rem;
  color: var(--text-muted); font-weight: 600; font-size: .8rem;
  border-bottom: 1px solid var(--border);
  background: var(--bg); white-space: nowrap;
}
.table td {
  padding: .7rem .85rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle; color: var(--text);
}
.table tr:last-child td { border-bottom: none; }
.table tr:hover td { background: var(--color-brand-mist); }

/* ===== TABS ===== */
.tabs-list {
  display: flex; gap: .25rem;
  background: var(--bg); border: 1px solid var(--border);
  border-radius: var(--radius); padding: .25rem;
  width: fit-content;
}
.tab-btn {
  padding: .35rem .85rem; border-radius: calc(var(--radius) - 2px);
  font-size: .85rem; font-weight: 500; border: none;
  background: transparent; color: var(--text-muted);
  transition: background .15s, color .15s;
}
.tab-btn.active {
  background: var(--bg-card); color: var(--primary);
  font-weight: 600;
  box-shadow: 0 1px 4px rgba(0,0,0,.08);
}
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ===== MODAL ===== */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(15,23,42,.45); backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center;
  z-index: 100; padding: 1rem;
}
.modal-overlay.hidden { display: none; }
.modal-box {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 1.5rem;
  width: 100%; max-width: 480px; box-shadow: var(--shadow-md);
}
.modal-header { display: flex; justify-content: space-between; align-items: start; margin-bottom: 1rem; }
.modal-footer { display: flex; gap: .5rem; justify-content: flex-end; margin-top: 1.5rem; }

/* ===== SEPARATOR ===== */
.sep { border: none; border-top: 1px solid var(--border); margin: 1rem 0; }
.sep-text {
  display: flex; align-items: center; gap: .75rem;
  color: var(--text-hint); font-size: .8rem;
}
.sep-text::before, .sep-text::after {
  content: ''; flex: 1; height: 1px; background: var(--border);
}

/* ===== TOASTS ===== */
#toast-container {
  position: fixed; bottom: 1.5rem; right: 1.5rem;
  display: flex; flex-direction: column; gap: .5rem;
  z-index: 9999; pointer-events: none;
}
.toast {
  display: flex; align-items: center; gap: .6rem;
  padding: .75rem 1rem; border-radius: var(--radius);
  font-size: .875rem; font-weight: 500;
  background: var(--bg-card); border: 1px solid var(--border);
  box-shadow: var(--shadow-md); pointer-events: all;
  animation: slideIn .2s ease; min-width: 280px; color: var(--text);
}
.toast.fade-out { animation: slideOut .2s ease forwards; }
/* Toast succès → fond teal mist (design system) */
.toast-success { border-left: 3px solid var(--success); background: var(--color-action-mist); }
.toast-error   { border-left: 3px solid var(--danger); }
.toast-info    { border-left: 3px solid var(--primary); }
@keyframes slideIn  { from { transform: translateX(100%); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes slideOut { to { transform: translateX(120%); opacity: 0; } }

/* ===== PROGRESS ===== */
.progress-bar  { height: .5rem; background: var(--border); border-radius: 999px; overflow: hidden; }
.progress-fill { height: 100%; background: var(--action); border-radius: 999px; transition: width .3s ease; }

/* ===== DROPDOWN ===== */
.dropdown { position: relative; display: inline-block; }
.dropdown-menu {
  position: absolute; top: calc(100% + .25rem); right: 0;
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); min-width: 160px;
  box-shadow: var(--shadow-md); z-index: 50;
  display: none; flex-direction: column; overflow: hidden;
}
.dropdown-menu.open { display: flex; }
.dropdown-item {
  padding: .5rem .85rem; font-size: .875rem; color: var(--text);
  cursor: pointer; border: none; background: none; text-align: left;
  display: flex; align-items: center; gap: .5rem; transition: background .12s;
}
.dropdown-item:hover { background: var(--bg-hover); }
.dropdown-item.danger { color: var(--danger); }

/* ===== UTILS ===== */
.flex        { display: flex; }
.flex-col    { display: flex; flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-1 { gap: .25rem; } .gap-2 { gap: .5rem; } .gap-3 { gap: .75rem; } .gap-4 { gap: 1rem; }
.mt-1 { margin-top: .25rem; } .mt-2 { margin-top: .5rem; } .mt-4 { margin-top: 1rem; } .mt-6 { margin-top: 1.5rem; }
.mb-2 { margin-bottom: .5rem; } .mb-4 { margin-bottom: 1rem; }
.text-sm     { font-size: .875rem; }
.text-muted  { color: var(--text-muted); }
.text-hint   { color: var(--text-hint); }
.text-success { color: var(--success); }
.text-danger  { color: var(--danger); }
.text-warning { color: var(--warning); }
.text-primary { color: var(--primary); }
.font-bold     { font-weight: 700; }
.font-semibold { font-weight: 600; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hidden   { display: none !important; }
.w-full   { width: 100%; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.grid-3 { display: grid; grid-template-columns: repeat(3,1fr); gap: 1rem; }
.grid-4 { display: grid; grid-template-columns: repeat(4,1fr); gap: 1rem; }
.rounded { border-radius: var(--radius); }

/* ===== KPI CARD ===== */
.kpi-card  { display: flex; flex-direction: column; gap: .5rem; }
.kpi-label { font-size: .8rem; color: var(--text-muted); display: flex; align-items: center; gap: .35rem; }
.kpi-value { font-size: 1.75rem; font-weight: 700; color: var(--text); }
.kpi-delta { font-size: .8rem; display: flex; align-items: center; gap: .2rem; }
.kpi-delta.up   { color: var(--success); }
.kpi-delta.down { color: var(--danger); }

/* ===== SKELETON LOADER ===== */
.skeleton {
  background: linear-gradient(90deg, var(--bg-hover) 25%, #e9eef5 50%, var(--bg-hover) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite;
  border-radius: var(--radius);
}
@keyframes shimmer { to { background-position: -200% 0; } }

/* ===== EMPTY STATE ===== */
.empty-state {
  display: flex; flex-direction: column; align-items: center;
  gap: 1rem; padding: 3rem 1rem; text-align: center;
  color: var(--text-hint);
}
.empty-state .icon-lg { font-size: 3rem; opacity: .3; }

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  h1 { font-size: 1.4rem; }
}
