/* Feuille de style dédiée à l'administration */
:root {
  --admin-primary: #2563eb;
  --admin-primary-dark: #1d4ed8;
  --admin-bg: #f1f5f9;
  --admin-sidebar: #0f172a;
  --admin-sidebar-text: #94a3b8;
  --admin-sidebar-active: #38bdf8;
  --admin-card: #ffffff;
  --admin-border: #e2e8f0;
  --admin-text: #1e293b;
  --admin-text-muted: #64748b;
  --admin-success: #10b981;
  --admin-warning: #f59e0b;
  --admin-danger: #ef4444;
}

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

body.admin-body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background-color: var(--admin-bg);
  color: var(--admin-text);
  display: flex;
  min-height: 100vh;
}

/* Sidebar d'administration */
.admin-sidebar {
  width: 260px;
  background: var(--admin-sidebar);
  color: #fff;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  position: sticky;
  top: 0;
  height: 100vh;
  box-shadow: 2px 0 10px rgba(0,0,0,0.1);
}

.sidebar-header {
  padding: 1.5rem 1.25rem;
  border-bottom: 1px solid #1e293b;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.sidebar-logo-icon {
  width: 36px;
  height: 36px;
  background: var(--admin-primary);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
}

.sidebar-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: #ffffff;
}

.sidebar-subtitle {
  font-size: 0.75rem;
  color: var(--admin-sidebar-text);
}

.sidebar-nav {
  padding: 1.25rem 0.75rem;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  overflow-y: auto;
}

.nav-group-title {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #475569;
  padding: 0.75rem 0.5rem 0.25rem 0.5rem;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.65rem 0.85rem;
  color: var(--admin-sidebar-text);
  text-decoration: none;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 500;
  transition: all 0.15s ease;
}

.sidebar-link:hover {
  background: #1e293b;
  color: #ffffff;
}

.sidebar-link.active {
  background: var(--admin-primary);
  color: #ffffff;
  font-weight: 600;
}

.sidebar-footer {
  padding: 1rem;
  border-top: 1px solid #1e293b;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.user-mini {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: #cbd5e1;
  font-size: 0.85rem;
}

.user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #334155;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
}

.btn-logout {
  color: #ef4444;
  text-decoration: none;
  font-size: 0.82rem;
  padding: 0.35rem 0.6rem;
  border-radius: 6px;
  background: rgba(239, 68, 68, 0.1);
  transition: all 0.15s;
}

.btn-logout:hover {
  background: #ef4444;
  color: white;
}

/* Zone de contenu principal */
.admin-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow-y: auto;
}

.admin-topbar {
  background: #ffffff;
  border-bottom: 1px solid var(--admin-border);
  padding: 1rem 2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 20;
}

.topbar-title h2 {
  font-size: 1.25rem;
  color: #0f172a;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.btn-public-site {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  text-decoration: none;
  font-size: 0.85rem;
  color: var(--admin-primary);
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  padding: 0.45rem 0.85rem;
  border-radius: 6px;
  font-weight: 500;
  transition: all 0.15s;
}

.btn-public-site:hover {
  background: var(--admin-primary);
  color: white;
}

.admin-content {
  padding: 2rem;
  flex: 1;
}

/* Cartes KPI / Statistiques */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1.25rem;
  margin-bottom: 2rem;
}

.kpi-card {
  background: #ffffff;
  border: 1px solid var(--admin-border);
  border-radius: 12px;
  padding: 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.kpi-info h3 {
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--admin-text-muted);
  margin-bottom: 0.35rem;
}

.kpi-value {
  font-size: 1.75rem;
  font-weight: 700;
  color: #0f172a;
}

.kpi-icon {
  width: 48px;
  height: 48px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.35rem;
}

