/* ===========================
   BB Shop Page CSS
   =========================== */

/* ===========================
   SHOP PAGE LAYOUT (BV-style - large products)
   =========================== */
.bb-shop {
    padding: 40px 0;
    background: #fff;
    width: 100%;
}

.bb-shop__container {
    width: 100%;
    max-width: 1920px;
    margin: 0 auto;
    padding: 0 clamp(20px, 2.5vw, 10px);
}

/* Override any theme constraints */
.woocommerce-page .bb-shop__container,
.post-type-archive-product .bb-shop__container,
.tax-product_cat .bb-shop__container {
    max-width: 1920px !important;
    width: 100% !important;
}

/* ===========================
   CATEGORY FILTER ICONS
   =========================== */
.bb-category-filter {
    margin-bottom: 40px;
    border-bottom: 1px solid var(--bb-line);
}

.bb-category-filter__scroll {
    display: flex;
    gap: 32px;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding-bottom: 20px;
    cursor: grab;
    user-select: none;
}

.bb-category-filter__scroll::-webkit-scrollbar {
    display: none;
}

.bb-category-filter__scroll.is-grabbing {
    cursor: grabbing;
    scroll-behavior: auto;
}

.bb-category-filter__scroll.is-grabbing .bb-category-filter__item {
    pointer-events: none;
}

.bb-category-filter__item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    text-decoration: none;
    color: var(--bb-fg);
    min-width: 90px;
    transition: opacity var(--bb-transition-base);
}

.bb-category-filter__item:hover {
    opacity: 0.7;
}

.bb-category-filter__icon {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    overflow: hidden;
    border: 1px solid var(--bb-line);
    background: var(--bb-light-gray);
    transition: border-color var(--bb-transition-fast);
}

.bb-category-filter__item:hover .bb-category-filter__icon {
    border-color: var(--bb-fg);
}

.bb-category-filter__icon img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform var(--bb-transition-slow);
}

.bb-category-filter__item:hover .bb-category-filter__icon img {
    transform: scale(1.05);
}

.bb-category-filter__name {
    font-size: 11px;
    letter-spacing: var(--bb-ls-wide);
    text-transform: uppercase;
    text-align: center;
    white-space: nowrap;
    font-weight: 400;
}

/* ===========================
   MODELS FILTER (modello attribute)
   =========================== */
.bb-models-filter {
    margin-bottom: 32px;
    padding-bottom: 24px;
    border-bottom: 1px solid var(--bb-line);
}

.bb-models-filter__scroll {
    display: flex;
    gap: 24px;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding: 4px 0;
    cursor: grab;
    user-select: none;
}

.bb-models-filter__scroll::-webkit-scrollbar {
    display: none;
}

.bb-models-filter__scroll.is-grabbing {
    cursor: grabbing;
    scroll-behavior: auto;
}

.bb-models-filter__scroll.is-grabbing .bb-models-filter__item {
    pointer-events: none;
}

.bb-models-filter__item {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
    text-decoration: none;
    color: var(--bb-fg);
    min-width: 140px;
    max-width: 160px;
    flex-shrink: 0;
}

.bb-models-filter__image {
    width: 140px;
    height: 165px;
    overflow: hidden;
    background: var(--bb-light-gray);
}

.bb-models-filter__image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.bb-models-filter__name {
    font-size: 10px;
    letter-spacing: var(--bb-ls-wide);
    text-transform: uppercase;
    text-align: left;
    font-weight: 400;
    color: var(--bb-fg);
    max-width: 140px;
}

/* Mobile adjustments for models filter */
@media (max-width: 767px) {
    .bb-models-filter {
        margin-bottom: 24px;
        padding-bottom: 16px;
    }

    .bb-models-filter__scroll {
        gap: 12px;
    }

    .bb-models-filter__item {
        min-width: 100px;
        max-width: 120px;
        gap: 8px;
    }

    .bb-models-filter__image {
        width: 100px;
        height: 118px;
    }

    .bb-models-filter__name {
        font-size: 9px;
    }
}

