/* ═══════════════════════════════════════════
   CAMUSAT BF — Gestion Stock Magasin
   Charte graphique officielle
═══════════════════════════════════════════ */

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

:root {
  --blue:        #003366;
  --blue-mid:    #004488;
  --blue-hover:  #002855;
  --blue-light:  #E8EFF8;
  --blue-muted:  #C5D5E8;
  --red:         #E31E24;
  --red-dark:    #B5171C;
  --red-light:   #FDEAEA;
  --red-mid:     #f5bcbd;
  --white:       #FFFFFF;
  --gray-50:     #F7F8FA;
  --gray-100:    #EEF0F4;
  --gray-200:    #DDE1E9;
  --gray-300:    #C4CAD6;
  --gray-400:    #8A94A6;
  --gray-600:    #4A5568;
  --gray-900:    #1A202C;
  --success:     #1A7A45;
  --success-bg:  #E6F4ED;
  --success-bdr: #a8d5bb;
  --warning:     #955800;
  --warning-bg:  #FFF3E0;
  --warning-bdr: #f5c87a;
  --sidebar-w:   220px;
  --topbar-h:    56px;
  --tabs-h:      42px;
  --radius-sm:   6px;
  --radius:      10px;
  --shadow-sm:   0 1px 3px rgba(0,0,0,.08);
  --shadow:      0 2px 8px rgba(0,51,102,.10);
}

html, body { height: 100%; }
body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--gray-50);
  color: var(--gray-900);
  font-size: 13px;
  line-height: 1.5;
}

/* ─── SCROLLBAR ─── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--gray-300); border-radius: 3px; }

/* ─── APP SHELL ─── */
.app { display: flex; height: 100vh; overflow: hidden; }

/* ═══ SIDEBAR ═══ */
.sidebar {
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  background: var(--blue);
  display: flex;
  flex-direction: column;
  box-shadow: 2px 0 10px rgba(0,51,102,.2);
  z-index: 100;
}

.sb-logo {
  padding: 20px 18px 18px;
  border-bottom: 1px solid rgba(255,255,255,.1);
  display: flex;
  align-items: center;
  gap: 11px;
  text-decoration: none;
}
.sb-logo-icon {
  width: 38px; height: 38px;
  background: var(--red);
  border-radius: 9px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.sb-logo-icon i { font-size: 21px; color: white; }
.sb-logo-title { color: white; font-size: 14px; font-weight: 700; letter-spacing: .2px; }
.sb-logo-sub { color: rgba(255,255,255,.45); font-size: 10px; letter-spacing: .4px; text-transform: uppercase; margin-top: 1px; }

.sb-section {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 1.3px;
  text-transform: uppercase;
  color: rgba(255,255,255,.3);
  padding: 18px 18px 5px;
}

.sb-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 18px;
  color: rgba(255,255,255,.6);
  font-size: 13px;
  cursor: pointer;
  text-decoration: none;
  transition: background .15s, color .15s;
  position: relative;
}
.sb-item:hover { background: rgba(255,255,255,.07); color: rgba(255,255,255,.9); }
.sb-item.active {
  background: rgba(255,255,255,.13);
  color: white;
  font-weight: 500;
}
.sb-item.active::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  background: var(--red);
  border-radius: 0 3px 3px 0;
}
.sb-item i { font-size: 17px; width: 20px; flex-shrink: 0; }

.sb-badge {
  margin-left: auto;
  background: var(--red);
  color: white;
  font-size: 10px;
  font-weight: 700;
  padding: 1px 7px;
  border-radius: 20px;
  min-width: 20px;
  text-align: center;
}

.sb-footer {
  margin-top: auto;
  padding: 14px 18px;
  border-top: 1px solid rgba(255,255,255,.1);
  display: flex;
  align-items: center;
  gap: 10px;
}
.sb-avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--red);
  display: flex; align-items: center; justify-content: center;
  color: white; font-size: 11px; font-weight: 700;
  flex-shrink: 0;
}
.sb-user-name { color: white; font-size: 12px; font-weight: 500; }
.sb-user-role { color: rgba(255,255,255,.4); font-size: 10px; }

/* ═══ MAIN ═══ */
.main { flex: 1; display: flex; flex-direction: column; overflow: hidden; }