.kpi-blue { background: #dbeafe; color: #1d4ed8; }
.kpi-green { background: #d1fae5; color: #047857; }
.kpi-yellow { background: #fef3c7; color: #b45309; }
.kpi-purple { background: #ede9fe; color: #6d28d9; }

/* Conteneurs et Tableaux */
.admin-card {
  background: #ffffff;
  border: 1px solid var(--admin-border);
  border-radius: 12px;
  padding: 1.5rem;
  margin-bottom: 2rem;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.card-header-flex {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
  gap: 1rem;
  flex-wrap: wrap;
}

.card-header-flex h3 {
  font-size: 1.1rem;
  color: #0f172a;
}

/* Boutons d'action */
.btn-primary {
  background: var(--admin-primary);
  color: white;
  padding: 0.55rem 1.1rem;
  border-radius: 8px;
  border: none;
  font-weight: 600;
  font-size: 0.88rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  text-decoration: none;
  transition: all 0.15s;
}

.btn-primary:hover {
  background: var(--admin-primary-dark);
}

.btn-sm {
  padding: 0.35rem 0.65rem;
  font-size: 0.8rem;
  border-radius: 6px;
}

.btn-danger {
  background: #fee2e2;
  color: #dc2626;
  border: 1px solid #fecaca;
  padding: 0.35rem 0.65rem;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.8rem;
  font-weight: 500;
  text-decoration: none;
}

.btn-danger:hover {
  background: #dc2626;
  color: white;
}

.btn-edit {
  background: #f1f5f9;
  color: #334155;
  border: 1px solid var(--admin-border);
  padding: 0.35rem 0.65rem;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.8rem;
  font-weight: 500;
  text-decoration: none;
}

.btn-edit:hover {
  background: #e2e8f0;
}

/* Tableaux modernes */
.table-responsive {
  overflow-x: auto;
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.88rem;
}

.admin-table th {
  background: #f8fafc;
  color: var(--admin-text-muted);
  font-weight: 600;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--admin-border);
  text-transform: uppercase;
  font-size: 0.72rem;
  letter-spacing: 0.05em;
}

.admin-table td {
  padding: 0.9rem 1rem;
  border-bottom: 1px solid var(--admin-border);
  vertical-align: middle;
}

.admin-table tr:hover td {
  background: #f8fafc;
}

/* Formulaires */
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1.25rem;
}

.form-group {
  margin-bottom: 1.25rem;
}

.form-group label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: #334155;
  margin-bottom: 0.4rem;
}

.form-control {
  width: 100%;
  padding: 0.6rem 0.85rem;
  border: 1px solid var(--admin-border);
  border-radius: 8px;
  font-size: 0.9rem;
  color: #1e293b;
  outline: none;
  background: #fff;
  transition: border-color 0.15s;
}

.form-control:focus {
  border-color: var(--admin-primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

textarea.form-control {
  min-height: 90px;
  resize: vertical;
}

/* Alertes & Messages Flash */
.alert {
  padding: 0.85rem 1.25rem;
  border-radius: 8px;
  font-size: 0.9rem;
  margin-bottom: 1.5rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.alert-success { background: #dcfce7; color: #166534; border: 1px solid #bbf7d0; }
.alert-error { background: #fee2e2; color: #991b1b; border: 1px solid #fecaca; }
.alert-warning { background: #fef3c7; color: #92400e; border: 1px solid #fde68a; }

/* Page de connexion (Auth Card) */
.login-body {
  background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 1.5rem;
}

.login-card {
  background: #ffffff;
  border-radius: 16px;
  max-width: 420px;
  width: 100%;
  padding: 2.25rem;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.3);
}

.login-header {
  text-align: center;
  margin-bottom: 2rem;
}

.login-lock-icon {
  width: 56px;
  height: 56px;
  background: #eff6ff;
  color: var(--admin-primary);
  border-radius: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.6rem;
  margin-bottom: 1rem;
}

.login-header h1 {
  font-size: 1.35rem;
  color: #0f172a;
}

.login-header p {
  font-size: 0.85rem;
  color: var(--admin-text-muted);
  margin-top: 0.25rem;
}

/* ==========================================================================
   Responsive Administration (Tablettes & Smartphones)
   ========================================================================== */
@media (max-width: 900px) {
  body.admin-body {
    flex-direction: column;
    min-height: 100vh;
  }

  .admin-sidebar {
    width: 100%;
    height: auto;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
  }

  .sidebar-header {
    padding: 0.65rem 1rem;
  }

  .sidebar-nav {
    flex-direction: row;
    flex-wrap: nowrap;
    overflow-x: auto;
    padding: 0.4rem 0.75rem;
    gap: 0.35rem;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }

  .sidebar-nav::-webkit-scrollbar {
    display: none;
  }

  .nav-group-title {
    display: none;
  }

  .sidebar-link {
    white-space: nowrap;
    padding: 0.4rem 0.7rem;
    font-size: 0.82rem;
    border-radius: 6px;
    flex-shrink: 0;
  }

  .sidebar-footer {
    display: none;
  }

  .admin-topbar {
    padding: 0.75rem 1rem;
    flex-wrap: wrap;
    gap: 0.5rem;
  }

  .admin-content {
    padding: 1rem;
  }

  .kpi-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
    margin-bottom: 1.25rem;
  }

  .kpi-card {
    padding: 1rem;
  }

  .kpi-value {
    font-size: 1.35rem;
  }

  .kpi-icon {
    width: 38px;
    height: 38px;
    font-size: 1.1rem;
  }

  .admin-card {
    padding: 1.1rem;
    margin-bottom: 1.25rem;
  }

  .form-grid {
    grid-template-columns: 1fr;
    gap: 0.75rem;
  }
}

@media (max-width: 480px) {
  .kpi-grid {
    grid-template-columns: 1fr;
  }
  
  .card-header-flex {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
  }

  .admin-table th, .admin-table td {
    padding: 0.6rem 0.5rem;
    font-size: 0.78rem;
  }
}

.theme-editor-grid {
  display: grid;
  grid-template-columns: 1fr 360px;
  gap: 1.5rem;
  align-items: start;
}

@media (max-width: 900px) {
  .theme-editor-grid {
    grid-template-columns: 1fr;
  }
}

