/**
 * BPC Triathlon - Corrections Mobile Critiques
 * Corrige les problèmes de débordement, boutons flottants et footer
 */

/* ==================== CORRECTION 1 : DÉBORDEMENT HORIZONTAL ==================== */

/* Empêcher tout débordement horizontal */
html, body {
  overflow-x: hidden;
  max-width: 100vw;
  position: relative;
}

/* Tous les conteneurs respectent la largeur de l'écran */
* {
  max-width: 100%;
}

/* Box-sizing pour tous les éléments */
*, *::before, *::after {
  box-sizing: border-box;
}

/* Conteneurs principaux */
.container,
.section,
section,
main {
  width: 100%;
  max-width: 100vw;
  overflow-x: hidden;
}

/* Images et médias */
img, video, iframe, embed {
  max-width: 100%;
  height: auto;
}

/* Tableaux responsive */
table {
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  display: block;
}

/* Éviter les débordements de texte */
h1, h2, h3, h4, h5, h6, p, li, span {
  word-wrap: break-word;
  overflow-wrap: break-word;
  hyphens: auto;
}

/* ==================== CORRECTION 2 : BOUTONS FLOTTANTS ==================== */

@media (max-width: 768px) {
  /* Menu Toggle - Position fixe dans l'écran */
  .menu-toggle {
    position: fixed;
    bottom: 24px !important;
    right: 16px !important;
    left: auto !important;
    width: 56px !important;
    height: 56px !important;
    z-index: 2200;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    /* S'assurer qu'il reste visible */
    margin: 0;
    transform: none;
  }

  /* Sticky CTA "Réserver" - Position dans l'écran */
  .mobile-sticky-cta,
  .fab-cta {
    position: fixed;
    left: 16px !important;
    right: 16px !important;
    bottom: 16px !important;
    width: auto !important;
    max-width: calc(100vw - 32px) !important;
    z-index: 1800;
    display: inline-flex;
    justify-content: center;
    margin: 0;
    padding: 14px 24px;
    transform: none;
  }

  /* Si les deux boutons sont présents, ajuster le menu toggle */
  body:has(.mobile-sticky-cta) .menu-toggle,
  body:has(.fab-cta) .menu-toggle {
    bottom: 90px !important;
  }

  /* Bouton CTA dans le header - Masquer sur mobile */
  .header-cta {
    display: none !important;
  }
}

@media (max-width: 480px) {
  /* Ajustements pour petits écrans */
  .menu-toggle {
    width: 52px !important;
    height: 52px !important;
    bottom: 20px !important;
    right: 12px !important;
  }

  .mobile-sticky-cta,
  .fab-cta {
    left: 12px !important;
    right: 12px !important;
    bottom: 12px !important;
    font-size: 15px;
    padding: 12px 20px;
  }

  body:has(.mobile-sticky-cta) .menu-toggle,
  body:has(.fab-cta) .menu-toggle {
    bottom: 80px !important;
  }
}

/* ==================== CORRECTION 3 : FOOTER OPTIMISÉ ==================== */

@media (max-width: 768px) {
  /* Footer en colonne unique sur mobile */
  footer {
    padding: 40px 16px 24px 16px !important;
    overflow-x: hidden;
  }

  footer .container {
    padding: 0 !important;
    max-width: 100%;
  }

  /* Grid du footer en colonne unique */
  footer > .container > div[style*="grid"],
  footer .container > div[style*="grid-template-columns"] {
    display: flex !important;
    flex-direction: column !important;
    gap: 32px !important;
    grid-template-columns: 1fr !important;
  }

  /* Colonnes du footer */
  footer > .container > div > div {
    width: 100%;
    margin-bottom: 24px;
  }

  /* Titres du footer */
  footer h3 {
    font-size: 18px !important;
    margin-bottom: 16px !important;
    color: white;
  }

  /* Listes du footer */
  footer ul {
    padding: 0 !important;
    margin: 0 !important;
    list-style: none;
  }

  footer li {
    margin-bottom: 12px !important;
    line-height: 1.6;
  }

  /* Liens du footer */
  footer a {
    color: rgba(255, 255, 255, 0.9);
    text-decoration: none;
    display: inline-block;
    padding: 4px 0;
    font-size: 15px;
  }

  /* Paragraphes du footer */
  footer p {
    line-height: 1.6;
    margin-bottom: 12px;
    font-size: 15px;
    opacity: 0.9;
  }

  /* Icônes réseaux sociaux */
  footer > .container > div > div > div[style*="display: flex"] {
    display: flex !important;
    gap: 16px;
    flex-wrap: wrap;
  }

  /* Ligne de séparation */
  footer > .container > div[style*="border-top"] {
    margin-top: 32px !important;
    padding-top: 24px !important;
    text-align: center;
  }
}