/* ─── STRIPE ─── */
.stripe { height: 4px; background: linear-gradient(90deg, var(--blue) 0%, var(--red) 100%); flex-shrink: 0; }

/* ═══ TOPBAR ═══ */
.topbar {
  background: white;
  border-bottom: 1px solid var(--gray-200);
  padding: 0 24px;
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
  box-shadow: var(--shadow-sm);
}
.topbar-title { font-size: 16px; font-weight: 700; color: var(--blue); }
.topbar-sub { font-size: 11px; color: var(--gray-400); margin-top: 1px; }
.topbar-right { display: flex; align-items: center; gap: 8px; }

/* ═══ BUTTONS ═══ */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 15px;
  border-radius: var(--radius-sm);
  font-size: 12px; font-weight: 500;
  cursor: pointer;
  transition: all .15s;
  border: 1px solid transparent;
  text-decoration: none;
  white-space: nowrap;
  font-family: inherit;
}
.btn i { font-size: 15px; }
.btn-ghost { background: white; color: var(--gray-600); border-color: var(--gray-200); }
.btn-ghost:hover { border-color: var(--blue); color: var(--blue); background: var(--blue-light); }
.btn-blue { background: var(--blue); color: white; border-color: var(--blue); }
.btn-blue:hover { background: var(--blue-hover); }
.btn-red { background: var(--red); color: white; border-color: var(--red); }
.btn-red:hover { background: var(--red-dark); }
.btn-sm { padding: 5px 11px; font-size: 11px; }
.btn-sm i { font-size: 13px; }
.btn-icon { padding: 7px; border: 1px solid var(--gray-200); background: white; color: var(--gray-400); border-radius: var(--radius-sm); cursor: pointer; display: flex; align-items: center; position: relative; }
.btn-icon:hover { border-color: var(--blue); color: var(--blue); }
.btn-icon i { font-size: 17px; }
.notif-dot { position: absolute; top: 5px; right: 5px; width: 7px; height: 7px; background: var(--red); border-radius: 50%; border: 1.5px solid white; }

/* ═══ TABS ═══ */
.tabs {
  display: flex;
  border-bottom: 1px solid var(--gray-200);
  background: white;
  padding: 0 24px;
  flex-shrink: 0;
  height: var(--tabs-h);
  align-items: flex-end;
}
.tab {
  padding: 10px 16px;
  font-size: 13px;
  color: var(--gray-400);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  display: flex; align-items: center; gap: 6px;
  transition: color .15s;
  text-decoration: none;
  margin-bottom: -1px;
}
.tab:hover { color: var(--blue); }
.tab.active { color: var(--blue); border-bottom-color: var(--blue); font-weight: 600; }
.tab i { font-size: 15px; }

/* ═══ CONTENT ═══ */
.content { flex: 1; overflow-y: auto; padding: 20px 24px 40px; display: flex; flex-direction: column; gap: 16px; }

/* ═══ ALERT BANNER ═══ */
.alert-banner {
  background: var(--red-light);
  border: 1px solid var(--red-mid);
  border-left: 4px solid var(--red);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12.5px;
  color: var(--red-dark);
}
.alert-banner i { font-size: 18px; color: var(--red); flex-shrink: 0; }

