/* Thèmes via variables CSS */

/* Thème clair par défaut */
:root {
  --bg: #f7f7f8;
  --surface: #ffffff;
  --surface-soft: #fafafa;
  --text: #1f2937;
  --text-dim: #6b7280;
  --primary: #d62d2d;      /* Rouge principal */
  --primary-700: #b71c1c;
  --accent: #f59e0b;
  --border: #e5e7eb;
  --muted: #e5e7eb;
  --success: #22c55e;
  --error: #ef4444;
  --shadow: 0 10px 30px rgba(0,0,0,0.08);
}

/* Overrides pour le thème sombre */
body.theme-dark {
  --bg: #0f172a;
  --surface: #0b1220;
  --surface-soft: #0e1626;
  --text: #e5e7eb;
  --text-dim: #cbd5e1;
  --primary: #ef4444;
  --primary-700: #dc2626;
  --accent: #f59e0b;
  --border: #1f2937;
  --muted: #334155;
  --success: #16a34a;
  --error: #ef4444;
  --shadow: 0 10px 30px rgba(0,0,0,0.35);
}

* { box-sizing: border-box; }
html, body { height: 100%; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Inter", "Helvetica Neue", Arial, "Noto Sans", "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Layout container */
.container {
  width: 100%;
  max-width: 980px;
  margin: 0 auto;
  padding: 20px;
}

/* Header */
.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 24px;
  margin: 0 auto;
  max-width: 980px;
  border-bottom: 1px solid var(--border);
}
.header .brand-logo { width: 52px; height: 52px; object-fit: contain; }
.header .title { margin: 0; font-size: 26px; letter-spacing: 0.2px; color: var(--primary); }
.header .subtitle { margin: 6px 0 0 0; color: var(--text-dim); font-size: 14px; }
.header .header-actions { display: flex; align-items: center; gap: 8px; }

/* Theme toggle bouton */
.theme-toggle.btn {
  background: transparent;
  color: var(--primary);
  border: 1px solid var(--primary);
  box-shadow: none;
  padding: 8px 12px;
  font-size: 13px;
}
.theme-toggle.btn:hover { filter: none; transform: none; background: rgba(214,45,45,0.06); }

/* Card */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 18px;
  margin-bottom: 16px;
}
.card.no-blur { backdrop-filter: none; }
.form-title { font-weight: 700; font-size: 20px; margin-bottom: 6px; color: var(--primary); }
.form-subtitle { color: var(--text-dim); font-size: 13px; margin-bottom: 14px; }

/* Inputs */
.input {
  width: 100%;
  padding: 12px 14px;
  background: var(--surface-soft);
  border: 1px solid var(--muted);
  border-radius: 12px;
  color: var(--text);
  outline: none;
  transition: border-color .15s ease, box-shadow .15s ease, background .15s ease;
}
.input::placeholder { color: #9ca3af; }
.input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(214, 45, 45, 0.22);
  background: #fff;
}
.label { display: block; font-size: 13px; color: var(--text-dim); margin: 8px 0 6px; }

/* Grid */
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 720px) { .row { grid-template-columns: 1fr; } }
.col { display: flex; flex-direction: column; }

/* Buttons */
.btn {
  display: inline-flex;
  gap: 8px;
  align-items: center;
  justify-content: center;
  padding: 12px 16px;
  border-radius: 12px;
  color: white;
  background: linear-gradient(180deg, var(--primary) 0%, var(--primary-700) 100%);
  border: 1px solid #b91c1c;
  cursor: pointer;
  text-decoration: none;
  transition: transform .08s ease, box-shadow .12s ease, filter .12s ease;
  box-shadow: 0 10px 20px rgba(214, 45, 45, 0.18);
}
.btn:hover { filter: brightness(1.05); transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn.btn-small { padding: 8px 12px; font-size: 13px; }

/* Table */
.table-container {
  overflow: auto;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface);
}
.table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
}
.table thead th {
  position: sticky;
  top: 0;
  background: #f3f4f6; /* clair comme maquette */
  color: var(--text);
  font-weight: 700;
  text-align: left;
  padding: 12px;
  border-bottom: 1px solid var(--border);
}
body.theme-dark .table thead th {
  background: #0c1628;
}
.table tbody td {
  padding: 12px;
  border-bottom: 1px solid var(--border);
}
.table tbody tr:hover { background: #fff7f7; }
body.theme-dark .table tbody tr:hover { background: #0a1324; }

/* Badges (groupes, statuts) */
.badge {
  display: inline-block;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 12px;
  border: 1px solid var(--border);
  background: #fdecec;
  color: var(--primary);
}
.badge.muted { background: #f3f4f6; color: var(--text-dim); }

/* Alerts */
.success, .error {
  padding: 12px 14px;
  border-radius: 12px;
  margin: 8px 0 12px;
  border: 1px solid transparent;
}
.success {
  background: #ecfdf5;
  border-color: #86efac;
  color: #166534;
}
.error {
  background: #fef2f2;
  border-color: #fecaca;
  color: #7f1d1d;
}

/* Footer */
.footer { color: var(--text-dim); text-align: center; font-size: 12px; padding: 16px 0 24px; }

/* Réduction des flickers table (sombre) */
.table-container { -webkit-backface-visibility: hidden; backface-visibility: hidden; transform: translateZ(0); }


/* Centrage plein écran du formulaire */
.page {
  min-height: calc(100vh - 160px);
  display: grid;
  place-items: center;
  padding: 16px 24px;
}

/* Carte de formulaire centrée et contrainte */
.card.center-card {
  width: 100%;
  max-width: 600px; /* cible desktop */
  margin: 0 auto;
}

/* Grille du formulaire: 2 colonnes sur desktop */
.row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

/* Responsive mobile */
@media (max-width: 640px) {
  .card.center-card {
    max-width: 100%;
    border-radius: 16px;
    padding: 16px;
  }
  .row {
    grid-template-columns: 1fr; /* une colonne sur mobile */
  }
}

/* Actions du formulaire centrées */
.form-actions {
  display: flex;
  justify-content: center;
  margin-top: 16px;
}

/* Réduction du logo pour éviter la casse mise en page */
.header .brand-logo { width: 52px; height: 52px; object-fit: contain; }

/* Option: resserrer un peu les inputs sur petits écrans */
@media (max-width: 480px) {
  .card.center-card { padding: 16px; }
}