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

:root {
  --primary: #2563eb;
  --primary-light: #60a5fa;
  --primary-dark: #1d4ed8;
  --bg: #f1f5f9;
  --bg-card: #ffffff;
  --text: #1e293b;
  --text-muted: #64748b;
  --border: #e2e8f0;
  --sidebar-bg: #1e293b;
  --sidebar-text: #94a3b8;
  --sidebar-hover: #334155;
  --sidebar-active: #2563eb;
  --header-bg: rgba(255,255,255,0.95);
  --footer-bg: #ffffff;
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --revenue: #2563eb;
  --users: #10b981;
  --orders: #f59e0b;
  --growth: #8b5cf6;
  --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.08), 0 4px 6px -2px rgba(0,0,0,0.04);
  --radius: 12px;
  --radius-sm: 8px;
  --transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  display: grid;
  grid-template-columns: 250px 1fr;
  min-height: 100vh;
  transition: background var(--transition), color var(--transition);
}

#sidebar-toggle, #dark-mode-toggle {
  display: none;
}

/* ========== BARRE LATÉRALE ========== */
.sidebar {
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  height: 100vh;
  position: sticky;
  top: 0;
  overflow-y: auto;
  transition: transform var(--transition), margin var(--transition), width var(--transition);
  z-index: 100;
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}

.logo {
  font-size: 1.5rem;
  font-weight: 700;
  color: #fff;
  letter-spacing: -0.02em;
  white-space: nowrap;
}

.sidebar-close {
  display: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--sidebar-text);
  line-height: 1;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  padding: 12px;
  gap: 2px;
  flex: 1;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  color: var(--sidebar-text);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 500;
  transition: all var(--transition);
  position: relative;
  white-space: nowrap;
}

.nav-item:hover {
  background: var(--sidebar-hover);
  color: #fff;
}

.nav-item.active {
  background: var(--sidebar-active);
  color: #fff;
}

.nav-item.active::before {
  content: '';
  position: absolute;
  left: -12px;
  top: 50%;
  transform: translateY(-50%);
  width: 4px;
  height: 20px;
  background: #fff;
  border-radius: 0 4px 4px 0;
}

.nav-icon {
  font-size: 0.75rem;
  flex-shrink: 0;
}

.sidebar-footer {
  padding: 16px 20px;
  font-size: 0.75rem;
  border-top: 1px solid rgba(255,255,255,0.08);
  color: var(--sidebar-text);
  text-align: center;
  white-space: nowrap;
}

/* ========== PANEL PRINCIPAL ========== */
.main {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  transition: background var(--transition), color var(--transition);
}

/* ========== BARRE SUPÉRIEURE ========== */
.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  background: var(--header-bg);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(12px);
  position: sticky;
  top: 0;
  z-index: 50;
  transition: background var(--transition), border-color var(--transition);
}

.top-bar-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

.top-bar-left h1 {
  font-size: 1.25rem;
  font-weight: 600;
  transition: color var(--transition);
}

.hamburger {
  font-size: 1.5rem;
  cursor: pointer;
  display: inline-block;
  user-select: none;
  line-height: 1;
}

.top-bar-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

.dark-mode-btn {
  font-size: 1.25rem;
  cursor: pointer;
  padding: 8px;
  border-radius: 50%;
  background: var(--bg);
  color: var(--text);
  transition: all var(--transition);
  user-select: none;
  line-height: 1;
  border: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.dark-mode-btn:hover {
  background: var(--border);
}

.user-profile {
  display: flex;
  align-items: center;
  gap: 10px;
}

.avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  object-fit: cover;
}

.user-name {
  font-size: 0.9rem;
  font-weight: 500;
  transition: color var(--transition);
}

/* ========== CONTENU ========== */
.content {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 20px;
  padding: 24px;
  flex: 1;
}

.content > .stats {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 20px;
}

.content > .charts-row {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 20px;
}

.content > .table-section {
  grid-column: 1 / -1;
}

/* ========== CARTES STATISTIQUES ========== */
.stat-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  box-shadow: var(--shadow);
  transition: all var(--transition);
  cursor: default;
}

.stat-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
}

.stat-icon {
  width: 50px;
  height: 50px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
}

.stat-icon.revenue { background: var(--revenue); }
.stat-icon.users { background: var(--users); }
.stat-icon.orders { background: var(--orders); }
.stat-icon.growth { background: var(--growth); }

.stat-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.stat-label {
  font-size: 0.8rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 500;
  transition: color var(--transition);
}

