/* =============================================================================
   JAOS V2 · Responsive — 1920 / 1366 / iPad 1024 paysage / iPad 768 / 390
   ============================================================================= */

/* ── Ordinateur portable 1366 ── */
@media (max-width: 1365px) {
    html.fi .fi-global-search-field .fi-input-wrp {
        min-width: min(20rem, 34vw);
    }
}

/* ── Anti-débordement (préexistants en Atelier, relevés par le balayage V2) ── */

/* ToggleButtons groupés (ex. type de présentation, options de devis) :
   passent à la ligne au lieu de pousser la page hors écran. */
html.fi .fi-fo-toggle-buttons {
    max-width: 100%;
    flex-wrap: wrap;
}

/* Radio invisible (le label porte le clic via for=) : Filament lui donne la
   largeur du parent, décalée → débordement. 1px suffit (focus géré sur le label). */
html.fi .fi-fo-toggle-buttons-input {
    width: 1px !important;
    height: 1px !important;
    max-width: 1px;
}

@media (max-width: 1024px) {
    html.fi .fi-fo-toggle-buttons.fi-btn-group {
        display: flex !important;
        flex-wrap: wrap;
    }

    html.fi .fi-fo-toggle-buttons.fi-btn-group > * {
        flex: 1 1 auto;
    }
}

/* Grilles de cartes : un enfant de grille ne doit jamais imposer sa largeur
   min-content (min-width:auto) au-delà de l'écran. */
html.fi .ja-avail-hub__grid > *,
html.fi .ja-page__grid > *,
html.fi .ja-catalog-grid > * {
    min-width: 0;
}

/* Blocs de code / URL / snippets (ex. paramètres boutique) : défilement
   interne — l'utilitaire Tailwind overflow-x-auto n'est pas compilé. */
html.fi .fi-main pre {
    max-width: 100%;
    overflow-x: auto;
    white-space: pre;
}

html.fi .fi-main :not(pre) > code {
    overflow-wrap: anywhere;
}

/* En-têtes de page : la zone d'actions se replie au lieu de déborder. */
html.fi .fi-header > * {
    min-width: 0;
}

html.fi .fi-header-actions-ctn {
    max-width: 100%;
}

/* Déclencheurs de dropdown (filtres de tableau) : ne pas comprimer le bouton
   tactile 44px dans un conteneur plus étroit. */
html.fi .fi-dropdown-trigger,
html.fi .fi-ta-filters-dropdown {
    flex: none;
    min-width: max-content;
}

html.fi .fi-main pre {
    padding: 0.75rem 0.9rem;
    border-radius: var(--ja-radius-md);
    background: var(--ja-surface-sunken);
    border: 1px solid var(--ja-border-subtle);
    color: var(--ja-text-soft);
    font-size: var(--ja-text-sm);
}

@media (max-width: 1023px) {
    html.fi .ja-avail-hub__grid {
        grid-template-columns: minmax(0, 1fr) !important;
    }
}

/* ── iPad paysage (≤ 1024) ── */
@media (max-width: 1024px) {
    html.fi .fi-header,
    html.fi .ja-page-header {
        align-items: flex-start;
    }

    html.fi .fi-ta-header-toolbar {
        flex-wrap: wrap;
    }

    html.fi .fi-ta-search-field {
        flex: 1 1 16rem;
    }

    html.fi .ja-pipeline__kanban {
        scroll-snap-type: x proximity;
    }

    html.fi .ja-pipeline__col {
        scroll-snap-align: start;
    }
}

/* ── iPad portrait (≤ 834) ── */
@media (max-width: 834px) {
    html.fi .fi-header-actions-ctn,
    html.fi .ja-page-header__actions {
        width: 100%;
    }

    html.fi .fi-wi-stats-overview-stat,
    html.fi .ja-stat-card {
        min-height: 4.75rem;
        padding: 0.95rem 1rem !important;
    }

    html.fi .fi-modal-window {
        border-radius: var(--ja-radius-lg) !important;
    }
}

/* ── Mobile (≤ 640 · réf. 390) ── */
@media (max-width: 640px) {
    html.fi .fi-header-heading,
    html.fi .ja-page-header__title {
        font-size: 1.75rem !important;
    }

    html.fi .fi-header-subheading,
    html.fi .ja-page-header__subtitle {
        font-size: var(--ja-text-md) !important;
    }

    /* Actions d'en-tête : pleine largeur, empilées */
    html.fi .fi-header-actions-ctn > *,
    html.fi .ja-page-header__actions > * {
        flex: 1 1 auto;
    }

    html.fi .fi-header-actions-ctn .fi-btn,
    html.fi .ja-page-header__actions .fi-btn,
    html.fi .ja-page-header__actions .ja-btn {
        width: 100%;
        justify-content: center;
    }

    html.fi .fi-ta-search-field {
        flex-basis: 100%;
        min-width: 0;
    }

    /* Tableaux empilés Filament (->stackedOnMobile()) : cartes lisibles */
    html.fi .fi-ta-table-stacked-on-mobile .fi-ta-row {
        border-bottom: 1px solid var(--ja-border-subtle) !important;
    }

    html.fi .fi-ta-table-stacked-on-mobile .fi-ta-cell {
        height: auto;
        border-bottom: 0 !important;
        padding-block: 0.25rem !important;
    }

    html.fi .fi-modal-window {
        border-radius: var(--ja-radius-lg) var(--ja-radius-lg) 0 0 !important;
    }

    html.fi .fi-tabs-item,
    html.fi .ja-filter-chip {
        padding-inline: 0.8rem !important;
    }

    /* Pas de police < 13px pour « faire tenir » */
    html.fi .fi-ta-cell,
    html.fi .fi-ta-text-item {
        font-size: var(--ja-text-md) !important;
    }
}

/* ── Accessibilité : mouvement réduit ── */
@media (prefers-reduced-motion: reduce) {
    html.fi *,
    html.fi *::before,
    html.fi *::after {
        transition-duration: 0.01ms !important;
        animation-duration: 0.01ms !important;
    }
}

/* Événements empilés (iPad portrait) : pas de hauteur de ligne minimale par cellule */
@media (max-width: 768px) and (orientation: portrait) {
    html.fi .ja-events__table .fi-ta-row > td,
    html.fi .ja-events__table .fi-ta-cell {
        height: auto !important;
        border-bottom: 0 !important;
    }

    html.fi .ja-events__table .fi-ta-cell :is(.fi-ta-text, .fi-ta-icon, .fi-ta-image) {
        padding-block: 0.15rem !important;
    }

    html.fi .ja-events__table .fi-ta-row {
        border-bottom: 1px solid var(--ja-border-subtle) !important;
    }
}

/* Les cartes Devis réutilisent les cellules Filament : leur contenu complet
   (référence, date, montant et suivi) ne doit pas être limité à une ligne. */
@media (max-width: 1199px), (max-width: 1399px) and (any-pointer: coarse) {
    html.fi .ja-quote-list-page .ja-premium-table--quotes .fi-ta-row > td,
    html.fi .ja-quote-list-page .ja-premium-table--quotes .fi-ta-cell {
        height: auto;
        min-height: var(--ja-touch);
    }
}