/* ═══ KPI ROW ═══ */
.kpi-row { display: grid; grid-template-columns: repeat(4,1fr); gap: 12px; }
.kpi {
  background: white;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 16px;
  display: flex;
  align-items: flex-start;
  gap: 14px;
  box-shadow: var(--shadow-sm);
}
.kpi-icon {
  width: 44px; height: 44px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.kpi-icon i { font-size: 22px; }
.kpi-icon.blue   { background: var(--blue-light); color: var(--blue); }
.kpi-icon.red    { background: var(--red-light);  color: var(--red);  }
.kpi-icon.green  { background: var(--success-bg); color: var(--success); }
.kpi-icon.orange { background: var(--warning-bg); color: var(--warning); }
.kpi-val  { font-size: 26px; font-weight: 700; color: var(--gray-900); line-height: 1.1; }
.kpi-lbl  { font-size: 11px; color: var(--gray-400); margin-top: 3px; }
.kpi-trend { font-size: 11px; margin-top: 6px; font-weight: 500; display: flex; align-items: center; gap: 3px; }
.kpi-trend i { font-size: 13px; }
.trend-up   { color: var(--success); }
.trend-down { color: var(--red); }
.trend-flat { color: var(--gray-400); }

/* ═══ GRID 2 COLS ═══ */
.row2 { display: grid; grid-template-columns: 1.5fr 1fr; gap: 14px; }
.row3 { display: grid; grid-template-columns: repeat(3,1fr); gap: 14px; }

/* ═══ CARD ═══ */
.card {
  background: white;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}
.card-head {
  padding: 13px 16px;
  border-bottom: 1px solid var(--gray-100);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.card-head h3 { font-size: 13px; font-weight: 700; color: var(--gray-900); display: flex; align-items: center; gap: 7px; }
.card-head h3 i { font-size: 16px; color: var(--blue); }
.card-head-right { display: flex; align-items: center; gap: 8px; }
.card-link { font-size: 11px; color: var(--blue); cursor: pointer; font-weight: 500; text-decoration: none; }
.card-body { padding: 14px 16px; }

/* ═══ CHART ═══ */
.chart-legend { display: flex; gap: 16px; margin-bottom: 12px; }
.cl { display: flex; align-items: center; gap: 6px; font-size: 11px; color: var(--gray-600); }
.cl-dot { width: 10px; height: 10px; border-radius: 3px; }
.cl-dot.in  { background: var(--blue); }
.cl-dot.out { background: var(--red); }
.bar-chart { display: flex; align-items: flex-end; gap: 8px; height: 100px; }
.bar-group { flex: 1; display: flex; gap: 3px; align-items: flex-end; }
.bar { flex: 1; border-radius: 3px 3px 0 0; transition: opacity .2s; cursor: pointer; }
.bar:hover { opacity: .75; }
.bar.in  { background: var(--blue); }
.bar.out { background: var(--red); opacity: .8; }
.bar-months { display: flex; gap: 8px; margin-top: 6px; }
.bm { flex: 1; text-align: center; font-size: 10px; color: var(--gray-400); }

/* ═══ ALERT LIST ═══ */
.alert-list { display: flex; flex-direction: column; }
.alert-row { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--gray-100); }
.alert-row:last-child { border-bottom: none; }
.al-dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }
.al-dot.danger  { background: var(--red); }
.al-dot.warning { background: #f59e0b; }
.al-info { flex: 1; }
.al-name { font-size: 12.5px; font-weight: 600; color: var(--gray-900); }
.al-sub  { font-size: 10.5px; color: var(--gray-400); margin-top: 1px; }
.al-qty  { font-size: 15px; font-weight: 700; }
.al-qty.danger  { color: var(--red); }
.al-qty.warning { color: #b96c00; }
.reorder-note {
  margin-top: 12px;
  background: var(--red-light);
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  font-size: 11.5px;
  color: var(--red-dark);
  display: flex; align-items: center; gap: 7px;
}
.reorder-note i { font-size: 15px; flex-shrink: 0; }

/* ═══ TABLE TOOLBAR ═══ */
.tbl-toolbar {
  padding: 10px 16px;
  display: flex; gap: 8px; align-items: center;
  border-bottom: 1px solid var(--gray-100);
  background: var(--gray-50);
  flex-wrap: wrap;
}
.tbl-search {
  flex: 1; min-width: 180px;
  padding: 7px 10px 7px 32px;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-sm);
  font-size: 12px;
  background: white url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%238A94A6' stroke-width='2'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cpath d='m21 21-4.35-4.35'/%3E%3C/svg%3E") no-repeat 9px center;
  color: var(--gray-900);
  outline: none;
  transition: border-color .15s;
}
.tbl-search:focus { border-color: var(--blue); }
.tbl-select {
  padding: 7px 10px;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-sm);
  font-size: 12px;
  background: white;
  color: var(--gray-600);
  outline: none;
  cursor: pointer;
  font-family: inherit;
}
.tbl-select:focus { border-color: var(--blue); }