/* ===========================
   TEXT FILTERS
   =========================== */
.bb-text-filters {
    display: flex;
    align-items: center;
    gap: 32px;
    margin-bottom: 40px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}

.bb-text-filters::-webkit-scrollbar {
    display: none;
}

.bb-text-filter {
    font-size: 11px;
    letter-spacing: var(--bb-ls-wide);
    text-transform: uppercase;
    text-decoration: none;
    color: var(--bb-muted);
    white-space: nowrap;
    padding: 10px 0;
    border-bottom: 1px solid transparent;
    transition: all var(--bb-transition-base);
    font-weight: 400;
}

.bb-text-filter:hover,
.bb-text-filter.is-active {
    color: var(--bb-fg);
    border-bottom-color: var(--bb-fg);
}

/* ===========================
   SUBCATEGORY MENU + TOOLBAR ROW
   =========================== */
.bb-shop-toolbar-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--bb-line);
    gap: 24px;
    width: 100%;
}

.bb-subcategory-menu {
    display: flex;
    align-items: center;
    flex: 1;
    min-width: 0;
}

.bb-subcategory-menu__spacer {
    flex: 1;
}

.bb-subcategory-menu__list {
    display: flex;
    align-items: center;
    gap: 24px;
    list-style: none;
    margin: 0;
    padding: 0;
    flex-wrap: wrap;
}

.bb-subcategory-menu__item {
    margin: 0;
    padding: 0;
}

.bb-subcategory-menu__link {
    font-size: .875rem;
    letter-spacing: var(--bb-ls-tight);
    text-transform: capitalize;
    text-decoration: none;
    color: var(--bb-muted);
    padding: 8px 0;
    transition: color var(--bb-transition-base);
    font-weight: 400;
    white-space: nowrap;
}

.bb-subcategory-menu__link:hover {
    color: var(--bb-fg);
}

.bb-subcategory-menu__link.is-active {
    color: var(--bb-fg);
    font-weight: 500;
    text-decoration: underline;
}

/* Mobile adjustments for toolbar row */
@media (max-width: 767px) {
    .bb-shop-toolbar-row {
        flex-direction: column;
        align-items: flex-start;
        gap: 16px;
    }

    .bb-subcategory-menu {
        width: 100%;
    }

    .bb-subcategory-menu__list {
        gap: 16px;
        flex-wrap: wrap;
    }

    .bb-subcategory-menu__link {
        font-size: .75rem;
        padding: 6px 0;
    }
}

/* ===========================
   SHOP TOOLBAR
   =========================== */

/* Hide WooCommerce default ordering and result count from top */
.woocommerce-page .woocommerce-ordering,
.woocommerce-page .woocommerce-result-count,
.woocommerce .woocommerce-ordering,
.woocommerce .woocommerce-result-count,
.bb-shop .woocommerce-ordering,
.bb-shop .woocommerce-result-count {
    display: none !important;
}

.bb-shop-toolbar,
.bb-shop__container .bb-shop-toolbar,
.woocommerce .bb-shop-toolbar {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 16px;
    flex-shrink: 0;
}

.bb-shop-toolbar__results {
    font-size: 10px;
    color: var(--bb-muted);
    letter-spacing: var(--bb-ls-tight);
    text-transform: uppercase;
}

.bb-shop-toolbar__actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.bb-shop-toolbar__filter-btn {
    background: #fff!important;
    border: 1px solid #131313;
    padding: 6px 12px!important;
    font-size: .75rem!important;
    letter-spacing: var(--bb-ls-wide);
    /*text-transform: uppercase;*/
    cursor: pointer;
    transition: all var(--bb-transition-base);
    display: flex;
    align-items: center;
    gap: 6px;
    color: #000!important;
    font-weight: 400;
}

.bb-shop-toolbar__filter-btn:hover {
    background: #000;
    color: #fff;
    border-color: #000;
}

.bb-shop-toolbar__filter-btn svg {
    width: 12px;
    height: 12px;
}

