:root {
  --sidebar-width: 260px;
  --sidebar-bg: #0f172a;
  --sidebar-hover: #1e293b;
  --sidebar-active: #2563eb;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --topbar-h: 60px;
}

/* ── Layout ─────────────────────────────────────────────────────────────────── */
body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: #f1f5f9;
  min-height: 100vh;
}

.sidebar {
  position: fixed;
  top: 0; left: 0; bottom: 0;
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  overflow-y: auto;
  overflow-x: hidden;
  z-index: 1040;
  transition: transform .25s ease;
  scrollbar-width: thin;
  scrollbar-color: #334155 transparent;
}

.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-thumb { background: #334155; border-radius: 2px; }

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 18px 20px;
  border-bottom: 1px solid #1e293b;
  text-decoration: none;
}

.sidebar-brand img {
  width: 36px; height: 36px;
  object-fit: contain;
  border-radius: 8px;
}

.sidebar-brand span {
  color: #f8fafc;
  font-weight: 700;
  font-size: 1.1rem;
  letter-spacing: -.3px;
}

.nav-section {
  padding: 16px 12px 4px;
  font-size: .65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: #475569;
}

.sidebar .nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  color: #94a3b8;
  border-radius: 8px;
  margin: 2px 8px;
  font-size: .875rem;
  font-weight: 500;
  transition: background .15s, color .15s;
  text-decoration: none;
  white-space: nowrap;
}

