/* =============================================================================
   BlueArk Catalog — Frontend CSS
   Catálogo de productos WooCommerce con filtros AJAX.
   ============================================================================= */

/* =============================================================================
   1. Layout principal
   ============================================================================= */

.bap-catalog {
    position: relative;
    width: 100%;
    font-family: inherit;
    padding: 40px 89px;
    box-sizing: border-box;
}

.bap-catalog__layout {
    display: grid;
    grid-template-columns: 260px 1fr;
    gap: 40px;
    align-items: start;
}

/* =============================================================================
   2. Sidebar
   ============================================================================= */

.bap-catalog__sidebar {
    position: sticky;
    top: 20px;
    align-self: start;
}

/* =============================================================================
   3. Filtros — estructura general
   ============================================================================= */

.bap-filter {
    padding-bottom: 24px;
    margin-bottom: 24px;
    border-bottom: 1px solid #e8e8e8;
}

.bap-filter:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

.bap-filter__title {
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: #1a1a1a;
    margin: 0 0 14px;
    padding: 0;
}

/* =============================================================================
   4. Filtro por categoría
   ============================================================================= */

.bap-filter__options {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.bap-filter-option {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    font-size: 14px;
    color: #333;
    line-height: 1.4;
}

.bap-filter-option input[type="checkbox"] {
    width: 16px;
    height: 16px;
    border: 1.5px solid #ccc;
    border-radius: 3px;
    cursor: pointer;
    accent-color: #1a1a1a;
    flex-shrink: 0;
}

.bap-filter-option__label {
    flex: 1;
}

.bap-filter-option__count {
    color: #999;
    font-size: 12px;
    white-space: nowrap;
}

/* =============================================================================
   5. Filtro de precio — slider doble
   ============================================================================= */

.bap-price-range {
    position: relative;
    padding: 12px 0 0;
    height: 20px;
    margin-bottom: 20px;
}

.bap-price-range__track {
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    transform: translateY(-50%);
    height: 3px;
    background: #e0e0e0;
    border-radius: 2px;
    pointer-events: none;
}

.bap-price-range__fill {
    position: absolute;
    top: 0;
    height: 100%;
    background: #1a1a1a;
    border-radius: 2px;
}

.bap-range {
    position: absolute;
    top: 50%;
    left: 0;
    transform: translateY(-50%);
    width: 100%;
    height: 3px;
    -webkit-appearance: none;
    appearance: none;
    background: transparent;
    outline: none;
    pointer-events: none;
    margin: 0;
    padding: 0;
}

.bap-range::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #fff;
    border: 2px solid #1a1a1a;
    cursor: pointer;
    pointer-events: all;
    box-shadow: 0 1px 4px rgba(0,0,0,0.15);
    transition: transform 0.1s;
}

.bap-range::-webkit-slider-thumb:hover,
.bap-range::-webkit-slider-thumb:active {
    transform: scale(1.2);
}

.bap-range::-moz-range-thumb {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #fff;
    border: 2px solid #1a1a1a;
    cursor: pointer;
    pointer-events: all;
    box-shadow: 0 1px 4px rgba(0,0,0,0.15);
    box-sizing: border-box;
}

.bap-range::-moz-range-track {
    background: transparent;
    border: none;
}

.bap-price-fields {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 28px;
}

.bap-price-field {
    display: flex;
    align-items: center;
    gap: 4px;
    flex: 1;
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 5px 8px;
    background: #fafafa;
}

.bap-price-currency {
    font-size: 13px;
    color: #666;
    flex-shrink: 0;
}

.bap-price-input {
    width: 100%;
    border: none;
    background: transparent;
    font-size: 13px;
    color: #1a1a1a;
    outline: none;
    padding: 0;
    -moz-appearance: textfield;
}

.bap-price-input::-webkit-outer-spin-button,
.bap-price-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
}

.bap-price-separator {
    font-size: 13px;
    color: #999;
    flex-shrink: 0;
}

/* =============================================================================
   6. Filtro de ordenamiento
   ============================================================================= */

.bap-sort-select {
    width: 100%;
    padding: 9px 32px 9px 12px;
    border: 1px solid #ddd;
    border-radius: 6px;
    background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%23666' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E") no-repeat right 12px center;
    -webkit-appearance: none;
    appearance: none;
    font-size: 14px;
    color: #1a1a1a;
    cursor: pointer;
    outline: none;
    transition: border-color 0.15s;
}

.bap-sort-select:focus {
    border-color: #1a1a1a;
}

/* =============================================================================
   7. Grid de productos
   ============================================================================= */

.bap-catalog__main {
    min-width: 0;
}

.bap-catalog__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    min-height: 32px;
}

.bap-product-count {
    font-size: 13px;
    color: #666;
}

.bap-catalog__grid {
    display: grid;
    grid-template-columns: repeat(var(--bap-cols, 3), 1fr);
    gap: 24px 20px;
    transition: opacity 0.2s;
}

