/* ===== VARIABLES ET RESET ===== */
:root {
  --bg1: #0b1220;
  --bg2: #0e1830;
  --glass: rgba(255,255,255,.06);
  --border: rgba(255,255,255,.15);
  --text: #e6e6f0;
  --primary: #11cdc6;
  --primary-700: #0fb2aa;
  --navbar-height: 60px; /* Hauteur fixe pour la navbar */
  --safe-area-inset-top: env(safe-area-inset-top, 0px); /* Pour iPhone notch */
}

* {
  font-family: 'Poppins', system-ui, -apple-system, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  box-sizing: border-box;
}

/* ===== CORPS ET ARRIÈRE-PLAN ===== */
html, body { 
  height: 100%;
  margin: 0;
  padding: 0;
  overflow-x: hidden; /* Prévient le défilement horizontal */
}

body.bg {
  min-height: 100vh;
  background: radial-gradient(1200px 600px at -10% -20%, #153158 0, transparent 40%),
              radial-gradient(1000px 800px at 120% -20%, #13233e 0, transparent 40%),
              linear-gradient(180deg, var(--bg1), var(--bg2));
  color: var(--text);
  display: flex;
  flex-direction: column;
  padding-top: calc(var(--navbar-height) + var(--safe-area-inset-top));
}

/* ===== NAVBAR RESPONSIVE ===== */
.navbar-glass {
  backdrop-filter: blur(8px);
  background: linear-gradient(180deg, rgba(7,14,26,.85), rgba(7,14,26,.45));
  border-bottom: 1px solid var(--border);
  height: var(--navbar-height);
  padding: 0.5rem 1rem;
  z-index: 1030;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
}

/* Logo et marque */
.navbar-glass .navbar-brand {
  color: var(--text) !important;
  font-size: 1.1rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* Navigation responsive */
.navbar-glass .navbar-nav {
  background: rgba(7, 14, 26, 0.95);
  backdrop-filter: blur(10px);
  padding: 0 1rem;
  border-radius: 0 0 12px 12px;
  margin-top: 0;
}

.navbar-glass .nav-link {
  color: var(--text) !important;
  opacity: .95;
  padding: 0.75rem 1rem;
  border-radius: 8px;
  transition: all 0.2s ease;
  font-size: 0.95rem;
}

.navbar-glass .nav-link:hover,
.navbar-glass .nav-link:focus {
  color: #fff !important;
  opacity: 1;
  background: rgba(255, 255, 255, 0.1);
}

.navbar-glass .nav-link.active {
  color: var(--primary) !important;
  font-weight: 600;
  background: rgba(17, 205, 198, 0.1);
}

/* Boutons dans la navbar */
.navbar-glass .btn {
  font-size: 0.9rem;
  padding: 0.4rem 1rem;
  margin: 0.25rem;
}

/* Toggle burger personnalisé */
.navbar-toggler {
  border: 1px solid rgba(255, 255, 255, 0.3);
  padding: 0.25rem 0.5rem;
  background: rgba(255, 255, 255, 0.1);
}

.navbar-toggler:focus {
  box-shadow: 0 0 0 0.1rem rgba(17, 205, 198, 0.3);
}

.navbar-toggler-icon {
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 30 30'%3e%3cpath stroke='rgba%28230, 230, 240, 0.8%29' stroke-linecap='round' stroke-miterlimit='10' stroke-width='2' d='M4 7h22M4 15h22M4 23h22'/%3e%3c/svg%3e");
}

/* ===== LAYOUT PRINCIPAL ===== */
.page-wrap {
  flex: 1 0 auto;
  padding: 1rem;
  padding-top: 1.5rem;
  padding-bottom: 3rem;
  width: 100%;
  max-width: 100vw;
}

.container {
  max-width: 100%;
  padding-left: 1rem;
  padding-right: 1rem;
}

/* ===== CARTES ET COMPOSANTS ===== */
.card-glass {
  background: var(--glass);
  border: 1px solid var(--border);
  border-radius: 16px;
  color: var(--text);
  padding: 1rem;
  margin-bottom: 1rem;
}

/* ===== FORMULAIRES ===== */
input.form-control,
.form-select,
.input-group-text,
textarea.form-control {
  background: rgba(255, 255, 255, .08);
  border: 1px solid rgba(255, 255, 255, .18);
  color: #fff;
  font-size: 16px; /* Empêche le zoom sur iOS */
  padding: 0.5rem 0.75rem;
}

.form-control::placeholder {
  color: #94a3b8;
  opacity: 0.8;
}

label.form-label {
  color: #e2e8f0;
  font-size: 0.9rem;
  margin-bottom: 0.4rem;
  font-weight: 500;
}

/* ===== BOUTONS ===== */
.btn {
  padding: 0.5rem 1rem;
  border-radius: 8px;
  font-size: 0.95rem;
  font-weight: 500;
  transition: all 0.2s ease;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.btn-primary {
  background: var(--primary);
  border-color: var(--primary);
  color: #000;
}

.btn-primary:hover {
  background: var(--primary-700);
  border-color: var(--primary-700);
  color: #000;
}

.btn-outline-light {
  color: var(--text);
  border-color: rgba(255, 255, 255, 0.3);
  background: transparent;
}

.btn-outline-light:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.5);
  color: #fff;
}

/* ===== TABLEAUX RESPONSIFS ===== */
.table-responsive {
  border-radius: 8px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin: 0 -0.5rem;
  padding: 0 0.5rem;
}

.table {
  font-size: 0.85rem;
  white-space: nowrap;
  margin-bottom: 0;
}

.table th {
  font-weight: 600;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 0.75rem 0.5rem;
}

.table td {
  padding: 0.5rem;
}

.table input.form-control,
.table .form-select {
  min-width: 100px;
  font-size: 0.85rem;
  padding: 0.35rem 0.5rem;
}

.table-dark {
  --bs-table-color: var(--text);
  --bs-table-bg: rgba(255, 255, 255, .04);
}

.table-dark th,
.table-dark td {
  color: #e9ecef;
  border-color: rgba(255, 255, 255, 0.1);
}

/* ===== TOGGLES ET SWITCHES ===== */
.toggle-card {
  border-radius: 12px;
  transition: all 0.3s ease;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, .03);
  padding: 1rem;
  margin-bottom: 0.75rem;
}

.toggle-card.on {
  border-color: rgba(17, 205, 198, .55);
  box-shadow: 0 0 0 .15rem rgba(17, 205, 198, .25) inset,
              0 4px 12px rgba(17, 205, 198, .1);
  background: linear-gradient(180deg, rgba(17, 205, 198, .08), rgba(17, 205, 198, .02));
}

.form-switch.form-switch-lg .form-check-input {
  width: 2.5rem;
  height: 1.25rem;
  cursor: pointer;
}

.form-switch .form-check-input:focus {
  box-shadow: 0 0 0 .2rem rgba(17, 205, 198, .25);
}

.form-check-input {
  background-color: rgba(255, 255, 255, .25);
  border-color: rgba(255, 255, 255, .35);
}

.form-check-input:checked {
  background-color: var(--primary);
  border-color: var(--primary);
}

.toggle-card .form-check-label {
  color: var(--text);
  font-weight: 500;
  font-size: 0.9rem;
}

/* ===== BADGES ===== */
.badge {
  font-size: 0.75rem;
  padding: 0.25rem 0.5rem;
  border-radius: 6px;
  font-weight: 500;
}

.badge.text-bg-success {
  background: #22c55e;
}

.badge.text-bg-secondary {
  background: #475569;
}

.badge.bg-success-subtle {
  background: rgba(34, 197, 94, .15) !important;
  color: #86efac !important;
  border: 1px solid rgba(34, 197, 94, .35);
}

.badge.bg-warning-subtle {
  background: rgba(234, 179, 8, .15) !important;
  color: #fde68a !important;
  border: 1px solid rgba(234, 179, 8, .35);
}

/* ===== ALERTES ===== */
.alert {
  border-radius: 12px;
  padding: 1rem;
  margin-bottom: 1rem;
  font-size: 0.9rem;
}

.alert-info {
  background: rgba(59, 130, 246, 0.1);
  border: 1px solid rgba(59, 130, 246, 0.3);
  color: #93c5fd;
}

.alert-success {
  background: rgba(34, 197, 94, 0.1);
  border: 1px solid rgba(34, 197, 94, 0.3);
  color: #86efac;
}

/* ===== FOOTER ===== */
.footer {
  margin-top: auto;
  background: linear-gradient(180deg, transparent, rgba(0, 0, 0, .25));
  border-top: 1px solid var(--border);
  padding: 1.5rem 1rem;
  text-align: center;
}

/* ===== UTILITAIRES ===== */
.hero {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 40vh;
  padding: 2rem 1rem;
}

.text-muted {
  color: #94a3b8 !important;
  opacity: .9;
}

.help-dim {
  color: #9aa4ad;
  font-size: 0.85rem;
}

.icon-btn {
  border: none;
  background: transparent;
  color: #cbd5e1;
  padding: 0.5rem;
  transition: color 0.2s ease;
  cursor: pointer;
}

.icon-btn:hover {
  color: #fff;
}

/* ===== OTP INPUTS ===== */
.otp {
  display: flex;
  gap: 8px;
  justify-content: center;
  flex-wrap: wrap;
}

.otp input {
  width: 42px;
  height: 48px;
  text-align: center;
  font-size: 1.1rem;
  border-radius: 8px;
  background: rgba(255, 255, 255, .08);
  border: 1px solid rgba(255, 255, 255, .18);
  color: #fff;
}

.otp input:focus {
  outline: none;
  box-shadow: 0 0 0 .2rem rgba(17, 205, 198, .25);
}

/* ===== MEDIA QUERIES MOBILE ===== */
@media (max-width: 768px) {
  /* Ajustements généraux */
  .page-wrap {
    padding: 0.75rem;
    padding-top: 1rem;
  }
  
  .container {
    padding-left: 0.75rem;
    padding-right: 0.75rem;
  }
  
  /* Titres */
  h1, .h1 {
    font-size: 1.5rem;
  }
  
  h2, .h2 {
    font-size: 1.25rem;
  }
  
  h3, .h3, h4, .h4 {
    font-size: 1.1rem;
  }
  
  h5, .h5 {
    font-size: 1rem;
  }
  
  /* Cartes */
  .card-glass {
    padding: 0.75rem;
    border-radius: 12px;
  }
  
  .card-body {
    padding: 0.75rem;
  }
  
  /* Boutons */
  .btn {
    font-size: 0.85rem;
    padding: 0.45rem 0.75rem;
  }
  
  .btn-sm {
    font-size: 0.8rem;
    padding: 0.35rem 0.6rem;
  }
  
  /* Formulaires dans les tableaux */
  .table {
    font-size: 0.75rem;
  }
  
  .table th {
    font-size: 0.7rem;
    padding: 0.5rem 0.25rem;
  }
  
  .table td {
    padding: 0.35rem 0.25rem;
  }
  
  .table input.form-control,
  .table .form-select {
    font-size: 0.75rem;
    padding: 0.25rem 0.35rem;
    min-width: 80px;
  }
  
  /* Toggle cards */
  .toggle-card {
    padding: 0.75rem;
  }
  
  .toggle-card .h6 {
    font-size: 0.95rem;
  }
  
  .toggle-card .small {
    font-size: 0.8rem;
  }
  
  /* Badges */
  .badge {
    font-size: 0.7rem;
    padding: 0.2rem 0.4rem;
  }
  
  /* Alertes */
  .alert {
    padding: 0.75rem;
    font-size: 0.85rem;
  }
  
  /* Hero section */
  .hero {
    min-height: 30vh;
    padding: 1.5rem 0.75rem;
  }
  
  /* Navigation mobile */
  .navbar-collapse {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: rgba(7, 14, 26, 0.98);
    backdrop-filter: blur(12px);
    border: 1px solid var(--border);
    border-top: none;
    border-radius: 0 0 12px 12px;
    padding: 1rem;
    max-height: calc(100vh - var(--navbar-height));
    overflow-y: auto;
  }
  
  .navbar-nav {
    margin: 0;
    padding: 0;
  }
  
  .navbar-nav .nav-item {
    margin-bottom: 0.25rem;
  }
  
  .navbar-nav .nav-link {
    display: block;
    padding: 0.6rem 1rem;
    border-radius: 8px;
  }
  
  /* Stack de boutons dans les en-têtes */
  .d-flex.justify-content-between {
    flex-wrap: wrap;
    gap: 0.5rem;
  }
  
  /* Tables super responsive */
  .table-responsive {
    margin: 0 -0.75rem;
    padding: 0 0.75rem;
  }
  
  /* Amélioration de la lisibilité des dates sur mobile */
  input[type="date"],
  input[type="month"] {
    min-width: 140px;
  }
  
  /* Boutons d'action dans les tableaux */
  .icon-btn {
    padding: 0.35rem;
    font-size: 1rem;
  }
  
  /* Footer */
  .footer {
    padding: 1rem 0.75rem;
    font-size: 0.8rem;
  }
}

/* ===== MEDIA QUERIES TRÈS PETIT MOBILE ===== */
@media (max-width: 380px) {
  /* Encore plus compact */
  .page-wrap {
    padding: 0.5rem;
  }
  
  .container {
    padding-left: 0.5rem;
    padding-right: 0.5rem;
  }
  
  .card-glass {
    padding: 0.5rem;
  }
  
  .btn {
    font-size: 0.8rem;
    padding: 0.4rem 0.6rem;
  }
  
  /* Tables ultra-compactes */
  .table {
    font-size: 0.7rem;
  }
  
  .table th,
  .table td {
    padding: 0.25rem;
  }
  
  .table input.form-control,
  .table .form-select {
    font-size: 0.7rem;
    padding: 0.2rem 0.3rem;
    min-width: 70px;
  }
  
  /* OTP plus petit */
  .otp input {
    width: 38px;
    height: 44px;
    font-size: 1rem;
  }
  
  /* Navigation encore plus compacte */
  .navbar-brand {
    font-size: 0.95rem;
  }
  
  .navbar-brand img {
    width: 24px;
    height: 24px;
  }
}

/* ===== CORRECTIONS SPÉCIFIQUES iOS ===== */
@supports (-webkit-touch-callout: none) {
  /* iOS Safari fixes */
  body {
    -webkit-text-size-adjust: 100%;
  }
  
  input, select, textarea {
    font-size: 16px; /* Empêche le zoom automatique */
  }
  
  .navbar-glass {
    -webkit-backdrop-filter: blur(8px);
  }
  
  .navbar-collapse {
    -webkit-backdrop-filter: blur(12px);
  }
}

/* ===== DARK MODE IMPROVEMENTS ===== */
@media (prefers-color-scheme: dark) {
  :root {
    --glass: rgba(255, 255, 255, .08);
    --border: rgba(255, 255, 255, .18);
  }
}

/* ===== PRINT STYLES ===== */
@media print {
  body.bg {
    background: white;
    color: black;
  }
  
  .navbar-glass,
  .footer,
  .btn,
  .icon-btn {
    display: none !important;
  }
  
  .card-glass {
    border: 1px solid #ccc;
    background: white;
  }
  
  .page-wrap {
    padding-top: 0;
  }
}

/* ===== ANIMATIONS ===== */
@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.navbar-collapse.show {
  animation: slideDown 0.3s ease;
}

.alert {
  animation: fadeIn 0.3s ease;
}

/* ===== CORRECTIFS FINAUX ===== */

/* Fix pour éviter le chevauchement avec la navbar */
.container > .d-flex:first-child {
  margin-top: 0.5rem;
}

/* Amélioration de l'espacement vertical */
.mb-3 {
  margin-bottom: 1rem !important;
}

.mb-2 {
  margin-bottom: 0.75rem !important;
}

/* Textes plus lisibles */
body.bg * {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Boutons plus clairs dans les formulaires */
button[type="submit"] {
  min-width: 120px;
  font-weight: 500;
}

/* Meilleure lisibilité des placeholders */
input::placeholder,
textarea::placeholder {
  opacity: 0.7;
}

/* Focus amélioré pour l'accessibilité */
*:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
  border-radius: 4px;
}

/* Scroll smooth */
html {
  scroll-behavior: smooth;
}

/* Empêche le débordement horizontal */
* {
  max-width: 100%;
}

/* Fix pour les tableaux dans les cartes */
.card-glass .table-responsive {
  margin-left: -0.75rem;
  margin-right: -0.75rem;
  padding-left: 0.75rem;
  padding-right: 0.75rem;
}

/* Amélioration du contraste pour les textes dimmed */
.help-dim,
.text-white-50 {
  color: #94a3b8 !important;
}


/* --- Ajuste l'espacement global du bloc --- */
.toggle-card { padding: .75rem; }
.toggle-header { align-items: center; }

/* --- Statut (Activé/Désactivé) en style "chip" mince --- */
.toggle-switch { display:flex; align-items:center; gap:.65rem; }

.toggle-status{
  display:inline-flex; align-items:center; justify-content:center;
  min-width:110px;                        /* plus court */
  padding:6px 12px;                       /* plus mince */
  line-height:1.1; font-weight:800; font-size:.95rem;
  border-radius:999px;
  border:1px solid var(--border);
  background: rgba(255,255,255,.04);      /* léger fond, pas massif */
  color:#cbd3dd;
  user-select:none; cursor:pointer;
  transition:all .18s ease-in-out;
}
.toggle-status.active{
  background: rgba(25,135,84,.16);        /* vert discret */
  color:#b5f0cd;
  border-color: rgba(25,135,84,.38);
}
.toggle-status:focus-visible{ outline:2px solid var(--primary); outline-offset:2px; }

/* --- Interrupteur "long et fin" --- */
.form-switch.form-switch-wide .form-check-input{
  width:5.2rem;       /* plus long */
  height:1.4rem;      /* plus fin */
  border-radius:2rem;
  cursor:pointer;
  background-color: rgba(255,255,255,.14);
  background-size: 1.2rem 1.2rem;         /* taille du "bouton" interne */
  border-color: rgba(255,255,255,.25);
}
.form-switch.form-switch-wide .form-check-input:focus{
  box-shadow:0 0 0 .18rem rgba(17,205,198,.25);
}
.form-switch.form-switch-wide .form-check-input:checked{
  background-color:#2bbf6f;               /* vert lisible */
  border-color:#2bbf6f;
}

/* Optionnel: si la ligne te semble encore trop présente, rends le chip "outline only" */
.toggle-status{ background: transparent; }               /* <- décommente pour outline only */
.toggle-status.active{ background: rgba(25,135,84,.10); }/* <- léger remplissage en mode actif */


/* === Fix visuel des <select> en thème sombre === */
:root { color-scheme: dark; } /* aide iOS/Windows */

select, .form-select{
  background-color: rgba(255,255,255,.06) !important;
  color: #e6e6f0 !important;
  border-color: var(--border) !important;
}
.form-select:focus{
  background-color: rgba(255,255,255,.10) !important;
  color: #e6e6f0 !important;
  border-color: #11cdc6 !important;
  box-shadow: 0 0 0 .25rem rgba(17,205,198,.25) !important;
}

/* Options du menu déroulant (Chrome/Firefox/Edge) */
select option,
.form-select option,
.form-select optgroup {
  background-color: #0e1830;
  color: #e6e6f0;
}

/* Si tu utilises des menus Bootstrap (dropdowns “custom”) */
.dropdown-menu{
  background: #0e1830;
  color: #e6e6f0;
  border-color: var(--border);
}
.dropdown-item{ color:#e6e6f0; }
.dropdown-item:hover{ background: rgba(17,205,198,.12); }
