/* ================= RESET & BASE ================= */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

html, body {
  width: 100%;
  overflow-x: hidden; /* Empêche le scroll gauche-droite */
}

body {
  background: linear-gradient(135deg, #f8fafc, #e2e8f0);
  color: #0f172a;
  min-height: 100vh;
}

a {
  color: inherit;
  text-decoration: none;
}

/* ================= LAYOUT ================= */
.layout {
  display: flex;
  min-height: 100vh;
  width: 100%; /* S'assure que le container ne dépasse pas */
}

/* --- SIDEBAR (PC) --- */
.sidebar {
  width: 260px;
  background: #0f172a;
  color: #e5e7eb;
  padding: 24px 20px;
  flex-shrink: 0; /* Empêche la sidebar de s'écraser */
}

.sidebar h1 {
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 24px;
}

.sidebar nav a {
  display: block;
  padding: 10px 12px;
  border-radius: 999px;
  margin-bottom: 8px;
  font-size: 14px;
  transition: all 0.2s ease;
}

.sidebar nav a.active,
.sidebar nav a:hover {
  background: #facc15;
  color: #0f172a;
  font-weight: 600;
}

/* --- MAIN CONTENT --- */
.main {
  flex: 1;
  padding: 32px 40px;
  width: 100%; /* Force le contenu à rester dans les limites */
  max-width: 100vw; /* Sécurité supplémentaire */
}

.page-title {
  font-size: 32px;
  font-weight: 700;
  margin-bottom: 8px;
}

.page-subtitle {
  font-size: 16px;
  color: #64748b;
  margin-bottom: 24px;
}

/* --- GRILLE ET CARTES --- */
.card-grid {
  display: grid;
  /* Utilisation de minmax avec 100% pour éviter le dépassement sur petits écrans */
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 20px;
  width: 100%;
}

.card {
  background: white;
  border-radius: 24px;
  padding: 20px 22px;
  box-shadow: 0 12px 30px rgba(15, 23, 42, 0.08);
  border: 1px solid #e2e8f0;
}

/* --- BADGES --- */
.badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
}
.badge-good { background: #dcfce7; color: #166534; }
.badge-warning { background: #ffedd5; color: #c2410c; }
.badge-critical { background: #fee2e2; color: #b91c1c; }

/* --- FORMULAIRES --- */
.form-group { margin-bottom: 16px; }
.form-group label {
  font-size: 14px;
  font-weight: 600;
  display: block;
  margin-bottom: 4px;
}
.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid #cbd5f5;
  font-size: 14px;
  /* Empêche le zoom auto sur iPhone */
  font-size: 16px; 
}

/* --- BOUTONS --- */
.button-primary {
  display: inline-block;
  padding: 10px 18px;
  border-radius: 999px;
  border: none;
  cursor: pointer;
  background: linear-gradient(135deg, #facc15, #eab308);
  color: #111827;
  font-weight: 600;
}

.button-icon-delete {
  background: none;
  border: none;
  cursor: pointer;
  color: #94a3b8;
  padding: 4px;
  border-radius: 6px;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}
.button-icon-delete:hover {
  background-color: #fee2e2;
  color: #ef4444;
}

.alert-critical {
  background: linear-gradient(135deg, #ef4444, #b91c1c);
  color: white;
  border-radius: 20px;
  padding: 16px 18px;
  margin-bottom: 24px;
}
.alert-critical ul {
  margin-top: 8px;
  padding-left: 18px;
  font-size: 14px;
}

.table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 10px;
}
.table th, .table td {
  border-bottom: 1px solid #e2e8f0;
  padding: 8px 4px;
  font-size: 14px;
}
.table th { text-align: left; color: #6b7280; }


/* ================= RESPONSIVE ================= */

/* TABLETTES (Max 992px) */
@media (max-width: 992px) {
  .layout {
    flex-direction: column; /* La sidebar passe en haut */
  }

  .sidebar {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 20px;
    position: sticky;
    top: 0;
    z-index: 100;
    /* Effet Blur Glassmorphism */
    background: rgba(15, 23, 42, 0.95);
    backdrop-filter: blur(10px);
  }

  .sidebar h1 {
    margin-bottom: 0;
    font-size: 18px;
  }

  .sidebar nav {
    display: flex;
    gap: 10px;
    overflow-x: auto; /* Scroll horizontal UNIQUEMENT sur le menu si besoin */
    -ms-overflow-style: none;  /* Cache scrollbar IE/Edge */
    scrollbar-width: none;  /* Cache scrollbar Firefox */
  }
  .sidebar nav::-webkit-scrollbar { display: none; /* Cache scrollbar Chrome */ }

  .sidebar nav a {
    white-space: nowrap; /* Empêche les boutons de passer à la ligne */
    font-size: 13px;
    padding: 8px 14px;
    margin-bottom: 0;
  }

  .main {
    padding: 24px; /* Réduction du padding */
  }
}

/* MOBILES (Max 600px) */
@media (max-width: 600px) {
  
  .sidebar {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }
  
  .sidebar nav {
    width: 100%;
    padding-bottom: 4px; /* Espace pour le scroll tactile */
  }

  .main {
    padding: 16px; /* Padding minimal pour ne pas écraser l'écran */
  }

  .page-title { font-size: 24px; }
  .page-subtitle { font-size: 14px; margin-bottom: 16px; }

  /* La grille passe en 1 colonne stricte */
  .card-grid {
    grid-template-columns: 1fr; 
  }

  .card {
    padding: 16px;
    border-radius: 16px;
  }

  .button-primary {
    width: 100%; /* Bouton pleine largeur sur mobile */
    text-align: center;
  }
  
  /* Ajustement tableaux si vous en avez */
  .table { display: block; overflow-x: auto; }
}