/**
 * MiMarket Filters - UI Rediseñado
 * Paleta: Navy #1B2A4A, Green #16A34A, Borders #E5E7EB
 */

/* ==========================================================================
   RESET
   ========================================================================== */
.mimarket-filters-sidebar,
.mimarket-filters-sidebar *,
.mimarket-filters-toggle,
.mimarket-filters-overlay {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

/* ==========================================================================
   BOTON TOGGLE - Solo visible en movil
   ========================================================================== */
button.mimarket-filters-toggle {
    display: none !important;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    padding: 13px 24px;
    margin: 0 0 20px 0;
    background: #1B2A4A;
    color: #fff;
    border: none;
    border-radius: 10px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s ease;
}

button.mimarket-filters-toggle:hover {
    background: #152238;
}

button.mimarket-filters-toggle svg {
    width: 20px;
    height: 20px;
    stroke: currentColor;
}

span.mimarket-filter-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 22px;
    height: 22px;
    padding: 0 7px;
    margin-left: 4px;
    background: #fff;
    color: #1B2A4A;
    border-radius: 11px;
    font-size: 12px;
    font-weight: 700;
}

/* ==========================================================================
   OVERLAY - Solo movil
   ========================================================================== */
.mimarket-filters-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 99998;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.mimarket-filters-overlay.is-visible {
    opacity: 1;
    visibility: visible;
}

/* ==========================================================================
   SIDEBAR - Desktop
   ========================================================================== */
aside.mimarket-filters-sidebar {
    display: block;
    width: 100%;
    background: #fff;
    border: 1px solid #E5E7EB;
    border-radius: 12px;
    overflow: hidden;
    margin: 0 0 25px 0;
}

/* Header - Oculto en desktop */
.mimarket-filters-sidebar .mimarket-filters-header {
    display: none;
}

/* ==========================================================================
   FILTROS ACTIVOS (Chips)
   ========================================================================== */
.mf-active-filters {
    padding: 16px 18px;
    border-bottom: 1px solid #E5E7EB;
}

.mf-active-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
}

.mf-active-count {
    font-size: 12px;
    font-weight: 700;
    color: #1B2A4A;
    letter-spacing: 0.5px;
}

a.mf-clear-all {
    font-size: 13px;
    font-weight: 600;
    color: #DC2626;
    text-decoration: none;
    cursor: pointer;
    transition: color 0.2s;
}

a.mf-clear-all:hover {
    color: #B91C1C;
}

.mf-active-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.mf-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 10px;
    background: #EFF6FF;
    border: 1px solid #BFDBFE;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 500;
    color: #1B2A4A;
    line-height: 1.3;
}

button.mf-chip-remove {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    padding: 0;
    background: transparent;
    border: none;
    border-radius: 50%;
    font-size: 16px;
    font-weight: 400;
    color: #6B7280;
    cursor: pointer;
    line-height: 1;
    transition: all 0.15s;
}

button.mf-chip-remove:hover {
    background: #1B2A4A;
    color: #fff;
}

/* ==========================================================================
   ACORDEONES
   ========================================================================== */
.mimarket-filter-accordion {
    border-bottom: 1px solid #E5E7EB;
}

.mimarket-filter-accordion:last-of-type {
    border-bottom: none;
}

button.mimarket-accordion-header {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 14px 18px;
    margin: 0;
    background: #fff;
    border: none;
    border-radius: 0;
    font-size: 15px;
    font-weight: 700;
    color: #1B2A4A;
    text-align: left;
    cursor: pointer;
    transition: background 0.15s ease;
}

button.mimarket-accordion-header:hover {
    background: #F8FAFC;
}

button.mimarket-accordion-header > span:first-child {
    flex: 1;
}

/* Badge de conteo en accordion header */
.mf-accordion-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    background: #1B2A4A;
    color: #fff;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 700;
}

svg.mimarket-accordion-icon {
    width: 18px;
    height: 18px;
    stroke: #9CA3AF;
    transition: transform 0.25s ease;
    flex-shrink: 0;
}

.mimarket-filter-accordion.is-open svg.mimarket-accordion-icon,
.mimarket-filter-accordion.is-active svg.mimarket-accordion-icon {
    transform: rotate(180deg);
}

.mimarket-accordion-content {
    display: none;
    padding: 0 18px 18px 18px;
}

.mimarket-filter-accordion.is-open .mimarket-accordion-content,
.mimarket-filter-accordion.is-active .mimarket-accordion-content {
    display: block;
}

