/*****************************
Product Filter — Filtro horizontal + Load More + Dropdown Marcas
*****************************/

/* El loop nativo se oculta via JS después de ser movido a #pf-results
   No se usa CSS aquí para evitar ocultar los productos antes de que JS corra */

#product-filter {
    width: 100%;
    background: #f5f5f5;
    border-radius: 8px;
    padding: 16px 20px;
    margin-bottom: 16px;
    box-sizing: border-box;
}

/* Sección */
.pf-section {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
}

.pf-section:last-child {
    margin-bottom: 0;
}

.pf-label {
    font-size: 0.85rem;
    font-weight: 600;
    color: #555;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    white-space: nowrap;
    margin-right: 4px;
}

/* Pills de categoría */
.pf-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.pf-pill {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 6px 14px;
    border: 1px solid #ccc;
    border-radius: 20px;
    background: #fff;
    color: #333;
    font-size: 0.875rem;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
    line-height: 1.4;
}

.pf-pill:hover {
    border-color: #2a2a2a;
    background: #f0f0f0;
}

.pf-pill--active {
    background: #2a2a2a !important;
    color: #fff !important;
    border-color: #2a2a2a !important;
}

.pf-pill--active .pf-count {
    color: #aaa;
}

.pf-count {
    font-size: 0.75rem;
    color: #888;
}

/* Sección marcas */
.pf-section--brands {
    padding-top: 12px;
    border-top: 1px solid #e0e0e0;
    align-items: flex-start;
    flex-wrap: wrap;
    gap: 10px;
}

/* ===========================
   DROPDOWN MULTI-SELECT
=========================== */

.pf-dropdown-wrap {
    position: relative;
    min-width: 220px;
}

.pf-dropdown-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    width: 100%;
    padding: 7px 14px;
    border: 1px solid #ccc;
    border-radius: 6px;
    background: #fff;
    color: #333;
    font-size: 0.9rem;
    cursor: pointer;
    transition: border-color 0.2s ease;
    white-space: nowrap;
}

.pf-dropdown-toggle:hover {
    border-color: #2a2a2a;
}

.pf-dropdown-arrow {
    font-size: 0.75rem;
    color: #666;
    transition: transform 0.2s ease;
}

.pf-dropdown-menu {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    z-index: 500;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 6px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.12);
    width: 280px;
    max-height: 360px;
    display: flex;
    flex-direction: column;
}

/* Búsqueda */
.pf-dropdown-search-wrap {
    padding: 10px 12px 6px;
    border-bottom: 1px solid #eee;
}

.pf-brand-search {
    width: 100%;
    padding: 6px 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 0.85rem;
    box-sizing: border-box;
    outline: none;
}

.pf-brand-search:focus {
    border-color: #2a2a2a;
}

/* Lista de opciones */
.pf-dropdown-list {
    list-style: none;
    margin: 0;
    padding: 6px 0;
    overflow-y: auto;
    flex: 1;
}

.pf-dropdown-item {
    padding: 0;
}

.pf-dropdown-item label {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 14px;
    cursor: pointer;
    font-size: 0.875rem;
    color: #333;
    transition: background 0.15s ease;
}

.pf-dropdown-item label:hover {
    background: #f5f5f5;
}

.pf-dropdown-item input[type="checkbox"] {
    width: 15px;
    height: 15px;
    accent-color: #2a2a2a;
    cursor: pointer;
    flex-shrink: 0;
}

.pf-brand-name {
    flex: 1;
}

/* Footer del dropdown */
.pf-dropdown-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    border-top: 1px solid #eee;
    gap: 8px;
}

.pf-dropdown-clear {
    background: none;
    border: none;
    color: #999;
    font-size: 0.8rem;
    cursor: pointer;
    padding: 4px 0;
    transition: color 0.2s ease;
}

.pf-dropdown-clear:hover {
    color: #aafac1;
}

.pf-dropdown-apply {
    padding: 6px 16px;
    background: #2a2a2a;
    color: #fff;
    border: none;
    border-radius: 4px;
    font-size: 0.85rem;
    cursor: pointer;
    transition: background 0.2s ease;
}

.pf-dropdown-apply:hover {
    background: #444;
}

/* ===========================
   TAGS DE MARCAS SELECCIONADAS
=========================== */

.pf-selected-brands {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 6px;
    width: 100%;
}

.pf-brand-tag {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 10px;
    background: #2a2a2a;
    color: #fff;
    border-radius: 20px;
    font-size: 0.8rem;
}

.pf-brand-tag-remove {
    background: none;
    border: none;
    color: #aaa;
    cursor: pointer;
    font-size: 0.75rem;
    padding: 0;
    line-height: 1;
    transition: color 0.2s ease;
}

.pf-brand-tag-remove:hover {
    color: #fff;
}

/* ===========================
   ACCIONES
=========================== */

.pf-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 10px;
    flex-wrap: wrap;
    gap: 8px;
}

.pf-summary {
    font-size: 0.85rem;
    color: #666;
}

.pf-clear {
    background: none;
    border: none;
    color: #1c6b04;
    font-size: 0.85rem;
    cursor: pointer;
    padding: 0;
    transition: color 0.2s ease;
}

.pf-clear:hover {
    color: #b71c1c;
}

/* ===========================
   RESULTADOS
=========================== */

#pf-results {
    transition: opacity 0.2s ease;
    min-height: 100px;
}

/* ===========================
   LOAD MORE
=========================== */

.pf-load-more-wrap {
    display: flex;
    justify-content: center;
    margin: 32px 0 16px;
}

.pf-load-more {
    padding: 12px 36px;
    background: var(--color-custom-loadmore);
    color: #fff;
    border: none;
    border-radius: 4px;
    font-size: 1rem;
    cursor: pointer;
    transition: background 0.2s ease, opacity 0.2s ease;
}

.pf-load-more:hover {
    background: var(--color-custom-loadmore_hover);
}

.pf-load-more:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* ===========================
   SPINNER
=========================== */

#pf-loading {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 9999;
    background: rgba(255,255,255,0.85);
    border-radius: 50%;
    padding: 16px;
}

.pf-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid #e0e0e0;
    border-top-color: #2a2a2a;
    border-radius: 50%;
    animation: pf-spin 0.7s linear infinite;
}

@keyframes pf-spin {
    to { transform: rotate(360deg); }
}

/* Sin resultados / error */
.pf-no-results,
.pf-error {
    text-align: center;
    padding: 40px 20px;
    color: #666;
    font-size: 1rem;
}

.pf-error { color: #e53935; }

/* ===========================
   RESPONSIVE MOBILE
=========================== */

@media (max-width: 767px) {
    #product-filter {
        padding: 12px 14px;
    }

    .pf-section {
        flex-direction: column;
        align-items: flex-start;
    }

    .pf-pill {
        font-size: 0.82rem;
        padding: 5px 12px;
    }

    .pf-dropdown-wrap {
        width: 100%;
    }

    .pf-dropdown-menu {
        width: 100%;
    }

    .pf-load-more {
        width: 100%;
        text-align: center;
    }
}