/* ============================================================
   Phase 9 — UX Mobile & Polish — PFAC Cameroun v2.7.0
   ============================================================
   - Responsive table wrappers (scroll horizontal sur mobile)
   - Drop zone avec drag & drop visuel
   - Touch targets (min 44px)
   - Mobile input optimizations
   - Smooth scrolling
   - Navigation mobile (menu slide-in + overlay + accordéon)
   ============================================================ */

/* ---------- Responsive Table Wrappers ---------- */
.table-responsive-wrapper {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    -ms-overflow-style: -ms-autohiding-scrollbar;
    border-radius: 0.5rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.table-responsive-wrapper table {
    min-width: 700px;
    margin-bottom: 0;
}

.table-responsive-wrapper thead th {
    white-space: nowrap;
    background: #003366;
    color: #fff;
    font-size: 0.85rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    padding: 0.75rem 1rem;
    position: sticky;
    top: 0;
    z-index: 1;
}

.table-responsive-wrapper tbody td {
    vertical-align: middle;
    font-size: 0.875rem;
    padding: 0.65rem 1rem;
}

/* Scrollbar styling */
.table-responsive-wrapper::-webkit-scrollbar {
    height: 6px;
}

.table-responsive-wrapper::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

.table-responsive-wrapper::-webkit-scrollbar-thumb {
    background: #003366;
    border-radius: 3px;
}

/* ---------- Drop Zone (Drag & Drop) ---------- */
.drop-zone {
    position: relative;
    border: 2px dashed #d1d5db;
    border-radius: 0.75rem;
    padding: 2rem 1.5rem;
    text-align: center;
    background: #f9fafb;
    transition: all 0.25s ease;
    cursor: pointer;
    min-height: 130px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.drop-zone:hover,
.drop-zone.drag-over {
    border-color: #003366;
    background: rgba(0, 51, 102, 0.04);
}

.drop-zone.drag-over {
    border-style: solid;
    box-shadow: 0 0 0 4px rgba(0, 51, 102, 0.1);
    transform: scale(1.01);
}

.drop-zone.has-file {
    border-color: #16a34a;
    border-style: solid;
    background: rgba(22, 163, 74, 0.04);
}

.drop-zone.has-file .drop-zone-content .placeholder-text {
    display: none;
}

.drop-zone.has-file .drop-zone-content .file-name-display {
    display: block;
}

.drop-zone-input {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
    z-index: 2;
}

.drop-zone-content {
    z-index: 1;
    pointer-events: none;
}

.drop-zone-content i {
    font-size: 2rem;
    color: #003366;
    margin-bottom: 0.5rem;
}

.drop-zone-content .drop-zone-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
}

.drop-zone-content .file-name-display {
    display: none;
    font-weight: 600;
    color: #003366;
    word-break: break-all;
    max-width: 280px;
    font-size: 0.85rem;
}

.drop-zone-content .file-name-display .file-size {
    font-weight: 400;
    color: #6b7280;
    font-size: 0.75rem;
}

.drop-zone-remove {
    position: absolute;
    top: 8px;
    right: 8px;
    z-index: 3;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: none;
    background: #ef4444;
    color: #fff;
    font-size: 0.8rem;
    cursor: pointer;
    display: none;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.drop-zone.has-file .drop-zone-remove {
    display: flex;
}

.drop-zone-remove:hover {
    background: #dc2626;
}

/* ---------- Touch-friendly form elements ---------- */
@media (max-width: 767.98px) {
    /* Touch targets : 44px minimum */
    .form-control,
    .form-select,
    .btn {
        min-height: 44px;
        font-size: 16px !important; /* Évite le zoom iOS */
    }

    .form-control-sm,
    .btn-sm {
        min-height: 38px;
        font-size: 14px !important;
    }

    .form-check-input {
        min-width: 20px;
        min-height: 20px;
    }

    .form-check-label {
        min-height: 44px;
        display: flex;
        align-items: center;
    }

    /* Navigation prev/next plus larges */
    .btn-prev,
    .btn-next {
        min-width: 120px;
        min-height: 48px;
        font-size: 1rem;
    }

    /* Select et inputs pleine largeur */
    .form-select,
    .form-control[type="text"],
    .form-control[type="date"],
    .form-control[type="number"],
    .form-control[type="email"],
    .form-control[type="tel"] {
        width: 100%;
    }

    /* Espacement vertical accru entre les champs */
    .row.g-3 > [class*='col-'],
    .row.g-4 > [class*='col-'] {
        margin-bottom: 0.75rem;
    }

    /* Drop zone adaptée mobile */
    .drop-zone {
        padding: 1.5rem 1rem;
        min-height: 110px;
    }

    .drop-zone-content i {
        font-size: 1.5rem;
    }

    /* Tables: scroll horizontal natif */
    .table-responsive-wrapper table {
        min-width: 600px;
    }
}

/* ---------- Inputmode visual hints ---------- */
input[inputmode="numeric"] {
    font-variant-numeric: tabular-nums;
}

input[inputmode="decimal"] {
    font-variant-numeric: tabular-nums;
}

/* ---------- Smooth scroll (respecte prefers-reduced-motion) ---------- */
html {
    scroll-behavior: smooth;
}

@media (prefers-reduced-motion: reduce) {
    html {
        scroll-behavior: auto;
    }

    .drop-zone,
    .drop-zone.drag-over {
        transition: none;
    }
}

/* ============================================================
   Navigation Mobile — Menu slide-in + overlay + accordéon
   ============================================================ */

/* Overlay (backdrop) du menu mobile */
.mobile-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 40;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    -webkit-tap-highlight-color: transparent;
}

.mobile-overlay.open {
    opacity: 1;
    visibility: visible;
}

/* Menu mobile — version améliorée */
.mobile-menu {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: 80%;
    max-width: 320px;
    background: linear-gradient(180deg, #002244 0%, #003366 60%, #004080 100%);
    box-shadow: -8px 0 40px rgba(0, 0, 0, 0.3);
    z-index: 50;
    padding: 0;
    overflow-y: auto;
    overflow-x: hidden;
    transform: translateX(100%);
    transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    -webkit-overflow-scrolling: touch;
}

.mobile-menu.open {
    transform: translateX(0);
}

/* En-tête du menu mobile avec bouton fermeture */
.mobile-menu-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    flex-shrink: 0;
}

.mobile-menu-brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.mobile-menu-brand img {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
}

.mobile-menu-brand span {
    color: #fff;
    font-weight: 700;
    font-size: 1.1rem;
    letter-spacing: -0.01em;
}

.mobile-menu-close {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: none;
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    font-size: 1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
    -webkit-tap-highlight-color: transparent;
}

.mobile-menu-close:hover,
.mobile-menu-close:focus-visible {
    background: rgba(255, 255, 255, 0.2);
}

/* Contenu du menu (scrollable) */
.mobile-menu-content {
    flex: 1;
    overflow-y: auto;
    padding: 0.75rem 0;
    -webkit-overflow-scrolling: touch;
}

/* Liens de navigation mobile */
.mobile-menu-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1.5rem;
    color: rgba(255, 255, 255, 0.7);
    font-size: 0.95rem;
    font-weight: 500;
    transition: all 0.2s ease;
    text-decoration: none;
    border-left: 3px solid transparent;
    -webkit-tap-highlight-color: transparent;
}

