/* ═══════════════════════════════════════════════════════════
   responsive.css — Portail Opérateur DossierFacile
   Appliqué sur toutes les pages via <link rel="stylesheet">
   ═══════════════════════════════════════════════════════════ */

/* ─── 1. BASE GLOBALE ────────────────────────────────────── */

*, *::before, *::after { box-sizing: border-box; }

img {
  max-width: 100%;
  height: auto;
  display: block;
}

table {
  width: 100%;
}

body {
  overflow-x: hidden;
}

/* ─── 2. BREAKPOINTS
   --bp-sm  : 30rem  = ~480px  (mobile paysage)
   --bp-md  : 48rem  = ~768px  (tablette)
   --bp-lg  : 64rem  = ~1024px (desktop)
   ─────────────────────────────────────────────────────────── */

/* ─── 3. GRILLE DES CARTES (index.php) ──────────────────── */

/* Desktop : 3 colonnes fixes → fluides */
.grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--card-gap, 0.875rem);
  width: 100%;
}

.grid-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--card-gap, 0.875rem);
  width: 100%;
}

.grid-1 {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--card-gap, 0.875rem);
  width: 100%;
  max-width: 20rem;
}

/* Cartes dans la grille : fluides (sans toucher .btn-card desktop) */
.grid .card,
.grid-2 .card,
.grid-1 .card {
  width: 100%;
  max-width: 100%;
  height: auto;
  min-height: 5rem;
  white-space: normal;
}

.card-label {
  white-space: normal;
}

/* Diviseur : calcul fixe → 100% */
.divider {
  width: 100% !important;
}

/* ─── 4. LIENS UTILES ────────────────────────────────────── */

.links-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1rem;
  width: 100% !important;      /* écrase le 860px fixe */
  max-width: 56rem;
}

/* ─── 5. BOUTONS CARDS (btn-card) ───────────────────────── */
/* Sur desktop : on laisse les .btn-card à leur taille naturelle (284px)
   On intervient uniquement en mobile via la media query ci-dessous */

/* ─── 6. BOUTON DÉCONNEXION / RETOUR ────────────────────── */

.logout-btn,
.back-btn {
  font-size: 0.75rem;
}

/* ─── 7. TABLEAUX ───────────────────────────────────────── */

.table-wrap {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: 0.5rem;
}

/* Wrap automatique sur les tables dans les cards */
.card table,
.container table {
  min-width: 36rem;
}

/* ─── 8. IMAGES HEADER ───────────────────────────────────── */

.header img,
header img {
  max-height: 3.5rem;
  width: auto;
}

/* ─── 9. TYPOGRAPHY FLUIDE ──────────────────────────────── */

h1       { font-size: clamp(1.2rem, 4vw, 1.75rem); }
h2       { font-size: clamp(1rem,   3vw, 1.375rem); }
.page-title { font-size: clamp(1.1rem, 3.5vw, 1.5rem); }
.logo-text  { font-size: clamp(1.2rem, 5vw, 1.75rem); }

/* ─── 10. CONTENEUR PRINCIPAL ───────────────────────────── */

.container {
  width: 100%;
  max-width: 68.75rem;  /* 1100px */
  margin-inline: auto;
  padding-inline: 1rem;
}

body {
  padding-inline: 1rem;
}


/* ═══════════════════════════════════════════════════════════
   TABLETTE  — max 768px
   ═══════════════════════════════════════════════════════════ */
@media (max-width: 48rem) {

  body {
    padding: 1.5rem 1rem;
  }

  /* Grilles : 3 col → 2 col */
  .grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .links-grid {
    grid-template-columns: 1fr;
  }

  /* Bouton déconnexion — moins intrusif */
  .logout-btn {
    top: 0.5rem;
    right: 0.5rem;
    padding: 0.3rem 0.75rem;
    font-size: 0.7rem;
  }

  .back-btn {
    margin-bottom: 1rem;
  }

  /* Tableaux scrollables */
  table {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  thead, tbody, tr { min-width: max-content; }

}


/* ═══════════════════════════════════════════════════════════
   MOBILE  — max 480px
   ═══════════════════════════════════════════════════════════ */
@media (max-width: 30rem) {

  body {
    padding: 1rem 0.75rem;
  }

  /* Grilles : 2 col → 1 col */
  .grid,
  .grid-2 {
    grid-template-columns: 1fr;
  }

  .grid-1 {
    max-width: 100%;
  }

  /* Boutons guide de validation — pleine largeur sur mobile */
  .choices {
    flex-direction: column;
    align-items: stretch;
  }

  .btn-card {
    width: 100% !important;
    height: auto !important;
    min-height: 3.5rem;
    padding: 1rem 1.5rem !important;
  }

  /* Logo header */
  header img,
  .header img {
    max-height: 2.75rem;
  }

  /* Bouton déconnexion en bas sur mobile */
  .logout-btn {
    position: fixed;
    top: auto;
    bottom: 1rem;
    right: 1rem;
    font-size: 0.7rem;
  }

  /* Lien retour */
  .back-btn {
    font-size: 0.7rem;
    padding: 0.3rem 0.75rem;
  }

  /* Légende */
  .legend {
    gap: 0.75rem;
  }

  /* Section labels */
  .section-label {
    font-size: 0.6rem;
  }

  /* Tableaux admin */
  table th,
  table td {
    padding: 0.5rem 0.625rem;
    font-size: 0.75rem;
  }

  .actions {
    flex-direction: column;
    gap: 0.375rem;
  }

  .btn {
    width: 100%;
    text-align: center;
  }

  /* Question boxes */
  .question-box {
    padding: 0.875rem 1rem;
    font-size: 0.875rem;
  }

  .btn-row {
    gap: 1rem;
  }

}


/* ═══════════════════════════════════════════════════════════
   MOBILE PAYSAGE — max 768px + orientation landscape
   ═══════════════════════════════════════════════════════════ */
@media (max-height: 30rem) and (orientation: landscape) {

  body {
    padding-top: 0.75rem;
    padding-bottom: 0.75rem;
  }

  .header, header {
    margin-bottom: 0.75rem;
  }

  .logout-btn {
    bottom: auto;
    top: 0.5rem;
    right: 0.5rem;
  }

}
