/* ==========================================================
   CONTENEUR DU FILTRE
   ========================================================== */

.card-dashboard > .card-filter {
    display: block;
    width: 100%;
    padding: 10px 12px;

    background: #f8fafc;
    border-bottom: 1px solid #e3e8ef;
}


/* Le widget shortcode doit occuper toute la largeur. */
.card-dashboard > .card-filter > .elementor-widget-shortcode,
.card-dashboard > .card-filter .elementor-shortcode,
.card-dashboard > .card-filter .frm_forms,
.card-dashboard > .card-filter form,
.card-dashboard > .card-filter .frm_form_fields,
.card-dashboard > .card-filter fieldset {
    width: 100%;
    max-width: none;
    margin: 0;
    padding: 0;
}


/* Suppression de la bordure éventuelle du fieldset Formidable. */
.card-dashboard > .card-filter fieldset {
    border: 0;
}


/* ==========================================================
   GRILLE DES FILTRES
   ========================================================== */

.card-dashboard > .card-filter .frm_fields_container {
    display: grid;

    /*
     * Recherche plus large, puis cinq filtres,
     * puis le bouton Réinitialiser.
     */
    grid-template-columns:
        minmax(280px, 2.8fr)
        minmax(145px, 0.85fr)
        minmax(145px, 0.9fr)
        minmax(145px, 0.9fr)
        minmax(165px, 1fr)
        minmax(190px, 1.15fr)
        auto;

    align-items: center;
    gap: 8px;

    width: 100%;
}


/* Tous les champs visibles du filtre. */
.card-dashboard > .card-filter .frm_form_field {
    width: 100%;
    min-width: 0;
    margin: 0;
}


/* ==========================================================
   MASQUAGE DES ÉLÉMENTS TECHNIQUES
   ========================================================== */

/*
 * Champs Lookup servant uniquement de filtres internes :
 * 110 = type de référence Statut
 * 112 = type de référence Type de dossier
 * 114 = type de référence Opérateur
 */
.card-dashboard > .card-filter #frm_field_110_container,
.card-dashboard > .card-filter #frm_field_112_container,
.card-dashboard > .card-filter #frm_field_114_container {
    display: none !important;
}


/* Bouton Envoyer Formidable. */
.card-dashboard > .card-filter #frm_field_108_container,
.card-dashboard > .card-filter .frm_submit {
    display: none !important;
}


/*
 * Les labels restent dans le DOM pour l’accessibilité,
 * mais ne sont pas visibles graphiquement.
 */
.card-dashboard > .card-filter .frm_primary_label {
    position: absolute !important;

    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;

    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    white-space: nowrap !important;

    border: 0 !important;
}


/* ==========================================================
   CHAMPS FORMIDABLE
   ========================================================== */

.card-dashboard > .card-filter input[type="text"],
.card-dashboard > .card-filter input[type="search"],
.card-dashboard > .card-filter select {
    width: 100%;
    height: 38px;
    min-height: 38px;

    margin: 0;
    padding: 0 12px;

    color: #344054 !important;
    background-color: #ffffff;

    border: 1px solid #d0d5dd;
    border-radius: 7px;

    box-shadow: 0 1px 2px rgba(16, 24, 40, 0.03);

    font-family: inherit;
    font-size: 12px;
    font-weight: 400;
    line-height: 1.2;

    outline: none;

    transition:
        border-color 0.18s ease,
        box-shadow 0.18s ease,
        background-color 0.18s ease;
}


/* Espace réservé pour la flèche native des selects. */
.card-dashboard > .card-filter select {
    padding-right: 30px;
    cursor: pointer;
}


/* Champ de recherche avec pictogramme loupe. */
.card-dashboard > .card-filter #field_rch_recherche {
    padding-left: 36px;

    background-image:
        url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23667085' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cpath d='m21 21-4.35-4.35'/%3E%3C/svg%3E");

    background-repeat: no-repeat;
    background-position: 12px center;
    background-size: 15px 15px;
}


/* Placeholder du champ texte. */
.card-dashboard > .card-filter input::placeholder {
    color: #98a2b3;
    opacity: 1;
}


/* Valeurs et placeholders des listes. */
.card-dashboard > .card-filter select,
.card-dashboard > .card-filter select option {
    color: #344054 !important;
}


