:root {
    --hf-bg: #fff;
    --hf-line: #e8eaf0;
    --hf-text: #20222a;
    --hf-muted: #6b7280;
    --hf-accent: #5b6cff;
    --hf-accent-weak: #eef0ff;
    --hf-radius: 16px;
    --hf-shadow: 0 10px 30px rgba(15,23,42,.10), 0 2px 10px rgba(15,23,42,.04);
}
/* ancre du popover */
.hf-filter-anchor {
    position: relative;
    display: inline-block;
}

/* carte popover */
.hf-popover {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    width: min(720px, 92vw);
    background: var(--hf-bg);
    border: 1px solid var(--hf-line);
    border-radius: 16px;
    box-shadow: var(--hf-shadow);
    z-index: 2000;
    display: grid;
    grid-template-rows: auto 1fr auto;
}

    .hf-popover[hidden] {
        display: none;
    }

.hf-filter-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 14px;
    border-bottom: 1px solid var(--hf-line);
}

    .hf-filter-header .title {
        display: flex;
        gap: 8px;
        align-items: center;
        font-weight: 700
    }

.hf-filter-body {
    display: grid;
    gap: 14px;
    padding: 14px
}

.hf-filter-footer {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    border-top: 1px solid var(--hf-line);
    padding: 12px 14px
}

/* assure le menu Select2 DANS le popover */
.select2-container.select2-container--open {
    z-index: 2100 !important;
}

.grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 1.5rem;
    margin: 3%;
    margin-top: 2%;
    margin-bottom: 1%;
}

.card {
    background: white;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.08);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transition: transform 0.2s;
    cursor: pointer;
    width: 17rem;
    height: 17rem;
    position: relative; /* Pour positionner les éléments absolus à l'intérieur */
}

    .card:hover {
        transform: scale(1.02);
    }

    .card img {
        width: 100%;
        height: 180px;
        object-fit: cover;
    }

.card-content {
    padding: 1rem;
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}
/* Titre de la recette */

.card h3 {
    margin: 0;
    font-size: 0.82rem;
    color: #333;
    font-weight: 800;
}
/* (Optionnel) Sous-titre ou autres infos */

.card h5 {
    margin-top: 1%;
    font-size: 0.80rem;
}
/* Lien (non utilisé ici, mais présent dans d'autres contextes) */

.card a {
    text-decoration: none;
    color: #fff;
    background: #27ae60;
    padding: 0.5rem 1rem;
    border-radius: 8px;
    font-weight: bold;
    display: inline-block;
    margin-top: 1rem;
    transition: background 0.2s;
}

    .card a:hover {
        background: #1e874b;
    }

.placeholder {
    text-align: center;
    color: #888;
}
/* Conteneur des étiquettes (tags) de chaque recette */

.label-container {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 8px;
    padding: 0 10px;
    position: absolute;
    top: 8px;
    left: 0;
}

.label-badge {
    padding: 4px 10px;
    border-radius: 8px;
    font-size: 0.60rem;
    font-weight: 600;
    white-space: nowrap;
    line-height: 1.5;
    opacity: .9;
}
/* Informations de recette (temps de préparation, etc.) */

.recipe-info {
    font-size: 0.9rem;
    font-weight: 700; /* Le texte (temps) sera aligné à droite par le jeu de flexbox dans .footerCard */
}
/* Infobulle (tooltip) */

.tooltip {
    position: absolute;
    bottom: 110%;
    left: 10px;
    background-color: #333;
    color: #fff;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 0.9em;
    white-space: pre-wrap;
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transform: translateY(-10px);
    transition: opacity 0.2s ease, transform 0.2s ease;
    width: max-content;
    max-width: 250px;
}

.card:hover .tooltip {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(-14px);
}
/* Styles pour la section pliable */

.section-toggle {
    position: relative;
    margin: 45px 0 0 0;
}

.section-hr {
    border: 0;
    border-top: 2px solid #ddd;
    margin: 0;
}

.section-chip {
    position: absolute;
    left: 50%;
    top: 0;
    transform: translate(-50%, -50%);
    display: flex;
    gap: 8px;
    align-items: center;
    padding: 6px 12px;
    border-radius: 5px;
    border: 1px solid #e5e7eb;
    background: #f4f4f4;
    font-weight: 600;
    cursor: pointer;
    user-select: none;
}

.collapse-icon {
    transition: transform 0.25s ease;
}

.section-toggle.open .collapse-icon {
    transform: rotate(180deg);
}

.collapse-wrap {
    overflow: hidden;
    height: 0;
    opacity: 0;
    transition: height 0.26s ease, opacity 0.26s ease;
}

    .collapse-wrap.open {
        opacity: 1;
    }
/* Pour la zone de contenu défilable (si applicable) */

.content {
    overflow: auto;
}

.sticky-search {
    position: sticky;
    top: 0;
    z-index: 10;
    padding: 8px 12px;
}
/* Conteneur en bas de la carte pour temps + contrôles de portions */

.footerCard {
    display: flex;
    justify-content: space-between;
    align-items: flex-end !important;
    flex-direction: row-reverse;
}
/* Badge affichant le nombre de portions sélectionnées sur l'image */