.mobile-menu-link:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.06);
}

.mobile-menu-link:focus-visible {
    outline: 2px solid #FFA500;
    outline-offset: -2px;
}

.mobile-menu-link i {
    width: 20px;
    text-align: center;
    font-size: 0.9rem;
    color: rgba(255, 255, 255, 0.4);
    transition: color 0.2s;
}

.mobile-menu-link:hover i {
    color: #FFA500;
}

.mobile-menu-link.active {
    color: #FFA500;
    background: rgba(255, 165, 0, 0.08);
    border-left-color: #FFA500;
    font-weight: 600;
}

.mobile-menu-link.active i {
    color: #FFA500;
}

/* Séparateur de section */
.mobile-menu-section-label {
    padding: 0.75rem 1.5rem 0.35rem;
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: rgba(255, 255, 255, 0.3);
    pointer-events: none;
}

/* Accordéon mobile — version améliorée */
.mobile-accordion-trigger {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 0.75rem 1.5rem;
    color: rgba(255, 255, 255, 0.7);
    font-size: 0.95rem;
    font-weight: 500;
    background: none;
    border: none;
    border-left: 3px solid transparent;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: left;
    -webkit-tap-highlight-color: transparent;
}

.mobile-accordion-trigger:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.06);
}

.mobile-accordion-trigger:focus-visible {
    outline: 2px solid #FFA500;
    outline-offset: -2px;
}

.mobile-accordion-trigger .trigger-icon {
    width: 20px;
    text-align: center;
    font-size: 0.9rem;
    color: rgba(255, 255, 255, 0.4);
    transition: color 0.2s;
}

.mobile-accordion-trigger:hover .trigger-icon {
    color: #FFA500;
}

.mobile-accordion-trigger .trigger-arrow {
    font-size: 0.7rem;
    color: rgba(255, 255, 255, 0.3);
    transition: transform 0.3s ease, color 0.2s;
}