.sidebar .nav-link i { width: 18px; text-align: center; font-size: 1rem; }
.sidebar .nav-link:hover { background: var(--sidebar-hover); color: #e2e8f0; }
.sidebar .nav-link.active { background: var(--sidebar-active); color: #fff; }

.sidebar-footer {
  padding: 12px 8px;
  border-top: 1px solid #1e293b;
}

.main-content {
  margin-left: var(--sidebar-width);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  position: sticky;
  top: 0;
  height: var(--topbar-h);
  background: #fff;
  border-bottom: 1px solid #e2e8f0;
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 12px;
  z-index: 1030;
  box-shadow: 0 1px 3px rgba(0,0,0,.06);
}

.topbar-title {
  font-size: 1.05rem;
  font-weight: 600;
  color: #0f172a;
  flex: 1;
}

.page-content {
  flex: 1;
  padding: 24px;
}

/* ── Cards ──────────────────────────────────────────────────────────────────── */
.card {
  border: none;
  border-radius: 12px;
  box-shadow: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.04);
}

.card-header {
  background: transparent;
  border-bottom: 1px solid #f1f5f9;
  padding: 16px 20px;
  font-weight: 600;
  font-size: .9rem;
}

.stat-card {
  border-radius: 12px;
  padding: 20px;
  color: #fff;
  position: relative;
  overflow: hidden;
}

.stat-card .stat-value {
  font-size: 2rem;
  font-weight: 700;
  line-height: 1;
}

.stat-card .stat-label {
  font-size: .8rem;
  opacity: .85;
  margin-top: 4px;
}

.stat-card .stat-icon {
  position: absolute;
  right: 16px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 3rem;
  opacity: .2;
}

.stat-primary { background: linear-gradient(135deg, #2563eb, #1d4ed8); }
.stat-success { background: linear-gradient(135deg, #059669, #047857); }
.stat-warning { background: linear-gradient(135deg, #d97706, #b45309); }
.stat-danger  { background: linear-gradient(135deg, #dc2626, #b91c1c); }
.stat-info    { background: linear-gradient(135deg, #0891b2, #0e7490); }
.stat-purple  { background: linear-gradient(135deg, #7c3aed, #6d28d9); }

/* ── Tables ─────────────────────────────────────────────────────────────────── */
.table {
  font-size: .875rem;
  margin-bottom: 0;
}

.table thead th {
  font-size: .75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: #64748b;
  background: #f8fafc;
  border-bottom: 2px solid #e2e8f0;
  padding: 10px 16px;
  white-space: nowrap;
}

.table tbody td {
  padding: 12px 16px;
  vertical-align: middle;
  border-color: #f1f5f9;
  color: #374151;
}

.table tbody tr:hover { background: #f8fafc; }

/* ── Badges / Status ────────────────────────────────────────────────────────── */
.badge-status {
  padding: 4px 10px;
  border-radius: 20px;
  font-size: .72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .3px;
}

.status-actif, .status-effectue, .status-validee_client, .status-terminee { background: #dcfce7; color: #166534; }
.status-en_attente, .status-planifiee { background: #fef9c3; color: #713f12; }
.status-en_cours, .status-en_route { background: #dbeafe; color: #1e40af; }
.status-suspendu, .status-expire, .status-refuse { background: #fee2e2; color: #991b1b; }
.status-banni, .status-echoue, .status-annulee { background: #fee2e2; color: #7f1d1d; }
.status-devis_recu, .status-acceptee { background: #ede9fe; color: #5b21b6; }
.status-litige, .status-ouvert { background: #ffedd5; color: #9a3412; }
.status-resolu, .status-clos { background: #f0fdf4; color: #15803d; }
.status-est_verifie { background: #d1fae5; color: #065f46; }

/* ── Avatar ─────────────────────────────────────────────────────────────────── */
.avatar {
  width: 38px; height: 38px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid #e2e8f0;
}

.avatar-lg {
  width: 80px; height: 80px;
  border-radius: 50%;
  object-fit: cover;
  border: 3px solid #e2e8f0;
}

.avatar-placeholder {
  width: 38px; height: 38px;
  border-radius: 50%;
  background: linear-gradient(135deg, #2563eb, #7c3aed);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: .85rem;
  flex-shrink: 0;
}

.avatar-placeholder-lg {
  width: 80px; height: 80px;
  border-radius: 50%;
  background: linear-gradient(135deg, #2563eb, #7c3aed);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 1.8rem;
}

/* ── Photo grid ─────────────────────────────────────────────────────────────── */
.photo-grid { display: flex; flex-wrap: wrap; gap: 8px; }
.photo-thumb {
  width: 100px; height: 100px;
  object-fit: cover;
  border-radius: 8px;
  border: 2px solid #e2e8f0;
  cursor: zoom-in;
  transition: transform .15s;
}
.photo-thumb:hover { transform: scale(1.05); }

/* ── Pagination ─────────────────────────────────────────────────────────────── */
.pagination .page-link {
  border: none;
  color: #374151;
  border-radius: 8px !important;
  margin: 0 2px;
  font-size: .85rem;
}
.pagination .page-item.active .page-link {
  background: var(--primary);
  color: #fff;
}

/* ── Search bar ─────────────────────────────────────────────────────────────── */
.search-box {
  position: relative;
}
.search-box .bi-search {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: #94a3b8;
  pointer-events: none;
}
.search-box input {
  padding-left: 36px;
  border-radius: 8px;
  border: 1px solid #e2e8f0;
  background: #f8fafc;
  font-size: .875rem;
}
.search-box input:focus {
  background: #fff;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,.15);
}

/* ── Filter pills ───────────────────────────────────────────────────────────── */
.filter-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  border-radius: 20px;
  font-size: .8rem;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid #e2e8f0;
  background: #fff;
  color: #374151;
  text-decoration: none;
  transition: all .15s;
}
.filter-pill:hover, .filter-pill.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

/* ── Login page ─────────────────────────────────────────────────────────────── */
.login-page {
  min-height: 100vh;
  background: linear-gradient(135deg, #0f172a 0%, #1e293b 50%, #0f172a 100%);
  display: flex;
  align-items: center;
  justify-content: center;
}

.login-card {
  background: #fff;
  border-radius: 16px;
  padding: 40px;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 25px 50px rgba(0,0,0,.3);
}

.login-logo {
  width: 64px; height: 64px;
  object-fit: contain;
  border-radius: 12px;
}

/* ── Btn overrides ──────────────────────────────────────────────────────────── */
.btn { border-radius: 8px; font-size: .875rem; font-weight: 500; }
.btn-primary { background: var(--primary); border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); }

/* ── Sidebar overlay (mobile) ───────────────────────────────────────────────── */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 1039;
}

/* ── Responsive ─────────────────────────────────────────────────────────────── */
@media (max-width: 991.98px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.show { transform: translateX(0); }
  .sidebar-overlay.show { display: block; }
  .main-content { margin-left: 0; }
  .page-content { padding: 16px; }
  .topbar { padding: 0 16px; }
}

@media (max-width: 575.98px) {
  .stat-card .stat-value { font-size: 1.5rem; }
  .login-card { padding: 28px 20px; margin: 16px; }
  .photo-thumb { width: 80px; height: 80px; }
  .table-responsive-sm { font-size: .8rem; }
}

/* ── Lightbox ───────────────────────────────────────────────────────────────── */
.lightbox-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.9);
  z-index: 9999;
  align-items: center;
  justify-content: center;
}
.lightbox-overlay.show { display: flex; }
.lightbox-overlay img { max-width: 90vw; max-height: 90vh; object-fit: contain; border-radius: 4px; }
.lightbox-close {
  position: absolute;
  top: 16px; right: 20px;
  color: #fff;
  font-size: 2rem;
  cursor: pointer;
  line-height: 1;
}

/* ── Detail page ────────────────────────────────────────────────────────────── */
.detail-label { font-size: .75rem; font-weight: 600; text-transform: uppercase; letter-spacing: .5px; color: #94a3b8; }
.detail-value { font-size: .9rem; color: #1e293b; font-weight: 500; }

/* ── Map placeholder ────────────────────────────────────────────────────────── */
.map-link {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: .85rem; color: var(--primary);
  text-decoration: none;
}
.map-link:hover { text-decoration: underline; }

/* ── empty state ────────────────────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: #94a3b8;
}
.empty-state i { font-size: 3rem; margin-bottom: 12px; display: block; }
