/**
 * ACF Smart Filter v3.0.0 - Estilos
 * Color primario: var(--asf-primary) — Configurable desde wp-admin
 * Author: Iván Studio — https://ivanstudioweb.com/
 */

/* ============================================================
   VARIABLES CSS (tokens del design system)
   ============================================================ */
:root {
    --asf-primary:      #608a3c; /* Valor por defecto, será sobreescrito por PHP */
    --asf-primary-dark: #4d7030;
    --asf-text:         #333333;
    --asf-text-light:   #666666;
    --asf-border:       #e0e0e0;
    --asf-bg:           #f9f9f9;
    --asf-white:        #ffffff;
    --asf-radius:       6px;
    --asf-shadow:       0 4px 12px rgba(0,0,0,0.08);
}

/* ============================================================
   LAYOUT PRINCIPAL
   ============================================================ */
.asf-wrapper {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    color: var(--asf-text);
}

.asf-layout {
    display: flex;
    gap: 30px;
    flex-wrap: wrap;
}

.asf-sidebar {
    flex: 0 0 280px;
    max-width: 320px;
}

.asf-content {
    flex: 1;
    min-width: 0;
}

/* ============================================================
   FORMULARIO DE FILTROS — LAYOUT VERTICAL (tienda)
   ============================================================ */
.asf-form {
    background: var(--asf-bg);
    border: 1px solid var(--asf-border);
    border-radius: var(--asf-radius);
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 18px;
}

/* ============================================================
   CAMPOS
   ============================================================ */
