/**
 * SimCrise - Layout & Page Structure
 * Index Page Layout
 * 
 * Description: Reset, body, containers, cards, grids, logos, tooltips et structure de page
 * Usage: Importé après design-system et animations pour structure générale
 * Version: 1.0.0
 */

/* 🏗️ NIVEAU 3: SYSTÈME DE GRILLE AVANCÉ */

/* Classes de grille responsive intelligente */
.grid-responsive {
  display: grid;
  grid-template-columns: var(--grid-cols-responsive);
  gap: var(--grid-gap-md);
  width: 100%;
}

.grid-auto {
  display: grid;
  grid-template-columns: var(--grid-cols-auto);
  gap: var(--grid-gap-md);
  align-items: stretch;
}

.grid-3-cols {
  display: grid;
  grid-template-columns: var(--grid-cols-3);
  gap: var(--grid-gap-md);
}

/* Grille adaptative qui s'ajuste au contenu */
.grid-adaptive {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 280px), 1fr));
  gap: var(--grid-gap-md);
  align-items: start;
}

/* Responsive breakpoints pour grilles */
@media (max-width: 768px) {
  .grid-3-cols,
  .grid-responsive,
  .grid-auto {
    grid-template-columns: var(--grid-cols-1);
    gap: var(--grid-gap-sm);
  }
}

@media (min-width: 769px) and (max-width: 1024px) {
  .grid-3-cols {
    grid-template-columns: var(--grid-cols-2);
  }
}

/* NIVEAU 2: Reset complet pour mobile */
* {
  box-sizing: border-box;
}

html {
  font-size: var(--text-base); /* Système fluide au lieu de clamp fixe */
  margin: 0;
  padding: 0;
  width: 100%;
  overflow-x: hidden; /* Empêche le scroll horizontal */
}

body {
  margin: 0;
  padding: 0;
  width: 100%;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: var(--text-base);
  line-height: clamp(1.4, 2.5vw, 1.6); /* NIVEAU 2: Line-height fluide */
  -webkit-text-size-adjust: 100%;
  overflow-x: hidden; /* Empêche le scroll horizontal */
}

/* NIVEAU 2: Conteneurs fluides */
.wrap { 
  max-width: var(--container-xl); /* NIVEAU 2: Conteneur fluide */
  margin: var(--space-2xl) auto; /* NIVEAU 2: Marge fluide */
  padding: 0 var(--space-xs); /* NIVEAU 2: Padding minimal pour mobile */
  overflow: visible;
  width: 100%;
  box-sizing: border-box;
  z-index: 1;
  background: white; /* Fond blanc pour effet boîte centrée */
  border-radius: 8px; /* Coins arrondis pour l'effet carte */
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1); /* Ombre subtile */
}

/* Padding plus généreux sur écrans plus grands */
@media (min-width: 600px) {
  .wrap {
    padding: 0 var(--space-md);
  }
}

/* NIVEAU 2: Cards avec espacement fluide */
.card { 
  background: var(--card); 
  border: none; /* Suppression bordure pour design épuré */
  border-radius: var(--radius-lg); /* NIVEAU 2: Rayon fluide */
  padding: var(--space-lg); /* NIVEAU 2: Padding fluide */
  margin-bottom: var(--space-lg); /* NIVEAU 2: Marge fluide */
  box-shadow: var(--shadow-sm);
  overflow-x: hidden;
  overflow-y: visible;
  width: 100%;
  box-sizing: border-box;
}

/* Form elements and interactive components */
h1 { 
  font-size: var(--text-2xl); /* NIVEAU 2: Titre fluide */
  margin: 0 0 var(--space-md); /* NIVEAU 2: Marge fluide */
  line-height: 1.2;
}

h2 {
  font-size: var(--text-xl); /* NIVEAU 2: Sous-titre fluide */
  margin: 0 0 var(--space-sm);
  line-height: 1.3;
}

h3 {
  font-size: var(--text-lg); /* NIVEAU 2: Titre section fluide */
  margin: 0 0 var(--space-sm);
  line-height: 1.4;
}

label { 
  display: block; 
  font-size: var(--text-sm); /* NIVEAU 2: Label fluide */
  margin: var(--space-md) 0 var(--space-xs); /* NIVEAU 2: Marges fluides */
  font-weight: 500;
}

/* NIVEAU 2: Layout et système de grille fluide */
.row { 
  display: grid; 
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 250px), 1fr)); /* NIVEAU 2: Grille adaptive */
  gap: var(--space-md); /* NIVEAU 2: Gap fluide */
}

.configuration-grid { 
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 280px), 1fr)); /* NIVEAU 2: Configuration adaptive */
  gap: var(--space-md); /* NIVEAU 2: Gap fluide */
}

