/* ============================================================
   SOS Habitat – Feuille de style Administration
   ============================================================ */

:root {
  --primary:       #1a4a7a;
  --primary-light: #2d7dd2;
  --accent:        #f07b28;
  --sidebar-bg:    #0f2d4e;
  --sidebar-text:  rgba(255,255,255,.75);
  --sidebar-active:#2d7dd2;
  --bg:            #f0f4f9;
  --white:         #ffffff;
  --dark:          #1e2d3d;
  --gray:          #6b7a8d;
  --light:         #e8eef6;
  --success:       #27ae60;
  --danger:        #e74c3c;
  --warning:       #f39c12;
  --info:          #2196F3;
  --border:        #d0dcea;
  --shadow:        0 4px 20px rgba(26,74,122,.1);
  --radius:        10px;
  --radius-sm:     6px;
  --sidebar-w:     260px;
}

/* ── Reset ───────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: 'Segoe UI', system-ui, sans-serif;
  background: var(--bg); color: var(--dark);
  line-height: 1.6;
}
a { color: var(--primary-light); text-decoration: none; }

/* ── Login page ──────────────────────────────────────────── */
.login-page {
  min-height: 100vh; display: flex;
  align-items: center; justify-content: center;
  background: linear-gradient(135deg, var(--primary) 0%, #0d2a4a 100%);
  padding: 1.5rem;
}
.login-card {
  background: var(--white); border-radius: 16px;
  padding: 2.5rem; width: 100%; max-width: 420px;
  box-shadow: 0 20px 60px rgba(0,0,0,.3);
}
.login-logo {
  text-align: center; margin-bottom: 2rem;
}
.login-logo .icon {
  width: 60px; height: 60px; background: var(--accent);
  border-radius: 14px; font-size: 1.8rem;
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto .75rem;
}
.login-logo h1 { color: var(--primary); font-size: 1.5rem; margin-bottom: .25rem; }
.login-logo p  { color: var(--gray); font-size: .9rem; }
.login-form { display: flex; flex-direction: column; gap: 1.25rem; }
.login-form .form-group { display: flex; flex-direction: column; gap: .4rem; }
.login-form label { font-weight: 600; font-size: .9rem; color: var(--dark); }
.login-form input {
  padding: .85rem 1rem; border: 2px solid var(--border);
  border-radius: var(--radius-sm); font-size: 1rem;
  transition: border-color .2s;
}
.login-form input:focus { outline: none; border-color: var(--primary-light); }
.login-error {
  background: #fce4ec; color: #c62828; padding: .75rem 1rem;
  border-radius: var(--radius-sm); font-size: .9rem; display: none;
}
.btn-login {
  background: var(--primary); color: var(--white);
  padding: .9rem; border: none; border-radius: var(--radius-sm);
  font-size: 1rem; font-weight: 700; cursor: pointer;
  transition: background .2s; width: 100%;
}
.btn-login:hover { background: var(--primary-light); }

/* ── Admin layout ────────────────────────────────────────── */
.admin-wrap { display: flex; min-height: 100vh; }

/* Sidebar */
.sidebar {
  width: var(--sidebar-w); background: var(--sidebar-bg);
  color: var(--sidebar-text); display: flex; flex-direction: column;
  position: fixed; top: 0; left: 0; height: 100vh;
  overflow-y: auto; z-index: 200; transition: transform .3s;
}
.sidebar-logo {
  padding: 1.5rem 1.25rem; border-bottom: 1px solid rgba(255,255,255,.1);
  display: flex; align-items: center; gap: .75rem;
}
.sidebar-logo .icon {
  width: 40px; height: 40px; background: var(--accent);
  border-radius: 8px; font-size: 1.2rem;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.sidebar-logo h2 { color: var(--white); font-size: 1.1rem; line-height: 1.2; }
.sidebar-logo span { font-size: .75rem; color: rgba(255,255,255,.5); font-weight: 400; }

.sidebar-nav { flex: 1; padding: 1rem 0; }
.nav-section { padding: .5rem 1.25rem .25rem; font-size: .7rem; font-weight: 700; letter-spacing: 1px; text-transform: uppercase; color: rgba(255,255,255,.35); }
.nav-item {
  display: flex; align-items: center; gap: .75rem;
  padding: .7rem 1.25rem; cursor: pointer;
  transition: background .15s, color .15s;
  color: var(--sidebar-text); font-size: .9rem;
  border-left: 3px solid transparent;
}
.nav-item:hover { background: rgba(255,255,255,.08); color: var(--white); text-decoration: none; }
.nav-item.active { background: rgba(45,125,210,.25); color: var(--white); border-left-color: var(--primary-light); }
.nav-item .nav-icon { font-size: 1rem; width: 20px; text-align: center; }
.nav-item .nav-badge {
  margin-left: auto; background: var(--danger); color: var(--white);
  font-size: .7rem; font-weight: 700; padding: .1rem .45rem;
  border-radius: 50px;
}

.sidebar-user {
  padding: 1rem 1.25rem; border-top: 1px solid rgba(255,255,255,.1);
  display: flex; align-items: center; gap: .75rem;
}
.user-avatar {
  width: 36px; height: 36px; background: var(--primary-light);
  border-radius: 50%; display: flex; align-items: center;
  justify-content: center; font-size: 1rem; flex-shrink: 0;
}
.user-info span { display: block; }
.user-info .name  { color: var(--white); font-size: .85rem; font-weight: 600; }
.user-info .role  { color: rgba(255,255,255,.45); font-size: .75rem; }
.btn-logout {
  margin-left: auto; background: transparent; border: none;
  color: rgba(255,255,255,.4); cursor: pointer; font-size: 1rem;
  padding: .25rem; border-radius: 4px; transition: color .2s;
}
.btn-logout:hover { color: var(--danger); }

/* Main content */
.admin-main {
  margin-left: var(--sidebar-w); flex: 1; display: flex; flex-direction: column;
}
.admin-topbar {
  background: var(--white); padding: 1rem 2rem;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  position: sticky; top: 0; z-index: 100;
  box-shadow: 0 2px 8px rgba(0,0,0,.06);
}
.topbar-title { font-size: 1.25rem; font-weight: 700; color: var(--primary); }
.topbar-actions { display: flex; gap: .75rem; align-items: center; }

.admin-content { padding: 2rem; flex: 1; }
.page-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 1.75rem; flex-wrap: wrap; gap: 1rem;
}
.page-header h1 { font-size: 1.5rem; color: var(--primary); }

/* ── Stats cards ─────────────────────────────────────────── */
.stats-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1.25rem; margin-bottom: 2rem;
}
.stat-card {
  background: var(--white); border-radius: var(--radius);
  padding: 1.5rem; box-shadow: var(--shadow);
  display: flex; align-items: flex-start; justify-content: space-between;
  border-left: 4px solid var(--primary-light);
}
.stat-card.accent  { border-color: var(--accent); }
.stat-card.success { border-color: var(--success); }
.stat-card.danger  { border-color: var(--danger); }
.stat-card.warning { border-color: var(--warning); }
.stat-num { font-size: 2rem; font-weight: 800; color: var(--primary); line-height: 1; }
.stat-label { font-size: .8rem; color: var(--gray); margin-top: .25rem; }
.stat-icon { font-size: 1.75rem; }