.bb-shop-toolbar__sort {
    font-size: 11px;
    letter-spacing: var(--bb-ls-tight);
    border: 1px solid var(--bb-line);
    padding: 10px 16px;
    background: var(--bb-bg);
    color: var(--bb-fg);
    cursor: pointer;
    transition: all var(--bb-transition-base);
    text-transform: uppercase;
}

.bb-shop-toolbar__sort:hover {
    border-color: var(--bb-fg);
}

/* ===========================
   PRODUCT GRID (BV Style - Force 4 Columns, Large Products)
   =========================== */
.bb-product-grid,
.products.bb-product-grid,
ul.products.bb-product-grid {
    display: grid !important;
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 20px 12px;
    margin-bottom: 48px;
    width: 100%;
    list-style: none;
    padding: 0;
}

@media (min-width: 768px) {
    .bb-product-grid,
    .products.bb-product-grid,
    ul.products.bb-product-grid {
        grid-template-columns: repeat(3, 1fr) !important;
        gap: 24px 14px;
    }
}

@media (min-width: 1024px) {
    .bb-product-grid,
    .products.bb-product-grid,
    ul.products.bb-product-grid {
        grid-template-columns: repeat(4, 1fr) !important;
        gap: 28px 16px;
    }
}

/* Override Shoptimizer float-based layout - Force CSS Grid */
.columns-4 ul.products li.product,
.columns-4 .bb-product-grid li.product,
ul.products.columns-4 li.product,
.bb-product-grid li.product,
.bb-product-grid .bb-product-card {
    float: none !important;
    width: auto !important;
    display: flex !important;
    flex-direction: column !important;
    margin: 0 !important;
}

/* Ensure grid works properly */
.columns-4 .bb-product-grid,
ul.products.columns-4.bb-product-grid {
    display: grid !important;
    grid-template-columns: repeat(4, 1fr) !important;
}

/* Remove all padding from Shoptimizer product items */
ul.products li.product,
.bb-product-grid li.product {
    padding: 0 !important;
}

/* Remove Shoptimizer's hover frame/box-shadow effect */
ul.products li.product:not(.product-category):before,
.bb-product-grid li.product:not(.product-category):before,
ul.products li.product:not(.product-category):after,
.bb-product-grid li.product:not(.product-category):after {
    display: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
    content: none !important;
}

/* Disable any box-shadow on product cards */
.bb-product-card,
.bb-product-card:hover,
ul.products li.product,
ul.products li.product:hover {
    box-shadow: none !important;
}

/* Hide product category from cards (show only name + price) */
ul.products li.product .posted_in,
ul.products li.product .product-category-title,
ul.products li.product .woocommerce-loop-product__category,
.bb-product-card .posted_in,
.bb-product-card .product-category-title,
.bb-product-card__subtitle,
.bb-product-card__flag {
    display: none !important;
}

/* ===========================
   PRODUCT CARD
   =========================== */
.bb-product-card {
    position: relative;
    display: flex;
    flex-direction: column;
}

.bb-product-card__image-wrapper {
    position: relative;
    aspect-ratio: 3 / 4;
    overflow: hidden;
    background: var(--bb-light-gray);
    margin-bottom: 12px;
}

.bb-product-card__image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* Product card icons */
.bb-product-card__icons {
    position: absolute;
    top: 12px;
    right: 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    z-index: var(--bb-z-base);
}

.bb-product-card__icon {
    width: 32px;
    height: 32px;
    background: var(--bb-bg);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all var(--bb-transition-fast);
    border: none;
    padding: 0;
    color: var(--bb-fg);
}

.bb-product-card__icon:hover {
    background: var(--bb-fg);
    color: var(--bb-bg);
}

.bb-product-card__icon svg {
    width: 16px;
    height: 16px;
}

/* Members Exclusive Badge */
.bb-product-card__badge {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity var(--bb-transition-base);
}

.bb-product-card.has-badge .bb-product-card__badge {
    opacity: 1;
}

.bb-product-card__badge-text {
    color: #fff;
    font-size: var(--bb-small);
    letter-spacing: var(--bb-ls-wide);
    text-transform: uppercase;
    font-weight: 500;
}