.responsive-input-group { 
  display: flex; 
  gap: var(--space-sm); /* NIVEAU 2: Gap fluide */
  align-items: center; 
  flex-wrap: wrap; 
  margin-bottom: var(--space-md); /* NIVEAU 2: Marge fluide */
}

/* NIVEAU 2: Optimisations layout mobile avec système fluide */
@media (max-width: var(--tablet)) {
  .configuration-grid { 
    grid-template-columns: 1fr !important; 
    gap: var(--space-sm) !important; /* NIVEAU 2: Gap fluide mobile */
  }
  
  .responsive-input-group { 
    flex-direction: column; 
    align-items: stretch; 
    gap: var(--space-xs) !important; /* NIVEAU 2: Gap réduit mobile */
  }
  
  .responsive-input-group input, 
  .responsive-input-group button { 
    width: 100%; 
    min-width: 0;
    /* NIVEAU 1 FIX: Touch targets améliorés pour formulaires */
    min-height: 48px !important;
    touch-action: manipulation;
    font-size: max(16px, var(--text-base)) !important; /* NIVEAU 2: Taille fluide */
    padding: var(--space-sm) var(--space-md) !important; /* NIVEAU 2: Padding fluide */
  }
  
  /* GDPR form reorganization for mobile */
  .risk-major-form,
  .first-aid-form {
    display: flex !important;
    flex-direction: column !important;
  }
  
  .risk-consent-box,
  .first-aid-consent-box {
    order: 2;
    margin: 10px 0 8px 0 !important;
  }
  
  .risk-major-form input,
  .first-aid-form input {
    order: 1;
  }
  
  .risk-major-form button,
  .first-aid-form button {
    order: 3;
  }
  .row { 
    grid-template-columns: 1fr !important; 
    gap: var(--space-sm) !important; /* NIVEAU 2: Gap fluide */
  }
  
  .wrap { 
    padding: 0 var(--space-md); /* NIVEAU 2: Padding fluide */
    margin: var(--space-lg) auto; /* NIVEAU 2: Marge fluide */
  }
  
  .card { 
    padding: var(--space-sm); /* NIVEAU 2: Padding fluide */
    margin-bottom: var(--space-sm); /* NIVEAU 2: Marge fluide */
    overflow-y: visible !important; /* Assure que les pastilles dépassent sur mobile */
    border-radius: var(--radius-md); /* NIVEAU 2: Rayon fluide */
  }
  
  /* NIVEAU 2: Logo optimisé avec système fluide */
  .logo-container img { 
    max-height: clamp(100px, 20vw, 140px) !important; /* NIVEAU 2: Hauteur fluide */
    max-width: 95vw !important;
    width: auto !important;
    display: block !important;
    margin: 0 auto !important;
    border-radius: var(--radius-lg) !important; /* NIVEAU 2: Rayon fluide */
  }
  .logo-container {
    margin-bottom: var(--space-lg) !important; /* NIVEAU 2: Marge fluide */
  }
}

@media (max-width: 480px) {
  /* NIVEAU 2: Très petits écrans avec système fluide */
  .logo-container img { 
    max-height: clamp(80px, 18vw, 110px) !important; /* NIVEAU 2: Plus compact mais fluide */
    max-width: 90vw !important;
    width: auto !important;
  }
  .logo-container p {
    font-size: var(--text-xs) !important; /* NIVEAU 2: Taille fluide */
    margin-top: var(--space-sm) !important; /* NIVEAU 2: Marge fluide */
  }
  .logo-container {
    margin-bottom: var(--space-md) !important; /* NIVEAU 2: Marge fluide */
  }
  
  /* NIVEAU 2: Cards encore plus compactes */
  .card {
    padding: var(--space-xs) !important; /* NIVEAU 2: Padding minimal fluide */
    border-radius: var(--radius-sm) !important; /* NIVEAU 2: Rayon réduit */
  }
  
  /* NIVEAU 2: Ajustements typographiques */
  h1 {
    font-size: var(--text-xl) !important; /* NIVEAU 2: Titre réduit fluide */
  }
  
  h2 {
    font-size: var(--text-lg) !important; /* NIVEAU 2: Sous-titre réduit fluide */
  }
  
  h3 {
    font-size: var(--text-base) !important; /* NIVEAU 2: Section réduite fluide */
  }
}

/* NIVEAU 2: Infobulles fluides */
.info-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: clamp(16px, 4vw, 20px); /* NIVEAU 2: Taille fluide */
  height: clamp(16px, 4vw, 20px); /* NIVEAU 2: Taille fluide */
  background: var(--card-semi);
  border: 1px solid var(--line);
  border-radius: 50%;
  cursor: pointer;
  margin-left: var(--space-xs); /* NIVEAU 2: Marge fluide */
  font-size: var(--text-xs); /* NIVEAU 2: Taille de texte fluide */
  color: var(--muted);
  transition: all 0.3s ease;
  position: relative;
}

