/**
 * SimCrise - Forms & Input Elements
 * Index Page Forms
 * 
 * Description: Formulaires, inputs, selects, buttons, checkboxes RGPD et boutons spéciaux
 * Usage: Importé après layout pour styles formulaires
 * Version: 1.0.0
 */

/* NIVEAU 2: Éléments de formulaire fluides */
select, input[type="text"], button {
  font: inherit;
  padding: var(--space-sm) var(--space-md); /* NIVEAU 2: Padding fluide */
  border: 1px solid var(--line);
  border-radius: var(--radius-md); /* NIVEAU 2: Rayon fluide */
  background: var(--card);
  min-height: max(44px, var(--tap-min)); /* NIVEAU 1 FIX: Touch target minimum garanti */
  min-width: max(44px, 48px); /* NIVEAU 1 FIX: Largeur minimum touch */
  box-sizing: border-box;
  font-size: var(--text-base); /* NIVEAU 2: Taille de texte fluide */
  /* NIVEAU 1 FIX: Optimisations touch universelles */
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
  transition: var(--transition);
}

select, input[type="text"] { 
  width: 100%; 
  font-size: var(--text-base); /* NIVEAU 2: Taille fluide */
}

/* NIVEAU 1 FIX: Permettre sélection de texte dans les inputs */
select, input[type="text"], textarea {
  -webkit-user-select: text !important;
  user-select: text !important;
}

/* NIVEAU 2: Boutons avec design fluide */
button {
  cursor: pointer;
  background: var(--accent);
  color: var(--card);
  border: none;
  transition: var(--transition);
  min-height: max(44px, var(--tap-min));
  min-width: max(48px, var(--space-3xl));
  font-size: var(--text-base); /* NIVEAU 2: Taille fluide */
  font-weight: 600;
  touch-action: manipulation;
  border-radius: var(--radius-md); /* NIVEAU 2: Rayon fluide */
  padding: var(--space-sm) var(--space-md); /* NIVEAU 2: Espacement fluide */
}

button:disabled { 
  opacity: 0.7; 
  cursor: not-allowed; 
}

button:hover:not(:disabled), button:active:not(:disabled) {
  transform: translateY(-1px) scale(1.03);
  box-shadow: var(--shadow-md);
}

/* Special First Aid button styling with logo colors */
#firstAidBtn:hover:not(:disabled) {
  background: linear-gradient(135deg, #BF2424, #8C3048) !important;
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(140, 48, 72, 0.6);
}

#firstAidName:focus {
  border-color: #BF2424;
  box-shadow: 0 0 0 3px rgba(140, 48, 72, 0.2);
  outline: none;
}

/* Disabled button styles - GDPR UX improvement */
button:disabled {
  cursor: not-allowed !important;
  opacity: 0.5 !important;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

/* Visual feedback for enabled buttons */
#startBtn:not(:disabled):hover {
  opacity: 0.9;
  transform: translateY(-1px);
}

#riskPreparationBtn:not(:disabled):hover {
  opacity: 0.9;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(197, 37, 41, 0.5);
}

#firstAidBtn:not(:disabled) {
  opacity: 1;
}

/* Enhanced tooltips for simulator buttons */
#endBtn, #autoScrollToggle {
  position: relative;
}

#endBtn:focus, #autoScrollToggle:focus {
  outline: 3px solid rgba(255, 255, 255, 0.5);
  outline-offset: 2px;
}

/* Style des tooltips natifs amélioré */
#endBtn[title]:hover::after,
#autoScrollToggle[title]:hover::after {
  content: attr(title);
  position: absolute;
  bottom: 120%;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(30, 41, 59, 0.95);
  color: white;
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 0.8rem;
  font-weight: 400;
  white-space: nowrap;
  max-width: 200px;
  text-align: center;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
  z-index: 1000;
  backdrop-filter: blur(4px);
  animation: tooltip-appear 0.2s ease-out;
}

#endBtn[title]:hover::before,
#autoScrollToggle[title]:hover::before {
  content: '';
  position: absolute;
  bottom: 112%;
  left: 50%;
  transform: translateX(-50%);
  border: 5px solid transparent;
  border-top-color: rgba(30, 41, 59, 0.95);
  z-index: 1000;
}

/* 🔑 Styles pour le système d'accès rapide */
#access_code_input:focus {
  border-color: var(--primary, #1a3f6e);
  box-shadow: 0 0 0 3px rgba(26, 63, 110, 0.1);
  outline: none;
}

#access_code_btn:hover:not(:disabled) {
  background: linear-gradient(135deg, #164a83, #0f3a6b);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(26, 63, 110, 0.35);
}

#access_code_btn:active {
  transform: translateY(0);
}

#access_code_btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.responsive-input-group {
  position: relative;
}

.responsive-input-group input:invalid {
  border-color: var(--danger, #dc2626);
}

.responsive-input-group input:valid:not(:placeholder-shown) {
  border-color: #059669;
}

/* 📱 Cases à cocher RGPD optimisées pour mobile */
@media (max-width: 768px) {
  .risk-consent-box input[type="checkbox"],
  .first-aid-consent-box input[type="checkbox"],
  #normal_consent,
  #code_consent,
  #first_aid_consent,
  #risk_consent {
    transform: scale(0.9) !important; /* Plus petit sur mobile */
    min-width: 14px !important;
    min-height: 14px !important;
    margin-top: 1px !important;
    margin-right: 8px !important;
    /* Force la visibilité des cases à cocher */
    -webkit-appearance: checkbox !important;
    appearance: auto !important;
    opacity: 1 !important;
    display: inline-block !important;
    position: relative !important;
  }
  
  /* 🎯 Correction spécifique PSE pour cases à cocher */
  #premier-secours-equipe-section input[type="checkbox"] {
    transform: scale(0.8) !important; /* Encore plus petit pour PSE */
    min-width: 12px !important;
    min-height: 12px !important;
  }
  
  /* 📝 Texte RGPD plus petit sur mobile */
  .risk-consent-box,
  .first-aid-consent-box {
    font-size: 0.75rem !important; /* Texte plus petit */
    line-height: 1.3 !important;
    padding: 12px !important; /* Padding réduit */
  }
}