/* Product Info */
.bb-product-card__info {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.bb-product-card__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.bb-product-card__title {
    font-size: 13px;
    letter-spacing: var(--bb-ls-tight);
    /*text-transform: uppercase;*/
    text-decoration: none;
    color: var(--bb-fg);
    transition: opacity var(--bb-transition-base);
    flex: 1;
    margin: 0;
    font-weight: 500;
    line-height: var(--bb-lh-tight);
}

.bb-product-card__title:hover {
    opacity: 0.7;
}

.bb-product-card__flag {
    width: 20px;
    height: 14px;
    flex-shrink: 0;
}

.bb-product-card__subtitle {
    font-size: 11px;
    color: var(--bb-muted);
    text-transform: capitalize;
    letter-spacing: var(--bb-ls-tight);
    line-height: var(--bb-lh-normal);
}

.bb-product-card__price {
    font-size: 13px;
    color: var(--bb-fg);
    font-weight: 300;
    letter-spacing: var(--bb-ls-tight);
    margin-top: -10px;
}

/* Modello Swatches - inline with title */
.bb-product-card__swatches {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
    margin-left: auto;
}

.bb-product-card__swatch {
    display: block;
    width: 16px;
    height: 16px;
    border: 1px solid var(--bb-line);
    overflow: hidden;
    transition: border-color var(--bb-transition-fast);
    background: var(--bb-bg);
}

.bb-product-card__swatch:hover {
    border-color: var(--bb-fg);
}

.bb-product-card__swatch img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.bb-product-card__swatch-count {
    font-size: 9px;
    color: var(--bb-fg);
    letter-spacing: var(--bb-ls-tight);
    font-weight: 500;
}

/* Mobile adjustments for swatches */
@media (max-width: 767px) {
    .bb-product-card__swatch {
        width: 14px;
        height: 14px;
    }

    .bb-product-card__swatch-count {
        font-size: 8px;
    }
}

/* ===========================
   PAGINATION
   =========================== */
.bb-pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 48px 0;
}

.bb-pagination__item {
    min-width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--bb-line);
    background: var(--bb-bg);
    color: var(--bb-fg);
    text-decoration: none;
    font-size: 11px;
    letter-spacing: var(--bb-ls-tight);
    transition: all var(--bb-transition-base);
    font-weight: 400;
}

.bb-pagination__item:hover,
.bb-pagination__item.is-current {
    background: var(--bb-fg);
    color: var(--bb-bg);
    border-color: var(--bb-fg);
}

.bb-pagination__item.is-disabled {
    opacity: 0.4;
    cursor: not-allowed;
    pointer-events: none;
}

/* ===========================
   MOBILE RESPONSIVE
   =========================== */
@media (max-width: 767px) {
    .bb-shop {
        padding: 24px 0;
    }

    .bb-product-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 20px 12px;
    }

    .bb-category-filter {
        margin-bottom: 32px;
    }

    .bb-category-filter__scroll {
        gap: 24px;
        padding-bottom: 16px;
    }

    .bb-category-filter__icon {
        width: 60px;
        height: 60px;
    }

    .bb-category-filter__item {
        min-width: 70px;
        gap: 8px;
    }

    .bb-category-filter__name {
        font-size: 10px;
    }

    .bb-text-filters {
        gap: 24px;
        margin-bottom: 32px;
    }

    .bb-text-filter {
        font-size: 10px;
        padding: 8px 0;
    }

    .bb-shop-toolbar {
        width: 100%;
        justify-content: flex-end;
    }

    .bb-shop-toolbar__results {
        font-size: 10px;
    }

    .bb-shop-toolbar__filter-btn,
    .bb-shop-toolbar__sort {
        font-size: 10px;
        padding: 8px 14px;
    }

    .bb-product-card__image-wrapper {
        margin-bottom: 10px;
    }

    .bb-product-card__info {
        gap: 4px;
    }

    .bb-product-card__title {
        font-size: 12px;
    }

    .bb-product-card__subtitle {
        font-size: 10px;
    }

    .bb-product-card__price {
        font-size: 12px;
    }

    .bb-product-card__icons {
        top: 8px;
        right: 8px;
    }

    .bb-product-card__icon {
        width: 28px;
        height: 28px;
    }

    .bb-product-card__icon svg {
        width: 14px;
        height: 14px;
    }

    .bb-pagination {
        padding: 32px 0;
        gap: 8px;
    }

    .bb-pagination__item {
        min-width: 36px;
        height: 36px;
        font-size: 10px;
    }
}

