/* ── Variables ─────────────────────────────────────────────── */
:root {
  --primary:      #2563eb;
  --primary-dark: #1d4ed8;
  --success:      #16a34a;
  --warning:      #d97706;
  --danger:       #dc2626;
  --secondary:    #6b7280;
  --bg:           #f8fafc;
  --surface:      #ffffff;
  --border:       #e2e8f0;
  --text:         #1e293b;
  --text-muted:   #64748b;
  --nav-bg:       #1e293b;
  --nav-text:     #f1f5f9;
  --radius:       8px;
  --shadow:       0 1px 3px rgba(0,0,0,.1), 0 1px 2px rgba(0,0,0,.06);
}

/* ── Reset & base ──────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; }
body {
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Navigation ────────────────────────────────────────────── */
.navbar {
  background: var(--nav-bg);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: .75rem 1.5rem;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 4px rgba(0,0,0,.2);
}
.nav-brand {
  color: var(--nav-text);
  font-weight: 700;
  font-size: 1.1rem;
  text-decoration: none;
}
.nav-links { display: flex; align-items: center; gap: .25rem; }
.nav-links a {
  color: #94a3b8;
  text-decoration: none;
  padding: .4rem .8rem;
  border-radius: var(--radius);
  font-size: .9rem;
  transition: background .15s, color .15s;
}
.nav-links a:hover,
.nav-links a.active {
  background: rgba(255,255,255,.1);
  color: var(--nav-text);
}
.nav-logout { margin-left: 1rem; color: #f87171 !important; }

/* ── Container ─────────────────────────────────────────────── */
.container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 1.5rem;
}

/* ── Page header ───────────────────────────────────────────── */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
  gap: .5rem;
}
.page-header h2 {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--text);
}

/* ── Cards ─────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.card-header {
  padding: .875rem 1.25rem;
  border-bottom: 1px solid var(--border);
  background: #f8fafc;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: .5rem;
}
.card-header h3 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
}
.card-body { padding: 1.25rem; }
.mt-1 { margin-top: 1rem; }
.mt-2 { margin-top: 1.5rem; }

/* ── Grid ──────────────────────────────────────────────────── */
.row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
  gap: 1.25rem;
}

/* ── Stats ─────────────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  text-align: center;
  box-shadow: var(--shadow);
}
.stat-card-success { border-top: 3px solid var(--success); }
.stat-card-warning { border-top: 3px solid var(--warning); }
.stat-card-danger  { border-top: 3px solid var(--danger); }
.stat-number {
  font-size: 2rem;
  font-weight: 800;
  color: var(--primary);
  line-height: 1;
}
.stat-label {
  font-size: .8rem;
  color: var(--text-muted);
  margin-top: .35rem;
  text-transform: uppercase;
  letter-spacing: .04em;
}

/* ── Quick links ───────────────────────────────────────────── */
.quick-links {
  display: flex;
  flex-direction: column;
  gap: .5rem;
}
.quick-link {
  display: block;
  padding: .75rem 1rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  text-decoration: none;
  font-weight: 500;
  transition: background .15s, border-color .15s;
}
.quick-link:hover {
  background: #eff6ff;
  border-color: var(--primary);
  color: var(--primary);
  text-decoration: none;
}

/* ── Boutons ───────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  padding: .5rem 1rem;
  border-radius: var(--radius);
  border: none;
  cursor: pointer;
  font-size: .875rem;
  font-weight: 500;
  text-decoration: none;
  transition: background .15s, opacity .15s;
  white-space: nowrap;
}
.btn:hover { opacity: .88; text-decoration: none; }
.btn-primary   { background: var(--primary);   color: #fff; }
.btn-success   { background: var(--success);   color: #fff; }
.btn-warning   { background: var(--warning);   color: #fff; }
.btn-danger    { background: var(--danger);    color: #fff; }
.btn-secondary { background: #e2e8f0;          color: var(--text); }
.btn-sm   { padding: .3rem .65rem; font-size: .8rem; }
.btn-lg   { padding: .7rem 1.5rem; font-size: 1rem; }
.btn-full { width: 100%; justify-content: center; }
.btn-group { display: flex; gap: .5rem; flex-wrap: wrap; }

/* ── Tables ────────────────────────────────────────────────── */
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: .875rem;
}
.table th,
.table td {
  padding: .6rem .875rem;
  border-bottom: 1px solid var(--border);
  text-align: left;
}
.table th {
  font-weight: 600;
  color: var(--text-muted);
  background: #f8fafc;
  font-size: .8rem;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.table tbody tr:hover { background: #f8fafc; }
.table-sm th,
.table-sm td { padding: .4rem .75rem; }

/* ── Formulaires ───────────────────────────────────────────── */
.form-group {
  margin-bottom: 1rem;
}
.form-group label {
  display: block;
  font-size: .875rem;
  font-weight: 500;
  margin-bottom: .35rem;
  color: var(--text);
}
.form-check label {
  display: flex;
  align-items: center;
  gap: .5rem;
  cursor: pointer;
  font-weight: 400;
}
.form-control {
  width: 100%;
  padding: .5rem .75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: .875rem;
  color: var(--text);
  background: #fff;
  transition: border-color .15s, box-shadow .15s;
}
.form-control:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,.15);
}
.form-control[readonly] {
  background: var(--bg);
  color: var(--text-muted);
}
textarea.form-control { resize: vertical; min-height: 80px; }
.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0 1rem;
}
.form-actions {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-top: 1.5rem;
  padding: 1rem 0;
  border-top: 1px solid var(--border);
}
.required { color: var(--danger); }