/* ═══ TABLE ═══ */
table { width: 100%; border-collapse: collapse; }
thead th {
  font-size: 10.5px; text-transform: uppercase; letter-spacing: .5px;
  color: var(--gray-400); font-weight: 700;
  padding: 9px 14px; text-align: left;
  background: var(--gray-50);
  border-bottom: 1px solid var(--gray-200);
  white-space: nowrap;
}
tbody td { padding: 10px 14px; border-bottom: 1px solid var(--gray-100); vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: #f5f8ff; }
.no-results { text-align: center; padding: 40px; color: var(--gray-400); font-size: 13px; }
.no-results i { font-size: 32px; display: block; margin-bottom: 8px; }

/* ═══ TABLE CELL HELPERS ═══ */
.ref-num  { font-size: 10px; color: var(--gray-400); font-weight: 600; }
.ref-date { font-size: 10.5px; color: var(--gray-400); margin-top: 2px; }
.prod-name { font-size: 12.5px; font-weight: 600; color: var(--gray-900); }
.prod-ref  { font-size: 10px; color: var(--gray-400); margin-top: 1px; }
.dest-main { font-size: 12.5px; color: var(--gray-600); }
.dest-sub  { font-size: 10px; color: var(--gray-400); margin-top: 1px; }
.qty-in  { font-size: 13px; font-weight: 700; color: var(--success); }
.qty-out { font-size: 13px; font-weight: 700; color: var(--red); }

/* ═══ BADGES ═══ */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 9px; border-radius: 20px;
  font-size: 11px; font-weight: 600; white-space: nowrap;
}
.badge i { font-size: 11px; }
.badge-entree  { background: var(--success-bg); color: var(--success); }
.badge-sortie  { background: var(--red-light);  color: var(--red); }
.badge-valide  { background: var(--success-bg); color: var(--success); }
.badge-attente { background: var(--warning-bg); color: var(--warning); }
.badge-annule  { background: var(--gray-100);   color: var(--gray-600); }
.badge-ok      { background: var(--success-bg); color: var(--success); }
.badge-bas     { background: var(--warning-bg); color: var(--warning); }
.badge-epuise  { background: var(--red-light);  color: var(--red); }

/* ═══ AVATAR ═══ */
.av {
  display: inline-flex; align-items: center; justify-content: center;
  width: 28px; height: 28px; border-radius: 50%;
  font-size: 10px; font-weight: 700;
  flex-shrink: 0;
}
.av-blue { background: var(--blue-light); color: var(--blue); }
.av-red  { background: var(--red-light);  color: var(--red); }

.person-cell { display: flex; align-items: center; gap: 8px; white-space: nowrap; }
.person-name { font-size: 12px; font-weight: 500; }
.person-role { font-size: 10px; color: var(--gray-400); }

/* ═══ FORMULAIRES ═══ */
.form-wrap { max-width: 700px; }
.form-card {
  background: white;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}
