/* ============================================================
   SO.DI.CE Backoffice — Feuille de style
   Police : Figtree (Google Fonts)
   Palette : bleu marine SO.DI.CE + accents cyan
============================================================ */

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

:root {
  --bg:           #0f1117;
  --surface:      #1a1d27;
  --surface-2:    #22263a;
  --border:       #2e3250;
  --border-light: #3a3f62;

  --primary:      #3d6bff;
  --primary-dark: #2a52d4;
  --primary-glow: rgba(61,107,255,.18);

  --cyan:         #00c8e0;
  --cyan-dim:     rgba(0,200,224,.12);

  --text:         #e8eaf6;
  --text-dim:     #8b90b8;
  --text-muted:   #555a80;

  --success:      #22c55e;
  --warning:      #f59e0b;
  --danger:       #ef4444;
  --info:         #38bdf8;

  --sidebar-w:    240px;
  --radius:       10px;
  --radius-sm:    6px;
  --shadow:       0 4px 24px rgba(0,0,0,.4);

  font-family: 'Figtree', system-ui, sans-serif;
  color: var(--text);
  background: var(--bg);
  font-size: 14px;
  line-height: 1.55;
}

/* ---- Layout -------------------------------------------- */
body { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  min-height: 100vh;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
}

.main-content {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  background: var(--bg);
}

/* ---- Sidebar ------------------------------------------- */
.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 20px 16px;
  border-bottom: 1px solid var(--border);
  font-weight: 700;
  font-size: 15px;
  color: var(--text);
}
.sidebar-logo img { height: 32px; object-fit: contain; }

.sidebar-nav {
  flex: 1;
  padding: 12px 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  text-decoration: none;
  color: var(--text-dim);
  font-weight: 500;
  font-size: 13.5px;
  transition: all .15s;
  position: relative;
}
.nav-item svg { width: 18px; height: 18px; flex-shrink: 0; }
.nav-item:hover  { background: var(--surface-2); color: var(--text); }
.nav-item.active { background: var(--primary-glow); color: var(--primary); }
.nav-item.active::before {
  content: '';
  position: absolute;
  left: 0; top: 20%; bottom: 20%;
  width: 3px;
  border-radius: 3px;
  background: var(--primary);
}

.badge {
  margin-left: auto;
  background: var(--danger);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 999px;
  min-width: 20px;
  text-align: center;
}

.sidebar-footer {
  padding: 12px 14px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
}
.user-info { display: flex; align-items: center; gap: 9px; flex: 1; min-width: 0; }
.user-avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--primary);
  display: grid; place-items: center;
  font-weight: 700; font-size: 14px; flex-shrink: 0;
}
.user-name { font-weight: 600; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { font-size: 11px; color: var(--text-muted); text-transform: capitalize; }
.logout-btn {
  width: 32px; height: 32px; border-radius: var(--radius-sm);
  display: grid; place-items: center;
  color: var(--text-muted); text-decoration: none; flex-shrink: 0;
  transition: all .15s;
}
.logout-btn:hover { background: rgba(239,68,68,.15); color: var(--danger); }
.logout-btn svg { width: 17px; height: 17px; }

/* ---- Topbar -------------------------------------------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 28px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}
.page-title { font-size: 20px; font-weight: 700; }
.topbar-right { display: flex; gap: 8px; }

/* ---- Content ------------------------------------------- */
.content-wrapper { padding: 24px 28px; }

/* ---- Buttons ------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-family: inherit; font-size: 13.5px; font-weight: 600;
  border: none; cursor: pointer; text-decoration: none;
  transition: all .15s;
  white-space: nowrap;
}
.btn-primary  { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-danger   { background: rgba(239,68,68,.15); color: var(--danger); border: 1px solid rgba(239,68,68,.3); }
.btn-danger:hover { background: var(--danger); color: #fff; }
.btn-ghost    { background: var(--surface-2); color: var(--text-dim); border: 1px solid var(--border); }
.btn-ghost:hover { color: var(--text); border-color: var(--border-light); }
.btn-success  { background: rgba(34,197,94,.15); color: var(--success); border: 1px solid rgba(34,197,94,.3); }
.btn-success:hover { background: var(--success); color: #fff; }
.btn-sm { padding: 5px 11px; font-size: 12.5px; }
.btn svg { width: 15px; height: 15px; }

/* ---- Cards --------------------------------------------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}
.card-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 16px;
}
.card-title { font-size: 15px; font-weight: 700; }

/* ---- Stats grid ---------------------------------------- */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  display: flex; align-items: center; gap: 16px;
  transition: border-color .2s;
}
.stat-card:hover { border-color: var(--border-light); }
.stat-icon {
  width: 48px; height: 48px; border-radius: 12px;
  display: grid; place-items: center; flex-shrink: 0;
}
.stat-icon svg { width: 22px; height: 22px; }
.stat-icon.blue   { background: var(--primary-glow); color: var(--primary); }
.stat-icon.cyan   { background: var(--cyan-dim); color: var(--cyan); }
.stat-icon.green  { background: rgba(34,197,94,.12); color: var(--success); }
.stat-icon.orange { background: rgba(245,158,11,.12); color: var(--warning); }
.stat-value { font-size: 28px; font-weight: 700; line-height: 1; }
.stat-label { font-size: 12px; color: var(--text-dim); margin-top: 3px; }
.stat-sub   { font-size: 11px; color: var(--text-muted); margin-top: 2px; }