@media (max-width: 480px) {
  footer {
    padding: 32px 12px 20px 12px !important;
  }

  footer h3 {
    font-size: 16px !important;
  }

  footer a,
  footer p {
    font-size: 14px;
  }

  footer > .container > div > div {
    margin-bottom: 20px;
  }
}

/* ==================== CORRECTIONS ADDITIONNELLES ==================== */

@media (max-width: 768px) {
  /* Hero - Éviter débordement */
  .hero,
  .hero-modern {
    width: 100%;
    max-width: 100vw;
    overflow: hidden;
  }

  .hero .container,
  .hero-modern .container {
    padding-left: 16px;
    padding-right: 16px;
  }

  /* Cards et éléments - Éviter débordement */
  .card,
  .pricing-card,
  .comparison-card,
  .article-card {
    width: 100%;
    max-width: 100%;
    margin-left: 0;
    margin-right: 0;
  }

  /* Grilles - Forcer une colonne */
  .grid,
  .grid-2,
  .grid-3,
  .grid-4,
  .comparison-grid,
  .pricing-grid,
  .blog-grid {
    display: flex !important;
    flex-direction: column;
    width: 100%;
    gap: 16px;
  }

  /* Boutons - Largeur adaptée */
  .btn,
  .btn-primary,
  .btn-secondary {
    max-width: 100%;
    width: auto;
    white-space: normal;
    text-align: center;
  }

  /* Tableaux - Scroll horizontal si nécessaire */
  .dates-table-container {
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* Sections - Padding correct */
  section,
  .section {
    padding-left: 16px !important;
    padding-right: 16px !important;
    width: 100%;
    max-width: 100vw;
  }

  /* Header - Éviter débordement */
  .site-header {
    width: 100%;
    max-width: 100vw;
    overflow: hidden;
  }

  .site-header .container {
    width: 100%;
    padding: 12px 16px;
  }

  /* Brand - Ajustement */
  .brand {
    max-width: calc(100vw - 120px);
  }

  .brand strong,
  .brand .note {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
}

/* ==================== SAFE ZONE POUR BOUTONS ==================== */

@media (max-width: 768px) {
  /* Zone de sécurité pour les boutons flottants */
  body {
    padding-bottom: 100px; /* Espace pour les boutons flottants */
  }

  /* Ajuster si sticky CTA présent */
  body:has(.mobile-sticky-cta),
  body:has(.fab-cta) {
    padding-bottom: 140px; /* Plus d'espace si CTA + menu */
  }
}

/* ==================== CORRECTION SLIDING MENU ==================== */

@media (max-width: 768px) {
  /* Menu glissant - S'assurer qu'il ne dépasse pas */
  .sliding-menu {
    width: 100%;
    max-width: min(400px, 100vw);
    right: -100%;
    left: auto;
  }

  .sliding-menu.active {
    right: 0;
  }

  .sliding-menu-content {
    padding: 24px 16px;
    max-width: 100%;
  }

  .sliding-menu-nav a {
    word-wrap: break-word;
    white-space: normal;
  }
}

/* ==================== DEBUG MODE (Optionnel) ==================== */

/* Décommenter pour voir les éléments qui débordent */
/*
* {
  outline: 1px solid red !important;
}
*/