.badge-portions {
    position: absolute;
    right: 8px;
    bottom: 8px;
    background: rgba(0,0,0,0.75);
    color: #fff;
    font-size: 0.8rem;
    padding: 4px 8px;
    border-radius: 12px;
    display: none; /* Masqué par défaut, s'affichera si portions > 0 */
}
/* Contrôles de quantité (boutons +/− et affichage du nombre) */

.quantity-controls {
    display: flex;
    align-items: center;
    gap: 4px; /* Initialement, on les masque dans le HTML via style="display:none" (géré en JS) */
}

    .quantity-controls button {
        background: #f1f1f1;
        border: 0;
        padding: 0px 4px;
        border-radius: 6px;
        cursor: pointer;
    }

        .quantity-controls button:hover {
            background: #e6e6e6;
        }

.quantity {
    font-weight: 700;
    min-width: 1.5rem;
    text-align: center;
}
/* Base: un léger contour pour qu'on voie le surlignage quand sélectionnée */

.card {
    border: 1px solid #eee;
}
/* Les cartes dans OWNED n'ont pas de surlignage vert (c'est implicite qu'elles sont choisies) */

#recipeGridOwned .card {
    border-color: #eee; /* force un rendu "neutre" */
    box-shadow: 0 4px 10px rgba(0,0,0,0.08);
}

.footerCard {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-direction: row; /* plus de row-reverse */
}
/* Contrôles visibles seulement dans OWNED */

#recipeGrid .quantity-controls {
    display: none !important;
}

#recipeGridOwned .quantity-controls {
    display: flex;
}

.placeholder-result {
    background: none;
    color: black;
    width: 40rem;
    text-align: left;
    font-style: italic;
}

.pagination-modern {
    bottom: 20px;
    right: 65px;
    backdrop-filter: blur(6px);
    border-radius: 12px;
    padding: 6px 14px;
    display: flex;
    align-items: center;
    gap: 8px;
    font-family: 'Segoe UI', sans-serif;
    font-size: 14px;
    z-index: 999;
    width: fit-content;
    MARGIN: auto;
    margin-right: 2.4%;
}

.pagination-btn {
    border: none;
    background: #4CAF50;
    color: white;
    font-size: 16px;
    padding: 6px 10px;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.2s ease, transform 0.1s ease;
}

    .pagination-btn:hover {
        background: #45a049;
    }

    .pagination-btn:disabled {
        background: #ccc;
        cursor: not-allowed;
    }

#pageInfo {
    font-weight: 500;
    color: #333;
}

.owned-empty {
    display: block;
    color: #666;
    font-weight: 600;
    border-radius: 10px;
    font-style: italic;
}
/* Section pliable ULTRA FIABLE en max-height */ /* --- FIX: n'utiliser que max-height pour la section pliable --- */

.collapse-wrap { /* on annule la vieille règle à base de height:0 */
    height: auto !important; /* on garde le système au max-height */
    overflow: hidden;
    max-height: 0;
    opacity: 0;
    transition: max-height .30s ease, opacity .30s ease;
}

    .collapse-wrap.open {
        opacity: 1;
        max-height: 2000px; /* assez grand pour tout contenir */
    }
/* Message "aucune recette" masqué par défaut */

#noSelectedMsg {
    display: none;
    font-style: italic;
    color: #666; /* texte grisé par exemple */
}
/* Emplacement réservé pour l'indicateur (évite les décalages) */

.selection-slot {
    display: flex;
    align-items: center;
    gap: 6px;
    min-height: 18px; /* hauteur de la pastille */
    min-width: 110px; /* réserve de la place pour "Sélectionné" */
    visibility: hidden; /* masqué par défaut mais prend la place */
}

    .selection-slot.active { /* quand sélectionné */
        visibility: visible;
    }

.selection-indicator {
    display: flex;
    align-items: center;
    gap: 6px;
    font-weight: 700;
    color: #27ae60;
}

    .selection-indicator .check-icon {
        background: #27ae60;
        color: #fff;
        font-size: .75rem;
        width: 18px;
        height: 18px;
        display: flex;
        align-items: center;
        justify-content: center;
        border-radius: 50%;
    }

.selection-text {
    font-size: .8rem;
    font-weight: 900;
}

#pdfModal {
    z-index: 2000 !important; /* au-dessus de tout */
}

.modal-backdrop {
    z-index: 1999 !important;
}
/* Trigger & badge */

.hf-icon-btn {
    display: inline-flex;
    align-items: center;
    gap: .5rem;
    border: 1px solid var(--hf-line);
    background: #fff;
    padding: .5rem .65rem;
    border-radius: 12px;
    box-shadow: none;
    cursor: pointer;
}

    .hf-icon-btn svg {
        fill: #475569
    }

    .hf-icon-btn:hover {
        border-color: #cbd5e1;
        background: #fcfcfe
    }

.hf-badge {
    display: inline-block;
    min-width: 1.5rem;
    padding: .1rem .45rem;
    font-size: .75rem;
    border-radius: 999px;
    background: var(--hf-accent);
    color: #fff;
    text-align: center;
}
/* Overlay + Drawer */

