/* ============================================================
   admin/assets/css/admin.css — Styles back-office
   v2 — Design system "Registre" (encre, béton, patine de cuivre)
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Fraunces:opsz,wght@9..144,340..600&family=Archivo:wght@400;500;600;700&family=IBM+Plex+Mono:wght@400;500;600&display=swap');

:root {
  /* ---- Palette ---- */
  --bg: #E7E9E4;              /* concrete — fond de page */
  --sidebar-bg: #1C2333;      /* ink */
  --sidebar-text: #C7CCD6;
  --sidebar-active: #4B7A6E;  /* verdigris */
  --surface: #FBFAF8;         /* paper */
  --border: #D7D9D3;          /* line */
  --border-strong: #C3C6BE;
  --text: #1C2333;            /* ink */
  --text-muted: #5B6472;      /* slate */
  --accent: #35594F;          /* verdigris-deep */
  --accent-hover: #2A473F;
  --accent-tint: #E3ECE9;
  --green: #35594F;
  --orange: #B98A3E;          /* brass */
  --orange-tint: #F3EADA;
  --red: #B5503E;             /* brick */
  --red-tint: #F6E4E0;
  --sidebar-width: 240px;
  --header-height: 60px;

  --font-display: 'Fraunces', serif;
  --font-body: 'Archivo', sans-serif;
  --font-mono: 'IBM Plex Mono', monospace;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 14px; }
body { font-family: var(--font-body); background: var(--bg); color: var(--text); line-height: 1.5; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { font-family: var(--font-display); font-weight: 500; letter-spacing: -0.01em; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

/* ---- LAYOUT ---- */
.page-wrapper { display: flex; min-height: calc(100vh - var(--header-height)); }

/* ---- HEADER ---- */
.admin-header {
  position: fixed; top: 0; left: 0; right: 0; z-index: 100;
  height: var(--header-height);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 20px 0 calc(var(--sidebar-width) + 20px);
}
.header-title { font-size: 15px; font-weight: 600; color: var(--text); }
.header-user { display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--text-muted); }
.header-avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--accent); color: white;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-mono); font-weight: 600; font-size: 12px;
}

/* ---- SIDEBAR ---- */
.sidebar {
  position: fixed; top: var(--header-height); left: 0; bottom: 0;
  width: var(--sidebar-width); background: var(--sidebar-bg);
  overflow-y: auto; z-index: 50;
  display: flex; flex-direction: column;
}
.sidebar-logo {
  padding: 20px 16px 12px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}
.sidebar-logo h2 { color: white; font-family: var(--font-display); font-size: 18px; font-weight: 500; }
.sidebar-logo p { color: var(--sidebar-text); font-size: 11px; margin-top: 2px; font-family: var(--font-mono); letter-spacing: 0.04em; }

.sidebar-section { padding: 16px 10px 8px; }
.sidebar-section-title {
  color: #6B7280; font-family: var(--font-mono); font-size: 10px; font-weight: 500;
  text-transform: uppercase; letter-spacing: 0.1em;
  padding: 0 6px; margin-bottom: 6px;
}
.sidebar-link {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; border-radius: 8px; color: var(--sidebar-text);
  font-size: 13.5px; font-weight: 500; transition: background 0.15s, color 0.15s; cursor: pointer;
  text-decoration: none;
}
.sidebar-link:hover { background: rgba(255,255,255,0.07); color: white; text-decoration: none; }
.sidebar-link.active { background: var(--sidebar-active); color: white; }
.sidebar-link.active .sidebar-icon { color: white; }
.sidebar-icon { font-size: 15px; width: 20px; text-align: center; }

.sidebar-footer {
  margin-top: auto; padding: 12px 10px;
  border-top: 1px solid rgba(255,255,255,0.08);
}

/* ---- MAIN ---- */
.main-content {
  margin-left: var(--sidebar-width);
  margin-top: var(--header-height);
  padding: 28px 32px; flex: 1;
}
.page-header { margin-bottom: 24px; }
.page-header h1 { font-size: 26px; font-weight: 500; }
.page-header p { color: var(--text-muted); margin-top: 4px; }

/* ---- KPI ---- */
.kpi-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 24px; }
.kpi-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; padding: 20px; display: flex; flex-direction: column; gap: 8px;
}
.kpi-icon {
  width: 40px; height: 40px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center; font-size: 18px;
}
.kpi-icon.blue { background: var(--accent-tint); }
.kpi-icon.green { background: var(--accent-tint); }
.kpi-icon.orange { background: var(--orange-tint); }
.kpi-icon.red { background: var(--red-tint); }
.kpi-value { font-family: var(--font-mono); font-size: 22px; font-weight: 600; color: var(--text); font-variant-numeric: tabular-nums; }
.kpi-label { font-size: 12px; color: var(--text-muted); }

/* ---- GRID ---- */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 20px; }

/* ---- CARD ---- */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; overflow: hidden;
}
.card-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px; border-bottom: 1px solid var(--border);
}
.card-header h2 { font-size: 16px; font-weight: 500; }
.card-body { padding: 20px; }

/* ---- TABLE ---- */
.table { width: 100%; border-collapse: collapse; }
.table th {
  background: transparent; padding: 0 16px 10px;
  font-family: var(--font-mono); font-size: 10.5px; font-weight: 500; text-transform: uppercase;
  letter-spacing: 0.06em; color: var(--text-muted);
  text-align: left; border-bottom: 1px solid var(--border-strong);
}
.table td { padding: 12px 16px; border-bottom: 1px solid var(--border); font-size: 13px; }
.table tr:last-child td { border-bottom: none; }
.table tr:hover td { background: rgba(75,122,110,0.05); }
.table .amount, .table td.text-right { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }

/* ---- BADGES ---- */
.badge {
  display: inline-block; padding: 3px 8px; border-radius: 5px;
  font-size: 11px; font-weight: 600; text-transform: capitalize;
}
.badge-tantiemes, .badge-validee { background: var(--accent-tint); color: var(--accent); }
.badge-groupe { background: var(--accent-tint); color: var(--accent); }
.badge-consommation { background: var(--orange-tint); color: #8A6526; }
.badge-brouillon { background: #EAEAE6; color: #5B6472; }
.badge-cloturee { background: var(--accent-tint); color: var(--accent); }
.badge-en_attente { background: var(--orange-tint); color: #8A6526; }
.badge-en_traitement { background: var(--accent-tint); color: var(--accent); }
.badge-paye { background: var(--accent-tint); color: var(--accent); }
.badge-en_retard { background: var(--red-tint); color: var(--red); }

/* ---- BUTTONS ---- */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  font-family: var(--font-body);
  padding: 9px 16px; border-radius: 8px; font-size: 13px;
  font-weight: 600; cursor: pointer; border: 1px solid var(--border-strong); transition: all 0.15s;
  text-decoration: none; background: var(--surface); color: var(--text);
}
.btn-primary { background: var(--accent); border-color: var(--accent); color: white; }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); text-decoration: none; color: white; }
.btn-secondary { background: var(--surface); color: var(--text); border: 1px solid var(--border-strong); }
.btn-secondary:hover { text-decoration: none; border-color: var(--accent); color: var(--accent); }
.btn-danger { background: var(--red); border-color: var(--red); color: white; }
.btn-sm { padding: 5px 12px; font-size: 12px; }

/* ---- FORMS ---- */
.form-group { margin-bottom: 16px; }
.form-label { display: block; font-size: 13px; font-weight: 500; color: var(--text); margin-bottom: 6px; }
.form-control {
  display: block; width: 100%; padding: 9px 12px;
  border: 1px solid var(--border-strong); border-radius: 8px;
  font-family: var(--font-body); font-size: 13px; color: var(--text); background: var(--surface);
  transition: border-color 0.15s;
}
.form-control:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-tint); }
.form-hint { font-size: 11px; color: var(--text-muted); margin-top: 4px; }

/* ---- ALERTS ---- */
.alert { padding: 12px 16px; border-radius: 8px; font-size: 13px; margin-bottom: 16px; border-left: 3px solid transparent; }
.alert-success { background: var(--accent-tint); border-left-color: var(--accent); color: var(--accent); }
.alert-error { background: var(--red-tint); border-left-color: var(--red); color: var(--red); }
.alert-warning { background: var(--orange-tint); border-left-color: var(--orange); color: #8A6526; }
.alert-info { background: var(--accent-tint); border-left-color: var(--accent); color: var(--accent); }

/* ---- QUICK ACTIONS ---- */
.quick-actions { display: flex; gap: 10px; padding: 16px 20px; flex-wrap: wrap; }
.quick-action-btn {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 18px; background: var(--surface); border: 1px solid var(--border-strong);
  border-radius: 999px; font-size: 13px; font-weight: 600; color: var(--text);
  cursor: pointer; transition: all 0.15s; text-decoration: none;
}
.quick-action-btn:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-tint); text-decoration: none; }

/* ---- UTILS ---- */
.text-muted { color: var(--text-muted); }
.text-center { text-align: center; }
.text-red { color: var(--red); }
.text-green { color: var(--green); }
.text-orange { color: var(--orange); }
.mt-4 { margin-top: 16px; }
.mb-4 { margin-bottom: 16px; }
.font-mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }

/* ---- MENU MOBILE (hamburger + overlay) ---- */
.menu-toggle {
  display: none;
  width: 34px; height: 34px;
  background: none; border: none; cursor: pointer;
  padding: 0; flex-shrink: 0;
  align-items: center; justify-content: center;
}
.menu-toggle span,
.menu-toggle span::before,
.menu-toggle span::after {
  display: block; width: 20px; height: 2px;
  background: var(--text); border-radius: 2px;
  transition: transform 0.2s, opacity 0.2s;
}
.menu-toggle span { position: relative; }
.menu-toggle span::before, .menu-toggle span::after { content: ''; position: absolute; left: 0; }
.menu-toggle span::before { top: -6px; }
.menu-toggle span::after { top: 6px; }
.sidebar.open ~ .sidebar-overlay,
.sidebar-overlay.open {
  display: block;
}
.sidebar-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(28,35,51,0.45);
  z-index: 45;
}

/* ---- RESPONSIVE ---- */
@media (max-width: 1024px) {
  .kpi-grid { grid-template-columns: 1fr 1fr; }
  .grid-2 { grid-template-columns: 1fr; }
}
@media (max-width: 768px) {
  :root { --sidebar-width: 0px; }
  .menu-toggle { display: flex; }
  .sidebar { transform: translateX(-100%); transition: transform 0.25s ease; width: 260px; }
  .sidebar.open { transform: translateX(0); }
  .admin-header { padding: 0 12px; }
  .header-copro-switch { min-width: 0 !important; max-width: 160px !important; font-size: 12px !important; padding: 6px 8px !important; }
  .header-user-name { display: none; }
  .kpi-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .main-content { padding: 16px; margin-left: 0; }
  .page-header { flex-direction: column; align-items: flex-start !important; gap: 10px; }
  .page-header h1 { font-size: 21px; }
  .hero-figure { font-size: 30px; }
  .hero-mini-stats { gap: 16px; }
  .table { display: block; overflow-x: auto; white-space: nowrap; }
}
@media (max-width: 480px) {
  .kpi-grid { grid-template-columns: 1fr; }
}