.asf-field {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.asf-field > label {
    font-weight: 600;
    font-size: 12px;
    color: var(--asf-text);
    text-transform: uppercase;
    letter-spacing: 0.3px;
    line-height: 1.2;
    margin-bottom: 2px;
}

/* ============================================================
   SELECT
   ============================================================ */
.asf-select {
    width: 100%;
    padding: 10px 38px 10px 12px;
    border: 1px solid var(--asf-border);
    border-radius: var(--asf-radius);
    background: var(--asf-white);
    font-size: 14px;
    color: var(--asf-text);
    cursor: pointer;
    transition: border-color 0.2s, box-shadow 0.2s;
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23666' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    height: 44px;
    box-sizing: border-box;
    line-height: 1.5;
}

.asf-select:hover {
    border-color: #b0b0b0;
    background-color: #fafafa;
}

.asf-select:focus {
    outline: none;
    border-color: var(--asf-primary);
    box-shadow: 0 0 0 3px rgba(var(--asf-primary-rgb, 96,138,60), 0.15);
    background-color: var(--asf-white);
}

.asf-select--hidden {
    display: none !important;
    visibility: hidden;
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

/* ============================================================
   CHECKBOXES (control tipo checklist)
   ============================================================ */
.asf-checklist {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 4px;
}

.asf-checkbox {
    position: relative;
    display: flex;
    align-items: center;
    padding: 10px 12px;
    border: 1px solid var(--asf-border);
    border-radius: var(--asf-radius);
    background: var(--asf-white);
    cursor: pointer;
    transition: all 0.18s ease;
    min-height: 42px;
    gap: 10px;
}

.asf-checkbox:hover {
    border-color: #b0b0b0;
    background-color: #fafafa;
}

.asf-checkbox:has(.asf-checkbox__input:checked) {
    border-color: var(--asf-primary);
    background-color: color-mix(in srgb, var(--asf-primary) 8%, white);
}

.asf-checkbox__input {
    position: absolute;
    opacity: 0;
    cursor: pointer;
    height: 0;
    width: 0;
}

.asf-checkbox__checkmark {
    position: relative;
    width: 18px;
    height: 18px;
    min-width: 18px;
    border: 2px solid #ccc;
    border-radius: 3px;
    background: var(--asf-white);
    transition: all 0.18s ease;
    flex-shrink: 0;
}

.asf-checkbox__input:checked ~ .asf-checkbox__checkmark {
    background: var(--asf-primary);
    border-color: var(--asf-primary);
}

.asf-checkbox__input:checked ~ .asf-checkbox__checkmark::after {
    content: '';
    position: absolute;
    left: 4px;
    top: 1px;
    width: 5px;
    height: 9px;
    border: solid white;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

.asf-checkbox__label {
    font-size: 14px;
    color: var(--asf-text);
    line-height: 1.4;
    flex: 1;
    user-select: none;
}

.asf-checkbox__input:checked ~ .asf-checkbox__label {
    color: var(--asf-primary);
    font-weight: 500;
}

/* ============================================================
   CHIPS DE CATEGORÍA
   ============================================================ */
.asf-category-chips {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    margin-top: 6px;
}

.asf-category-chip {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 8px 6px;
    border: 2px solid var(--asf-border);
    border-radius: var(--asf-radius);
    background: var(--asf-white);
    cursor: pointer;
    transition: all 0.2s ease;
    gap: 5px;
    width: 100%;
    user-select: none;
    pointer-events: auto;
}

.asf-category-chip__icon,
.asf-category-chip__icon img,
.asf-category-chip__label {
    pointer-events: none;
}

.asf-category-chip:hover {
    border-color: #b0b0b0;
    background: #fafafa;
    transform: translateY(-2px);
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

.asf-category-chip.is-active {
    border-color: var(--asf-primary) !important;
    background: color-mix(in srgb, var(--asf-primary) 8%, white);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--asf-primary) 15%, transparent);
}

.asf-category-chip__icon {
    width: 54px;
    height: 54px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.asf-category-chip__icon img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.asf-category-chip__placeholder {
    width: 100%;
    height: 100%;
    background: var(--asf-bg);
    border-radius: 4px;
}

.asf-category-chip__label {
    font-size: 10px;
    font-weight: 500;
    color: var(--asf-text-light);
    text-align: center;
    line-height: 1.2;
    word-break: break-word;
}

.asf-category-chip.is-active .asf-category-chip__label {
    color: var(--asf-primary);
    font-weight: 600;
}

/* ============================================================
   PRECIO — noUiSlider
   ============================================================ */
.asf-field--price {
    min-width: 180px;
}

.asf-price-wrapper {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.asf-price-track {
    height: 3px;
    margin: 12px 8px;
    position: relative;
}

/* noUiSlider base styles */
.asf-price-track.noUi-target {
    background: var(--asf-border);
    border: none;
    box-shadow: none;
    height: 3px;
    border-radius: 2px;
}

.asf-price-track .noUi-connect {
    background: var(--asf-primary);
    height: 3px;
    border-radius: 2px;
}

.asf-price-track .noUi-handle {
    width: 14px !important;
    height: 14px !important;
    background: var(--asf-primary) !important;
    border: 2px solid white !important;
    border-radius: 50% !important;
    box-shadow: 0 1px 4px rgba(0,0,0,0.2) !important;
    cursor: pointer;
    top: -5.5px !important;
    right: -7px !important;
}

.asf-price-track .noUi-handle::before,
.asf-price-track .noUi-handle::after {
    display: none !important;
}

.asf-price-track.noUi-horizontal {
    height: 3px !important;
}

.asf-price-inputs {
    display: flex;
    gap: 8px;
    margin-top: 4px;
}

.asf-price-input {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.asf-price-input > span {
    font-size: 10px;
    color: #999;
    font-weight: 400;
}

.asf-price-display-field {
    width: 100%;
    padding: 5px 8px;
    border: 1px solid var(--asf-border);
    border-radius: 4px;
    background: #f5f5f5;
    font-size: 13px;
    color: var(--asf-primary);
    font-weight: 700;
    cursor: default;
    height: 30px;
    box-sizing: border-box;
}

/* ============================================================
   BOTONES
   ============================================================ */
.asf-actions {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.asf-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 12px 20px;
    font-size: 14px;
    font-weight: 600;
    border-radius: var(--asf-radius);
    cursor: pointer;
    transition: all 0.2s;
    border: none;
    text-decoration: none;
    min-height: 46px;
    width: 100%;
    text-align: center;
}

.asf-btn--primary {
    background: var(--asf-primary) !important;
    color: white !important;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-size: 13px !important;
}

.asf-btn--primary:hover {
    background: var(--asf-primary-dark) !important;
    color: white !important;
    transform: translateY(-1px);
    box-shadow: 0 4px 14px color-mix(in srgb, var(--asf-primary) 40%, transparent);
}

.asf-btn--primary:active {
    transform: translateY(0);
}

.asf-btn--secondary {
    background: white !important;
    color: var(--asf-text-light) !important;
    border: 1px solid var(--asf-border) !important;
    font-weight: 500;
    font-size: 13px !important;
}

.asf-btn--secondary:hover {
    background: var(--asf-bg) !important;
    color: var(--asf-text) !important;
    border-color: #b0b0b0 !important;
}

/* ============================================================
   FORMULARIO HORIZONTAL (finder en Home/Banner)
   ============================================================ */
.asf-finder-only .asf-form {
    background: transparent !important;
    border: none !important;
    padding: 0 !important;
}

.asf-form--horizontal {
    flex-direction: row !important;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 12px !important;
}

.asf-form--horizontal .asf-field {
    flex: 1;
    min-width: 140px;
}

.asf-form--horizontal .asf-actions {
    flex: 0 0 auto;
    flex-direction: row;
    align-self: flex-end;
}

.asf-form--horizontal .asf-select,
.asf-form--horizontal .asf-btn,
.asf-form--horizontal .asf-price-display-field {
    height: 36px;
    min-height: 36px;
    font-size: 13px;
    padding-top: 6px;
    padding-bottom: 6px;
}

/* ============================================================
   TEMAS (dark/light labels)
   ============================================================ */
.asf-theme-dark .asf-field > label {
    color: #ffffff !important;
}

.asf-theme-light .asf-field > label {
    color: var(--asf-text) !important;
}

.asf-finder-only .asf-select {
    background-color: white;
}

/* ============================================================
   ESTADO LOADING
   ============================================================ */
.asf-content.loading {
    opacity: 0.5;
    pointer-events: none;
    transition: opacity 0.2s;
}

/* ============================================================
   GRID DE PRODUCTOS
   ============================================================ */
.asf-grid {
    display: grid;
    gap: 24px;
}

.asf-grid--cols-2 { grid-template-columns: repeat(2, 1fr); }
.asf-grid--cols-3 { grid-template-columns: repeat(3, 1fr); }
.asf-grid--cols-4 { grid-template-columns: repeat(4, 1fr); }

/* ============================================================
   TARJETA DE PRODUCTO
   ============================================================ */
.asf-card {
    background: var(--asf-white);
    border: 1px solid var(--asf-border);
    border-radius: var(--asf-radius);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transition: transform 0.2s, box-shadow 0.2s;
}

.asf-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--asf-shadow);
}

.asf-card__image {
    aspect-ratio: 4/3;
    overflow: hidden;
    background: var(--asf-bg);
}

.asf-card__image a {
    display: block;
    width: 100%;
    height: 100%;
}

.asf-card__image img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    padding: 12px;
    box-sizing: border-box;
    transition: transform 0.3s;
}

.asf-card:hover .asf-card__image img {
    transform: scale(1.04);
}

.asf-card__placeholder {
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #f0f0f0, #e0e0e0);
}

.asf-card__content {
    padding: 18px;
    display: flex;
    flex-direction: column;
    flex-grow: 1;
}

.asf-card__title {
    margin: 0 0 12px;
    font-size: 16px;
    font-weight: 600;
    line-height: 1.4;
}

.asf-card__title a {
    color: var(--asf-text);
    text-decoration: none;
    transition: color 0.2s;
}

.asf-card__title a:hover {
    color: var(--asf-primary);
}

.asf-card__specs {
    list-style: none;
    padding: 0;
    margin: 0 0 auto;
    font-size: 13px;
    color: var(--asf-text-light);
}

.asf-card__specs li {
    padding: 3px 0;
    border-bottom: 1px solid #f5f5f5;
    line-height: 1.4;
}

.asf-card__specs li:last-child {
    border-bottom: none;
}

.asf-card__footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 16px;
    padding-top: 14px;
    border-top: 1px solid #f0f0f0;
    gap: 8px;
}

.asf-card__price {
    font-size: 16px;
    font-weight: 700;
    color: var(--asf-text);
}

.asf-card__price .woocommerce-Price-amount {
    color: var(--asf-primary);
}

.asf-card__btn {
    display: inline-flex;
    align-items: center;
    padding: 8px 14px;
    background: var(--asf-primary);
    color: white;
    border-radius: var(--asf-radius);
    font-size: 12px;
    font-weight: 600;
    text-decoration: none;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    transition: background 0.2s, transform 0.2s;
    white-space: nowrap;
}

.asf-card__btn:hover {
    background: var(--asf-primary-dark);
    color: white;
    transform: translateY(-1px);
}

/* ============================================================
   ESTADO VACÍO
   ============================================================ */
.asf-empty {
    grid-column: 1 / -1;
    padding: 50px 20px;
    text-align: center;
    color: var(--asf-text-light);
    background: var(--asf-bg);
    border-radius: var(--asf-radius);
    border: 2px dashed var(--asf-border);
}

.asf-empty p {
    margin: 0;
    font-size: 15px;
}

/* ============================================================
   PAGINACIÓN
   ============================================================ */
.asf-pagination {
    display: flex;
    gap: 6px;
    justify-content: center;
    padding: 24px 0 8px;
    flex-wrap: wrap;
}

.asf-page {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 34px;
    height: 34px;
    padding: 0 8px;
    border: 1px solid var(--asf-border);
    border-radius: var(--asf-radius);
    color: var(--asf-text-light);
    text-decoration: none;
    font-size: 13px;
    font-weight: 500;
    transition: all 0.2s;
}

.asf-page:hover {
    background: var(--asf-bg);
    border-color: #b0b0b0;
    color: var(--asf-text);
}

.asf-page.active {
    background: var(--asf-primary);
    border-color: var(--asf-primary);
    color: white;
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 900px) {
    .asf-layout {
        flex-direction: column;
    }

    .asf-sidebar {
        flex: none;
        max-width: 100%;
    }

    .asf-grid--cols-3,
    .asf-grid--cols-4 {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 580px) {
    .asf-grid--cols-2,
    .asf-grid--cols-3,
    .asf-grid--cols-4 {
        grid-template-columns: 1fr;
    }

    .asf-form--horizontal {
        flex-direction: column !important;
    }

    .asf-form--horizontal .asf-field {
        min-width: 100%;
    }

    .asf-category-chips {
        grid-template-columns: repeat(2, 1fr);
    }
}
