/* ==========================================================================
   Recetas · Filtro widget
   Colors: #124F43 (primary) · #BCFFF0 (secondary) · #FF805C (accent)
   ========================================================================== */

.recetas-filtro {
    --rf-primary: #124f43;
    --rf-secondary: #bcfff0;
    --rf-accent: #124f43;
    --rf-cols: 3;
    position: relative;
}

/* ---- Buscador ------------------------------------------------------------- */
.recetas-filtro__search {
    position: relative;
    margin-bottom: 20px;
}

.recetas-filtro__search input {
    width: 100%;
    padding: 16px 20px 16px 52px;
    border: 1px solid #e4e4e4;
    border-radius: 100px;
    background-color: #fff;
    color: var(--rf-primary);
    font-family: "Cabinet Grotesk", sans-serif;
    font-size: 16px;
    box-shadow: 0 2px 10px rgba(18, 79, 67, 0.05);
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.recetas-filtro__search input::placeholder {
    color: #9aa6a2;
    opacity: 1;
}

.recetas-filtro__search input:focus {
    outline: none;
    border-color: var(--rf-accent);
    box-shadow: 0 4px 16px rgba(18, 79, 67, 0.12);
}

.recetas-filtro__search-icon {
    position: absolute;
    top: 50%;
    left: 22px;
    width: 16px;
    height: 16px;
    margin-top: -8px;
    border: 2px solid var(--rf-primary);
    border-radius: 50%;
    pointer-events: none;
}

.recetas-filtro__search-icon::after {
    content: "";
    position: absolute;
    top: 13px;
    left: 12px;
    width: 7px;
    height: 2px;
    background: var(--rf-primary);
    transform: rotate(45deg);
    transform-origin: left center;
}

/* ---- Filtros (multiselect fancy) ----------------------------------------- */
.recetas-filtro__filters {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: center;
    justify-content: center;
    margin-bottom: 40px;
}

.rf-select {
    position: relative;
    flex: 0 1 auto;
}

.rf-select__toggle {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 12px 18px;
    border: 1px solid #e4e4e4;
    border-radius: 100px;
    background-color: #fff;
    color: var(--rf-primary);
    font-family: "Cabinet Grotesk", sans-serif;
    font-size: 15px;
    font-weight: 600;
    line-height: 1;
    cursor: pointer;
    box-shadow: 0 2px 10px rgba(18, 79, 67, 0.05);
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.rf-select__toggle:hover {
    border-color: var(--rf-accent);
}

.rf-select.is-open .rf-select__toggle,
.rf-select.has-selection .rf-select__toggle {
    border-color: var(--rf-accent);
    box-shadow: 0 4px 16px rgba(18, 79, 67, 0.12);
}

.rf-select__count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    border-radius: 100px;
    background-color: var(--rf-secondary);
    color: var(--rf-primary);
    font-size: 12px;
    font-weight: 700;
}

.rf-select__toggle:hover .rf-select__count {
    background-color: var(--rf-primary);
    color: var(--rf-secondary);
}

.rf-select__chevron {
    width: 10px;
    height: 10px;
    border-right: 2px solid currentColor;
    border-bottom: 2px solid currentColor;
    transform: rotate(45deg);
    margin-top: -4px;
    transition: transform 0.2s ease;
}

.rf-select.is-open .rf-select__chevron {
    transform: rotate(-135deg);
    margin-top: 2px;
}

.rf-select__panel {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    z-index: 20;
    min-width: 240px;
    max-height: 320px;
    overflow-y: auto;
    padding: 8px;
    border-radius: 18px;
    background-color: #fff;
    box-shadow: 0 18px 40px rgba(18, 79, 67, 0.18);
    border: 1px solid #eee;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-6px);
    transition: opacity 0.18s ease, transform 0.18s ease, visibility 0.18s;
}

.rf-select.is-open .rf-select__panel {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.rf-select__option {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: 12px;
    cursor: pointer;
    color: var(--rf-primary);
    font-size: 15px;
    transition: background-color 0.15s ease;
}

.rf-select__option:hover {
    background-color: #f3efe6;
}

.rf-select__option.is-disabled {
    opacity: 0.4;
    pointer-events: none;
}

.rf-select__opt-count {
    margin-left: auto;
    flex-shrink: 0;
    min-width: 22px;
    padding: 2px 7px;
    border-radius: 100px;
    background-color: #f0f0f0;
    color: #6b7672;
    font-size: 12px;
    font-weight: 700;
    text-align: center;
}

.rf-select__option input:checked ~ .rf-select__opt-count {
    background-color: var(--rf-accent);
    color: #fff;
}

.rf-select__option input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.rf-select__check {
    flex-shrink: 0;
    width: 20px;
    height: 20px;
    border: 2px solid #cfcfcf;
    border-radius: 6px;
    position: relative;
    transition: all 0.15s ease;
}

.rf-select__option input:checked + .rf-select__check {
    background-color: var(--rf-accent);
    border-color: var(--rf-accent);
}

.rf-select__option input:checked + .rf-select__check::after {
    content: "";
    position: absolute;
    top: 3px;
    left: 6px;
    width: 4px;
    height: 8px;
    border-right: 2px solid #fff;
    border-bottom: 2px solid #fff;
    transform: rotate(45deg);
}

.rf-select__option input:focus-visible + .rf-select__check {
    outline: 2px solid var(--rf-accent);
    outline-offset: 2px;
}

.recetas-filtro__clear {
    display: inline-flex;
    align-items: center;
    min-height: 39px;
    border: 0;
    border-bottom: 1px solid currentColor;
    border-radius: 0;
    background: transparent;
    color: var(--rf-primary);
    font-family: "Cabinet Grotesk", sans-serif;
    font-size: 14px;
    font-weight: 700;
    line-height: 1;
    text-decoration: none;
    cursor: pointer;
    padding: 0 2px;
    box-shadow: none;
    transition: color 0.2s ease, border-color 0.2s ease, opacity 0.2s ease;
}

.recetas-filtro__clear:hover,
.recetas-filtro__clear:focus-visible {
    background: transparent;
    color: var(--rf-accent);
    border-color: var(--rf-accent);
    outline: none;
}

/* ---- Grid ----------------------------------------------------------------- */
.recetas-filtro__grid {
    display: grid;
    grid-template-columns: repeat(var(--rf-cols), 1fr);
    gap: 30px;
}

.recetas-filtro__empty {
    grid-column: 1 / -1;
    text-align: center;
    color: var(--rf-primary);
    font-size: 18px;
    padding: 40px 0;
}

/* ---- Loading state -------------------------------------------------------- */
.recetas-filtro.is-loading .recetas-filtro__grid {
    opacity: 0.4;
    pointer-events: none;
    transition: opacity 0.2s ease;
}

.recetas-filtro__spinner {
    display: none;
    position: absolute;
    top: 50%;
    left: 50%;
    width: 44px;
    height: 44px;
    margin: -22px 0 0 -22px;
    border: 4px solid rgba(18, 79, 67, 0.2);
    border-top-color: var(--rf-primary);
    border-radius: 50%;
    animation: rf-spin 0.8s linear infinite;
    z-index: 2;
}

.recetas-filtro.is-loading .recetas-filtro__spinner {
    display: block;
}

@keyframes rf-spin {
    to {
        transform: rotate(360deg);
    }
}

/* ---- Paginación ----------------------------------------------------------- */
.recetas-filtro__pagination {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
    margin-top: 50px;
}

.recetas-filtro__page {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 44px;
    height: 44px;
    padding: 0 12px;
    border: 2px solid var(--rf-primary);
    border-radius: 100px;
    background-color: transparent;
    color: var(--rf-primary);
    font-weight: 700;
    font-size: 16px;
    line-height: 1;
    cursor: pointer;
    transition: all 0.2s ease;
}

.recetas-filtro__page:hover:not([disabled]) {
    background-color: var(--rf-secondary);
    color: var(--rf-primary);
}

.recetas-filtro__page.is-active {
    background-color: var(--rf-primary);
    color: var(--rf-secondary);
}

.recetas-filtro__page[disabled] {
    opacity: 0.35;
    cursor: default;
}

.recetas-filtro__page--prev,
.recetas-filtro__page--next {
    border-color: transparent;
    background-color: transparent;
}

.recetas-filtro__page--prev:hover:not([disabled]),
.recetas-filtro__page--next:hover:not([disabled]) {
    background-color: transparent;
    color: var(--rf-primary);
}

.recetas-filtro__ellipsis {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 28px;
    height: 44px;
    color: var(--rf-primary);
    font-weight: 700;
}

/* ---- Responsive ----------------------------------------------------------- */
@media (max-width: 1024px) {
    .recetas-filtro__grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 600px) {
    .recetas-filtro__grid {
        grid-template-columns: 1fr;
    }

    .rf-select {
        flex: 1 1 100%;
    }

    .rf-select__toggle {
        width: 100%;
        justify-content: space-between;
    }

    .rf-select__panel {
        width: 100%;
    }
}