/* Focus clavier et clic. */
.card-dashboard > .card-filter input[type="text"]:focus,
.card-dashboard > .card-filter input[type="search"]:focus,
.card-dashboard > .card-filter select:focus {
    background-color: #ffffff;
    border-color: #84adff;

    box-shadow:
        0 0 0 3px rgba(46, 105, 255, 0.12),
        0 1px 2px rgba(16, 24, 40, 0.04);
}


/* Survol discret. */
.card-dashboard > .card-filter input[type="text"]:hover,
.card-dashboard > .card-filter input[type="search"]:hover,
.card-dashboard > .card-filter select:hover {
    border-color: #98a2b3;
}


/* ==========================================================
   TEXTES PAR DÉFAUT DES SELECTS
   ========================================================== */

/*
 * Les Lookups renvoient actuellement une première option vide.
 * Les pseudo-textes suivants permettent de retrouver le rendu
 * de la maquette sans modifier les données des champs.
 */

.card-dashboard > .card-filter #frm_field_111_container,
.card-dashboard > .card-filter #frm_field_113_container,
.card-dashboard > .card-filter #frm_field_115_container,
.card-dashboard > .card-filter #frm_field_117_container {
    position: relative;
}


/*
 * Ces textes apparaissent uniquement lorsque le select
 * possède une valeur vide.
 *
 * Ils ne sont pas cliquables et laissent le select fonctionner.
 */
.card-dashboard > .card-filter #frm_field_111_container:has(select:invalid)::after,
.card-dashboard > .card-filter #frm_field_113_container:has(select:invalid)::after,
.card-dashboard > .card-filter #frm_field_115_container:has(select:invalid)::after,
.card-dashboard > .card-filter #frm_field_117_container:has(select:invalid)::after {
    position: absolute;
    top: 50%;
    left: 12px;

    overflow: hidden;
    max-width: calc(100% - 40px);

    color: #344054;
    font-size: 12px;
    line-height: 1;
    text-overflow: ellipsis;
    white-space: nowrap;

    pointer-events: none;

    transform: translateY(-50%);
}


/*
 * Ce bloc dépend du fonctionnement de :invalid.
 * Si les champs ne sont pas required, les textes peuvent plutôt
 * être définis directement dans Formidable Forms, ce qui est
 * la méthode la plus fiable.
 */
.card-dashboard > .card-filter #frm_field_111_container:has(select:invalid)::after {
    content: "Tous les statuts";
}

.card-dashboard > .card-filter #frm_field_113_container:has(select:invalid)::after {
    content: "Nouveau + Avenant";
}

.card-dashboard > .card-filter #frm_field_115_container:has(select:invalid)::after {
    content: "Tous les opérateurs";
}

.card-dashboard > .card-filter #frm_field_117_container:has(select:invalid)::after {
    content: "Renouvellement : tous";
}


/* ==========================================================
   BOUTON RÉINITIALISER
   ========================================================== */

.card-dashboard > .card-filter #frm_field_118_container {
    display: flex;
    align-items: center;
    justify-content: flex-end;

    width: auto;
    min-width: max-content;
}


/* Supprime les <br> sans modifier le HTML Formidable. */
.card-dashboard > .card-filter .crm-filter-reset br {
    display: none;
}


.card-dashboard > .card-filter .crm-filter-reset {
    display: inline-flex;
    align-items: center;
    justify-content: center;

    width: auto;
    min-width: max-content;
    height: 38px;
    min-height: 38px;

    margin: 0;
    padding: 0 13px;

    color: #475467;
    background: #ffffff;

    border: 1px solid #d0d5dd;
    border-radius: 7px;

    box-shadow: 0 1px 2px rgba(16, 24, 40, 0.03);

    font-size: 12px;
    font-weight: 600;
    line-height: 1;
    text-decoration: none;

    transition:
        color 0.18s ease,
        background-color 0.18s ease,
        border-color 0.18s ease,
        box-shadow 0.18s ease;
}


.card-dashboard > .card-filter .crm-filter-reset:hover,
.card-dashboard > .card-filter .crm-filter-reset:focus-visible {
    color: #1d4ed8;
    background: #f8fafc;
    border-color: #98a2b3;

    box-shadow: 0 2px 4px rgba(16, 24, 40, 0.07);
}