/* ---- Tables -------------------------------------------- */
.table-wrap { overflow-x: auto; border-radius: var(--radius); border: 1px solid var(--border); }
table { width: 100%; border-collapse: collapse; background: var(--surface); }
thead th {
  text-align: left; padding: 11px 14px;
  font-size: 11.5px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .04em; color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
tbody td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--border);
  font-size: 13.5px; vertical-align: middle;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: var(--surface-2); }

/* ---- Badges statut ------------------------------------- */
.status {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11.5px; font-weight: 600;
  padding: 3px 9px; border-radius: 999px;
}
.status::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.status-nouveau  { background: rgba(61,107,255,.15); color: var(--primary); }
.status-lu       { background: rgba(245,158,11,.15); color: var(--warning); }
.status-traite   { background: rgba(34,197,94,.15); color: var(--success); }
.status-archive  { background: rgba(139,144,184,.12); color: var(--text-muted); }
.status-actif    { background: rgba(34,197,94,.15); color: var(--success); }
.status-inactif  { background: rgba(239,68,68,.12); color: var(--danger); }

/* ---- Formulaires --------------------------------------- */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-full  { grid-column: 1 / -1; }
.form-group { display: flex; flex-direction: column; gap: 6px; }
label { font-size: 12.5px; font-weight: 600; color: var(--text-dim); }
input[type="text"],
input[type="email"],
input[type="password"],
input[type="tel"],
input[type="url"],
select,
textarea {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: inherit; font-size: 13.5px;
  padding: 9px 12px;
  transition: border-color .15s;
  width: 100%;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
}
select { appearance: none; cursor: pointer; }
textarea { resize: vertical; min-height: 100px; }

/* ---- Alerts -------------------------------------------- */
.alert {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 16px; border-radius: var(--radius-sm);
  margin: 0 28px 16px; font-size: 13.5px; font-weight: 500;
}
.alert-close {
  margin-left: auto; background: none; border: none;
  color: inherit; cursor: pointer; font-size: 18px; line-height: 1;
}
.alert-success { background: rgba(34,197,94,.12);  border: 1px solid rgba(34,197,94,.3);  color: var(--success); }
.alert-error   { background: rgba(239,68,68,.12);  border: 1px solid rgba(239,68,68,.3);  color: var(--danger); }
.alert-info    { background: rgba(56,189,248,.12); border: 1px solid rgba(56,189,248,.3); color: var(--info); }

/* ---- Dashboard charts ---------------------------------- */
.chart-bar { display: flex; align-items: flex-end; gap: 6px; height: 80px; }
.chart-bar-item {
  flex: 1; background: var(--primary-glow); border-radius: 4px 4px 0 0;
  border: 1px solid rgba(61,107,255,.3); position: relative;
  transition: background .2s;
  min-width: 14px;
}
.chart-bar-item:hover { background: var(--primary-glow); border-color: var(--primary); }

/* ---- Mini chart donut ---------------------------------- */
.donut-wrap { display: flex; align-items: center; gap: 20px; }
.donut-legend { display: flex; flex-direction: column; gap: 6px; }
.legend-item { display: flex; align-items: center; gap: 8px; font-size: 12.5px; }
.legend-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }

/* ---- Login page ---------------------------------------- */
body:has(.login-page) {
  display: block;
}
.login-page {
  min-height: 100vh; display: grid; place-items: center;
  background: var(--bg);
}
.login-box {
  width: 100%; max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 36px 32px;
  box-shadow: var(--shadow);
}
.login-logo { text-align: center; margin-bottom: 24px; }
.login-logo img { height: 44px; object-fit: contain; }
.login-title { font-size: 20px; font-weight: 700; text-align: center; margin-bottom: 4px; }
.login-sub { font-size: 13px; color: var(--text-dim); text-align: center; margin-bottom: 24px; }

/* ---- Modal --------------------------------------------- */
.modal-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,.7); z-index: 200;
  place-items: center;
}
.modal-overlay.open { display: grid; }
.modal {
  background: var(--surface); border: 1px solid var(--border-light);
  border-radius: var(--radius); box-shadow: var(--shadow);
  width: 90%; max-width: 580px; max-height: 90vh;
  overflow-y: auto; padding: 24px;
  animation: modal-in .15s ease;
}
@keyframes modal-in { from { opacity: 0; transform: translateY(-12px); } }
.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }
.modal-title { font-size: 16px; font-weight: 700; }
.modal-close {
  background: none; border: none; color: var(--text-dim);
  font-size: 22px; cursor: pointer; line-height: 1;
  transition: color .15s;
}
.modal-close:hover { color: var(--text); }

/* ---- Utils --------------------------------------------- */
.text-right { text-align: right; }
.text-dim   { color: var(--text-dim); }
.text-muted { color: var(--text-muted); }
.flex       { display: flex; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2  { gap: 8px; }
.gap-3  { gap: 12px; }
.mt-4   { margin-top: 16px; }
.mt-6   { margin-top: 24px; }
.mb-4   { margin-bottom: 16px; }
.mb-6   { margin-bottom: 24px; }
.w-full { width: 100%; }

.empty-state {
  text-align: center; padding: 48px 24px;
  color: var(--text-muted);
}
.empty-state svg { width: 48px; height: 48px; margin-bottom: 12px; opacity: .4; }
.empty-state p { font-size: 14px; }

/* ---- Scrollbar ----------------------------------------- */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-light); border-radius: 3px; }

/* ---- Responsive ---------------------------------------- */
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); transition: transform .25s; }
  .sidebar.open { transform: none; }
  .main-content { margin-left: 0; }
  .form-grid { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .content-wrapper { padding: 16px; }
}