.mobile-accordion-trigger.active .trigger-arrow {
    transform: rotate(180deg);
    color: #FFA500;
}

/* Contenu de l'accordéon — animation hauteur */
.mobile-accordion-content {
    overflow: hidden;
    max-height: 0;
    opacity: 0;
    transition: max-height 0.35s ease, opacity 0.3s ease;
    background: rgba(0, 0, 0, 0.15);
}

.mobile-accordion-content.open {
    max-height: 300px; /* suffisant pour le sous-menu */
    opacity: 1;
}

.mobile-accordion-content .mobile-menu-link {
    padding-left: 3rem;
    font-size: 0.88rem;
}

/* Pied du menu — CTA Connexion/Dashboard
   IMPORTANT : app.css (chargé APRÈS ce fichier) impose
   .mobile-menu-footer{background:#f8fafc}. On monte donc la spécificité
   (.mobile-menu .mobile-menu-footer) pour que le fond navy s'applique —
   sinon texte blanc sur fond blanc = bouton invisible. */
.mobile-menu .mobile-menu-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid rgba(255, 255, 255, 0.14);
    background: linear-gradient(180deg, #004080 0%, #002244 100%);
    flex-shrink: 0;
}

.mobile-menu .mobile-menu-footer .btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    width: 100%;
    padding: 0.75rem 1rem;
    border-radius: 9999px;
    font-weight: 700;
    font-size: 0.95rem;
    border: 1px solid rgba(255, 255, 255, 0.35);
    background: rgba(255, 255, 255, 0.16);
    color: #fff;
    cursor: pointer;
    transition: all 0.25s ease;
    text-decoration: none;
    -webkit-tap-highlight-color: transparent;
}

.mobile-menu .mobile-menu-footer .btn:hover {
    background: rgba(255, 255, 255, 0.28);
    transform: translateY(-1px);
}

.mobile-menu .mobile-menu-footer .btn:focus-visible {
    outline: 2px solid #FFA500;
    outline-offset: 2px;
}

/* Scrollbar menu mobile */
.mobile-menu::-webkit-scrollbar,
.mobile-menu-content::-webkit-scrollbar {
    width: 3px;
}

.mobile-menu::-webkit-scrollbar-track,
.mobile-menu-content::-webkit-scrollbar-track {
    background: transparent;
}

.mobile-menu::-webkit-scrollbar-thumb,
.mobile-menu-content::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.15);
    border-radius: 3px;
}

/* Responsive — adaptation très petits écrans */
@media (max-width: 374.98px) {
    .mobile-menu {
        width: 100%;
        max-width: 100%;
    }
}

@media (min-width: 768px) and (max-width: 1023.98px) {
    .mobile-menu {
        max-width: 360px;
    }
}

/* Désactiver scroll body quand menu ouvert */
body.mobile-menu-open {
    overflow: hidden;
}

/* ------------------------------------------------------------------
   CTA « Connexion » de l'en-tete — visible AUSSI sur telephone
   Avant : classes Tailwind `hidden md:inline-flex` => le bouton
   n'existait pas sous 768px et l'eleve n'avait aucun acces a la
   connexion (le CTA du menu mobile etait par ailleurs invisible).
   Style dedie volontaire : le CSS compile ne contient pas toutes les
   classes utilitaires (px-3.5, md:px-5, md:gap-* absentes).
------------------------------------------------------------------- */
/* --- CTA Connexion (en-tête) -------------------------------------
   Avant : « hidden md:inline-flex » => bouton absent sous 768px,
   l'élève n'avait aucun accès direct à la connexion sur téléphone.
   Les utilitaires Tailwind d'origine sont conservés sur le lien ;
   ici on ne fait que resserrer le bouton sur mobile.
   Spécificité a.nav-cta-login (0,1,1) pour battre .px-5/.text-sm (0,1,0) :
   app.css est chargé APRÈS ce fichier et l'en-tête est <nav id="navbar">.
------------------------------------------------------------------ */
.nav-cta-login {
    -webkit-tap-highlight-color: transparent;
}

@media (max-width: 767.98px) {
    a.nav-cta-login {
        gap: 0.4rem;
        padding: 0.78rem 1rem;
        font-size: 0.8rem;
        line-height: 1.2;
        white-space: nowrap;
    }
    a.nav-cta-login i {
        font-size: 0.8rem;
    }
}

/* NB : le libellé « Connexion » reste visible à toutes les largeurs
   (mesuré : ~119 px de bouton à 320 px, marge de 93 px avec le logo). */
