/* ═══════════════════════════════════════════════════════════════
   GestÉglise — Design System
   Palette : Luxury Dark + Gold accents
══════════════════════════════════════════════════════════════ */

/* ── Thème SOMBRE (défaut) ───────────────────────────────── */
:root {
  --bg-deep:    #070b13;
  --bg-dark:    #0d1525;
  --bg-mid:     #131d30;
  --bg-panel:   #192035;
  --bg-card:    #1e2840;
  --bg-hover:   #243050;
  --gold:       #c9a84c;
  --gold-light: #e8c97a;
  --gold-dim:   #8a6f2e;
  --blue:       #3b82f6;
  --blue-soft:  #60a5fa;
  --teal:       #14b8a6;
  --rose:       #f43f5e;
  --violet:     #8b5cf6;
  --emerald:    #10b981;
  --amber:      #f59e0b;
  --text-h:     #eef2ff;
  --text-body:  #94a3b8;
  --text-dim:   #8499b4;  /* éclairci pour lisibilité sur fond sombre */
  --border:     #1e2d45;
  --border-lit: #2a3d5c;
  --sidebar-w:  240px;
  --topbar-h:   60px;
  --radius:     10px;
  --radius-sm:  6px;
  --shadow:     0 4px 24px rgba(0,0,0,.45);
  --shadow-gold:0 0 0 2px rgba(201,168,76,.18);
  --font-serif: Georgia, 'Times New Roman', serif;
  --font-ui:    'Segoe UI', system-ui, -apple-system, sans-serif;
  --font-mono:  'JetBrains Mono', 'Fira Code', monospace;
  /* toggle icon */
  --theme-icon: '☀️';
}

/* ── Thème CLAIR ─────────────────────────────────────────── */
[data-theme="light"] {
  --bg-deep:    #f0f2f7;
  --bg-dark:    #f8f9fc;
  --bg-mid:     #ffffff;
  --bg-panel:   #ffffff;
  --bg-card:    #f3f5fb;
  --bg-hover:   #e8ecf6;
  --gold:       #a07828;
  --gold-light: #7a5a1a;
  --gold-dim:   #c9a84c;
  --blue:       #2563eb;
  --blue-soft:  #1d4ed8;
  --teal:       #0d9488;
  --rose:       #e11d48;
  --violet:     #7c3aed;
  --emerald:    #059669;
  --amber:      #d97706;
  --text-h:     #111827;
  --text-body:  #374151;
  --text-dim:   #9ca3af;
  --border:     #e2e8f0;
  --border-lit: #cbd5e1;
  --shadow:     0 4px 24px rgba(0,0,0,.10);
  --shadow-gold:0 0 0 2px rgba(160,120,40,.18);
  /* toggle icon */
  --theme-icon: '🌙';
}

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

html { font-size: 14px; scroll-behavior: smooth; }

body {
  font-family: var(--font-ui);
  background: var(--bg-dark);
  color: var(--text-body);
  min-height: 100vh;
}

a { color: var(--gold); text-decoration: none; }
a:hover { color: var(--gold-light); }

/* ── Scrollbar ───────────────────────────────────────────── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: var(--bg-mid); }
::-webkit-scrollbar-thumb { background: var(--border-lit); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--gold-dim); }

/* ── Buttons ─────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 9px 18px; border-radius: var(--radius-sm);
  font-size: .85rem; font-weight: 600; cursor: pointer;
  border: 1px solid var(--border-lit);
  background: var(--bg-panel); color: var(--text-h);
  transition: all .18s ease;
  white-space: nowrap;
}
.btn:hover { background: var(--bg-hover); border-color: var(--gold-dim); color: var(--gold-light); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: default; }

.btn-gold {
  background: linear-gradient(135deg, var(--gold), var(--gold-dim));
  color: var(--bg-deep); border-color: transparent;
}
.btn-gold:hover { background: linear-gradient(135deg, var(--gold-light), var(--gold)); color: var(--bg-deep); border-color: transparent; }

.btn-danger  { background: #3d0f16; color: #fca5a5; border-color: #5c1018; }
.btn-danger:hover  { background: #5c1018; border-color: #8b1a2a; color: #fca5a5; }
.btn-success { background: #0a3325; color: #6ee7b7; border-color: #0a5c40; }
.btn-success:hover { background: #0a5c40; color: #6ee7b7; border-color: #0d7a56; }
.btn-warning { background: #3d2a08; color: #fcd34d; border-color: #7a5014; }
.btn-sm { padding: 5px 12px; font-size: .78rem; }
.btn-icon { padding: 7px 10px; }
.btn-full { width: 100%; justify-content: center; }

/* ── Forms ───────────────────────────────────────────────── */
.form-group { margin-bottom: 1rem; position: relative; }
.form-group label {
  display: block; margin-bottom: .4rem;
  font-size: .8rem; font-weight: 600;
  color: var(--text-body); letter-spacing: .4px;
}
.form-group .icon { margin-right: 4px; }

