/* ══════════════════════════════════════════════════════════════
   NumaVie — Design System Core v4.0 LUXE
   Sidebar cuir bleu nuit + laiton, 56 modules, collapse, emojis
   ══════════════════════════════════════════════════════════════ */

/* ─── VARIABLES (Design Tokens) ─── */
:root {
  --bg-color:      #f6f3ee;
  --bg-card:       #ffffff;
  --bg-muted:      #faf8f4;
  --gold-accent:   #c5a059;
  --gold-light:    #e8d5a3;
  --text-main:     #1a1208;
  --text-muted:    #6b6051;
  --text-subtle:   #8a7a66;
  --border-color:  #ede8df;
  --border-gold:   rgba(197,160,89,0.12);
  --border-gold-h: rgba(197,160,89,0.3);
  --sidebar-bg:    #162032;
  --sidebar-text:  #9aa3b8;
  --sidebar-text-hover: #d4c5a0;
  --sidebar-w:     250px;
  --sidebar-w-collapsed: 56px;
  --success:       #2d7a4f;
  --danger:        #d03030;
  --warning:       #e0a020;
  --info:          #3a6ea5;
  --green:         #16a34a;
  --red:           #dc2626;
  --orange:        #d97706;
  --font:          'DM Sans', 'Inter', sans-serif;
  --font-display:  'Playfair Display', serif;
  --radius-sm:     8px;
  --radius-md:     12px;
  --radius-lg:     16px;
  --shadow:        0 2px 10px rgba(0,0,0,0.04);
  --shadow-hover:  0 8px 24px rgba(0,0,0,0.06);
}

/* ─── RESET ─── */
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body {
  height: 100%; font-family: var(--font); font-size: 14px;
  color: var(--text-main); background: var(--bg-color);
}
a { text-decoration: none; color: inherit; }
button {
  cursor: pointer; border: none; background: none;
  font-family: inherit; font-size: inherit;
}

/* ─── LAYOUT ─── */
body { display: flex; min-height: 100vh; }