/* ==========================================================
   LOADER DES LOOKUPS FORMIDABLE
   ========================================================== */

.card-dashboard > .card-filter .frm-loading-img,
.card-dashboard > .card-filter .frm_lookup_loading {
    width: 16px;
    height: 16px;
    margin: 0 6px;
}


/*
 * Évite qu’un loader ou message Formidable modifie
 * la hauteur de toute la ligne de filtres.
 */
.card-dashboard > .card-filter .frm_error,
.card-dashboard > .card-filter .frm_error_style {
    margin-top: 4px;
    font-size: 11px;
}


/* ==========================================================
   TABLETTE
   ========================================================== */

@media (max-width: 1280px) {

    .card-dashboard > .card-filter .frm_fields_container {
        grid-template-columns:
            minmax(260px, 2fr)
            repeat(3, minmax(145px, 1fr));
    }


    .card-dashboard > .card-filter #frm_field_116_container,
    .card-dashboard > .card-filter #frm_field_117_container {
        grid-column: span 1;
    }


    .card-dashboard > .card-filter #frm_field_118_container {
        justify-content: flex-start;
    }
}


/* ==========================================================
   PETITE TABLETTE
   ========================================================== */

@media (max-width: 900px) {

    .card-dashboard > .card-filter .frm_fields_container {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }


    .card-dashboard > .card-filter #frm_field_109_container {
        grid-column: 1 / -1;
    }


    .card-dashboard > .card-filter #frm_field_118_container {
        grid-column: 1 / -1;
    }
}


/* ==========================================================
   MOBILE
   ========================================================== */

@media (max-width: 600px) {

    .card-dashboard {
        border-radius: 8px;
    }


    .card-dashboard > .card-header {
        align-items: flex-start;
        gap: 12px;
        min-height: 0;
        padding: 14px;
    }


    .card-dashboard > .card-header h2.elementor-heading-title {
        font-size: 15px;
    }


    .card-dashboard > .card-header .elementor-button {
        min-height: 32px;
        padding: 7px 10px;
    }


    .card-dashboard > .card-filter {
        padding: 12px;
    }


    .card-dashboard > .card-filter .frm_fields_container {
        grid-template-columns: minmax(0, 1fr);
        gap: 10px;
    }


    .card-dashboard > .card-filter #frm_field_109_container,
    .card-dashboard > .card-filter #frm_field_118_container {
        grid-column: auto;
    }


    .card-dashboard > .card-filter #frm_field_118_container {
        justify-content: stretch;
    }


    .card-dashboard > .card-filter .crm-filter-reset {
        width: 100%;
    }
}

/* ==========================================================
   CORRECTIF — FILTRES DASHBOARD SUR UNE SEULE LIGNE
   ========================================================== */

#crm-client-filters.card-filter {
    display: block;
    width: 100%;
    padding: 10px 12px;

    background: #f8fafc;
    border-bottom: 1px solid #e3e8ef;
}


/*
 * Toute la chaîne de conteneurs intermédiaires doit
 * occuper la largeur disponible.
 */
#crm-client-filters .elementor-widget-shortcode,
#crm-client-filters .elementor-widget-container,
#crm-client-filters .elementor-shortcode,
#crm-client-filters .frm_forms,
#crm-client-filters form,
#crm-client-filters .frm_form_fields,
#crm-client-filters fieldset {
    width: 100%;
    max-width: none;
    margin: 0;
    padding: 0;
}


/* ==========================================================
   DASHBOARD — FILTRE INLINE SANS CHEVAUCHEMENT
   ========================================================== */

#crm-client-filters .frm_fields_container {
    display: flex !important;
    flex-direction: row;
    flex-wrap: nowrap;
    align-items: center;
    gap: 8px;

    width: 100%;
    min-width: 0;
}


/*
 * Chaque champ doit être autorisé à rétrécir.
 */
#crm-client-filters .frm_form_field {
    float: none !important;
    clear: none !important;

    width: auto !important;
    min-width: 0 !important;
    max-width: none !important;

    margin: 0 !important;
    padding: 0 !important;

    box-sizing: border-box;
}