input[type="text"], input[type="password"], input[type="email"],
input[type="number"], input[type="date"], input[type="tel"],
input[type="time"], select, textarea {
  width: 100%; padding: 9px 14px;
  background: var(--bg-panel); color: var(--text-h);
  border: 1px solid var(--border-lit); border-radius: var(--radius-sm);
  font-family: var(--font-ui); font-size: .88rem;
  transition: border-color .2s, background .2s;
  outline: none;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--gold); background: var(--bg-hover);
  box-shadow: var(--shadow-gold);
}
input::placeholder, textarea::placeholder { color: var(--text-dim); }
select option { background: var(--bg-panel); color: var(--text-h); }
textarea { resize: vertical; min-height: 80px; }

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 1rem; }
@media (max-width: 640px) {
  .form-row, .form-row-3 { grid-template-columns: 1fr; }
}

/* ── Cards & Panels ──────────────────────────────────────── */
.card {
  background: var(--bg-panel); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1.5rem;
}
.card-title {
  font-family: var(--font-serif); font-size: 1.1rem;
  color: var(--text-h); margin-bottom: 1rem;
  display: flex; align-items: center; gap: .5rem;
}
.card-title .title-icon { font-size: 1.2rem; }

/* ── Stat Cards ───────────────────────────────────────────── */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(175px, 1fr));
  gap: 1rem; margin-bottom: 1.5rem;
}
.stat-card {
  background: var(--bg-panel); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1rem 1.2rem;
  display: flex; align-items: center; gap: .9rem;
  transition: border-color .2s, background .2s;
  cursor: default;
}
.stat-card:hover { background: var(--bg-card); border-color: var(--border-lit); }
.stat-icon {
  width: 44px; height: 44px; border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.4rem; flex-shrink: 0;
}
.stat-body { overflow: hidden; }
.stat-value {
  font-family: var(--font-serif); font-size: 1.5rem;
  font-weight: 700; color: var(--text-h);
  line-height: 1;
}
.stat-label {
  font-size: .68rem; text-transform: uppercase;
  letter-spacing: 1px; color: var(--text-body);
  margin-top: 3px; font-weight: 600;
}
.stat-sub { font-size: .75rem; color: var(--text-body); margin-top: 2px; }

/* ── Tables ──────────────────────────────────────────────── */
.table-wrap {
  overflow-x: auto; border-radius: var(--radius);
  border: 1px solid var(--border);
}
table {
  width: 100%; border-collapse: collapse;
  font-size: .85rem;
}
thead th {
  background: var(--bg-deep); color: var(--gold);
  padding: 10px 14px; text-align: left;
  font-size: .72rem; text-transform: uppercase; letter-spacing: 1px;
  font-weight: 700; white-space: nowrap;
  border-bottom: 1px solid var(--gold-dim);
}
thead th:first-child { border-radius: var(--radius) 0 0 0; }
thead th:last-child  { border-radius: 0 var(--radius) 0 0; }
tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background .15s;
}
tbody tr:hover { background: var(--bg-hover); }
tbody tr:last-child { border-bottom: none; }
tbody td { padding: 10px 14px; color: var(--text-body); vertical-align: middle; }
tbody td strong { color: var(--text-h); }
.td-center { text-align: center; }
.td-right  { text-align: right; }
.td-mono   { font-family: var(--font-mono); font-size: .8rem; }