/* ==========================================================================
   CATEGORIAS - Checkboxes jerarquicos
   ========================================================================== */
.mf-category-list {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.mf-category-label {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    margin: 0;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.15s;
    position: relative;
}

.mf-category-label:hover {
    background: #F1F5F9;
}

.mf-category-label.is-selected {
    background: #EFF6FF;
}

/* Radio oculto */
.mf-category-radio {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

/* Checkbox visual custom */
.mf-category-check {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    border: 2px solid #D1D5DB;
    border-radius: 4px;
    background: #fff;
    flex-shrink: 0;
    transition: all 0.15s;
}

.mf-category-radio:checked ~ .mf-category-check {
    background: #1B2A4A;
    border-color: #1B2A4A;
}

.mf-category-radio:checked ~ .mf-category-check::after {
    content: "";
    display: block;
    width: 5px;
    height: 9px;
    border: solid #fff;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
    margin-top: -2px;
}

.mf-category-emoji {
    font-size: 18px;
    line-height: 1;
    flex-shrink: 0;
}

.mf-category-name {
    flex: 1;
    font-size: 14px;
    font-weight: 500;
    color: #1B2A4A;
}

.mf-category-count {
    font-size: 13px;
    font-weight: 500;
    color: #9CA3AF;
    flex-shrink: 0;
}

/* Subcategorias */
.mf-subcategories {
    display: flex;
    flex-direction: column;
    gap: 1px;
    padding-left: 28px;
    margin-top: 4px;
}

.mf-subcategory-label {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 5px 10px;
    margin: 0;
    border-radius: 6px;
    cursor: default;
    font-size: 13px;
    color: #4B5563;
}

.mf-subcategory-check {
    display: none;
}

.mf-subcategory-name {
    font-size: 13px;
    font-weight: 400;
    color: #4B5563;
}

/* ==========================================================================
   UBICACION - Selects
   ========================================================================== */
.mimarket-filter-group {
    margin-bottom: 14px;
}

.mimarket-filter-group:last-child {
    margin-bottom: 0;
}

label.mimarket-filter-label {
    display: block;
    margin-bottom: 6px;
    font-size: 11px;
    font-weight: 700;
    color: #6B7280;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

select.mimarket-filter-select {
    display: block;
    width: 100%;
    padding: 10px 36px 10px 14px;
    margin: 0;
    background-color: #fff;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%236B7280' stroke-width='2.5'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 14px;
    border: 1px solid #D1D5DB;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 400;
    color: #1B2A4A;
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

select.mimarket-filter-select:hover {
    border-color: #1B2A4A;
}

select.mimarket-filter-select:focus {
    outline: none;
    border-color: #1B2A4A;
    box-shadow: 0 0 0 3px rgba(27, 42, 74, 0.1);
}

select.mimarket-filter-select:disabled {
    background-color: #F3F4F6;
    color: #9CA3AF;
    cursor: not-allowed;
}

/* ==========================================================================
   PRECIO - Inputs + Slider + Chips
   ========================================================================== */
.mf-price-container {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.mf-price-inputs {
    display: flex;
    align-items: center;
    gap: 10px;
}

.mf-price-input-wrap {
    display: flex;
    align-items: stretch;
    flex: 1;
    border: 1px solid #D1D5DB;
    border-radius: 8px;
    overflow: hidden;
    transition: border-color 0.2s, box-shadow 0.2s;
    min-width: 0;
}

.mf-price-input-wrap:focus-within {
    border-color: #1B2A4A;
    box-shadow: 0 0 0 3px rgba(27, 42, 74, 0.1);
}

.mf-price-prefix {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 10px;
    font-size: 14px;
    font-weight: 700;
    color: #1B2A4A;
    background: #F3F4F6;
    border-right: 1px solid #D1D5DB;
    flex-shrink: 0;
    pointer-events: none;
    user-select: none;
}

input.mf-price-field {
    width: 100%;
    min-width: 0;
    padding: 9px 8px;
    border: none;
    outline: none;
    font-size: 14px;
    font-weight: 500;
    color: #1B2A4A;
    background: #fff;
    -moz-appearance: textfield;
}

input.mf-price-field::-webkit-inner-spin-button,
input.mf-price-field::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.mf-price-dash {
    color: #9CA3AF;
    font-size: 14px;
    flex-shrink: 0;
}

/* Slider de rango */
.mimarket-range-slider {
    position: relative;
    width: 100%;
    height: 8px;
    margin: 8px 0 4px 0;
}

.mimarket-range-track {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 8px;
    background: #E5E7EB;
    border-radius: 4px;
}

.mimarket-range-progress {
    position: absolute;
    top: 0;
    height: 8px;
    background: #1B2A4A;
    border-radius: 4px;
    left: 0;
    width: 100%;
}

input.mimarket-range-input {
    position: absolute;
    top: -6px;
    left: 0;
    width: 100%;
    height: 20px;
    margin: 0;
    padding: 0;
    background: transparent;
    border: none;
    outline: none;
    pointer-events: none;
    -webkit-appearance: none;
    appearance: none;
}

input.mimarket-range-input::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 22px;
    height: 22px;
    background: #fff;
    border: 3px solid #1B2A4A;
    border-radius: 50%;
    cursor: pointer;
    pointer-events: auto;
    box-shadow: 0 1px 4px rgba(0,0,0,0.15);
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

input.mimarket-range-input::-webkit-slider-thumb:hover {
    transform: scale(1.15);
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

input.mimarket-range-input::-moz-range-thumb {
    width: 22px;
    height: 22px;
    background: #fff;
    border: 3px solid #1B2A4A;
    border-radius: 50%;
    cursor: pointer;
    pointer-events: auto;
    box-shadow: 0 1px 4px rgba(0,0,0,0.15);
}

/* Chips de precio rapido */
.mf-price-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

button.mf-price-chip {
    padding: 5px 12px;
    background: #F3F4F6;
    border: 1px solid #E5E7EB;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
    color: #4B5563;
    cursor: pointer;
    transition: all 0.15s;
    white-space: nowrap;
}

button.mf-price-chip:hover {
    background: #E5E7EB;
    border-color: #D1D5DB;
    color: #1B2A4A;
}

button.mf-price-chip.is-active {
    background: #1B2A4A;
    border-color: #1B2A4A;
    color: #fff;
}

/* ==========================================================================
   VALORACIONES
   ========================================================================== */
.mimarket-rating-options {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

label.mimarket-rating-option {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 10px;
    margin: 0;
    background: #fff;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.15s;
}

label.mimarket-rating-option:hover {
    background: #F8FAFC;
}

label.mimarket-rating-option input[type="radio"] {
    width: 16px;
    height: 16px;
    margin: 0;
    accent-color: #1B2A4A;
    cursor: pointer;
    flex-shrink: 0;
}

label.mimarket-rating-option:has(input:checked) {
    background: #EFF6FF;
}

.mimarket-rating-stars {
    display: flex;
    gap: 1px;
    font-size: 16px;
    line-height: 1;
}

.mimarket-rating-stars .star.filled {
    color: #F59E0B;
}

.mimarket-rating-stars .star.empty {
    color: #D1D5DB;
}

.mimarket-rating-text {
    font-size: 13px;
    font-weight: 400;
    color: #6B7280;
    flex: 1;
}

.mimarket-rating-count {
    font-size: 13px;
    font-weight: 500;
    color: #9CA3AF;
    flex-shrink: 0;
}

/* ==========================================================================
   TOGGLES - Ofertas y disponibilidad
   ========================================================================== */
.mf-toggle-group {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.mf-toggle-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 0;
    border-bottom: 1px solid #F3F4F6;
}

.mf-toggle-item:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.mf-toggle-item:first-child {
    padding-top: 0;
}

.mf-toggle-text {
    font-size: 14px;
    font-weight: 500;
    color: #374151;
}

label.mimarket-toggle-switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
    margin: 0;
    flex-shrink: 0;
}

label.mimarket-toggle-switch input {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

span.mimarket-toggle-slider {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: #D1D5DB;
    border-radius: 24px;
    cursor: pointer;
    transition: background 0.3s ease;
}

span.mimarket-toggle-slider::before {
    content: "";
    position: absolute;
    top: 2px;
    left: 2px;
    width: 20px;
    height: 20px;
    background: #fff;
    border-radius: 50%;
    box-shadow: 0 1px 3px rgba(0,0,0,0.15);
    transition: transform 0.3s ease;
}

label.mimarket-toggle-switch input:checked + span.mimarket-toggle-slider {
    background: #1B2A4A;
}

label.mimarket-toggle-switch input:checked + span.mimarket-toggle-slider::before {
    transform: translateX(20px);
}

/* ==========================================================================
   BOTONES DE ACCION
   ========================================================================== */
.mimarket-filter-actions {
    padding: 16px 18px;
    border-top: 1px solid #E5E7EB;
}

a.mimarket-btn-clear {
    display: block;
    width: 100%;
    padding: 11px 16px;
    background: #fff;
    border: 1px solid #D1D5DB;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    color: #6B7280;
    text-align: center;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.2s ease;
}

a.mimarket-btn-clear:hover {
    background: #F3F4F6;
    border-color: #9CA3AF;
    color: #1B2A4A;
}

button.mimarket-btn-apply {
    display: block;
    width: 100%;
    padding: 12px 16px;
    margin-top: 10px;
    background: #1B2A4A;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    color: #fff;
    cursor: pointer;
    transition: background 0.2s ease;
}

button.mimarket-btn-apply:hover {
    background: #152238;
}

/* ==========================================================================
   LOADING STATE
   ========================================================================== */
select.mimarket-filter-select.is-loading {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 50 50'%3E%3Ccircle cx='25' cy='25' r='20' fill='none' stroke='%231B2A4A' stroke-width='4' stroke-dasharray='80' stroke-linecap='round'%3E%3CanimateTransform attributeName='transform' type='rotate' from='0 25 25' to='360 25 25' dur='0.8s' repeatCount='indefinite'/%3E%3C/circle%3E%3C/svg%3E");
    background-size: 20px;
    pointer-events: none;
    opacity: 0.7;
}

/* ==========================================================================
   RESPONSIVE - Tablet y Movil
   ========================================================================== */
@media screen and (max-width: 991px) {
    /* Mostrar boton toggle */
    button.mimarket-filters-toggle {
        display: flex !important;
    }

    /* Overlay visible en movil */
    .mimarket-filters-overlay {
        display: block;
    }

    /* Sidebar como panel lateral */
    aside.mimarket-filters-sidebar {
        position: fixed;
        top: 0;
        left: 0;
        width: 320px;
        min-width: 320px;
        max-width: 90vw;
        height: 100vh;
        height: 100dvh;
        margin: 0;
        border: none;
        border-radius: 0;
        box-shadow: 4px 0 25px rgba(0,0,0,0.15);
        z-index: 99999;
        float: none;
        transform: translateX(-100%);
        transition: transform 0.3s ease;
        overflow-y: auto;
        overflow-x: hidden;
    }

    aside.mimarket-filters-sidebar.is-open {
        transform: translateX(0);
    }

    /* Mostrar header en movil */
    .mimarket-filters-sidebar .mimarket-filters-header {
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 16px 18px;
        background: #1B2A4A;
        color: #fff;
        position: sticky;
        top: 0;
        z-index: 10;
    }

    .mimarket-filters-header h3 {
        margin: 0;
        font-size: 18px;
        font-weight: 600;
        color: #fff;
    }

    button.mimarket-filters-close {
        display: flex;
        align-items: center;
        justify-content: center;
        width: 36px;
        height: 36px;
        padding: 0;
        margin: 0;
        background: rgba(255,255,255,0.15);
        border: none;
        border-radius: 50%;
        cursor: pointer;
        transition: background 0.2s ease;
    }

    button.mimarket-filters-close:hover {
        background: rgba(255,255,255,0.25);
    }

    button.mimarket-filters-close svg {
        width: 20px;
        height: 20px;
        stroke: #fff;
    }

    /* Padding para contenido */
    .mimarket-filters-sidebar .mimarket-filters-form {
        padding-bottom: 90px;
    }

    /* Botones fijos abajo */
    .mimarket-filters-sidebar .mimarket-filter-actions {
        position: fixed;
        bottom: 0;
        left: 0;
        width: 320px;
        max-width: 90vw;
        padding: 14px 18px;
        background: #fff;
        border-top: 1px solid #E5E7EB;
        box-shadow: 0 -2px 10px rgba(0,0,0,0.06);
        z-index: 11;
    }
}

@media screen and (max-width: 480px) {
    aside.mimarket-filters-sidebar {
        width: 100%;
        min-width: 100%;
        max-width: 100%;
    }

    .mimarket-filters-sidebar .mimarket-filter-actions {
        width: 100%;
        max-width: 100%;
    }
}

/* ==========================================================================
   PRINT
   ========================================================================== */
@media print {
    .mimarket-filters-toggle,
    .mimarket-filters-overlay,
    .mimarket-filters-sidebar {
        display: none !important;
    }
}
