/**
 * ============================================
 * FEUILLE DE STYLES RESPONSIVE GLOBALE
 * Eden Family School - Tous les appareils
 * ============================================
 */

/* iOS & touch improvements */
html, body {
  -webkit-overflow-scrolling: touch; /* smooth scrolling on iOS */
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: rgba(0,0,0,0);
  touch-action: manipulation;
  -webkit-text-size-adjust: 100%; /* prevent automatic font zoom on iOS */
  text-size-adjust: 100%; /* standard property for broader browser support */
}

/* ===== VARIABLES DE BASE ===== */
:root {
  --screen-xs: 320px;
  --screen-sm: 480px;
  --screen-md: 768px;
  --screen-lg: 1024px;
  --screen-xl: 1200px;
  --screen-xxl: 1400px;
  
  /* Espacement */
  --spacing-xs: 0.25rem;
  --spacing-sm: 0.5rem;
  --spacing-md: 1rem;
  --spacing-lg: 1.5rem;
  --spacing-xl: 2rem;
  --spacing-xxl: 3rem;
  
  /* Typographie fluide */
  --font-size-xs: clamp(0.75rem, 2vw, 0.875rem);
  --font-size-sm: clamp(0.875rem, 2.5vw, 1rem);
  --font-size-base: clamp(1rem, 3vw, 1.125rem);
  --font-size-lg: clamp(1.125rem, 3.5vw, 1.5rem);
  --font-size-xl: clamp(1.5rem, 4vw, 2rem);
  --font-size-2xl: clamp(1.875rem, 5vw, 2.5rem);
  --font-size-3xl: clamp(2.25rem, 6vw, 3.5rem);
  --font-size-4xl: clamp(3rem, 8vw, 4rem);
}

/* ===== RÉSETS UNIVERSELS ===== */
* {
  box-sizing: border-box;
}

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  margin: 0;
  padding: 0;
  font-family: 'Poppins', 'Segoe UI', sans-serif;
  line-height: 1.6;
  overflow-x: hidden;
}

/* ===== IMAGES RESPONSIVES ===== */
img {
  max-width: 100%;
  height: auto;
  display: block;
}

/* ===== CONTENEURS FLUIDES ===== */
.container-fluid {
  width: 100%;
  padding-left: var(--spacing-md);
  padding-right: var(--spacing-md);
  margin-left: auto;
  margin-right: auto;
}

.container {
  width: 100%;
  padding-left: var(--spacing-md);
  padding-right: var(--spacing-md);
  margin-left: auto;
  margin-right: auto;
  max-width: 1400px;
}

/* ===== GRILLES RESPONSIVES ===== */
.grid {
  display: grid;
  gap: var(--spacing-md);
}

.grid-2 { grid-template-columns: 1fr; }
.grid-3 { grid-template-columns: 1fr; }
.grid-4 { grid-template-columns: 1fr; }

/* ===== TYPOGRAPHIE RESPONSIVE ===== */
h1 { font-size: var(--font-size-4xl); }
h2 { font-size: var(--font-size-3xl); }
h3 { font-size: var(--font-size-2xl); }
h4 { font-size: var(--font-size-xl); }
h5 { font-size: var(--font-size-lg); }
h6 { font-size: var(--font-size-base); }
p { font-size: var(--font-size-base); }

/* ===== BOUTONS RESPONSIVES ===== */
button, .btn {
  padding: var(--spacing-md) var(--spacing-lg);
  font-size: var(--font-size-base);
  border-radius: 8px;
  border: none;
  cursor: pointer;
  transition: all 0.3s ease;
  min-height: 44px;
  min-width: 44px;
}

/* improve touch targets and prevent double-tap zoom on interactive elements */
a, button, .btn {
  touch-action: manipulation;
  -webkit-tap-highlight-color: rgba(0,0,0,0);
}

/* ===== FORMULAIRES RESPONSIVES ===== */
input, textarea, select {
  font-size: 16px; /* Prévient le zoom sur mobile */
  width: 100%;
  padding: var(--spacing-md);
  border-radius: 8px;
  border: 1px solid #ddd;
  font-family: inherit;
  transition: all 0.3s ease;
}