.stat-value {
  font-size: 1.5rem;
  font-weight: 700;
  line-height: 1.2;
  transition: color var(--transition);
}

.stat-change {
  font-size: 0.8rem;
  font-weight: 600;
}

.stat-change.up { color: var(--success); }
.stat-change.down { color: var(--danger); }

/* ========== GRAPHIQUES ========== */
.chart-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  transition: background var(--transition), box-shadow var(--transition);
}

.chart-card h3 {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 16px;
  transition: color var(--transition);
}

.chart-placeholder {
  width: 100%;
  height: 200px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.chart-svg {
  width: 100%;
  height: 100%;
}

.chart-pie .chart-placeholder {
  flex-direction: column;
  gap: 12px;
}

.pie-svg {
  width: 120px;
  height: 120px;
}

.pie-legend {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  justify-content: center;
  font-size: 0.8rem;
  color: var(--text-muted);
  transition: color var(--transition);
}

.dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  margin-right: 6px;
  vertical-align: middle;
}

/* ========== TABLEAU ========== */
.table-section {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  transition: background var(--transition), box-shadow var(--transition);
}

.table-section h3 {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 16px;
  transition: color var(--transition);
}

.table-wrapper {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
}

thead th {
  text-align: left;
  padding: 12px 16px;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 2px solid var(--border);
  transition: color var(--transition), border-color var(--transition);
}

tbody td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem;
  transition: border-color var(--transition), color var(--transition);
}

tbody tr {
  transition: background var(--transition);
}

tbody tr:hover {
  background: rgba(37, 99, 235, 0.04);
}

.badge {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: capitalize;
}

.badge.completed {
  background: rgba(16, 185, 129, 0.12);
  color: var(--success);
}

.badge.pending {
  background: rgba(245, 158, 11, 0.12);
  color: var(--warning);
}

.badge.cancelled {
  background: rgba(239, 68, 68, 0.12);
  color: var(--danger);
}

/* ========== PIED DE PAGE ========== */
footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  background: var(--footer-bg);
  border-top: 1px solid var(--border);
  font-size: 0.8rem;
  color: var(--text-muted);
  transition: all var(--transition);
}

/* ========== MODE SOMBRE ========== */
#dark-mode-toggle:checked ~ .sidebar {
  --sidebar-bg: #0f172a;
  --sidebar-hover: #1e293b;
  --sidebar-text: #cbd5e1;
}

#dark-mode-toggle:checked ~ .main {
  --header-bg: rgba(15, 23, 42, 0.95);
  --footer-bg: #0f172a;
  --bg-card: #1e293b;
  --text: #f1f5f9;
  --text-muted: #94a3b8;
  --border: #334155;
  --bg: #0f172a;
}

#dark-mode-toggle:checked ~ .main tbody tr:hover {
  background: rgba(255,255,255,0.04);
}

/* ========== RÉTRÉCISSEMENT BARRE LATÉRALE (desktop) ========== */
@media (min-width: 993px) {
  #sidebar-toggle:checked ~ .sidebar {
    margin-left: -250px;
    visibility: hidden;
  }

  body:has(#sidebar-toggle:checked) {
    grid-template-columns: 1fr;
  }
}

/* ========== OVERLAY BARRE LATÉRALE (mobile/tablette) ========== */
@media (max-width: 992px) {
  .hamburger {
    display: inline-block;
  }

  .sidebar-close {
    display: inline-block;
  }

  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    width: 260px;
    height: 100vh;
    transform: translateX(-100%);
    box-shadow: var(--shadow-lg);
  }

  #sidebar-toggle:checked ~ .sidebar {
    transform: translateX(0);
  }

  #sidebar-toggle:checked ~ .main::before {
    content: '';
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    z-index: 99;
  }

  body {
    grid-template-columns: 1fr;
  }

  .content > .stats {
    grid-template-columns: repeat(2, 1fr);
  }

  .content > .charts-row {
    grid-template-columns: 1fr;
  }
}

/* ========== ADAPTATIF ========== */
@media (max-width: 768px) {
  .content {
    padding: 16px;
    gap: 16px;
  }

  .content > .stats {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 576px) {
  .content > .stats {
    grid-template-columns: 1fr;
  }

  .content {
    padding: 12px;
    gap: 12px;
  }

  .top-bar {
    padding: 12px 16px;
  }

  .top-bar-left h1 {
    font-size: 1rem;
  }

  .user-name {
    display: none;
  }

  footer {
    flex-direction: column;
    gap: 4px;
    text-align: center;
  }
}
