/**
 * Search Facets Styles
 * Shortcode: [mcp_search]
 */

.mcp-search-facets {
    background-color: #fff;
    padding: 12px;
    border-radius: 6px;

    & > div {
        padding-bottom: 10px;
        &:not(:last-child) {
            margin-bottom: 20px;
            border-bottom: 1px solid rgba(0, 0, 0, 0.25);
        }
    }

    & h3 {
        font-weight: bold;
        margin-bottom: 10px;
    }

    & .mcp-categories-container .mcp-category-item,
    & .mcp-brand-container .mcp-brand-item,
    & .mcp-checkbox-item {
        display: flex;
        align-items: center;
        gap: 5px;

        & input[type="checkbox"] {
            appearance: none;
            -webkit-appearance: none;
            width: 16px;
            height: 16px;
            border: 1px solid #555;
            cursor: pointer;
            position: relative;
            background-color: #fff;

            &:checked {
                background-color: #48b4cf;
                border-color: #48b4cf;
            }

            &:checked::after {
                content: "✓";
                color: white;
                font-size: 14px;
                position: absolute;
                top: 50%;
                left: 50%;
                transform: translate(-50%, -50%);
            }
        }

        & label {
            flex: 1;
            display: grid;
            grid-template-columns: 1fr auto;
            align-items: center;
            gap: 5px;
            color: #000;
            cursor: pointer;

            & span.name {
                overflow: hidden;
                text-overflow: ellipsis;
                white-space: nowrap;
            }

            & span.count {
                color: rgba(0, 0, 0, 0.25);
            }
        }
    }

    & .mcp-search-actions {
        display: flex;
        flex-direction: column;
        gap: 10px;

        & > button {
            display: inline-flex;
            justify-content: center;
            align-items: center;
            gap: 5px;
            background-color: #48b4cf;
            color: #fff;
            border: 1px solid #48b4cf;
            border-radius: 4px;
            font-size: 1rem;
            padding-inline: 5px;
            height: 40px;
            cursor: pointer;
            transition:
                background-color 0.2s ease,
                color 0.2s ease,
                border-color 0.2s ease;

            &:hover {
                background-color: #44a7c0;
            }

            &:disabled {
                cursor: auto;
            }

            &.mcp-reset-filters {
                background-color: #fff;
                color: #000;
                border-color: rgba(0, 0, 0, 0.2);

                &:hover {
                    background-color: #48b4cf;
                    color: #fff;
                    border: 1px solid #48b4cf;
                }
            }
        }
    }
}

/* Multi-Select (Scales & Brands) */
:is(.mcp-scale-select, .mcp-brand-select) {
    position: relative;

    & :is(.mcp-scale-trigger, .mcp-brand-trigger) {
        display: flex;
        align-items: center;
        flex-wrap: wrap;
        gap: 6px;
        min-height: 38px;
        padding: 4px 30px 4px 8px;
        border: 1px solid #555;
        border-radius: 4px;
        cursor: pointer;
        background: #fff;
        position: relative;
    }

    & :is(.mcp-scale-caret, .mcp-brand-caret) {
        position: absolute;
        right: 8px;
        top: 50%;
        transform: translateY(-50%);
        font-size: 14px;
        color: #555;
        transition: transform 0.2s ease;
        pointer-events: none;
    }

    &.is-open :is(.mcp-scale-caret, .mcp-brand-caret) {
        transform: translateY(-50%) rotate(180deg);
    }

    & :is(.mcp-scale-placeholder, .mcp-brand-placeholder) {
        color: rgba(0, 0, 0, 0.35);
        font-size: 0.9rem;
    }

    & :is(.mcp-scale-tags, .mcp-brand-tags) {
        display: flex;
        flex-wrap: wrap;
        gap: 4px;
    }

    & :is(.mcp-scale-tag, .mcp-brand-tag) {
        display: inline-flex;
        align-items: center;
        gap: 4px;
        background: #48b4cf;
        color: #fff;
        border-radius: 3px;
        padding: 2px 6px;
        font-size: 0.8rem;

        & button {
            background: none;
            border: none;
            color: #fff;
            cursor: pointer;
            padding: 0;
            font-size: 14px;
            line-height: 1;
            opacity: 0.8;

            &:hover {
                opacity: 1;
            }
        }
    }

    & :is(.mcp-scale-dropdown, .mcp-brand-dropdown) {
        position: absolute;
        top: calc(100% + 4px);
        left: 0;
        right: 0;
        background: #fff;
        border: 1px solid rgba(0, 0, 0, 0.2);
        border-radius: 4px;
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
        z-index: 100;
        max-height: 200px;
        overflow-y: auto;
    }

    & :is(.mcp-scale-option, .mcp-brand-option) {
        display: flex;
        align-items: center;
        gap: 5px;
        padding: 8px 10px;
        cursor: pointer;
        font-size: 0.9rem;

        & span.count {
            margin-left: auto;
            color: rgba(0, 0, 0, 0.25);
        }

        &:hover {
            background: rgba(72, 180, 207, 0.08);
        }

        &.is-selected {
            color: #48b4cf;
            font-weight: 500;

            &::after {
                content: "✓";
                font-size: 12px;
                color: #48b4cf;
            }
        }
    }
}

/* Price Filter Duo Range Slider */
.price-filter {
    & .price-filter__slider {
        position: relative;
        width: 100%;
        height: 10px;
        margin: 10px 0;

        /* Style commun à tous les range */
        & input[type="range"] {
            position: absolute;
            left: 0;
            top: 0;
            width: 100%;
            pointer-events: none; /* IMPORTANT : seul le thumb doit être cliquable */
            background: none;
            -webkit-appearance: none;

            /* Permet de cliquer/glisser uniquement sur le thumb */
            &::-webkit-slider-thumb {
                pointer-events: all;
            }

            /* Piste invisible (on utilise un gradient en JS pour délimiter la plage active) */
            &::-webkit-slider-runnable-track {
                height: 6px;
            }

            /* Style du thumb (curseur) */
            &::-webkit-slider-thumb {
                -webkit-appearance: none;
                width: 15px;
                height: 15px;
                border: 2px solid #666;
                border-radius: 50%;
                background: white;
                cursor: pointer;
                position: relative;
                margin-top: -4px;
                z-index: 2;
            }

            /* Firefox */
            &::-moz-range-track {
                height: 6px;
                background: #d1d1d1;
                border-radius: 3px;
            }
            &::-moz-range-thumb {
                width: 16px;
                height: 16px;
                border-radius: 50%;
                border: 2px solid #666;
                background: white;
                cursor: pointer;
            }
        }
    }

    /* Valeurs affichées sous le slider */
    & .price-filter__values {
        display: flex;
        justify-content: space-between;
        font-size: 1rem;
        color: #000;
        margin-top: 8px;
    }
}