/* ── Badges ──────────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 10px; border-radius: 20px;
  font-size: .7rem; font-weight: 700; text-transform: uppercase; letter-spacing: .6px;
}
.badge-gold    { background: rgba(201,168,76,.15); color: var(--gold); border: 1px solid rgba(201,168,76,.3); }
.badge-blue    { background: rgba(59,130,246,.15);  color: var(--blue-soft); border: 1px solid rgba(59,130,246,.3); }
.badge-green   { background: rgba(16,185,129,.15);  color: #34d399; border: 1px solid rgba(16,185,129,.3); }
.badge-rose    { background: rgba(244,63,94,.15);   color: #fb7185; border: 1px solid rgba(244,63,94,.3); }
.badge-violet  { background: rgba(139,92,246,.15);  color: #a78bfa; border: 1px solid rgba(139,92,246,.3); }
.badge-amber   { background: rgba(245,158,11,.15);  color: var(--amber); border: 1px solid rgba(245,158,11,.3); }
.badge-siege   { background: linear-gradient(90deg,#c9a84c22,#8a6f2e22); color: var(--gold); border: 1px solid var(--gold-dim); }
.badge-fille   { background: rgba(59,130,246,.1); color: var(--blue-soft); border: 1px solid rgba(59,130,246,.25); }

/* ── Alerts ──────────────────────────────────────────────── */
.alert {
  padding: 10px 16px; border-radius: var(--radius-sm);
  margin-bottom: 1rem; font-size: .88rem;
}
.alert-danger  { background: rgba(244,63,94,.12); color: #fb7185; border: 1px solid rgba(244,63,94,.25); }
.alert-success { background: rgba(16,185,129,.12); color: #34d399; border: 1px solid rgba(16,185,129,.25); }
.alert-info    { background: rgba(59,130,246,.12); color: var(--blue-soft); border: 1px solid rgba(59,130,246,.25); }

/* ── Modal ───────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0; z-index: 999;
  background: rgba(7,11,19,.75); backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center; padding: 1rem;
  opacity: 0; pointer-events: none; transition: opacity .22s;
}
.modal-overlay.open { opacity: 1; pointer-events: auto; }
.modal {
  background: var(--bg-mid); border: 1px solid var(--border-lit);
  border-radius: var(--radius); width: 100%; max-width: 580px;
  max-height: 90vh; overflow-y: auto;
  transform: translateY(20px); transition: transform .22s;
  box-shadow: 0 24px 64px rgba(0,0,0,.55);
}
.modal-overlay.open .modal { transform: translateY(0); }
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 1.2rem 1.5rem; border-bottom: 1px solid var(--border);
}
.modal-title {
  font-family: var(--font-serif); font-size: 1.1rem;
  color: var(--text-h); display: flex; align-items: center; gap: .5rem;
}
.modal-close {
  background: none; border: none; color: var(--text-dim);
  font-size: 1.2rem; cursor: pointer; padding: 4px;
  transition: color .15s; line-height: 1;
}
.modal-close:hover { color: var(--rose); }
.modal-body { padding: 1.5rem; }
.modal-footer {
  padding: 1rem 1.5rem; border-top: 1px solid var(--border);
  display: flex; gap: .75rem; justify-content: flex-end;
}

/* ── Section header ──────────────────────────────────────── */
.section-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 1.5rem; flex-wrap: wrap; gap: .75rem;
}
.section-title {
  font-family: var(--font-serif); font-size: 1.4rem;
  color: var(--text-h); display: flex; align-items: center; gap: .5rem;
}
.section-actions { display: flex; gap: .75rem; flex-wrap: wrap; align-items: center; }

/* ── Search bar ──────────────────────────────────────────── */
.search-bar {
  display: flex; gap: .75rem; margin-bottom: 1rem; flex-wrap: wrap;
}
.search-input-wrap {
  position: relative; flex: 1; min-width: 200px;
}
.search-input-wrap input { padding-left: 36px; }
.search-input-wrap::before {
  content: '🔍'; position: absolute; left: 10px; top: 50%;
  transform: translateY(-50%); font-size: .9rem; pointer-events: none;
}

/* ── Tabs ────────────────────────────────────────────────── */
.tabs { display: flex; gap: 0; border-bottom: 1px solid var(--border); margin-bottom: 1.5rem; }
.tab-btn {
  padding: 10px 18px; background: none; border: none;
  color: var(--text-dim); font-size: .85rem; font-weight: 600;
  cursor: pointer; border-bottom: 2px solid transparent;
  transition: all .18s; white-space: nowrap;
}
.tab-btn:hover { color: var(--text-h); }
.tab-btn.active { color: var(--gold-light); border-bottom-color: var(--gold); }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ── Toast ───────────────────────────────────────────────── */
.toast-container {
  position: fixed; bottom: 1.5rem; right: 1.5rem; z-index: 1200;
  display: flex; flex-direction: column; gap: .5rem;
}
.toast {
  min-width: 260px; padding: 12px 18px;
  background: var(--bg-panel); border: 1px solid var(--border-lit);
  border-radius: var(--radius-sm); color: var(--text-h);
  box-shadow: var(--shadow); font-size: .88rem;
  animation: slideUp .25s ease;
  display: flex; align-items: center; gap: 8px;
}
.toast-success { border-left: 3px solid var(--emerald); }
.toast-danger  { border-left: 3px solid var(--rose); }
.toast-info    { border-left: 3px solid var(--blue); }
@keyframes slideUp {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Pagination ──────────────────────────────────────────── */
.pagination {
  display: flex; align-items: center; justify-content: center;
  gap: .35rem; margin-top: 1rem; flex-wrap: wrap;
}
.page-btn {
  min-width: 34px; height: 34px; padding: 0 8px;
  background: var(--bg-panel); border: 1px solid var(--border);
  border-radius: var(--radius-sm); color: var(--text-body);
  font-size: .82rem; cursor: pointer; transition: all .15s;
  display: flex; align-items: center; justify-content: center;
}
.page-btn:hover, .page-btn.active {
  background: var(--gold); color: var(--bg-deep);
  border-color: var(--gold); font-weight: 700;
}
.page-btn:disabled { opacity: .35; cursor: default; }

/* ── Empty state ─────────────────────────────────────────── */
.empty-state {
  text-align: center; padding: 3rem 1rem; color: var(--text-dim);
}
.empty-icon { font-size: 2.5rem; margin-bottom: .75rem; }
.empty-state h3 { color: var(--text-body); margin-bottom: .5rem; }

/* ── Responsive helpers ──────────────────────────────────── */
@media (max-width: 768px) {
  .hide-mobile { display: none !important; }
}
@media (min-width: 769px) {
  .show-mobile { display: none !important; }
}

/* ── Theme Toggle Button ─────────────────────────────────── */
.btn-theme {
  background: none; border: 1px solid var(--border-lit);
  border-radius: var(--radius-sm);
  color: var(--text-body); font-size: .95rem;
  cursor: pointer; padding: 5px 10px;
  transition: all .2s; line-height: 1;
  display: flex; align-items: center; gap: 5px;
  white-space: nowrap;
}
.btn-theme:hover {
  background: var(--bg-hover);
  border-color: var(--gold-dim);
  color: var(--gold);
}
.btn-theme .theme-label {
  font-size: .72rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: .5px;
  display: none;
}
@media (min-width: 900px) {
  .btn-theme .theme-label { display: inline; }
}

/* ── Corrections thème clair ─────────────────────────────── */
[data-theme="light"] body {
  background: var(--bg-dark);
}
[data-theme="light"] .sidebar {
  background: var(--bg-mid);
  border-right-color: var(--border);
  box-shadow: 2px 0 12px rgba(0,0,0,.06);
}
[data-theme="light"] .sidebar-logo {
  background: linear-gradient(180deg, #f0f4ff 0%, #ffffff 100%);
}
[data-theme="light"] .sidebar-cross {
  text-shadow: 0 0 12px rgba(160,120,40,.25);
}
[data-theme="light"] .nav-item { color: var(--text-body); }
[data-theme="light"] .nav-item:hover { background: var(--bg-hover); }
[data-theme="light"] .nav-item.active { background: #fffbe8; color: var(--gold); border-left-color: var(--gold); }
[data-theme="light"] .church-role { color: var(--gold-dim); }
[data-theme="light"] .sidebar-church { background: rgba(0,0,0,.02); }
[data-theme="light"] .btn-logout:hover { color: var(--rose); }

[data-theme="light"] .topbar {
  background: var(--bg-mid);
  border-bottom-color: var(--border);
  box-shadow: 0 1px 8px rgba(0,0,0,.06);
}
[data-theme="light"] .page-content { background: var(--bg-dark); }

[data-theme="light"] thead th { background: #f0f4ff; color: var(--gold); }
[data-theme="light"] tbody tr:hover { background: var(--bg-hover); }
[data-theme="light"] tbody td { color: var(--text-body); }
[data-theme="light"] tbody td strong { color: var(--text-h); }

[data-theme="light"] .modal { background: var(--bg-mid); box-shadow: 0 24px 64px rgba(0,0,0,.18); }
[data-theme="light"] .modal-overlay { background: rgba(0,0,0,.35); }

[data-theme="light"] select option { background: var(--bg-mid); color: var(--text-h); }

[data-theme="light"] .toast {
  background: var(--bg-mid);
  border-color: var(--border);
  box-shadow: 0 4px 16px rgba(0,0,0,.12);
  color: var(--text-h);
}
[data-theme="light"] ::-webkit-scrollbar-track { background: var(--bg-hover); }
[data-theme="light"] ::-webkit-scrollbar-thumb { background: var(--border-lit); }

/* Transition fluide lors du changement de thème */
body, .sidebar, .topbar, .card, .modal,
.stat-card, .table-wrap, table, .btn, .toast,
input, select, textarea, .nav-item, .badge {
  transition: background-color .25s ease, border-color .25s ease, color .2s ease;
}