.hf-drawer-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15,23,42,.35);
    backdrop-filter: saturate(80%) blur(2px);
    z-index: 1040;
}

.hf-drawer {
    position: fixed;
    top: 0;
    right: 0;
    height: 100%;
    width: 380px;
    max-width: 90vw;
    background: var(--hf-bg);
    box-shadow: var(--hf-shadow);
    z-index: 1050;
    border-left: 1px solid var(--hf-line);
    display: flex;
    flex-direction: column;
    transform: translateX(20px);
    opacity: 0;
    pointer-events: none;
    transition: transform .18s ease, opacity .18s ease;
}

    .hf-drawer[open] {
        transform: translateX(0);
        opacity: 1;
        pointer-events: auto;
    }

    .hf-drawer[hidden] {
        display: block
    }
/* pour pouvoir animer malgré hidden initial */

.hf-drawer-header {
    position: sticky;
    top: 0;
    background: var(--hf-bg);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 18px;
    border-bottom: 1px solid var(--hf-line);
}

    .hf-drawer-header h3 {
        margin: 0;
        font-size: 1rem;
        font-weight: 700;
        color: var(--hf-text)
    }

.hf-drawer-body {
    padding: 18px;
    overflow: auto;
    display: grid;
    gap: 18px;
}

.hf-section-title {
    font-weight: 600;
    color: var(--hf-text);
    margin-bottom: 8px;
}

.hf-field {
    display: block
}

.hf-time-row {
    display: flex;
    align-items: center;
    gap: 8px
}

.hf-input {
    border: 1px solid var(--hf-line);
    border-radius: 12px;
    padding: .55rem .7rem;
    width: 100%;
}

.hf-sep {
    color: var(--hf-muted)
}

.hf-chips {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 10px
}

.hf-chip {
    border: 1px solid var(--hf-line);
    background: #fff;
    padding: .35rem .6rem;
    border-radius: 999px;
    cursor: pointer;
    font-size: .85rem;
}

    .hf-chip:hover {
        border-color: #cbd5e1;
        background: #fafbff
    }

    .hf-chip.active {
        background: var(--hf-accent-weak);
        border-color: var(--hf-accent);
        color: var(--hf-accent);
        margin-bottom: 10px;
        margin-top: 7px;
        font-size: 10px;
        margin-right: 5px;
        border-radius: 13px;
    }

.hf-drawer-footer {
    margin-top: auto;
    padding: 14px 18px;
    display: flex;
    gap: 10px;
    border-top: 1px solid var(--hf-line);
}

.hf-btn {
    border-radius: 12px;
    padding: .65rem 1rem;
    border: 1px solid var(--hf-line);
    background: #fff;
    cursor: pointer;
}

    .hf-btn.primary {
        background: var(--hf-accent);
        border-color: var(--hf-accent);
        color: #fff
    }

    .hf-btn.ghost {
        background: transparent
    }
/* Tooltip plus petit (tu l’avais demandé) */

.tooltip-wrap {
    display: grid;
    gap: 6px;
    max-width: 360px;
    font-size: .85rem
}

    .tooltip-wrap .tt-title {
        font-weight: 700;
        font-size: .9rem
    }

    .tooltip-wrap .tt-desc {
        font-size: .85rem;
        line-height: 1.35
    }

    .tooltip-wrap .tt-foot {
        display: flex;
        justify-content: flex-end
    }

    .tooltip-wrap .tt-history {
        font-size: .8rem;
        opacity: .9
    }
/* Cartes “déjà fait” */

.card.card--done {
    opacity: .55;
    transition: opacity .15s ease
}

    .card.card--done:hover {
        opacity: .7
    }
/* Select2 rafraîchi pour s’aligner au style */

.select2-container--default .select2-selection--multiple {
    border: 1px solid var(--hf-line) !important;
    border-radius: 12px !important;
    padding: .25rem !important;
}

.select2-selection__choice {
    border-radius: 999px !important;
    padding: .15rem .6rem !important;
    border: 0 !important;
    background: var(--hf-accent-weak) !important;
    color: var(--hf-text) !important;
}

.select2-selection__choice__remove {
    margin-right: .35rem !important;
    color: #64748b !important
}

.select2-container--default .select2-search--inline .select2-search__field {
    margin-top: .25rem !important;
    font-size: .9rem !important;
}
/* ancre du bouton pour positionner la card en absolu */
/* ancre pour positionner la card juste sous le bouton */
.filter-anchor {
    position: relative;
}

.hf-filter-card {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    z-index: 1200;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 12px;
    width: 360px;
    max-width: min(90vw, 420px);
    box-shadow: 0 10px 30px rgba(2, 6, 23, .12);
    opacity: 0;
    transform: translateY(-6px);
    pointer-events: none;
    transition: opacity .14s ease, transform .14s ease;
}

    /* masquée par défaut quand l’attribut hidden est présent */
    .hf-filter-card[hidden] {
        display: none;
    }

    /* visible quand la CLASSE .open est posée */
    .hf-filter-card.open {
        opacity: 1;
        transform: translateY(0);
        pointer-events: auto;
    }