/*
 * Champ de recherche :
 * principal élément flexible de la ligne.
 */
#crm-client-filters #frm_field_109_container {
    flex: 1 1 260px;
    width: auto !important;
    min-width: 180px !important;
}


/*
 * Listes compactes.
 */
#crm-client-filters #frm_field_111_container {
    flex: 0 1 145px;
    width: 145px !important;
}

#crm-client-filters #frm_field_113_container {
    flex: 0 1 145px;
    width: 145px !important;
}

#crm-client-filters #frm_field_115_container {
    flex: 0 1 145px;
    width: 145px !important;
}

#crm-client-filters #frm_field_116_container {
    flex: 0 1 165px;
    width: 165px !important;
}

#crm-client-filters #frm_field_117_container {
    flex: 0 1 185px;
    width: 185px !important;
}


/*
 * Bouton Réinitialiser.
 */
#crm-client-filters #frm_field_118_container {
    display: flex !important;
    flex: 0 0 auto;

    align-items: center;
    justify-content: center;

    width: auto !important;
    min-width: max-content !important;
}


/*
 * Les contrôles ne doivent jamais dépasser
 * leur conteneur flex.
 */
#crm-client-filters input[type="text"],
#crm-client-filters input[type="search"],
#crm-client-filters select {
    display: block;

    width: 100% !important;
    min-width: 0 !important;
    max-width: 100% !important;

    box-sizing: border-box;
}


/*
 * Correction spécifique des styles Formidable.
 */
#crm-client-filters select {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}


/*
 * Classes de largeur Formidable.
 */
#crm-client-filters .frm12,
#crm-client-filters .frm_first {
    float: none !important;
    clear: none !important;
    width: auto !important;
}


/* ==========================================================
   RESPONSIVE DU FILTRE
   ========================================================== */

@media (max-width: 1550px) {

    #crm-client-filters .frm_fields_container {
        flex-wrap: wrap;
    }

    #crm-client-filters #frm_field_109_container {
        flex: 1 1 100%;
        width: 100%;
    }

    #crm-client-filters #frm_field_111_container,
    #crm-client-filters #frm_field_113_container,
    #crm-client-filters #frm_field_115_container,
    #crm-client-filters #frm_field_116_container,
    #crm-client-filters #frm_field_117_container {
        flex: 1 1 160px;
        width: auto;
    }
}


@media (max-width: 768px) {

    #crm-client-filters .frm_fields_container {
        flex-direction: column;
        align-items: stretch;
    }

    #crm-client-filters #frm_field_109_container,
    #crm-client-filters #frm_field_111_container,
    #crm-client-filters #frm_field_113_container,
    #crm-client-filters #frm_field_115_container,
    #crm-client-filters #frm_field_116_container,
    #crm-client-filters #frm_field_117_container,
    #crm-client-filters #frm_field_118_container {
        flex: 1 1 auto;
        width: 100%;
        min-width: 0;
    }

    #crm-client-filters .crm-filter-reset {
        width: 100%;
    }
}


/* ==========================================================
   CRM — FILTRE SAV
   Bouton Réinitialiser harmonisé avec les autres pages
   ========================================================== */

#form_frm_recherche_sav
#frm_field_162_container {
    display: flex;
    align-items: center;

    margin: 0 !important;
    padding: 0 !important;
}


/* Nettoyage des <br> injectés par Formidable */
#form_frm_recherche_sav
#frm_field_162_container br {
    display: none !important;
}


/* Bouton Réinitialiser */
#form_frm_recherche_sav
#crm-sav-reset {
    display: inline-flex;
    align-items: center;
    justify-content: center;

    box-sizing: border-box;

    min-height: 40px;

    margin: 0 !important;
    padding: 8px 14px !important;

    border: 1px solid #d5dde8;
    border-radius: 7px;

    background: #fff;

    color: #344054 !important;

    font-size: 12px;
    font-weight: 600;
    line-height: 1;

    text-decoration: none !important;

    white-space: nowrap;

    transition:
        border-color .15s ease,
        background-color .15s ease,
        color .15s ease;
}


#form_frm_recherche_sav
#crm-sav-reset:hover {
    border-color: #b8c5d8;

    background: #f5f8fc;

    color: #2563eb !important;
}