input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--primary-color, #667eea);
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

/* ===== NAVIGATION RESPONSIVE ===== */
nav {
  padding: var(--spacing-md);
}

.nav-container {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--spacing-md);
  padding: var(--spacing-md);
}

.nav-links {
  display: flex;
  list-style: none;
  gap: var(--spacing-lg);
  flex-wrap: wrap;
}

.nav-links a {
  text-decoration: none;
  padding: var(--spacing-sm) var(--spacing-md);
  transition: all 0.3s ease;
  border-radius: 6px;
}

.mobile-menu {
  display: none;
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  padding: var(--spacing-sm);
  color: inherit;
  transition: all 0.3s ease;
  z-index: 1000;
  position: relative;
}

/* ===== SECTION SPACING ===== */
section {
  padding: var(--spacing-xxl) var(--spacing-xl);
  width: 100%;
}

/* ===== CARTES RESPONSIVES ===== */
.card {
  border-radius: 12px;
  padding: var(--spacing-lg);
  transition: all 0.3s ease;
  overflow: hidden;
}

.card:hover {
  transform: translateY(-4px);
}

/* ===== FLEXBOX HELPERS ===== */
.flex {
  display: flex;
  flex-wrap: wrap;
  gap: var(--spacing-md);
}

.flex-center {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: var(--spacing-md);
}

.flex-between {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--spacing-md);
}

/* ===== MEDIA QUERY: TRÈS PETITS ÉCRANS (320px - 479px) ===== */
@media (max-width: 479px) {
  :root {
    --spacing-xs: 0.25rem;
    --spacing-sm: 0.375rem;
    --spacing-md: 0.75rem;
    --spacing-lg: 1rem;
    --spacing-xl: 1.25rem;
    --spacing-xxl: 1.5rem;
  }

  html {
    font-size: 14px;
  }

  body {
    padding: 0;
    margin: 0;
  }

  body.menu-open {
    overflow: hidden;
  }

  body.menu-open::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 998;
  }

  section {
    padding: var(--spacing-xl) var(--spacing-md);
  }

  .container-fluid,
  .container {
    padding-left: var(--spacing-md);
    padding-right: var(--spacing-md);
  }

  .nav-links {
    position: fixed;
    left: -100%;
    top: 70px;
    flex-direction: column;
    width: 100%;
    text-align: center;
    transition: left 0.3s ease;
    padding: var(--spacing-lg);
    gap: var(--spacing-md);
    z-index: 999;
    background-color: white;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    max-height: calc(100vh - 70px);
    overflow-y: auto;
  }

  /* Ensure nav links and buttons contrast on white mobile menu */
  .nav-links a,
  .nav-links button,
  .nav-links .btn {
    color: #222 !important;
  }

  .nav-links .btn-primary,
  .nav-links .btn-secondary {
    color: #fff !important;
  }

  .nav-links a i,
  .nav-links button i {
    color: inherit !important;
  }

  .nav-links.active {
    left: 0;
  }

  .mobile-menu {
    display: block;
  }

  .grid-2,
  .grid-3,
  .grid-4 {
    grid-template-columns: 1fr !important;
  }

  input, textarea, select, button {
    min-height: 48px;
    font-size: 16px;
  }

  button, .btn {
    width: 100%;
  }

  .card {
    padding: var(--spacing-lg);
    border-radius: 10px;
  }

  h1 { margin: var(--spacing-md) 0; }
  h2 { margin: var(--spacing-md) 0; }
  h3 { margin: var(--spacing-sm) 0; }
  p { margin: var(--spacing-sm) 0; }

  .hide-mobile {
    display: none;
  }

  .show-mobile {
    display: block;
  }
}