.bap-no-products {
    grid-column: 1 / -1;
    padding: 48px 24px;
    text-align: center;
    color: #999;
    border: 1px dashed #ddd;
    border-radius: 8px;
}

.bap-no-products p {
    margin: 0;
    font-size: 15px;
}

/* =============================================================================
   8. Tarjeta de producto
   ============================================================================= */

.bap-product-card {
    display: flex;
    flex-direction: column;
    background: var(--bap-card-bg, #ffffff);
    border: 1px solid #e8e8e8;
    border-radius: 8px;
    overflow: hidden;
    transition: box-shadow 0.2s;
}

.bap-product-card:hover {
    box-shadow: 0 4px 20px rgba(0,0,0,0.08);
}

.bap-product-card__image-link {
    display: block;
    overflow: hidden;
}

.bap-product-card__image {
    aspect-ratio: 4 / 5;
    overflow: hidden;
    background: #f5f5f5;
}

.bap-product-card__img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform 0.35s ease;
}

.bap-product-card:hover .bap-product-card__img {
    transform: scale(1.03);
}

.bap-product-card__body {
    display: flex;
    flex-direction: column;
    flex: 1;
    padding: 14px 12px 12px;
    gap: 4px;
}

.bap-product-card__category {
    font-size: 11px;
    font-weight: 500;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: #999;
    line-height: 1.4;
}

.bap-product-card__name {
    font-size: 14px;
    font-weight: 600;
    color: #1a1a1a;
    line-height: 1.4;
    margin: 4px 0 0;
    padding: 0;
}

.bap-product-card__name a {
    color: inherit;
    text-decoration: none;
}

.bap-product-card__name a:hover {
    text-decoration: underline;
}

.bap-product-card__price {
    font-size: 14px;
    color: #1a1a1a;
    margin-top: 6px;
    line-height: 1.4;
}

/* Precio tachado — WooCommerce genera <del> + <ins> */
.bap-product-card__price del {
    color: #aaa;
    font-weight: 400;
    margin-right: 4px;
}

.bap-product-card__price ins {
    color: #c0392b;
    font-weight: 600;
    text-decoration: none;
}

.bap-product-card__actions {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 12px;
    align-items: center;
}

/* =============================================================================
   9. Botones de la tarjeta
   ============================================================================= */

.bap-btn {
    display: inline-block;
    text-align: center;
    padding: 10px 16px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
    line-height: 1.4;
    border: 1.5px solid transparent;
    width: fit-content;
    min-width: 80%;
}


.bap-btn--view {
    display: inline-block;
    background: transparent;
    border-color: #1a1a1a;
    color: #1a1a1a;
}

.bap-btn--view:hover {
    background: #1a1a1a;
    color: #fff;
}

.bap-btn--cart {
    display: inline-block;
    background: #1a1a1a;
    color: #fff;
    border-color: #1a1a1a;
}

.bap-btn--cart:hover {
    background: #333;
    border-color: #333;
    color: #fff;
}

/* WooCommerce añade .loading al botón durante AJAX */
.bap-btn--cart.loading {
    opacity: 0.7;
    pointer-events: none;
    position: relative;
}

/* =============================================================================
   10. Paginación
   ============================================================================= */

.bap-catalog__pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    margin-top: 48px;
    flex-wrap: wrap;
}

.bap-page-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 38px;
    height: 38px;
    padding: 0 10px;
    border: 1.5px solid #e0e0e0;
    border-radius: 6px;
    background: #fff;
    color: #333;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s, color 0.15s;
    line-height: 1;
}

.bap-page-btn:hover {
    border-color: #1a1a1a;
    color: #1a1a1a;
}

.bap-page-btn--active {
    background: #1a1a1a;
    border-color: #1a1a1a;
    color: #fff;
    pointer-events: none;
}

.bap-page-btn--prev,
.bap-page-btn--next {
    font-size: 16px;
}

.bap-page-ellipsis {
    font-size: 14px;
    color: #999;
    padding: 0 4px;
    line-height: 38px;
}

/* =============================================================================
   11. Estado de carga (AJAX)
   ============================================================================= */

.bap-catalog--loading .bap-catalog__grid {
    opacity: 0.45;
    pointer-events: none;
}

.bap-catalog--loading .bap-catalog__pagination {
    pointer-events: none;
    opacity: 0.45;
}

/* =============================================================================
   12. Botón móvil "Filtros y ordenar"
   ============================================================================= */

.bap-mobile-filter-btn {
    display: none; /* visible solo en móvil via media query */
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 12px 16px;
    margin-bottom: 20px;
    background: #fff;
    border: 1.5px solid #e0e0e0;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    color: #1a1a1a;
    cursor: pointer;
    transition: border-color 0.15s;
}