/* ===========================
   IMAGE HOVER EFFECT (BV style - swap images only)
   =========================== */

/* Primary image - first img tag with bb-product-card__image class */
.bb-product-card__image-wrapper .bb-product-card__image {
    position: relative;
    z-index: 2;
    transition: opacity var(--bb-transition-base);
}

/* Hide primary image on hover */
.bb-product-card:hover .bb-product-card__image-wrapper .bb-product-card__image {
    opacity: 0;
}

/* Secondary image - second img (from gallery) */
.bb-product-card__image-wrapper .attachment-woocommerce_thumbnail:nth-child(2) {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    opacity: 0;
    z-index: 1;
    transition: opacity var(--bb-transition-base);
}

/* Show secondary image on hover */
.bb-product-card:hover .bb-product-card__image-wrapper .attachment-woocommerce_thumbnail:nth-child(2) {
    opacity: 1;
}

/* Ensure product info is always visible and not affected by hover */
.bb-product-card__info {
    position: relative;
    z-index: 10;
    pointer-events: auto;
}

.bb-product-card:hover .bb-product-card__info {
    opacity: 1;
}

/* Override Shoptimizer's gallery image hover behavior */
li.product:hover .woocommerce-image__wrapper .gallery-image,
li.product:hover .woocommerce-image__wrapper .gallery-image img,
.bb-product-card:hover .woocommerce-image__wrapper .gallery-image,
.bb-product-card:hover .woocommerce-image__wrapper .gallery-image img {
    z-index: auto !important;
    opacity: 1 !important;
}

li.product:not(.product-category):hover .woocommerce-image__wrapper:has(.gallery-image) img:not(.gallery-image),
.bb-product-card:not(.product-category):hover .woocommerce-image__wrapper:has(.gallery-image) img:not(.gallery-image) {
    opacity: 1 !important;
}

/* ===========================
   OVERRIDE THEME CONSTRAINTS (Selective overrides)
   =========================== */

/* Override Shoptimizer content wrappers only on shop pages */
.woocommerce-page.archive .col-full,
.post-type-archive-product .col-full,
.tax-product_cat .col-full {
    max-width: none;
    padding: 0;
}

/* Ensure shop content is not constrained */
.woocommerce.archive #content,
.post-type-archive-product #content,
.tax-product_cat #content {
    max-width: none;
}

.woocommerce.archive .site-main,
.post-type-archive-product .site-main,
.tax-product_cat .site-main {
    max-width: none;
    padding: 0;
}


/* ===========================
   INFINITE SCROLL LOADER
   =========================== */
.bb-infinite-loader {
    text-align: center;
    padding: 48px 0;
    width: 100%;
}

.bb-loader-spinner {
    display: inline-block;
    width: 40px;
    height: 40px;
    border: 3px solid var(--bb-line);
    border-top-color: var(--bb-fg);
    border-radius: 50%;
    animation: bb-spin 0.8s linear infinite;
    margin: 0 auto 16px;
}

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

.bb-loader-text {
    font-size: var(--bb-small);
    letter-spacing: var(--bb-ls-tight);
    text-transform: uppercase;
    color: var(--bb-muted);
    margin: 0;
}

.bb-no-more-products {
    font-size: var(--bb-small);
    letter-spacing: var(--bb-ls-tight);
    text-transform: uppercase;
    color: var(--bb-muted);
    margin: 0;
    padding: 24px 0;
}

/* Hide pagination when infinite scroll is active */
body.infinite-scroll-enabled .woocommerce-pagination,
body.infinite-scroll-enabled .bb-pagination {
    display: none;
}