/* ===== MEDIA QUERY: PETITES TABLETTES (480px - 767px) ===== */
@media (min-width: 480px) and (max-width: 767px) {
  :root {
    --spacing-xs: 0.375rem;
    --spacing-sm: 0.5rem;
    --spacing-md: 0.875rem;
    --spacing-lg: 1.25rem;
    --spacing-xl: 1.5rem;
    --spacing-xxl: 2rem;
  }

  html {
    font-size: 15px;
  }

  section {
    padding: var(--spacing-xxl) var(--spacing-xl);
  }

  .grid-2 { grid-template-columns: 1fr; }
  .grid-3 { grid-template-columns: repeat(2, 1fr); }
  .grid-4 { grid-template-columns: repeat(2, 1fr); }

  .mobile-menu {
    display: block;
  }

  .nav-links {
    position: fixed;
    left: -100%;
    top: 70px;
    flex-direction: column;
    width: 100%;
    transition: left 0.3s ease;
    padding: var(--spacing-lg);
    gap: var(--spacing-md);
    z-index: 999;
    background-color: white;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    max-height: calc(100vh - 70px);
    overflow-y: auto;
  }

  .nav-links.active {
    left: 0;
  }

  input, textarea, select {
    font-size: 15px;
  }
}

/* ===== MEDIA QUERY: TABLETTES (768px - 1023px) ===== */
@media (min-width: 768px) and (max-width: 1023px) {
  :root {
    --spacing-md: 1rem;
    --spacing-lg: 1.5rem;
    --spacing-xl: 2rem;
    --spacing-xxl: 2.5rem;
  }

  html {
    font-size: 15.5px;
  }

  section {
    padding: var(--spacing-xxl) var(--spacing-xl);
  }

  .grid-2 { grid-template-columns: repeat(2, 1fr); }
  .grid-3 { grid-template-columns: repeat(2, 1fr); }
  .grid-4 { grid-template-columns: repeat(2, 1fr); }

  .mobile-menu {
    display: none;
  }

  .nav-links {
    position: static;
    flex-direction: row;
    width: auto;
    padding: 0;
  }

  input, textarea, select {
    font-size: 16px;
  }
}

/* ===== MEDIA QUERY: ÉCRANS MOYENS (1024px - 1199px) ===== */
@media (min-width: 1024px) and (max-width: 1199px) {
  section {
    padding: var(--spacing-xxl) var(--spacing-xl);
  }

  .container {
    max-width: 960px;
  }

  .grid-2 { grid-template-columns: repeat(2, 1fr); }
  .grid-3 { grid-template-columns: repeat(3, 1fr); }
  .grid-4 { grid-template-columns: repeat(3, 1fr); }
}

/* ===== MEDIA QUERY: ÉCRANS LARGES (1200px - 1399px) ===== */
@media (min-width: 1200px) and (max-width: 1399px) {
  .container {
    max-width: 1140px;
  }

  .grid-2 { grid-template-columns: repeat(2, 1fr); }
  .grid-3 { grid-template-columns: repeat(3, 1fr); }
  .grid-4 { grid-template-columns: repeat(4, 1fr); }
}

/* ===== MEDIA QUERY: TRÈS LARGES ÉCRANS (1400px+) ===== */
@media (min-width: 1400px) {
  .container {
    max-width: 1400px;
  }

  .grid-2 { grid-template-columns: repeat(2, 1fr); }
  .grid-3 { grid-template-columns: repeat(3, 1fr); }
  .grid-4 { grid-template-columns: repeat(4, 1fr); }
}

/* ===== ORIENTATION: PAYSAGE MOBILE ===== */
@media (max-height: 500px) and (orientation: landscape) {
  nav {
    padding: var(--spacing-sm);
  }

  section {
    padding: var(--spacing-lg) var(--spacing-md);
  }

  h1 { font-size: var(--font-size-2xl); }
  h2 { font-size: var(--font-size-xl); }
}

/* ===== ACCESSIBILITÉ: PRÉFÉRENCE MOUVEMENT RÉDUIT ===== */
@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ===== ACCESSIBILITÉ: MODE SOMBRE ===== */
@media (prefers-color-scheme: dark) {
  body {
    background-color: #1a1a1a;
    color: #f0f0f0;
  }

  input, textarea, select {
    background-color: #2a2a2a;
    color: #f0f0f0;
    border-color: #444;
  }
}

/* ===== UTILITAIRES CACHÉS/AFFICHÉS ===== */
.hide-mobile { display: none; }
.show-mobile { display: block; }

@media (min-width: 768px) {
  .hide-mobile { display: block; }
  .show-mobile { display: none; }
  .hide-tablet { display: none; }
  .show-tablet { display: block; }
}