.form-head {
  padding: 16px 20px;
  border-bottom: 1px solid var(--gray-100);
  background: var(--gray-50);
}
.form-head h2 { font-size: 15px; font-weight: 700; color: var(--blue); display: flex; align-items: center; gap: 8px; }
.form-head h2 i { font-size: 18px; }
.form-head p { font-size: 12px; color: var(--gray-400); margin-top: 4px; }
.form-body { padding: 20px; display: flex; flex-direction: column; gap: 16px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-group { display: flex; flex-direction: column; gap: 5px; }
.form-group.full { grid-column: 1 / -1; }
.form-label { font-size: 12px; font-weight: 600; color: var(--gray-600); }
.form-label span { color: var(--red); }
.form-input, .form-select, .form-textarea {
  padding: 9px 12px;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: var(--gray-900);
  background: white;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
  font-family: inherit;
  width: 100%;
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(0,51,102,.08);
}
.form-textarea { resize: vertical; min-height: 80px; }
.form-hint { font-size: 10.5px; color: var(--gray-400); margin-top: 2px; }
.form-footer {
  padding: 14px 20px;
  border-top: 1px solid var(--gray-100);
  background: var(--gray-50);
  display: flex; gap: 10px; justify-content: flex-end;
}

/* ─── Aperçu produit (dans formulaire) ─── */
.product-preview {
  background: var(--blue-light);
  border: 1px solid var(--blue-muted);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  display: flex; align-items: center; gap: 12px;
  display: none;
}
.product-preview.show { display: flex; }
.pp-icon { width: 38px; height: 38px; background: var(--blue); border-radius: 8px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.pp-icon i { font-size: 20px; color: white; }
.pp-ref   { font-size: 10px; color: var(--blue-mid); font-weight: 600; }
.pp-name  { font-size: 13px; font-weight: 700; color: var(--blue); }
.pp-stock { font-size: 11px; color: var(--blue-mid); margin-top: 2px; }
.pp-stock strong { color: var(--blue); }

/* ═══ TOP PRODUITS ═══ */
.top-list { display: flex; flex-direction: column; gap: 0; }
.top-row { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--gray-100); }
.top-row:last-child { border-bottom: none; }
.top-rank { width: 22px; height: 22px; border-radius: 50%; background: var(--blue-light); color: var(--blue); font-size: 11px; font-weight: 700; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.top-name { flex: 1; font-size: 12.5px; font-weight: 500; color: var(--gray-900); }
.top-sub  { font-size: 10px; color: var(--gray-400); margin-top: 1px; }
.top-bar-wrap { width: 80px; height: 5px; background: var(--gray-100); border-radius: 3px; overflow: hidden; }
.top-bar-fill { height: 100%; background: var(--red); border-radius: 3px; }
.top-qty { font-size: 12px; font-weight: 700; color: var(--gray-900); min-width: 24px; text-align: right; }

/* ═══ TOAST ═══ */
.toast-container { position: fixed; bottom: 20px; right: 20px; z-index: 999; display: flex; flex-direction: column; gap: 8px; }
.toast {
  background: var(--gray-900);
  color: white;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  display: flex; align-items: center; gap: 10px;
  box-shadow: 0 4px 16px rgba(0,0,0,.2);
  animation: slideIn .3s ease;
  min-width: 260px;
}
.toast i { font-size: 18px; flex-shrink: 0; }
.toast.success { background: var(--success); }
.toast.error   { background: var(--red); }
.toast.warning { background: var(--warning); }
@keyframes slideIn { from { transform: translateX(100px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* ═══ MODAL ═══ */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.4);
  z-index: 500;
  display: none; align-items: center; justify-content: center;
}
.modal-overlay.open { display: flex; }
.modal {
  background: white;
  border-radius: var(--radius);
  width: 420px;
  max-width: 95vw;
  box-shadow: 0 20px 60px rgba(0,0,0,.2);
  overflow: hidden;
}
.modal-head {
  padding: 16px 20px;
  border-bottom: 1px solid var(--gray-100);
  display: flex; align-items: center; justify-content: space-between;
}
.modal-head h3 { font-size: 15px; font-weight: 700; color: var(--gray-900); }
.modal-close { background: none; border: none; color: var(--gray-400); cursor: pointer; font-size: 20px; display: flex; align-items: center; }
.modal-close:hover { color: var(--gray-900); }
.modal-body { padding: 20px; }
.modal-footer { padding: 14px 20px; border-top: 1px solid var(--gray-100); display: flex; gap: 10px; justify-content: flex-end; }

/* ═══ PAGINATION ═══ */
.pagination { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; border-top: 1px solid var(--gray-100); background: var(--gray-50); }
.pagination-info { font-size: 12px; color: var(--gray-400); }
.pagination-btns { display: flex; gap: 4px; }
.page-btn { width: 30px; height: 30px; border: 1px solid var(--gray-200); background: white; border-radius: var(--radius-sm); font-size: 12px; cursor: pointer; display: flex; align-items: center; justify-content: center; font-family: inherit; color: var(--gray-600); }
.page-btn:hover { border-color: var(--blue); color: var(--blue); }
.page-btn.active { background: var(--blue); color: white; border-color: var(--blue); }

/* ═══ PAGE HEADER ═══ */
.page-header { display: flex; align-items: center; justify-content: space-between; }
.page-header-left h2 { font-size: 17px; font-weight: 700; color: var(--blue); }
.page-header-left p  { font-size: 12px; color: var(--gray-400); margin-top: 2px; }
.page-header-right { display: flex; gap: 8px; }

/* ═══ EMPTY STATE ═══ */
.empty-state { text-align: center; padding: 60px 20px; color: var(--gray-400); }
.empty-state i { font-size: 48px; display: block; margin-bottom: 12px; color: var(--gray-300); }
.empty-state h3 { font-size: 15px; font-weight: 600; color: var(--gray-600); margin-bottom: 6px; }
.empty-state p { font-size: 13px; }
