/* =====================================================================
   TERANGA TECH INSTITUTE - Adaptation à TOUS les écrans
   Fichier : assets/css/responsive.css
   (chargé APRÈS style.css dans header.php)
   =====================================================================
   Écrans couverts :
     - Très petits téléphones ........... moins de 360 px
     - Téléphones ....................... 360 à 575 px
     - Grands téléphones / phablettes ... 576 à 767 px
     - Tablettes (portrait) ............. 768 à 991 px
     - Tablettes (paysage) / petits PC .. 992 à 1199 px
     - Ordinateurs portables ............ 1200 à 1399 px
     - Ordinateurs fixes ................ 1400 à 1919 px
     - Écrans Full HD / TV .............. 1920 à 2559 px
     - Écrans 2K / grandes TV ........... 2560 à 3199 px
     - Écrans 4K / TV 4K ................ 3200 px et plus
   + Téléphones à l'horizontale, écrans tactiles, encoches (iPhone),
     écrans sans souris, mode contraste élevé.
   ===================================================================== */

/* =====================================================================
   1. TAILLE DE TEXTE FLUIDE
      Le texte grandit doucement avec la largeur de l'écran.
      Tout ce qui est en "rem" s'adapte automatiquement.
   ===================================================================== */
html {
    font-size: clamp(15px, 14px + 0.15vw, 17px);
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

/* Les éléments ne dépassent jamais de l'écran */
img,
video,
iframe,
svg,
canvas {
    max-width: 100%;
}

body {
    overflow-x: hidden;
}

.tti-principal,
.tti-contenu,
.card,
.card-body {
    min-width: 0;
}

/* Les mots très longs (adresses e-mail, noms de fichiers) passent à la ligne */
.tti-contenu p,
.tti-contenu td,
.tti-contenu li,
.tti-notif-titre,
.tti-notif-message {
    overflow-wrap: anywhere;
}

/* Défilement fluide des tableaux sur écrans tactiles */
.table-responsive {
    -webkit-overflow-scrolling: touch;
}

/* =====================================================================
   2. TÉLÉPHONES À ENCOCHE (iPhone, Android récents)
      Évite que le contenu passe sous l'encoche ou la barre du bas.
      (nécessite viewport-fit=cover dans header.php)
   ===================================================================== */
@supports (padding: env(safe-area-inset-top)) {
    .tti-topbar {
        padding-left: max(1.5rem, env(safe-area-inset-left));
        padding-right: max(1.5rem, env(safe-area-inset-right));
    }

    .tti-sidebar {
        padding-top: env(safe-area-inset-top);
        padding-bottom: env(safe-area-inset-bottom);
        padding-left: env(safe-area-inset-left);
    }

    .tti-footer {
        padding-bottom: max(1rem, env(safe-area-inset-bottom));
    }

    .tti-auth-formulaire {
        padding-top: max(2rem, env(safe-area-inset-top));
        padding-bottom: max(2rem, env(safe-area-inset-bottom));
    }
}

/* =====================================================================
   3. ÉCRANS TACTILES (téléphones, tablettes, TV tactiles)
      Boutons assez grands pour le doigt (44 px minimum).
   ===================================================================== */
@media (pointer: coarse) {
    .btn {
        min-height: 44px;
    }

    .btn-sm {
        min-height: 38px;
        padding-left: 0.85rem;
        padding-right: 0.85rem;
    }

    .btn-icone {
        width: 44px;
        height: 44px;
    }

    .tti-menu-lien {
        padding-top: 0.8rem;
        padding-bottom: 0.8rem;
    }

    .tti-bouton-menu,
    .tti-bouton-notif {
        width: 44px;
        height: 44px;
    }

    .dropdown-item {
        padding-top: 0.7rem;
        padding-bottom: 0.7rem;
    }

    .form-check-input {
        width: 1.3em;
        height: 1.3em;
    }

    .page-link {
        min-width: 44px;
        min-height: 44px;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .tti-oeil {
        padding: 0.5rem;
    }
}

/* Écrans sans souris : pas d'effet de survol qui « reste collé » */
@media (hover: none) {
    .card-survol:hover,
    .tti-stat:hover {
        transform: none;
        box-shadow: var(--tti-ombre);
    }

    .tti-carte-cours:hover .tti-carte-cours-image img {
        transform: none;
    }
}

/* =====================================================================
   4. TÉLÉPHONES ET TABLETTES : pas de zoom automatique sur iPhone
      (iOS zoome si le texte d'un champ fait moins de 16 px)
   ===================================================================== */
@media (max-width: 991.98px) {
    .form-control,
    .form-select,
    input,
    select,
    textarea {
        font-size: 16px !important;
    }
}

/* =====================================================================
   5. TRÈS PETITS TÉLÉPHONES (moins de 360 px)
   ===================================================================== */
@media (max-width: 359.98px) {
    html {
        font-size: 14px;
    }

    :root {
        --tti-sidebar-largeur: 86vw;
        --tti-topbar-hauteur: 56px;
    }

    .tti-topbar {
        padding-left: 0.6rem;
        padding-right: 0.6rem;
        gap: 0.4rem;
    }

    .tti-topbar-droite {
        gap: 0.3rem;
    }

    .tti-contenu {
        padding: 0.75rem 0.5rem;
    }

    .tti-stat {
        flex-direction: column;
        text-align: center;
        gap: 0.6rem;
    }

    .tti-page-entete h1 {
        font-size: 1.1rem;
    }

    .tti-notif-menu {
        width: calc(100vw - 1rem);
    }

    .table-cartes tr {
        margin: 0.5rem 0.25rem;
    }

    .table-cartes td {
        flex-direction: column;
        align-items: flex-start;
        text-align: left;
        gap: 0.2rem;
    }

    .tti-actions .btn {
        flex: 1 1 auto;
    }

    .tti-erreur-code {
        font-size: 4.5rem;
    }
}

/* =====================================================================
   6. TÉLÉPHONES (360 à 575 px)
   ===================================================================== */
@media (min-width: 360px) and (max-width: 575.98px) {
    :root {
        --tti-sidebar-largeur: 280px;
    }

    .tti-erreur-code {
        font-size: 5rem;
    }
}

/* Sur tous les téléphones : boutons d'action en pleine largeur dans les formulaires */
@media (max-width: 575.98px) {
    .tti-boutons-formulaire {
        display: flex;
        flex-direction: column-reverse;
        gap: 0.5rem;
    }

    .tti-boutons-formulaire .btn {
        width: 100%;
    }

    .modal-footer {
        flex-direction: column-reverse;
        align-items: stretch;
    }

    .modal-footer > .btn {
        width: 100%;
        margin: 0.25rem 0;
    }

    .modal-dialog-scrollable .modal-content {
        max-height: calc(100vh - 1rem);
    }

    .tti-video {
        border-radius: var(--tti-rayon-petit);
    }

    .nav-tabs .nav-link {
        padding: 0.6rem 0.75rem;
        font-size: 0.85rem;
    }
}

/* =====================================================================
   7. TÉLÉPHONES À L'HORIZONTALE (paysage, peu de hauteur)
   ===================================================================== */
@media (max-height: 500px) and (orientation: landscape) {
    :root {
        --tti-topbar-hauteur: 52px;
    }

    .tti-sidebar-entete {
        height: 52px;
        padding-top: 0.5rem;
        padding-bottom: 0.5rem;
    }

    .tti-menu-lien {
        padding-top: 0.45rem;
        padding-bottom: 0.45rem;
    }

    .tti-menu-titre {
        padding-top: 0.5rem;
    }

    .tti-auth {
        align-items: flex-start;
    }

    .tti-auth-formulaire {
        padding-top: 1rem;
        padding-bottom: 1rem;
    }

    .tti-auth-logo {
        width: 70px;
        margin-bottom: 0.6rem;
    }

    .tti-auth-carte .sous-titre {
        margin-bottom: 1rem;
    }

    .tti-notif-liste {
        max-height: 55vh;
    }

    .modal-dialog {
        margin-top: 0.5rem;
        margin-bottom: 0.5rem;
    }

    /* Vidéo : on limite la hauteur pour voir les contrôles */
    .tti-video {
        max-height: 80vh;
        aspect-ratio: auto;
        height: 80vh;
    }
}

/* =====================================================================
   8. TABLETTES EN PORTRAIT (768 à 991 px)
   ===================================================================== */
@media (min-width: 768px) and (max-width: 991.98px) {
    :root {
        --tti-sidebar-largeur: 290px;
    }

    .tti-edt {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .tti-contenu {
        padding: 1.25rem;
    }

    .tti-notif-menu {
        width: 380px;
    }
}

/* =====================================================================
   9. TABLETTES EN PAYSAGE / PETITS ORDINATEURS (992 à 1199 px)
      Menu visible mais un peu plus étroit.
   ===================================================================== */
@media (min-width: 992px) and (max-width: 1199.98px) {
    :root {
        --tti-sidebar-largeur: 230px;
    }

    .tti-menu-lien {
        font-size: 0.86rem;
        gap: 0.6rem;
    }

    .tti-marque-nom {
        font-size: 0.9rem;
    }

    .tti-contenu {
        padding: 1.25rem;
    }

    .tti-profil-texte {
        display: none;
    }
}

/* =====================================================================
   10. ORDINATEURS FIXES (1400 px et plus)
       Le contenu reste centré et lisible, il ne s'étire pas sans fin.
   ===================================================================== */
@media (min-width: 1400px) {
    .tti-contenu {
        padding: 2rem;
    }

    .tti-contenu > .tti-largeur-max,
    .tti-largeur-max {
        max-width: 1500px;
        margin-left: auto;
        margin-right: auto;
    }

    .tti-edt {
        gap: 1rem;
    }
}

/* =====================================================================
   11. ÉCRANS FULL HD ET TÉLÉVISIONS (1920 px et plus)
   ===================================================================== */
@media (min-width: 1920px) {
    html {
        font-size: 17px;
    }

    :root {
        --tti-sidebar-largeur: 300px;
        --tti-topbar-hauteur: 72px;
        --tti-rayon: 14px;
    }

    .tti-sidebar-entete img {
        width: 46px;
        height: 46px;
    }

    .tti-largeur-max {
        max-width: 1700px;
    }

    .tti-avatar,
    .tti-avatar-initiales {
        width: 44px;
        height: 44px;
    }

    .tti-stat-icone {
        width: 62px;
        height: 62px;
    }

    .tti-notif-menu {
        width: 420px;
    }

    .tti-auth-formulaire {
        max-width: 640px;
    }

    .tti-auth-carte {
        max-width: 460px;
    }

    .tti-auth-visuel h1 {
        font-size: 2.6rem;
    }

    .tti-auth-visuel p {
        max-width: 560px;
        font-size: 1.1rem;
    }
}

/* =====================================================================
   12. ÉCRANS 2K ET GRANDES TÉLÉVISIONS (2560 px et plus)
       Tout est agrandi pour être lisible de loin.
   ===================================================================== */
@media (min-width: 2560px) {
    html {
        font-size: 21px;
    }

    :root {
        --tti-sidebar-largeur: 380px;
        --tti-topbar-hauteur: 90px;
        --tti-rayon: 18px;
        --tti-rayon-petit: 12px;
    }

    .tti-sidebar-entete img {
        width: 58px;
        height: 58px;
    }

    .tti-largeur-max {
        max-width: 2200px;
    }

    .tti-avatar,
    .tti-avatar-initiales {
        width: 56px;
        height: 56px;
    }

    .tti-avatar-lg {
        width: 130px;
        height: 130px;
    }

    .tti-stat-icone {
        width: 78px;
        height: 78px;
    }

    .tti-bouton-notif,
    .tti-bouton-menu {
        width: 56px;
        height: 56px;
    }

    .tti-pastille {
        min-width: 24px;
        height: 24px;
        border-radius: 12px;
    }

    .tti-notif-menu {
        width: 540px;
    }

    .tti-notif-icone {
        width: 50px;
        height: 50px;
    }

    .tti-auth-formulaire {
        max-width: 860px;
    }

    .tti-auth-carte {
        max-width: 600px;
    }

    .tti-auth-logo {
        width: 170px;
    }

    .tti-force-mdp {
        height: 9px;
    }
}

/* =====================================================================
   13. ÉCRANS 4K ET TÉLÉVISIONS 4K (3200 px et plus)
   ===================================================================== */
@media (min-width: 3200px) {
    html {
        font-size: 28px;
    }

    :root {
        --tti-sidebar-largeur: 500px;
        --tti-topbar-hauteur: 120px;
        --tti-rayon: 24px;
        --tti-rayon-petit: 16px;
    }

    .tti-sidebar-entete img {
        width: 78px;
        height: 78px;
    }

    .tti-largeur-max {
        max-width: 3000px;
    }

    .tti-avatar,
    .tti-avatar-initiales {
        width: 74px;
        height: 74px;
    }

    .tti-avatar-lg {
        width: 170px;
        height: 170px;
    }

    .tti-stat-icone {
        width: 104px;
        height: 104px;
    }

    .tti-bouton-notif,
    .tti-bouton-menu {
        width: 74px;
        height: 74px;
    }

    .tti-pastille {
        min-width: 32px;
        height: 32px;
        border-radius: 16px;
        border-width: 3px;
    }

    .tti-notif-menu {
        width: 720px;
    }

    .tti-notif-icone {
        width: 66px;
        height: 66px;
    }

    .tti-auth-formulaire {
        max-width: 1150px;
    }

    .tti-auth-carte {
        max-width: 800px;
    }

    .tti-auth-logo {
        width: 230px;
    }

    .badge-direct::before,
    .badge-statut::before {
        width: 12px;
        height: 12px;
    }

    .tti-force-mdp {
        height: 12px;
    }
}

/* =====================================================================
   14. TÉLÉVISIONS ET ÉCRANS GÉANTS EN HAUTEUR LIMITÉE
       (grands écrans larges mais regardés de loin)
   ===================================================================== */
@media (min-width: 1920px) and (min-aspect-ratio: 16/9) {
    .tti-video {
        max-height: 78vh;
        margin-left: auto;
        margin-right: auto;
        width: min(100%, calc(78vh * 16 / 9));
    }
}

/* =====================================================================
   15. MODE CONTRASTE ÉLEVÉ (Windows, malvoyants)
   ===================================================================== */
@media (forced-colors: active) {
    .tti-menu-lien.actif,
    .btn-primary,
    .btn-orange {
        border: 2px solid ButtonText;
    }

    .badge-statut::before,
    .badge-direct::before,
    .tti-notif.non-lue::after {
        forced-color-adjust: none;
    }
}

/* =====================================================================
   16. ÉCRANS DE HAUTE DÉFINITION (Retina, écrans 2x/3x)
       Bordures fines plus nettes.
   ===================================================================== */
@media (min-resolution: 2dppx) {
    .card,
    .tti-stat,
    .table td,
    .table thead th {
        border-width: 0.5px;
    }
}