/* =====================================================================
 * Responsive — ajustements mobiles transverses
 *
 * Charge en dernier (après tokens + components) pour overrider sans !important
 * inutile. Toutes les règles ciblent les breakpoints Bootstrap.
 * =====================================================================
 */

/* -------- Tables : scroll-x automatique dans les cards ---------------- */
/* La majorité des templates ne wrappent pas leurs tables dans
   `.table-responsive`. Sur mobile, on rend la card parente scrollable
   horizontalement plutôt que de toucher au rendu de la table elle-même
   (modifier `display: table` casse le rendu Bootstrap). */
@media (max-width: 991.98px) {
    .card:has(> .card-body > .table),
    .card:has(> .card-body > .table-sm),
    .card:has(> .table),
    .card:has(> .table-sm) {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
}

/* -------- Layout topbar : éviter les débordements -------------------- */
@media (max-width: 575.98px) {
    .topbar {
        padding: 0 12px;
        gap: 6px;
    }
    .topbar__title {
        font-size: var(--fs-base);
        line-height: 1.2;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
    .topbar__actions {
        gap: 4px;
    }
}

/* -------- Sidebar drawer : largeur mobile plus confortable ------------ */
@media (max-width: 575.98px) {
    .sidebar {
        width: min(280px, 84vw) !important;
    }
}

/* -------- Boutons d'action : empilement sur mobile ------------------- */
/* Beaucoup de pages ont un en-tête `d-flex justify-content-between`
   avec un groupe de boutons à droite. Sur mobile, on laisse passer en
   colonne pour éviter les coupes. */
@media (max-width: 575.98px) {
    .d-flex.justify-content-between.align-items-center {
        flex-wrap: wrap;
        gap: 8px;
    }
    .btn-group, .btn-group-sm {
        flex-wrap: wrap;
    }
}

/* -------- Cards & textes : un peu de respirations sur mobile --------- */
@media (max-width: 575.98px) {
    .card-body { padding: 14px 14px; }
    .h1, h1 { font-size: var(--fs-2xl); }
    .h2, h2 { font-size: var(--fs-xl); }
    .h3, h3 { font-size: var(--fs-lg); }
    .display-6 { font-size: var(--fs-2xl); }
}

/* -------- Onglets (nav-tabs) : scrollable sur mobile ----------------- */
@media (max-width: 767.98px) {
    .nav-tabs,
    .nav-pills {
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        white-space: nowrap;
        scrollbar-width: thin;
    }
    .nav-tabs .nav-link,
    .nav-pills .nav-link {
        white-space: nowrap;
    }
}

/* -------- Forms : labels & inputs un peu plus grands au tap ---------- */
@media (max-width: 575.98px) {
    .form-control, .form-select {
        font-size: 16px; /* évite le zoom iOS */
    }
}

/* -------- Agenda hebdo / mois : scrollable plutôt qu'écrasé ---------- */
@media (max-width: 991.98px) {
    .agenda-grid,
    .agenda-week,
    .agenda-month {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
}

/* -------- Modals : largeur mobile -------------------------------------*/
@media (max-width: 575.98px) {
    .modal-dialog {
        margin: 8px;
        max-width: calc(100vw - 16px);
    }
}

/* -------- Layout public (formulaires /lead, /candidater, /entreprise/offre) - */
@media (max-width: 575.98px) {
    .public-shell {
        padding: 16px 12px 40px;
    }
    .public-header h1 { font-size: 18pt; }
}

/* -------- Menu latéral sur téléphone : lignes plus hautes, pour le doigt --- */
@media (max-width: 991.98px) {
    .sidebar__link { padding: 11px 12px; font-size: 1rem; gap: 12px; }
    .sidebar__link i { font-size: 1.2rem; }
    .sidebar__section { padding-top: 16px; }
    .sidebar__search .form-control { height: 40px; font-size: 16px; } /* 16 px : évite le zoom automatique de l'iPhone */
    .sidebar__search-btn { height: 40px; }
}

/* -------- Application installée (plein écran) ------------------------ */
.pwa-standalone .app-footer { display: none; }

/* -------- Tableaux « en cartes » sur téléphone (opt-in : .table-mobile-cards) -- */
/* Chaque ligne devient un bloc, chaque cellule affiche son data-label devant.
   td.td-title = ligne de titre (sans label), td.td-actions = boutons à droite. */
@media (max-width: 767.98px) {
    .table-mobile-cards thead { display: none; }
    .table-mobile-cards,
    .table-mobile-cards tbody,
    .table-mobile-cards tr,
    .table-mobile-cards td { display: block; width: 100%; }
    .table-mobile-cards tr { padding: 10px 12px; border-bottom: 1px solid var(--c-border); }
    .table-mobile-cards td {
        border: none;
        padding: 2px 0;
        display: flex;
        gap: 8px;
        align-items: baseline;
        white-space: normal !important;
        text-align: left !important;
    }
    .table-mobile-cards td[data-label]::before {
        content: attr(data-label);
        flex: 0 0 36%;
        color: var(--c-text-muted);
        font-size: var(--fs-xs);
        text-transform: uppercase;
        letter-spacing: 0.04em;
    }
    .table-mobile-cards td.td-title { display: block; font-weight: 600; font-size: 1rem; padding-bottom: 4px; }
    .table-mobile-cards td.td-actions { justify-content: flex-end; padding-top: 8px; }
    .table-mobile-cards td:empty { display: none; }
}

