/* ═══════════════════════════════════════════════════════════════
   SHOP PAGE  —  shop.css
   Sidebar layout, product cards, filter chips, responsive
   Usa variables de css/variables.css
═══════════════════════════════════════════════════════════════ */

/* ── BREADCRUMB BAR ─────────────────────────────────────────── */
.shop-breadcrumb-bar {
    background: var(--bg-muted, #f8f9fa);
    border-bottom: 1px solid var(--border-light, #e4e8ed);
    padding: 8px 0;
}
.shop-breadcrumb-bar .breadcrumb {
    background: none;
    padding: 0;
    margin: 0;
    font-size: 13px;
}
.shop-breadcrumb-bar .breadcrumb-item a {
    color: #c0282d;
    text-decoration: none;
}
.shop-breadcrumb-bar .breadcrumb-item.active { color: #888; }
.shop-breadcrumb-bar .breadcrumb-item + .breadcrumb-item::before {
    content: "›";
    color: #bbb;
}

/* ── MAIN SECTION ───────────────────────────────────────────── */
.shop-main-section {
    padding: 26px 0 70px;
    background: var(--bg-page, #f9fafb);
    min-height: 80vh;
}

/* ── MOBILE FILTER BUTTON ───────────────────────────────────── */
.mobile-filter-btn {
    display: none;
    background: #c0282d;
    color: #fff;
    border: none;
    border-radius: 9px;
    padding: 9px 17px;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    margin-bottom: 14px;
    align-items: center;
    gap: 8px;
    letter-spacing: 0.2px;
}
.mobile-filter-btn:active { opacity: 0.85; }

/* ── LAYOUT ─────────────────────────────────────────────────── */
.shop-layout {
    display: grid;
    grid-template-columns: 280px 1fr;
    gap: 24px;
    align-items: start;
}

/* ── SIDEBAR ─────────────────────────────────────────────────── */
.shop-sidebar {
    background: var(--bg-card, #fff);
    border-radius: var(--radius-xl, 14px);
    padding: 20px 17px;
    box-shadow: var(--shadow-card, 0 2px 16px rgba(0,0,0,0.08));
    position: sticky;
    top: 84px;
}

.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-bottom: 14px;
    margin-bottom: 18px;
    border-bottom: 2px solid #f0f2f5;
}
.sidebar-header h3 {
    font-size: 14px;
    font-weight: 700;
    margin: 0;
    color: #1a1a2e;
    display: flex;
    align-items: center;
    gap: 7px;
    white-space: nowrap;
}
.sidebar-header h3 i { color: #c0282d; font-size: 13px; }

.btn-clear-all {
    background: none;
    border: none;
    color: #c0282d;
    font-size: 11px;
    font-weight: 700;
    cursor: pointer;
    padding: 0;
    text-transform: uppercase;
    letter-spacing: 0.4px;
}
.btn-clear-all:hover { text-decoration: underline; }

/* Filter groups */
.filter-group { margin-bottom: 18px; }

.filter-title {
    font-size: 10px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.9px;
    color: #9aa5b4;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 6px;
}
.filter-title i { color: #c0282d; }

.filter-select {
    width: 100%;
    padding: 9px 30px 9px 11px;
    border: 1.5px solid #dde3ea;
    border-radius: 8px;
    font-size: 13px;
    color: #333;
    background: #fafbfc url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%23aaa'/%3E%3C/svg%3E") no-repeat right 11px center;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    cursor: pointer;
    line-height: 1.4;
    transition: border-color 0.18s, box-shadow 0.18s;
    /* Forzar texto en una sola línea */
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.filter-select:focus {
    outline: none;
    border-color: #c0282d;
    box-shadow: 0 0 0 3px rgba(192,40,45,0.12);
}

.btn-apply-filters {
    width: 100%;
    background: linear-gradient(135deg, #c0282d 0%, #c0282d 100%);
    color: #fff;
    border: none;
    padding: 11px 14px;
    border-radius: 9px;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    transition: opacity 0.18s, transform 0.15s;
    margin-top: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    letter-spacing: 0.3px;
}
.btn-apply-filters:hover { opacity: 0.9; transform: translateY(-1px); }
.btn-apply-filters:active { transform: translateY(0); opacity: 1; }

/* ── PRICE INPUTS ───────────────────────────────────────────── */
.price-inputs-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
}
.price-input {
    flex: 1;
    min-width: 80px;
    padding: 8px 10px;
    border: 1.5px solid #dde3ea;
    border-radius: 8px;
    font-size: 13px;
    font-variant-numeric: tabular-nums;
    color: #333;
    background: #fafbfc;
    transition: border-color 0.18s, box-shadow 0.18s;
    text-align: right;
}
.price-input:focus {
    outline: none;
    border-color: #c0282d;
    box-shadow: 0 0 0 3px rgba(192,40,45,0.12);
}
.price-sep {
    color: #bbb;
    font-size: 14px;
    flex-shrink: 0;
}

/* Category loading spinner inside filter title */
.cat-loading-icon {
    color: #c0282d;
    font-size: 12px;
    margin-left: 4px;
}

/* ── SEARCH INPUT ────────────────────────────────────────────── */
.search-input-wrap {
    display: flex; align-items: center;
    border: 1.5px solid #dde3ea; border-radius: 8px; overflow: hidden;
    background: #fafbfc;
    transition: border-color 0.18s, box-shadow 0.18s;
}
.search-input-wrap:focus-within {
    border-color: #c0282d;
    box-shadow: 0 0 0 3px rgba(192,40,45,0.12);
}
.filter-input-text {
    flex: 1; border: none; outline: none;
    padding: 9px 11px; font-size: 13px; color: #333;
    background: transparent; min-width: 0;
}
.btn-search-go {
    background: #c0282d; color: #fff; border: none;
    width: 36px; height: 36px; flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer; font-size: 13px;
    transition: background 0.15s;
}
.btn-search-go:hover { background: #9e2025; }

/* Filter count badge (shows number of available options) */
.filter-count-badge {
    background: #fbe9e9; color: #9e2025;
    border-radius: 10px; padding: 1px 6px;
    font-size: 10px; font-weight: 700;
    margin-left: auto;
}

/* Close button — mobile only */
.btn-close-sidebar { display: none; }

/* ── ACTIVE FILTER CHIPS ─────────────────────────────────────── */
.active-filters-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 16px;
    min-height: 0;
    /* Mobile: horizontal scroll */
    max-width: 100%;
}
@media (max-width: 767px) {
    .active-filters-bar {
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        padding-bottom: 4px;
        scroll-snap-type: x mandatory;
    }
    .active-filter-chip {
        flex-shrink: 0;
        scroll-snap-align: start;
    }
}
.active-filter-chip {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    background: #fbe9e9;
    color: #8e1d21;
    border: 1px solid #f0c4c4;
    border-radius: 20px;
    padding: 6px 12px 6px 14px;
    font-size: 12px;
    font-weight: 700;
    line-height: 1.2;
    white-space: nowrap;
}
.active-filter-chip span {
    white-space: nowrap;
}
.active-filter-chip .remove-filter {
    background: none;
    border: none;
    color: #8e1d21;
    cursor: pointer;
    padding: 0;
    font-size: 16px;
    line-height: 1;
    display: flex;
    align-items: center;
    margin-left: 1px;
    opacity: 0.65;
}
.active-filter-chip .remove-filter:hover { opacity: 1; }

/* ── PRODUCT CARDS ───────────────────────────────────────────── */
.product-card-shop {
    background: var(--bg-card, #fff);
    border-radius: var(--radius-lg, 10px);
    overflow: hidden;
    box-shadow: var(--shadow-card, 0 1px 4px rgba(0,0,0,0.07));
    transition: box-shadow var(--transition-base, 0.22s ease), transform var(--transition-base, 0.22s ease);
    display: flex;
    flex-direction: column;
    height: 100%;
}
.product-card-shop:hover {
    box-shadow: var(--shadow-card-hover, 0 8px 28px rgba(0,0,0,0.14));
    transform: translateY(-2px);
}

/* Image area */
.product-card-shop .card-img-wrap {
    position: relative;
    overflow: hidden;
    background: #f5f7fa;
    aspect-ratio: 1 / 1;
    display: flex;
    align-items: center;
    justify-content: center;
}
.product-card-shop .card-img-wrap img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    padding: 10px;
    transition: transform 0.3s ease;
}
.product-card-shop:hover .card-img-wrap img { transform: scale(1.06); }

/* Hover overlay - fondo sólido minimalista */
.product-card-shop .card-overlay {
    position: absolute;
    bottom: 0; left: 0; right: 0;
    background: rgba(17, 24, 39, 0.92);
    padding: 11px 12px;
    transform: translateY(100%);
    transition: transform var(--transition-base, 0.22s ease);
    text-align: center;
}
.product-card-shop:hover .card-overlay,
.product-card-shop:focus-within .card-overlay { transform: translateY(0); }

/* Touch devices: show overlay on tap/focus */
@media (hover: none) {
    .product-card-shop .card-overlay {
        transform: translateY(0);
        opacity: 0;
        transition: opacity 0.22s ease;
    }
    .product-card-shop:active .card-overlay,
    .product-card-shop:focus-within .card-overlay {
        opacity: 1;
    }
    /* Always visible on touch after first interaction */
    .product-card-shop .card-img-wrap:focus-within .card-overlay {
        opacity: 1;
    }
}
.product-card-shop .card-overlay a {
    color: #fff;
    font-size: 12px;
    font-weight: 700;
    text-decoration: none;
    letter-spacing: 0.4px;
    text-transform: uppercase;
}

/* Split overlay: "Ver producto" + "Añadir cotización" */
.product-card-shop .card-overlay.card-overlay--split {
    display: flex;
    align-items: stretch;
    gap: 8px;
    padding: 9px 10px;
}
.product-card-shop .card-overlay .ov-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    cursor: pointer;
    border-radius: 7px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.4px;
    text-transform: uppercase;
    transition: background 0.16s, transform 0.12s;
}
.product-card-shop .card-overlay .ov-view {
    flex: 1;
    background: rgba(255,255,255,0.16);
    color: #fff;
    padding: 9px 8px;
}
.product-card-shop .card-overlay .ov-view:hover { background: rgba(255,255,255,0.3); }
.product-card-shop .card-overlay .ov-quote {
    flex-shrink: 0;
    width: 40px;
    background: #fff;
    color: #c0282d;
    font-size: 15px;
}
.product-card-shop .card-overlay .ov-quote:hover { background: #fbe9e9; transform: scale(1.05); }
.product-card-shop .card-overlay .ov-quote.added { background: #1a9e4e; color: #fff; }

/* Card body - usando grid para altura consistente */
.product-card-shop .card-body {
    padding: 11px 13px 14px;
    display: grid;
    grid-template-rows: auto auto 1fr auto auto;
    gap: 4px;
    flex: 1;
}

.product-card-shop .card-brand-cat {
    font-size: 10px;
    color: #aab;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.product-card-shop .card-title {
    font-size: 13px;
    color: #1a1a2e;
    font-weight: 600;
    line-height: 1.45;
    margin: 0;
    flex: 1;
}
.product-card-shop .card-title a {
    color: inherit;
    text-decoration: none;
}
.product-card-shop .card-title a:hover { color: #c0282d; }

/* Product key specs (secondary text below main title) */
.product-card-shop .card-specs {
    font-size: 11px;
    color: #aaa;
    line-height: 1.35;
    margin-top: 1px;
    /* Line clamp para consistencia */
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    min-height: calc(2 * 1.35em); /* Reservar espacio para 2 líneas */
}

.product-card-shop .card-stock {
    font-size: 11px;
    color: #aaa;
    display: flex;
    align-items: center;
    gap: 5px;
    margin-top: 2px;
}

.product-card-shop .card-price {
    font-size: 15px;
    font-weight: 800;
    color: #c0282d;
    margin-top: 4px;
    letter-spacing: -0.3px;
}

/* ── LOADING / EMPTY ─────────────────────────────────────────── */
.products-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 70px 20px;
    color: #bbb;
    gap: 14px;
    width: 100%;
}
.products-loading .spinner {
    width: 38px; height: 38px;
    border: 3px solid #e8ecf0;
    border-top-color: #c0282d;
    border-radius: 50%;
    animation: shopSpin 0.75s linear infinite;
}
@keyframes shopSpin { to { transform: rotate(360deg); } }

.no-products-msg {
    text-align: center;
    padding: 60px 20px;
    color: #999;
}
.no-products-msg i {
    font-size: 52px;
    color: #d8e0e8;
    display: block;
    margin-bottom: 16px;
}
.no-products-msg p { margin: 4px 0; }
.no-products-msg small { color: #bbb; }

/* ── PAGINATION ──────────────────────────────────────────────── */
.post-pagination {
    margin-top: 38px;
    display: flex;
    justify-content: center;
}
.post-pagination ul.page-numbers {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    list-style: none;
    padding: 12px 20px;
    margin: 0;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 1px 6px rgba(0,0,0,0.07);
}
.post-pagination ul.page-numbers li { display: flex; }

/* Number buttons */
.post-pagination a.page-numbers {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 40px;
    height: 40px;
    padding: 0 12px;
    border-radius: 9px;
    font-size: 14px;
    font-weight: 600;
    text-decoration: none;
    background: #f4f6f8;
    color: #555;
    border: 1.5px solid transparent;
    transition: border-color 0.18s, color 0.18s, background 0.18s;
    cursor: pointer;
}
.post-pagination a.page-numbers:hover {
    border-color: #c0282d;
    color: #c0282d;
    background: #fdf2f2;
}

/* Active / current page */
.post-pagination span.page-numbers.current {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 40px;
    height: 40px;
    padding: 0 12px;
    border-radius: 9px;
    font-size: 14px;
    font-weight: 700;
    background: #c0282d;
    color: #fff;
    border: 1.5px solid #c0282d;
}

/* Ellipsis dots */
.post-pagination span.page-numbers.dots {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 28px;
    height: 40px;
    color: #bbb;
    font-size: 14px;
    border: none;
    background: none;
    cursor: default;
    padding: 0 4px;
}

/* Prev / Next arrows */
.post-pagination a.prev.page-numbers,
.post-pagination a.next.page-numbers {
    background: #f4f6f8;
    color: #444;
    border: 1.5px solid transparent;
    font-size: 13px;
}
.post-pagination a.prev.page-numbers:hover,
.post-pagination a.next.page-numbers:hover {
    border-color: #c0282d;
    color: #c0282d;
    background: #fdf2f2;
}

/* ── SIDEBAR OVERLAY (mobile) ────────────────────────────────── */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0; left: 0;
    width: 100vw; height: 100vh;
    background: rgba(0,0,0,0.48);
    z-index: 1040;
    -webkit-backdrop-filter: blur(2px);
    backdrop-filter: blur(2px);
}
.sidebar-overlay.show { display: block; }

/* ── PRODUCT GRID (CSS Grid — 5 columns desktop) ─────────────── */
.products-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 16px;
}

.product-grid-item {
    min-width: 0; /* prevent grid blowout */
    display: flex;
    flex-direction: column;
}

/* ── WIDE SCREENS (>1400px) — contenedor más amplio ──────────── */
@media (min-width: 1400px) {
    .shop-breadcrumb-bar .container,
    .shop-main-section .container {
        max-width: 1560px;
    }
    /* Sidebar un poco más ancho para textos largos */
    .shop-layout { grid-template-columns: 300px 1fr; }
}

@media (min-width: 1600px) {
    .shop-breadcrumb-bar .container,
    .shop-main-section .container {
        max-width: 1760px;
    }
    .shop-layout { grid-template-columns: 320px 1fr; gap: 28px; }
    /* Aprovechar el ancho extra con una columna más de productos */
    .products-grid { grid-template-columns: repeat(6, 1fr); }
}

/* ── RESPONSIVE ─────────────────────────────────────────────── */
@media (max-width: 1199px) {
    /* On LG screens → 4 columns */
    .products-grid { grid-template-columns: repeat(4, 1fr); }
}

@media (max-width: 991px) {
    /* Sidebar goes mobile → full width, 3 columns */
    .shop-layout { grid-template-columns: 1fr; }
    .products-grid { grid-template-columns: repeat(3, 1fr); }

    .shop-sidebar {
        position: fixed;
        top: 0; left: -295px;
        width: 280px;
        height: 100vh;
        height: 100dvh; /* Dynamic viewport height for mobile browsers */
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        border-radius: 0;
        z-index: 1050;
        padding-top: 62px;
        padding-bottom: calc(80px + env(safe-area-inset-bottom, 0px));
        transition: left 0.28s ease;
        box-shadow: 4px 0 24px rgba(0,0,0,0.16);
        display: flex;
        flex-direction: column;
    }
    .shop-sidebar.open { left: 0; }

    /* Sticky apply button at bottom on mobile */
    .shop-sidebar .btn-apply-filters {
        position: sticky;
        bottom: 0;
        margin-top: auto;
        z-index: 10;
        box-shadow: 0 -4px 12px rgba(0,0,0,0.1);
    }

    .btn-close-sidebar {
        display: flex;
        position: absolute;
        top: 12px; right: 12px;
        background: #f4f6f8;
        border: 1px solid #dde3ea;
        border-radius: 7px;
        padding: 6px 12px;
        cursor: pointer;
        color: #555;
        align-items: center;
        gap: 6px;
        font-size: 13px;
        font-weight: 500;
    }

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

    /* Pagination responsive */
    .post-pagination ul.page-numbers {
        max-width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        justify-content: flex-start;
        padding: 10px 14px;
        gap: 6px;
    }
    .post-pagination a.page-numbers,
    .post-pagination span.page-numbers.current {
        min-width: 36px;
        height: 36px;
        padding: 0 10px;
        font-size: 13px;
    }
}

@media (max-width: 767px) {
    .products-grid { grid-template-columns: repeat(2, 1fr); gap: 12px; }
}

@media (max-width: 575px) {
    .shop-main-section { padding: 14px 0 40px; }
    .product-card-shop .card-title { font-size: 12px; }
    .product-card-shop .card-price { font-size: 13px; }
    .product-card-shop .card-body { padding: 9px 10px 11px; gap: 3px; }
    .product-card-shop .card-overlay a { font-size: 11px; }
}