/* ── Data table ──────────────────────────────────────────── */
.table-card {
  background: var(--white); border-radius: var(--radius);
  box-shadow: var(--shadow); overflow: hidden;
}
.table-toolbar {
  padding: 1.25rem 1.5rem; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 1rem; flex-wrap: wrap;
}
.search-input {
  flex: 1; min-width: 200px; padding: .6rem 1rem;
  border: 2px solid var(--border); border-radius: var(--radius-sm);
  font-size: .9rem; transition: border-color .2s;
}
.search-input:focus { outline: none; border-color: var(--primary-light); }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
thead th {
  background: var(--bg); text-align: left;
  padding: .9rem 1.25rem; font-size: .8rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: .5px; color: var(--gray);
  border-bottom: 2px solid var(--border); white-space: nowrap;
}
tbody tr { border-bottom: 1px solid var(--border); transition: background .15s; }
tbody tr:hover { background: #f8fafd; }
tbody td { padding: .9rem 1.25rem; font-size: .9rem; vertical-align: middle; }
tbody tr:last-child { border-bottom: none; }

.badge-status {
  display: inline-flex; align-items: center; gap: .3rem;
  padding: .25rem .75rem; border-radius: 50px; font-size: .78rem; font-weight: 600;
}
.badge-actif    { background: #e8f5e9; color: #2e7d32; }
.badge-inactif  { background: #fce4ec; color: #c62828; }
.badge-nouveau  { background: #e3f2fd; color: #1565c0; }
.badge-encours  { background: #fff8e1; color: #e65100; }
.badge-resolu   { background: #e8f5e9; color: #2e7d32; }
.badge-ferme    { background: #f5f5f5; color: #757575; }

.table-actions { display: flex; gap: .5rem; }
.btn-icon {
  width: 32px; height: 32px; border: none; border-radius: var(--radius-sm);
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  font-size: .9rem; transition: all .15s;
}
.btn-edit   { background: #e3f2fd; color: #1565c0; }
.btn-edit:hover { background: #2196F3; color: var(--white); }
.btn-delete { background: #fce4ec; color: #c62828; }
.btn-delete:hover { background: #F44336; color: var(--white); }
.btn-view   { background: #f3e5f5; color: #6a1b9a; }
.btn-view:hover { background: #9c27b0; color: var(--white); }
.btn-toggle { background: #e8f5e9; color: #2e7d32; }
.btn-toggle:hover { background: #4CAF50; color: var(--white); }

.table-empty {
  text-align: center; padding: 3rem 1.5rem; color: var(--gray);
}
.table-empty .empty-icon { font-size: 3rem; margin-bottom: .75rem; }

/* ── Buttons ─────────────────────────────────────────────── */
.btn {
  padding: .65rem 1.25rem; border-radius: var(--radius-sm);
  font-size: .9rem; font-weight: 600; cursor: pointer; border: none;
  transition: all .2s; display: inline-flex; align-items: center; gap: .4rem;
}
.btn-primary   { background: var(--primary); color: var(--white); }
.btn-primary:hover   { background: var(--primary-light); }
.btn-accent    { background: var(--accent); color: var(--white); }
.btn-accent:hover    { background: #d4611a; }
.btn-success   { background: var(--success); color: var(--white); }
.btn-success:hover   { background: #1e8449; }
.btn-danger    { background: var(--danger); color: var(--white); }
.btn-danger:hover    { background: #c0392b; }
.btn-secondary { background: var(--light); color: var(--dark); }
.btn-secondary:hover { background: var(--border); }
.btn-outline {
  background: transparent; color: var(--primary-light);
  border: 2px solid var(--primary-light);
}
.btn-outline:hover { background: var(--primary-light); color: var(--white); }

/* ── Modal ───────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.5);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000; padding: 1rem; opacity: 0;
  pointer-events: none; transition: opacity .2s;
}
.modal-overlay.open { opacity: 1; pointer-events: all; }
.modal {
  background: var(--white); border-radius: var(--radius);
  width: 100%; max-width: 620px; max-height: 90vh;
  overflow-y: auto; box-shadow: 0 20px 60px rgba(0,0,0,.3);
  transform: scale(.95); transition: transform .2s;
}
.modal-overlay.open .modal { transform: scale(1); }
.modal-header {
  padding: 1.5rem 2rem; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.modal-header h2 { color: var(--primary); font-size: 1.2rem; }
.btn-close {
  width: 36px; height: 36px; border: none; background: var(--light);
  border-radius: 50%; cursor: pointer; font-size: 1.2rem;
  display: flex; align-items: center; justify-content: center;
  transition: background .15s;
}
.btn-close:hover { background: var(--border); }
.modal-body { padding: 1.5rem 2rem; }
.modal-footer {
  padding: 1.25rem 2rem; border-top: 1px solid var(--border);
  display: flex; justify-content: flex-end; gap: .75rem;
}

/* ── Form elements ───────────────────────────────────────── */
.form-group { display: flex; flex-direction: column; gap: .4rem; margin-bottom: 1.25rem; }
.form-group label { font-weight: 600; font-size: .875rem; color: var(--dark); }
.form-group input,
.form-group select,
.form-group textarea {
  padding: .75rem 1rem; border: 2px solid var(--border);
  border-radius: var(--radius-sm); font-size: .95rem;
  font-family: inherit; transition: border-color .2s; background: var(--bg);
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus { outline: none; border-color: var(--primary-light); background: var(--white); }
.form-group textarea { resize: vertical; min-height: 100px; }
.form-hint { font-size: .8rem; color: var(--gray); }
.required { color: var(--danger); }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }

/* ── Toggle switch ───────────────────────────────────────── */
.toggle-wrap { display: flex; align-items: center; gap: .75rem; }
.toggle-input { display: none; }
.toggle-label {
  width: 46px; height: 24px; background: var(--border);
  border-radius: 50px; cursor: pointer; position: relative;
  transition: background .2s;
}
.toggle-label::after {
  content: ''; position: absolute; top: 2px; left: 2px;
  width: 20px; height: 20px; background: var(--white);
  border-radius: 50%; transition: transform .2s;
  box-shadow: 0 1px 4px rgba(0,0,0,.2);
}
.toggle-input:checked + .toggle-label { background: var(--success); }
.toggle-input:checked + .toggle-label::after { transform: translateX(22px); }

/* ── Parcours tree (Questions admin) ─────────────────────── */
.tree-view { padding: 0; }
.tree-node {
  list-style: none; margin: 0;
}
.tree-item {
  background: var(--white); border: 1px solid var(--border);
  border-radius: var(--radius-sm); margin-bottom: .5rem;
  overflow: hidden;
}
.tree-item-header {
  padding: .85rem 1.25rem; display: flex;
  align-items: center; gap: .75rem; cursor: pointer;
  transition: background .15s;
}
.tree-item-header:hover { background: var(--bg); }
.tree-q-badge {
  background: var(--primary); color: var(--white);
  font-size: .7rem; font-weight: 700; padding: .2rem .6rem;
  border-radius: 50px; flex-shrink: 0;
}
.tree-r-badge {
  background: var(--accent); color: var(--white);
  font-size: .7rem; font-weight: 700; padding: .2rem .6rem;
  border-radius: 50px; flex-shrink: 0;
}
.tree-text { flex: 1; font-size: .9rem; }
.tree-children { padding: 0 0 .5rem 2rem; }
.tree-child-item {
  background: #f8fafd; border: 1px solid var(--light);
  border-radius: var(--radius-sm); margin-bottom: .4rem;
  padding: .65rem 1rem; display: flex; align-items: center; gap: .75rem;
}
.tree-child-arrow { color: var(--gray); font-size: .75rem; margin-left: auto; }

/* ── Dashboard charts placeholder ───────────────────────── */
.chart-card {
  background: var(--white); border-radius: var(--radius);
  padding: 1.5rem; box-shadow: var(--shadow);
}
.chart-card h3 { color: var(--primary); margin-bottom: 1rem; }

/* ── Responsive ──────────────────────────────────────────── */
@media (max-width: 900px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .admin-main { margin-left: 0; }
  .admin-topbar { padding: 1rem; }
  .admin-content { padding: 1.25rem; }
  .form-row { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 500px) {
  .stats-grid { grid-template-columns: 1fr; }
  .table-toolbar { flex-direction: column; align-items: stretch; }
}

/* ── Alerts ──────────────────────────────────────────────── */
.alert {
  padding: 1rem 1.25rem; border-radius: var(--radius-sm);
  margin-bottom: 1rem; display: flex; gap: .75rem; align-items: flex-start;
}
.alert-info    { background: #e3f2fd; border-left: 4px solid #2196F3; color: #1565c0; }
.alert-success { background: #e8f5e9; border-left: 4px solid #4CAF50; color: #2e7d32; }
.alert-warning { background: #fff8e1; border-left: 4px solid #FFC107; color: #e65100; }
.alert-danger  { background: #fce4ec; border-left: 4px solid #F44336; color: #c62828; }

/* ── Menu hamburger ──────────────────────────────────────── */
.menu-toggle {
  display: none; background: none; border: none;
  cursor: pointer; font-size: 1.4rem; color: var(--primary);
  padding: .25rem;
}
@media (max-width: 900px) { .menu-toggle { display: block; } }
.sidebar-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,.5); z-index: 199;
}
.sidebar-overlay.open { display: block; }