/* ─── SIDEBAR LUXE (cuir bleu nuit + laiton) ─── */
.sidebar {
  width: var(--sidebar-w); height: 100vh;
  background:
    repeating-radial-gradient(circle at 1px 1px, transparent 0, rgba(0,0,0,0.03) 1px, transparent 2px),
    repeating-radial-gradient(circle at 3px 2px, transparent 0, rgba(255,255,255,0.015) 1px, transparent 3px),
    linear-gradient(175deg, #1e2a3a 0%, #162032 30%, #111b2b 60%, #0e1825 100%);
  padding: 0; flex-shrink: 0; overflow: hidden;
  display: flex; flex-direction: column;
  transition: width 0.22s cubic-bezier(.4,0,.2,1);
  position: relative; z-index: 100;
  border-right: 3px solid #2a1f10;
  box-shadow:
    inset -1px 0 0 rgba(197,160,89,0.15),
    3px 0 25px rgba(0,0,0,0.3),
    inset 0 0 60px rgba(0,0,0,0.2);
}
/* Couture dorée sur le bord droit */
.sidebar::after {
  content: '';
  position: absolute; right: 0; top: 20px; bottom: 20px; width: 1px;
  background: repeating-linear-gradient(
    to bottom,
    rgba(197,160,89,0.4) 0px, rgba(197,160,89,0.4) 4px,
    transparent 4px, transparent 10px
  );
  pointer-events: none;
}

/* ── Sidebar zones ── */
.sidebar-header {
  display: flex; align-items: center; justify-content: center;
  padding: 20px 16px 16px;
  border-bottom: 1px solid rgba(197,160,89,0.2);
  background: linear-gradient(180deg, rgba(197,160,89,0.08) 0%, transparent 100%);
  flex-shrink: 0; position: relative;
}
.sidebar-header::after {
  content: '';
  position: absolute; bottom: -1px; left: 16px; right: 16px; height: 1px;
  background: linear-gradient(90deg, transparent, rgba(197,160,89,0.4), transparent);
}
.sidebar-nav {
  flex: 1; overflow-y: auto; overflow-x: hidden;
  padding: 8px 0;
  scrollbar-width: thin; scrollbar-color: rgba(197,160,89,0.25) transparent;
}
.sidebar-nav::-webkit-scrollbar { width: 4px; }
.sidebar-nav::-webkit-scrollbar-thumb { background: rgba(197,160,89,0.25); border-radius: 10px; }

.sidebar-bottom {
  flex-shrink: 0;
  border-top: 1px solid rgba(197,160,89,0.15);
  padding: 6px 0;
  background: linear-gradient(0deg, rgba(0,0,0,0.15) 0%, transparent 100%);
  position: relative;
}
.sidebar-bottom::before {
  content: '';
  position: absolute; top: -1px; left: 16px; right: 16px; height: 1px;
  background: linear-gradient(90deg, transparent, rgba(197,160,89,0.3), transparent);
}

/* ── Sidebar brand (titre laiton brossé) ── */
.sidebar-brand {
  display: flex; align-items: center; gap: 12px;
}
.sidebar-brand svg {
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.5));
}
.sidebar-title {
  font-family: var(--font-display); font-size: 20px;
  font-weight: 700; white-space: nowrap;
  background: linear-gradient(180deg, #e8c872 0%, #c5a059 40%, #a8853e 70%, #c5a059 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  filter: drop-shadow(0 1px 2px rgba(0,0,0,0.5));
}
.sidebar-title em {
  font-style: normal;
  background: linear-gradient(180deg, #ddd5c0 0%, #b8a88e 50%, #d4c5a0 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.sidebar-subtitle {
  font-size: 8px; letter-spacing: 3px; text-transform: uppercase;
  text-align: center; margin-top: 4px;
  background: linear-gradient(180deg, #9a8a70, #7a6a50);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* ── Collapse button (rivet en bas) ── */
.collapse-btn {
  width: 100%; height: 34px;
  display: flex; align-items: center; justify-content: center;
  color: #6a7a90; font-size: 13px;
  background: linear-gradient(180deg, rgba(197,160,89,0.08), rgba(0,0,0,0.1));
  cursor: pointer; border: none; border-top: 1px solid rgba(197,160,89,0.1);
  transition: all 0.2s;
}
.collapse-btn:hover {
  background: linear-gradient(180deg, rgba(197,160,89,0.15), rgba(197,160,89,0.05));
  color: var(--gold-accent);
  text-shadow: 0 0 6px rgba(197,160,89,0.3);
}

/* ── Collapsed state ── */
.sidebar.collapsed { width: var(--sidebar-w-collapsed); }
.sidebar.collapsed .menu-label,
.sidebar.collapsed .menu-section-title,
.sidebar.collapsed .sidebar-title,
.sidebar.collapsed .sync-indicator .menu-label { display: none; }
.sidebar.collapsed .sidebar-header { padding: 10px 0; }
.sidebar.collapsed .sidebar-brand { justify-content: center; }
.sidebar.collapsed .menu-item { justify-content: center; padding: 8px 0; border-left: none; }
.sidebar.collapsed .menu-item.active,
.sidebar.collapsed .menu-item:hover { border-left: none; border-bottom: none; background: rgba(197,160,89,0.15); border-radius: 8px; margin: 0 6px; }
.sidebar.collapsed .menu-icon { font-size: 18px; }
.sidebar.collapsed .sync-indicator { justify-content: center; padding: 8px 0; }

/* ── Menu sections & items (gravure dorée) ── */
.menu-section-title {
  font-size: 9px; font-weight: 700; letter-spacing: 2.5px;
  padding: 18px 18px 5px; text-transform: uppercase;
  white-space: nowrap; overflow: hidden;
  background: linear-gradient(180deg, rgba(197,160,89,0.6), rgba(197,160,89,0.35));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.menu-item {
  display: flex; align-items: center; gap: 11px; padding: 7px 18px;
  color: var(--sidebar-text); text-decoration: none; font-size: 13px;
  transition: all 0.25s; border-left: 3px solid transparent; white-space: nowrap;
  overflow: hidden; position: relative;
}
.menu-item:hover {
  color: #f0e4c8;
  border-left-color: rgba(197,160,89,0.7);
  background: linear-gradient(90deg, rgba(197,160,89,0.22) 0%, rgba(197,160,89,0.06) 70%, transparent 100%);
  text-shadow: 0 0 10px rgba(197,160,89,0.3);
  box-shadow: inset 0 0 12px rgba(197,160,89,0.08);
}
.menu-item.active {
  color: var(--gold-accent);
  border-left-color: var(--gold-accent);
  font-weight: 500;
  background: linear-gradient(90deg, rgba(197,160,89,0.15) 0%, rgba(197,160,89,0.05) 60%, transparent 100%);
  text-shadow: 0 1px 3px rgba(0,0,0,0.3);
}
.menu-item.active::before {
  content: '';
  position: absolute; left: 0; top: 0; bottom: 0; width: 3px;
  background: linear-gradient(180deg, #e8c872, #c5a059, #a8853e);
  box-shadow: 0 0 8px rgba(197,160,89,0.4);
}
.menu-icon {
  width: 24px; text-align: center; font-size: 15px; flex-shrink: 0;
  line-height: 1; filter: grayscale(0.2);
}
.menu-item.active .menu-icon,
.menu-item:hover .menu-icon {
  filter: none; transform: scale(1.05);
}
.menu-label {
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* ─── INDICATEUR DE SYNC ─── */
.sync-indicator {
  padding: 8px 18px;
  display: flex; align-items: center; gap: 8px;
  font-size: 11px; color: #5a6a80;
}
.sync-dot {
  width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0;
}
.sync-dot.online  {
  background: radial-gradient(circle at 3px 3px, #2ecc71, #16a34a);
  box-shadow: 0 0 6px rgba(22,163,74,0.5), inset 0 -1px 2px rgba(0,0,0,0.3);
}
.sync-dot.offline {
  background: radial-gradient(circle at 3px 3px, #f59e0b, #d97706);
  box-shadow: 0 0 6px rgba(217,119,6,0.5);
}

/* ─── MAIN CONTENT ─── */
.main-content {
  flex: 1; overflow-y: auto; padding: 35px 40px;
  scrollbar-width: thin; scrollbar-color: #d4c5a9 transparent;
}
.main-content::-webkit-scrollbar { width: 6px; }
.main-content::-webkit-scrollbar-thumb { background: #d4c5a9; border-radius: 10px; }

/* ─── PAGE HEADER ─── */
.page-header, .toolbar {
  display: flex; align-items: flex-start;
  justify-content: space-between; margin-bottom: 28px;
}
.page-title, .page-header h1 {
  font-family: var(--font-display); font-size: 28px;
  color: var(--text-main); font-weight: 700;
}
.page-subtitle, .page-header .subtitle {
  font-size: 14px; color: var(--text-subtle); margin-top: 4px;
}

/* ─── BOUTONS ─── */
.btn-primary {
  display: inline-flex; align-items: center; gap: 8px;
  background: linear-gradient(135deg, #c5a059 0%, #a8853e 50%, #c5a059 100%);
  color: #fff; padding: 10px 22px; border-radius: 10px;
  font-weight: 600; font-size: 13px; transition: all 0.2s;
  box-shadow: 0 2px 8px rgba(197,160,89,0.3),
    inset 0 1px 0 rgba(255,255,255,0.2),
    inset 0 -1px 0 rgba(0,0,0,0.15);
  text-shadow: 0 1px 2px rgba(0,0,0,0.2);
}
.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(197,160,89,0.4),
    inset 0 1px 0 rgba(255,255,255,0.25);
}
.btn-secondary {
  padding: 9px 20px; border-radius: var(--radius-sm);
  font-weight: 500; font-size: 13px; background: var(--bg-muted);
  border: 1px solid rgba(197,160,89,0.2); color: #5a4a32; transition: all 0.2s;
}
.btn-secondary:hover { border-color: var(--gold-accent); color: var(--gold-accent); }
.btn-action {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 14px; border-radius: var(--radius-sm); font-size: 12px;
  font-weight: 500; border: 1px solid rgba(197,160,89,0.2);
  color: #5a4a32; background: var(--bg-muted); transition: all 0.2s;
}
.btn-action:hover { border-color: var(--gold-accent); color: var(--gold-accent); background: #fff; }
.btn-action svg { width: 13px; height: 13px; }

/* ─── KPI GRID ─── */
.kpi-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px; margin-bottom: 28px;
}
.kpi-card {
  background: var(--bg-card); border: 1px solid var(--border-gold);
  border-radius: var(--radius-md); padding: 18px 20px; transition: all 0.2s;
}
.kpi-card:hover { border-color: var(--border-gold-h); box-shadow: var(--shadow); }
.kpi-label {
  font-size: 10px; letter-spacing: 1px; text-transform: uppercase;
  color: var(--text-subtle); margin-bottom: 6px; font-weight: 600;
}
.kpi-value {
  font-family: var(--font); font-size: 24px;
  color: var(--text-main); font-weight: 700;
  font-variant-numeric: lining-nums tabular-nums;
}
.kpi-value.green { color: var(--success); }
.kpi-value.gold  { color: var(--gold-accent); }
.kpi-value.red   { color: var(--danger); }

/* ─── CARDS ─── */
.card {
  background: var(--bg-card); border: 1px solid var(--border-gold);
  border-radius: var(--radius-lg); overflow: hidden; transition: all 0.3s;
}
.card:hover {
  transform: translateY(-2px); box-shadow: var(--shadow-hover);
  border-color: var(--border-gold-h);
}

/* ─── MODALS (système unifié) ─── */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(26,18,8,0.5);
  display: none; align-items: center; justify-content: center;
  z-index: 1000; backdrop-filter: blur(4px);
}
.modal-overlay.active { display: flex; animation: nv-fadeIn 0.2s ease; }
.modal {
  background: #fff; border-radius: var(--radius-lg);
  width: 600px; max-width: 90vw; max-height: 85vh;
  overflow-y: auto; box-shadow: 0 20px 60px rgba(0,0,0,0.15);
  scrollbar-width: thin;
}
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 20px 24px; border-bottom: 1px solid var(--border-gold);
}
.modal-header h2 {
  font-family: var(--font-display); font-size: 20px; color: var(--text-main);
}
.modal-body { padding: 24px; }
.modal-footer {
  display: flex; justify-content: flex-end; gap: 10px;
  padding: 16px 24px; border-top: 1px solid var(--border-gold);
}
@keyframes nv-fadeIn { from { opacity: 0; } to { opacity: 1; } }

/* ─── TABS ─── */
.tabs, .detail-tabs {
  display: flex; gap: 0;
  border-bottom: 1px solid var(--border-gold);
  padding: 0 24px; overflow-x: auto;
}
.tab, .detail-tab, .tab-btn {
  padding: 12px 18px; font-size: 13px; font-weight: 500;
  color: var(--text-subtle); border-bottom: 2px solid transparent;
  transition: all 0.2s; white-space: nowrap; cursor: pointer;
  background: none; border-top: none; border-left: none; border-right: none;
}
.tab:hover, .detail-tab:hover, .tab-btn:hover { color: #5a4a32; }
.tab.active, .detail-tab.active, .tab-btn.active {
  color: var(--gold-accent); border-bottom-color: var(--gold-accent); font-weight: 600;
}

/* ─── TABLES ─── */
.nv-table, .data-table {
  width: 100%; border-collapse: separate; border-spacing: 0;
}
.nv-table th, .data-table th {
  text-align: left; font-size: 10px; text-transform: uppercase;
  letter-spacing: 0.5px; color: var(--text-subtle); padding: 10px 14px;
  border-bottom: 1px solid var(--border-gold); font-weight: 600;
}
.nv-table td, .data-table td {
  padding: 12px 14px; border-bottom: 1px solid rgba(197,160,89,0.06); font-size: 13px;
}
.nv-table tr:hover td, .data-table tr:hover td {
  background: rgba(197,160,89,0.03);
}

/* ─── BADGES ─── */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 10px; border-radius: 20px; font-size: 11px; font-weight: 600;
}
.badge-success, .badge.green { background: #e6f5ec; color: var(--success); }
.badge-danger, .badge.red    { background: #fef3f3; color: var(--danger); }
.badge-warning, .badge.orange { background: #fff3da; color: #a67c00; }
.badge-info, .badge.blue     { background: #e8ecf5; color: var(--info); }

/* ─── FORMULAIRES ─── */
.form-group { margin-bottom: 16px; }
.form-label {
  display: block; font-size: 11px; text-transform: uppercase;
  letter-spacing: 0.5px; color: var(--text-subtle);
  font-weight: 600; margin-bottom: 6px;
}
.form-input, .form-select {
  width: 100%; padding: 10px 14px;
  border: 1px solid rgba(197,160,89,0.2); border-radius: var(--radius-sm);
  font-size: 14px; font-family: var(--font); color: var(--text-main);
  background: var(--bg-muted); transition: border-color 0.2s;
}
.form-input:focus, .form-select:focus {
  outline: none; border-color: var(--gold-accent); background: #fff;
}
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }

/* ─── GRIDS UTILITAIRES ─── */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
.two-col { display: grid; grid-template-columns: 2fr 1fr; gap: 24px; }

/* ─── RESPONSIVE ─── */
@media (max-width: 1024px) {
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .grid-3 { grid-template-columns: 1fr 1fr; }
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .two-col { grid-template-columns: 1fr; }
}
@media (max-width: 768px) {
  .sidebar { display: none; }
  .main-content { padding: 20px 16px; }
  .kpi-grid { grid-template-columns: 1fr 1fr; }
  .form-row { grid-template-columns: 1fr; }
  .grid-2 { grid-template-columns: 1fr; }
}

/* ─── TOOLTIP pour sidebar collapsed ─── */
.sidebar.collapsed .menu-item:hover::after {
  content: attr(title);
  position: absolute; left: 100%; top: 50%; transform: translateY(-50%);
  background: linear-gradient(135deg, #1e2a3a, #0e1825);
  color: var(--gold-light); padding: 6px 14px;
  border-radius: 8px; font-size: 12px; white-space: nowrap;
  box-shadow: 0 4px 16px rgba(0,0,0,0.35); z-index: 200;
  margin-left: 10px; pointer-events: none;
  border: 1px solid rgba(197,160,89,0.2);
}