/* ── Badges ────────────────────────────────────────────────── */
.badge {
  display: inline-block;
  padding: .2rem .55rem;
  border-radius: 999px;
  font-size: .75rem;
  font-weight: 600;
}
.badge-success   { background: #dcfce7; color: var(--success); }
.badge-warning   { background: #fef3c7; color: var(--warning); }
.badge-danger    { background: #fee2e2; color: var(--danger); }
.badge-secondary { background: #f1f5f9; color: var(--secondary); }
.badge-primary   { background: #dbeafe; color: var(--primary); }

/* ── Alertes ───────────────────────────────────────────────── */
.alert {
  padding: .875rem 1.25rem;
  border-radius: var(--radius);
  margin-bottom: 1rem;
  font-size: .9rem;
}
.alert-success { background: #dcfce7; color: #166534; border: 1px solid #bbf7d0; }
.alert-error   { background: #fee2e2; color: #991b1b; border: 1px solid #fecaca; }

/* ── Search ────────────────────────────────────────────────── */
.search-form { margin-bottom: 1rem; }
.search-bar {
  display: flex;
  gap: .5rem;
  flex-wrap: wrap;
}
.search-input {
  flex: 1;
  min-width: 240px;
  padding: .5rem .875rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: .9rem;
}
.search-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,.15);
}
.results-info {
  color: var(--text-muted);
  font-size: .85rem;
  margin-bottom: .75rem;
}

/* ── Pagination ────────────────────────────────────────────── */
.pagination {
  display: flex;
  gap: .25rem;
  flex-wrap: wrap;
  margin-top: 1rem;
  justify-content: center;
}
.pagination a,
.pagination span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2rem;
  height: 2rem;
  padding: 0 .5rem;
  border-radius: var(--radius);
  font-size: .85rem;
  color: var(--text);
  border: 1px solid var(--border);
  background: var(--surface);
  text-decoration: none;
}
.pagination a:hover { background: var(--bg); text-decoration: none; }
.pagination a.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

/* ── Export grid ───────────────────────────────────────────── */
.export-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 1.25rem;
}
.export-card .card-header {
  background: #f8fafc;
}

/* ── Utilitaires ───────────────────────────────────────────── */
.text-center  { text-align: center; }
.text-muted   { color: var(--text-muted); }
.text-sm      { font-size: .8rem; }
.text-success { color: var(--success); }
.text-danger  { color: var(--danger); }
hr { border: none; border-top: 1px solid var(--border); margin: 1rem 0; }
code {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: .1rem .35rem;
  font-size: .8rem;
  word-break: break-all;
}

/* ── Page de connexion ─────────────────────────────────────── */
body.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #1e293b 0%, #2563eb 100%);
}
.login-box {
  background: var(--surface);
  border-radius: 12px;
  padding: 2.5rem;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 20px 60px rgba(0,0,0,.3);
}
.login-box h1 {
  font-size: 1.6rem;
  font-weight: 800;
  color: var(--text);
  margin-bottom: .25rem;
}
.login-subtitle {
  color: var(--text-muted);
  margin-bottom: 1.75rem;
}

/* ── Responsive ────────────────────────────────────────────── */
@media (max-width: 640px) {
  .navbar { padding: .6rem 1rem; }
  .nav-links a { padding: .35rem .5rem; font-size: .8rem; }
  .container { padding: 1rem; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .form-row { grid-template-columns: 1fr; }
  .page-header { flex-direction: column; align-items: flex-start; }
}