.info-icon:hover {
  background: var(--bg-hover);
  border-color: var(--accent);
  color: var(--accent);
  transform: scale(1.1);
}

.tooltip {
  position: absolute;
  top: -8px;
  left: 50%;
  transform: translateX(-50%) translateY(-100%);
  background: #2c3e50;
  color: white;
  padding: var(--space-sm) var(--space-md); /* NIVEAU 2: Padding fluide */
  border-radius: var(--radius-md); /* NIVEAU 2: Rayon fluide */
  font-size: var(--text-sm); /* NIVEAU 2: Taille fluide */
  line-height: 1.4;
  width: clamp(240px, 50vw, 320px); /* NIVEAU 2: Largeur fluide */
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
  pointer-events: none;
}

.tooltip::after {
  content: '';
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 6px solid transparent;
  border-top-color: #2c3e50;
}

.info-icon:hover .tooltip, .info-icon:focus .tooltip, .info-icon.touch-active .tooltip {
  opacity: 1;
  visibility: visible;
  transform: translateX(-50%) translateY(-100%) translateY(-8px);
  pointer-events: auto;
}

/* 🛈 Touch-friendly modal tooltips on mobile */
@media (max-width: 700px) {
  .info-icon.touch-active::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 19999;
    opacity: 1;
    animation: fadeIn 0.2s ease;
  }
  
  .tooltip {
    position: fixed !important;
    top: 50% !important;
    left: 50% !important;
    transform: translate(-50%, -50%) !important;
    width: calc(100vw - 40px) !important;
    max-width: 320px;
    max-height: calc(100vh - 80px);
    overflow-y: auto;
    z-index: 20000;
    font-size: 0.9rem;
    padding: 16px 14px;
    border-radius: 12px;
    box-shadow: 0 12px 40px rgba(0,0,0,0.3);
    background: #ffffff;
    color: #2c3e50;
    border: 1px solid #e0e0e0;
    margin: 0;
    box-sizing: border-box;
  }
  
  .tooltip::after {
    display: none; /* Hide arrow on mobile modal */
  }
  
  .info-icon.touch-active .tooltip {
    transform: translate(-50%, -50%) !important;
    opacity: 1 !important;
    visibility: visible !important;
  }
  
  @keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
  }
}

@media (min-width: 601px) and (max-width: 768px) {
  .tooltip {
    width: 260px;
    font-size: 0.85rem;
    padding: 10px 14px;
  }
}

/* 🎯 Pastille titre responsive pour éviter le débordement */
.orientation-badge {
  max-width: calc(100% - 40px); /* Limite la largeur */
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

@media (max-width: 600px) {
  .orientation-badge {
    position: static !important; /* Pas de position absolue sur mobile */
    transform: none !important;
    margin: -12px auto 16px auto;
    display: block;
    text-align: center;
    font-size: 0.85rem !important;
    padding: 8px 16px !important;
    width: fit-content;
    max-width: 90%;
    animation: none !important; /* Pas d'animation sur mobile */
  }
  
  #orientation-guide {
    padding-top: 16px !important; /* Moins de padding en haut */
  }
}

@media (max-width: 480px) {
  .orientation-badge {
    font-size: 0.8rem !important;
    padding: 6px 12px !important;
  }
}

.mt-12{ margin-top:var(--space-sm); } .mt-16{ margin-top:var(--space-md); } .mt-24{ margin-top:var(--space-lg); }
/* 📏 Espacement amélioré avec variables fluides */
.mt-32{ margin-top:var(--space-xl); } .mt-40{ margin-top:var(--space-2xl); }

/* Variables fluides s'adaptent automatiquement sur mobile */

.hide { display:none; }

/* Styles simulation simplifiés */

/* Transition fluide pour les boutons */
.bottom-buttons {
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

/* 📋 Simulation pleine largeur - Force la sortie de tous les conteneurs */
.simulation-zone {
  position: relative !important;
  width: 100vw !important;
  left: 50% !important;
  right: 50% !important;
  margin-left: -50vw !important;
  margin-right: -50vw !important;
  max-width: none !important;
  padding: 0 !important;
  margin-bottom: 0 !important;
  box-sizing: border-box;
  overflow-x: visible !important; /* Surcharge le overflow-x: hidden de .card */
  overflow-y: visible !important;
  z-index: 25000 !important; /* Au-dessus de tous les autres éléments */
  background: white !important; /* S'assurer qu'elle a un fond visible */
}

/* Conteneur parent de la barre : zero padding en bas */
.simulation-zone > div:last-child {
  padding-bottom: 0 !important;
  margin-bottom: 0 !important;
}

.simulation-zone > div {
  max-width: none !important;
  width: 100% !important;
  padding: 0 !important;
  margin: 0 !important;
}