@media (min-width: 1024px) {
  .hide-desktop { display: none; }
  .show-desktop { display: block; }
}

/* ===== IMPRESSION ===== */
@media print {
  body {
    background: white;
    color: black;
  }

  nav, .mobile-menu {
    display: none;
  }

  section {
    padding: 1rem;
    page-break-inside: avoid;
  }
}

/* ===== ENHANCED MOBILE SUPPORT FOR ANDROID & iOS ===== */

/* iOS Safari specific fixes */
@supports (-webkit-touch-callout: none) {
  /* Prevent text selection on UI elements */
  button, .btn, .nav-btn, .card, .modal-header, .modal-footer {
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
  }

  /* Better input styling for iOS */
  input, textarea, select {
    -webkit-appearance: none;
    -webkit-border-radius: 8px;
    border-radius: 8px;
    background-clip: padding-box;
  }

  /* iOS modal improvements */
  .modal {
    -webkit-transform: translate3d(0, 0, 0);
    transform: translate3d(0, 0, 0);
  }

  /* iOS scrolling improvements */
  .modal-body, .card-body, .container {
    -webkit-overflow-scrolling: touch;
  }
}

/* Android specific enhancements */
@media screen and (max-width: 480px) and (-webkit-min-device-pixel-ratio: 1.5) {
  /* Android Chrome touch improvements */
  * {
    -webkit-tap-highlight-color: rgba(0,0,0,0);
    touch-action: manipulation;
  }

  /* Better button styling for Android */
  button, .btn {
    -webkit-appearance: none;
    border-radius: 8px;
    font-weight: 500;
  }

  /* Android modal positioning */
  .modal-dialog {
    margin: 1rem 0.5rem;
  }

  /* Android form improvements */
  input:focus, textarea:focus, select:focus {
    outline: none;
    border-color: #2196F3;
    box-shadow: 0 0 0 2px rgba(33, 150, 243, 0.2);
  }
}

/* Very small mobile devices (320px and below) */
@media (max-width: 320px) {
  html {
    font-size: 13px;
  }

  .container-fluid, .container {
    padding-left: 0.5rem;
    padding-right: 0.5rem;
  }

  section {
    padding: 1rem 0.5rem;
  }

  button, .btn {
    padding: 0.75rem 1rem;
    font-size: 14px;
  }

  input, textarea, select {
    padding: 0.75rem;
    font-size: 14px;
  }

  .card {
    padding: 1rem;
  }

  h1 { font-size: 1.5rem; }
  h2 { font-size: 1.25rem; }
  h3 { font-size: 1.125rem; }
}

/* Landscape orientation fixes for mobile */
@media (max-width: 767px) and (orientation: landscape) {
  body {
    padding-bottom: 0;
  }

  nav {
    padding: 0.5rem;
  }

  section {
    padding: 1rem 0.5rem;
  }

  .nav-links {
    max-height: calc(100vh - 60px);
  }

  /* Adjust font sizes for landscape */
  h1 { font-size: var(--font-size-2xl); }
  h2 { font-size: var(--font-size-xl); }
  h3 { font-size: var(--font-size-lg); }

  /* Better grid layout in landscape */
  .grid-2 { grid-template-columns: repeat(2, 1fr); }
  .grid-3 { grid-template-columns: repeat(3, 1fr); }
  .grid-4 { grid-template-columns: repeat(4, 1fr); }
}

/* High DPI mobile devices */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
  /* Sharper borders on high DPI screens */
  input, textarea, select, button, .btn, .card {
    border-width: 1px;
  }

  /* Better shadows for high DPI */
  .card, .btn {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  }
}

/* Safe area insets for devices with notches (iPhone X and newer) */
@supports (padding: max(0px)) {
  .container-fluid, .container {
    padding-left: max(1rem, env(safe-area-inset-left));
    padding-right: max(1rem, env(safe-area-inset-right));
  }

  nav {
    padding-top: max(1rem, env(safe-area-inset-top));
  }

  .toast-container {
    bottom: max(1rem, env(safe-area-inset-bottom));
  }
}