.bap-mobile-filter-btn:hover {
    border-color: #1a1a1a;
}

.bap-filter-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 20px;
    height: 20px;
    padding: 0 5px;
    border-radius: 10px;
    background: #1a1a1a;
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    line-height: 1;
    margin-left: auto;
}

/* =============================================================================
   13. Drawer móvil
   ============================================================================= */

.bap-drawer-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 9998;
    opacity: 0;
    transition: opacity 0.25s;
}

.bap-drawer-overlay--visible {
    display: block;
    opacity: 1;
}

.bap-drawer {
    position: fixed;
    top: 0;
    right: -100%;
    width: 320px;
    max-width: 90vw;
    height: 100dvh;
    height: 100vh; /* fallback */
    background: #fff;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    box-shadow: -4px 0 24px rgba(0,0,0,0.12);
    transition: right 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    overflow: hidden;
}

.bap-drawer--open {
    right: 0;
}

.bap-drawer__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 20px;
    border-bottom: 1px solid #e8e8e8;
    flex-shrink: 0;
}

.bap-drawer__title {
    font-size: 15px;
    font-weight: 700;
    color: #1a1a1a;
}

.bap-drawer-close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border: none;
    background: transparent;
    cursor: pointer;
    color: #666;
    border-radius: 6px;
    transition: background 0.15s, color 0.15s;
    padding: 0;
}

.bap-drawer-close:hover {
    background: #f5f5f5;
    color: #1a1a1a;
}

.bap-drawer__body {
    flex: 1;
    overflow-y: auto;
    padding: 24px 20px;
    -webkit-overflow-scrolling: touch;
}

.bap-drawer__footer {
    display: flex;
    gap: 12px;
    padding: 16px 20px;
    border-top: 1px solid #e8e8e8;
    flex-shrink: 0;
    background: #fff;
}

.bap-clear-all {
    flex: 1;
    padding: 12px;
    border: 1.5px solid #e0e0e0;
    border-radius: 6px;
    background: #fff;
    color: #333;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: border-color 0.15s;
}

.bap-clear-all:hover {
    border-color: #1a1a1a;
}

.bap-apply {
    flex: 1;
    padding: 12px;
    border: 1.5px solid #1a1a1a;
    border-radius: 6px;
    background: #1a1a1a;
    color: #fff;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s;
}

.bap-apply:hover {
    background: #333;
    border-color: #333;
}

.bap-grid-toggle {
    display: none;
}

/* =============================================================================
   14. Responsive — móvil (≤ 768px)
   ============================================================================= */

@media (max-width: 768px) {

    .bap-catalog {
        padding: 24px 16px;
    }

    .bap-mobile-filter-btn {
        display: flex;
    }

    .bap-catalog__layout {
        grid-template-columns: 1fr;
        gap: 0;
    }

    .bap-catalog__sidebar {
        display: none; /* reemplazado por el drawer en móvil */
    }

    .bap-catalog__grid {
        grid-template-columns: repeat(var(--bap-cols-mobile, 2), 1fr);
        gap: 16px 12px;
    }

    .bap-catalog__grid--1col {
        grid-template-columns: 1fr !important;
    }

    .bap-catalog__grid--2col {
        grid-template-columns: repeat(2, 1fr) !important;
    }

    .bap-catalog__header {
        margin-bottom: 16px;
    }

    .bap-product-card__body {
        padding: 10px 10px 10px;
    }

    .bap-catalog__pagination {
        margin-top: 32px;
        gap: 4px;
    }

    .bap-page-btn {
        min-width: 34px;
        height: 34px;
        font-size: 13px;
    }

    .bap-mobile-toolbar {
        display: flex;
        align-items: center;
        gap: 10px;
        margin-bottom: 20px;
    }

    .bap-mobile-filter-btn {
        flex: 1;
        margin-bottom: 0;
    }

    .bap-grid-toggle {
        display: flex;
        gap: 4px;
        flex-shrink: 0;
    }

    .bap-grid-toggle__btn {
        display: flex;
        align-items: center;
        justify-content: center;
        width: 44px;
        height: 44px;
        border: 1.5px solid #e0e0e0;
        border-radius: 8px;
        background: #fff;
        cursor: pointer;
        color: #999;
        transition: border-color 0.15s, color 0.15s;
        padding: 0;
    }

    .bap-grid-toggle__btn:hover {
        border-color: #1a1a1a;
        color: #1a1a1a;
    }

    .bap-grid-toggle__btn--active {
        border-color: #1a1a1a;
        background: #1a1a1a;
        color: #fff;
    }

    .bap-grid-toggle__btn--active svg {
        fill: #fff;
    }
}

@media (max-width: 400px) {
    .bap-catalog__grid {
        grid-template-columns: 1fr;
    }
}

.bap-btn-pill .bap-btn--view,
.bap-btn-pill .bap-btn--cart {
    border-radius: 999px;
}
