/* Generic custom dropdown (minimal, rounded, SaaS-like). */

.custom-dropdown {
    position: relative;
}

.custom-dropdown__trigger {
    width: 100%;
    min-width: 0;
    height: 42px;
    display: grid;
    grid-template-columns: 34px 1fr auto;
    align-items: center;
    gap: 0.35rem;
    padding: 0 0.55rem;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.12);
    border: 1px solid rgba(255, 255, 255, 0.16);
    color: rgba(255, 255, 255, 0.95);
    cursor: pointer;
}

    /* Sans icône leading : 2 colonnes */
    .custom-dropdown__trigger.custom-dropdown__trigger--no-leading {
        grid-template-columns: 1fr auto;
    }

        .custom-dropdown__trigger.custom-dropdown__trigger--no-leading .custom-dropdown__text {
            grid-column: 1;
        }

    /* Variant: classroom */
    .custom-dropdown__trigger.custom-dropdown__trigger--classroom {
        height: 36px;
        border-radius: 10px;
        background: #fff;
        border: 1px solid #ccc;
        color: var(--primary-color);
    }

        .custom-dropdown__trigger.custom-dropdown__trigger--classroom .custom-dropdown__text {
            font-weight: 700;
            color: var(--primary-color);
            border: none;
            outline: none;
        }

        .custom-dropdown__trigger.custom-dropdown__trigger--classroom:hover {
            border-color: #CFA551;
        }

        .custom-dropdown__trigger.custom-dropdown__trigger--classroom:focus-visible {
            outline: 3px solid rgba(207, 165, 81, 0.45);
            outline-offset: 2px;
        }

        .custom-dropdown__trigger.custom-dropdown__trigger--classroom .custom-dropdown__caret,
        .custom-dropdown__trigger.custom-dropdown__trigger--classroom .custom-dropdown__leading {
            color: var(--primary-color);
        }

    /* Variant: care sheet popup */
    .custom-dropdown__trigger.care-popup-dropdown {
        background: #fff;
        border: 0;
        border-radius: 10px;
        color: var(--primary-color);
    }

        .custom-dropdown__trigger.care-popup-dropdown .custom-dropdown__text,
        .custom-dropdown__trigger.care-popup-dropdown .custom-dropdown__caret,
        .custom-dropdown__trigger.care-popup-dropdown .custom-dropdown__leading {
            color: var(--primary-color);
            font-weight: 700;
        }

        .custom-dropdown__trigger.care-popup-dropdown:hover {
            background: #fff;
        }

    .custom-dropdown__trigger:hover {
        background: rgba(255, 255, 255, 0.16);
    }

    .custom-dropdown__trigger:focus-visible {
        outline: 3px solid rgba(255, 255, 255, 0.75);
        outline-offset: 2px;
    }

.custom-dropdown__leading,
.custom-dropdown__caret {
    display: grid;
    place-items: center;
}

.custom-dropdown__caret {
    justify-self: end;
}

/* Texte affiché (mode non-filtre) */
.custom-dropdown__text {
    text-align: left;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 0.92rem;
    min-width: 0;
}

/* Input de filtre dans le trigger — FIX: min-width: 0 pour respecter la colonne grid */
.custom-dropdown__trigger-filter {
    min-width: 0;
    width: 100%;
    background: transparent;
    border: none;
    outline: none;
    color: inherit;
    font-size: 0.92rem;
    font-weight: inherit;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    padding: 0;
}

    .custom-dropdown__trigger-filter::placeholder {
        color: inherit;
        opacity: 0.6;
    }

.custom-dropdown__backdrop {
    position: fixed;
    inset: 0;
    background: transparent;
    z-index: 1000;
}

/* Panel — FIX: right: auto + min-width: 100% pour s'élargir si besoin */
.custom-dropdown__panel {
    position: absolute;
    left: 0;
    right: auto;
    min-width: 100%;
    z-index: 1001;
    background: #fff;
    color: #111;
    border-radius: 12px;
    border: 1px solid rgba(17, 17, 17, 0.10);
    box-shadow: 0 12px 34px rgba(0, 0, 0, 0.22);
    overflow: hidden;
    max-height: min(420px, 55vh);
    overflow-y: auto;
}

.custom-dropdown__panel--bottom {
    top: calc(100% + 8px);
}

.custom-dropdown__panel--top {
    bottom: calc(100% + 8px);
}

.custom-dropdown__option {
    width: 100%;
    text-align: left;
    padding: 0.7rem 0.85rem;
    border: none;
    background: #fff;
    color: #111;
    cursor: pointer;
    font-size: 0.95rem;
    white-space: nowrap; /* FIX: empêche le retour à la ligne */
    overflow: hidden;
    text-overflow: ellipsis;
}

    .custom-dropdown__option:hover {
        background: rgba(0, 0, 0, 0.06);
    }

.custom-dropdown__option--selected {
    background: rgba(0, 0, 0, 0.08);
    font-weight: 600;
}

.custom-dropdown__panel {
    scrollbar-width: thin;
    scrollbar-color: rgba(0, 0, 0, 0.20) transparent;
}

    .custom-dropdown__panel::-webkit-scrollbar {
        width: 8px;
    }

    .custom-dropdown__panel::-webkit-scrollbar-track {
        background: transparent;
    }

    .custom-dropdown__panel::-webkit-scrollbar-thumb {
        background-color: rgba(0, 0, 0, 0.18);
        border-radius: 999px;
        border: 2px solid transparent;
        background-clip: content-box;
    }

        .custom-dropdown__panel::-webkit-scrollbar-thumb:hover {
            background-color: rgba(0, 0, 0, 0.26);
        }

.custom-dropdown__search-wrapper {
    padding: 0.5rem 0.6rem;
    border-bottom: 1px solid rgba(0, 0, 0, 0.08);
    position: sticky;
    top: 0;
    background: #fff;
    z-index: 1;
}

.custom-dropdown__search-input {
    width: 100%;
    border: 1px solid rgba(0, 0, 0, 0.15);
    border-radius: 8px;
    padding: 0.35rem 0.6rem;
    font-size: 0.88rem;
    outline: none;
    background: #f9f9f9;
    color: #111;
}

    .custom-dropdown__search-input:focus {
        border-color: var(--primary-color, #CFA551);
        background: #fff;
    }

.custom-dropdown__no-results {
    padding: 0.7rem 0.85rem;
    font-size: 0.9rem;
    color: rgba(0, 0, 0, 0.4);
    font-style: italic;
    text-align: center;
}
