/* =============================================================
   CPB Product Gallery  –  rewritten
   Replaces all previous .cpb-gallery-* / .cpb-product-main-image
   / .cpb-product-thumbnails / .cpb-lightbox-* blocks in style.css
   ============================================================= */

/* ── Shared wrapper ── */
.cpb-product-gallery {
    width: 100%;
    min-width: 0; /* prevents grid blowout */
}

/* ── Main image container (classic / left-thumb) ── */
.cpb-product-main-image {
    position: relative;
    width: 100%;
    background: var(--cpb-bg-alt, #f7f7f7);
    border-radius: var(--cpb-radius, 8px);
    overflow: hidden;
    line-height: 0;
}

.cpb-product-main-image img,
.cpb-main-product-img {
    width: 100%;
    height: auto;
    max-height: 520px;
    object-fit: contain;
    border-radius: var(--cpb-radius, 8px);
    display: block;
    transition: opacity 0.15s ease;
}

/* Fade transition when switching main image */
.cpb-main-product-img.cpb-main-img--fading {
    opacity: 0;
}

/* ── Thumbnails (classic – bottom row) ── */
.cpb-product-thumbnails {
    display: flex;
    gap: 8px;
    margin-top: 10px;
    flex-wrap: wrap;
    padding: 4px 0;
}

.cpb-gallery-thumb {
    width: 72px;
    height: 72px;
    object-fit: cover;
    border-radius: 6px;
    cursor: pointer;
    border: 2px solid transparent;
    flex-shrink: 0;
    transition: border-color 0.2s ease, opacity 0.2s ease;
    background: var(--cpb-bg-alt, #f7f7f7);
    display: block;
}

.cpb-gallery-thumb:hover {
    border-color: var(--cpb-primary, #253993);
    opacity: 0.85;
}

.cpb-gallery-thumb--active {
    border-color: var(--cpb-primary, #253993);
}

/* ── Left-thumbnail layout ── */
.cpb-gallery-left-layout {
    display: grid;
    grid-template-columns: 84px 1fr;
    gap: 10px;
    align-items: start;
}

.cpb-gallery-vertical-thumbs {
    display: flex;
    flex-direction: column;
    gap: 8px;
    overflow-y: auto;
    max-height: 520px;
    scrollbar-width: thin;
    scrollbar-color: var(--cpb-primary, #253993) transparent;
}

.cpb-gallery-vertical-thumbs::-webkit-scrollbar { width: 4px; }
.cpb-gallery-vertical-thumbs::-webkit-scrollbar-thumb {
    background: var(--cpb-primary, #253993);
    border-radius: 2px;
}

.cpb-gallery-vertical-thumbs .cpb-gallery-thumb {
    width: 100%;
    height: 72px;
}

/* ── Grid layout ── */
.cpb-gallery-grid-wrap {
    width: 100%;
}

.cpb-gallery-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
}

.cpb-gallery-grid-item {
    overflow: hidden;
    border-radius: var(--cpb-radius, 8px);
    cursor: zoom-in;
    background: var(--cpb-bg-alt, #f7f7f7);
    line-height: 0;
}

.cpb-gallery-grid-item--main {
    grid-column: 1 / -1;
}

.cpb-gallery-grid-img {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: cover;
    transition: transform 0.35s ease;
    aspect-ratio: 4 / 3;
}

.cpb-gallery-grid-item--main .cpb-gallery-grid-img {
    aspect-ratio: 16 / 9;
}

.cpb-gallery-grid-item:hover .cpb-gallery-grid-img {
    transform: scale(1.04);
}

/* ── Slider layout ── */
.cpb-gallery-slider {
    position: relative;
    border-radius: var(--cpb-radius, 8px);
    background: var(--cpb-bg-alt, #f7f7f7);
    overflow: hidden;
    user-select: none;
}

.cpb-gallery-slider-track {
    position: relative;
    width: 100%;
    overflow: hidden;
    line-height: 0;
}

/* Each slide */
.cpb-gallery-slide {
    display: none;
    position: absolute;
    inset: 0;
    transition: transform 0.35s ease, opacity 0.35s ease;
    opacity: 0;
    pointer-events: none;
}

.cpb-gallery-slide--visible {
    display: block;
}

.cpb-gallery-slide--active {
    display: block;
    position: relative;
    opacity: 1;
    pointer-events: auto;
}

/* Slide-in / slide-out animation classes */
.cpb-slide-enter--right {
    transform: translateX(100%);
    opacity: 0;
}

.cpb-slide-enter--left {
    transform: translateX(-100%);
    opacity: 0;
}

.cpb-gallery-slide--active:not(.cpb-slide-enter--right):not(.cpb-slide-enter--left) {
    transform: translateX(0);
    opacity: 1;
}

.cpb-slide-leave--left {
    position: absolute;
    inset: 0;
    transform: translateX(-100%);
    opacity: 0;
    display: block;
    transition: transform 0.35s ease, opacity 0.35s ease;
    pointer-events: none;
}

.cpb-slide-leave--right {
    position: absolute;
    inset: 0;
    transform: translateX(100%);
    opacity: 0;
    display: block;
    transition: transform 0.35s ease, opacity 0.35s ease;
    pointer-events: none;
}

.cpb-gallery-slide img {
    width: 100%;
    height: auto;
    max-height: 520px;
    object-fit: contain;
    display: block;
}

/* Arrow buttons */
.cpb-gallery-arrow {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    z-index: 10;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.92);
    border: none;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.18);
    font-size: 1.1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--cpb-text, #1a1a2e);
    transition: background 0.2s ease, color 0.2s ease, transform 0.2s ease;
    line-height: 1;
}

.cpb-gallery-arrow:hover {
    background: var(--cpb-primary, #253993);
    color: #fff;
    transform: translateY(-50%) scale(1.08);
}

.cpb-gallery-arrow--prev { left: 12px; }
.cpb-gallery-arrow--next { right: 12px; }

/* Dots */
.cpb-gallery-dots {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    padding: 12px 0 8px;
}

.cpb-gallery-dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: #ccc;
    cursor: pointer;
    transition: background 0.2s ease, transform 0.2s ease;
    border: none;
    padding: 0;
}

.cpb-gallery-dot--active,
.cpb-gallery-dot:hover {
    background: var(--cpb-primary, #253993);
    transform: scale(1.25);
}

/* ── Lightbox ── */
.cpb-lightbox-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.92);
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    cursor: pointer;
    animation: cpbLightboxIn 0.25s ease forwards;
}

.cpb-lightbox-overlay--closing {
    animation: cpbLightboxOut 0.25s ease forwards;
}

@keyframes cpbLightboxIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}

@keyframes cpbLightboxOut {
    from { opacity: 1; }
    to   { opacity: 0; }
}

.cpb-lightbox-inner {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    max-width: 100%;
    max-height: 100%;
}

.cpb-lightbox-img {
    max-width: min(90vw, 1200px);
    max-height: 88vh;
    object-fit: contain;
    border-radius: var(--cpb-radius, 8px);
    cursor: default;
    display: block;
    transition: opacity 0.2s ease;
}

.cpb-lightbox-img--loading {
    opacity: 0.2;
}

.cpb-lightbox-close {
    position: fixed;
    top: 16px;
    right: 20px;
    font-size: 2.2rem;
    line-height: 1;
    color: #fff;
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px 8px;
    transition: color 0.2s ease, transform 0.2s ease;
    z-index: 100000;
}

.cpb-lightbox-close:hover {
    color: #f0f0f0;
    transform: scale(1.15);
}

.cpb-lightbox-arrow {
    position: fixed;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(255, 255, 255, 0.15);
    border: none;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    font-size: 1.3rem;
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s ease;
    z-index: 100000;
}

.cpb-lightbox-arrow:hover { background: rgba(255, 255, 255, 0.3); }
.cpb-lightbox-arrow--prev { left: 16px; }
.cpb-lightbox-arrow--next { right: 16px; }

/* ── Zoom hint badge on classic / left-thumb main image ── */
.cpb-product-main-image { cursor: zoom-in; }
.cpb-product-main-image::after {
    content: "⤢";
    position: absolute;
    top: 10px; right: 10px;
    width: 32px; height: 32px;
    border-radius: 50%;
    background: rgba(0,0,0,0.55);
    color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-size: 16px; line-height: 1;
    opacity: 0; transition: opacity 0.2s ease;
    pointer-events: none;
}
.cpb-product-main-image:hover::after { opacity: 1; }

/* ── Right-thumb variant: flip the left-thumb layout ── */
.cpb-gallery-right .cpb-gallery-left-layout {
    grid-template-columns: 1fr 84px;
}
.cpb-gallery-right .cpb-gallery-vertical-thumbs { order: 2; }
.cpb-gallery-right .cpb-product-main-image       { order: 1; }

/* ── Slider thumbnail strip (under main slider) ── */
.cpb-gallery-slider-thumbs {
    display: flex;
    gap: 6px;
    padding: 10px 8px 6px;
    overflow-x: auto;
    background: var(--cpb-bg-alt, #f7f7f7);
    scrollbar-width: thin;
    scrollbar-color: var(--cpb-primary, #253993) transparent;
}
.cpb-gallery-slider-thumbs::-webkit-scrollbar { height: 4px; }
.cpb-gallery-slider-thumbs::-webkit-scrollbar-thumb {
    background: var(--cpb-primary, #253993); border-radius: 2px;
}
.cpb-gallery-slider-thumb {
    flex: 0 0 auto;
    width: 64px; height: 64px;
    padding: 0;
    border: 2px solid transparent;
    border-radius: 6px;
    background: #fff;
    overflow: hidden;
    cursor: pointer;
    transition: border-color 0.2s ease, transform 0.15s ease;
}
.cpb-gallery-slider-thumb img {
    width: 100%; height: 100%; object-fit: cover; display: block;
}
.cpb-gallery-slider-thumb:hover { transform: translateY(-2px); }
.cpb-gallery-slider-thumb--active { border-color: var(--cpb-primary, #253993); }

/* ── Carousel (multi-image side-by-side) ── */
.cpb-gallery-carousel {
    position: relative;
    width: 100%;
}
.cpb-carousel-track {
    display: flex;
    gap: 10px;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    scroll-behavior: smooth;
    padding: 4px 4px 12px;
    scrollbar-width: thin;
    scrollbar-color: var(--cpb-primary, #253993) transparent;
}
.cpb-carousel-track::-webkit-scrollbar { height: 6px; }
.cpb-carousel-track::-webkit-scrollbar-thumb {
    background: var(--cpb-primary, #253993); border-radius: 3px;
}
.cpb-carousel-item {
    flex: 0 0 calc((100% - 20px) / 3);
    scroll-snap-align: start;
    border-radius: var(--cpb-radius, 8px);
    overflow: hidden;
    background: var(--cpb-bg-alt, #f7f7f7);
    cursor: zoom-in;
}
.cpb-carousel-item img {
    width: 100%; height: 100%; object-fit: cover;
    aspect-ratio: 1 / 1; display: block;
    transition: transform 0.35s ease;
}
.cpb-carousel-item:hover img { transform: scale(1.05); }
.cpb-carousel-nav {
    position: absolute;
    top: 50%; transform: translateY(-50%);
    z-index: 5;
    width: 38px; height: 38px;
    border-radius: 50%;
    background: rgba(255,255,255,0.95);
    border: none;
    box-shadow: 0 2px 10px rgba(0,0,0,0.18);
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    color: var(--cpb-text, #1a1a2e);
    transition: background 0.2s ease, color 0.2s ease;
}
.cpb-carousel-nav:hover { background: var(--cpb-primary, #253993); color: #fff; }
.cpb-carousel-nav--prev { left: 6px; }
.cpb-carousel-nav--next { right: 6px; }
@media (max-width: 900px) {
    .cpb-carousel-item { flex: 0 0 calc((100% - 10px) / 2); }
}
@media (max-width: 600px) {
    .cpb-carousel-item { flex: 0 0 85%; }
    .cpb-carousel-item img { aspect-ratio: 4 / 3; }
}

/* ── Stacked (vertical full-width) ── */
.cpb-gallery-stacked {
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.cpb-stacked-item {
    width: 100%;
    border-radius: var(--cpb-radius, 8px);
    overflow: hidden;
    background: var(--cpb-bg-alt, #f7f7f7);
    cursor: zoom-in;
}
.cpb-stacked-item img {
    width: 100%; height: auto; display: block;
    transition: transform 0.4s ease;
}
.cpb-stacked-item:hover img { transform: scale(1.02); }

/* ── Hero galleries: 1 big featured + 3 medium tiles ── */
.cpb-gallery-hero { width: 100%; }
.cpb-hero-main {
    border-radius: var(--cpb-radius, 8px);
    overflow: hidden;
    background: var(--cpb-bg-alt, #f7f7f7);
    cursor: zoom-in;
    position: relative;
}
.cpb-hero-main img {
    width: 100%; height: 100%;
    object-fit: contain;
    display: block;
    transition: transform 0.4s ease;
    padding: 0;
    box-sizing: border-box;
}
.cpb-hero-main:hover img { transform: scale(1.02); }

.cpb-hero-tile {
    border-radius: var(--cpb-radius, 8px);
    overflow: hidden;
    background: var(--cpb-bg-alt, #f7f7f7);
    cursor: zoom-in;
}
.cpb-hero-tile img {
    width: 100%; height: 100%;
    object-fit: contain;
    display: block;
    transition: transform 0.35s ease;
    padding: 6px;
    box-sizing: border-box;
}
.cpb-hero-tile:hover img { transform: scale(1.04); }

/* Variant: hero-side — hero on left (2/3), 3 tiles stacked on right (1/3) */
.cpb-gallery-hero--hero-side {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 10px;
    align-items: stretch;
}
.cpb-gallery-hero--hero-side .cpb-hero-main { aspect-ratio: 1 / 1; }
.cpb-gallery-hero--hero-side .cpb-hero-tiles {
    display: grid;
    grid-template-rows: repeat(3, 1fr);
    gap: 10px;
}
.cpb-gallery-hero--hero-side .cpb-hero-tile { aspect-ratio: 1 / 1; }

/* Variant: hero-below — big hero on top, 3 tiles in a row underneath */
.cpb-gallery-hero--hero-below {
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.cpb-gallery-hero--hero-below .cpb-hero-main { aspect-ratio: 5 / 4; max-height: 640px; }
.cpb-gallery-hero--hero-below .cpb-hero-tiles {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
}
.cpb-gallery-hero--hero-below .cpb-hero-tile { aspect-ratio: 1 / 1; }

/* Variant: magazine — asymmetric mixed mosaic */
.cpb-gallery-hero--magazine {
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: auto auto;
    gap: 10px;
}
.cpb-gallery-hero--magazine .cpb-hero-main {
    grid-column: 1 / -1;
    aspect-ratio: 16 / 9;
}
.cpb-gallery-hero--magazine .cpb-hero-tiles {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
}
.cpb-gallery-hero--magazine .cpb-hero-tile { aspect-ratio: 1 / 1; }

/* Mobile: collapse hero layouts to a clean stack */
@media (max-width: 700px) {
    .cpb-gallery-hero--hero-side {
        grid-template-columns: 1fr;
    }
    .cpb-gallery-hero--hero-side .cpb-hero-main,
    .cpb-gallery-hero--hero-below .cpb-hero-main,
    .cpb-gallery-hero--magazine .cpb-hero-main { aspect-ratio: 1 / 1; }
    .cpb-gallery-hero--hero-side .cpb-hero-tiles,
    .cpb-gallery-hero--magazine .cpb-hero-tiles {
        grid-template-columns: repeat(3, 1fr);
        grid-template-rows: auto;
    }
}

/* ── Improve mosaic grid: featured larger, varied tiles ── */
.cpb-gallery-grid {
    grid-template-columns: repeat(3, 1fr);
    grid-auto-rows: 1fr;
}
.cpb-gallery-grid-item--main {
    grid-column: span 2;
    grid-row: span 2;
}
.cpb-gallery-grid-item--main .cpb-gallery-grid-img { aspect-ratio: 1 / 1; }
@media (max-width: 700px) {
    .cpb-gallery-grid { grid-template-columns: repeat(2, 1fr); }
    .cpb-gallery-grid-item--main { grid-column: span 2; grid-row: auto; }
    .cpb-gallery-grid-item--main .cpb-gallery-grid-img { aspect-ratio: 16 / 9; }
}

/* ── Responsive ── */
@media (max-width: 900px) {
    .cpb-gallery-thumb { width: 62px; height: 62px; }
    .cpb-gallery-vertical-thumbs .cpb-gallery-thumb { height: 62px; }
    .cpb-gallery-slide img,
    .cpb-product-main-image img,
    .cpb-main-product-img { max-height: 420px; }
}

@media (max-width: 600px) {
    /* Left-thumb: stack vertically (thumbs below main) */
    .cpb-gallery-left-layout {
        grid-template-columns: 1fr;
    }

    .cpb-gallery-vertical-thumbs {
        flex-direction: row;
        flex-wrap: wrap;
        overflow-y: visible;
        max-height: none;
        order: 2;
    }

    .cpb-gallery-vertical-thumbs .cpb-gallery-thumb {
        width: 58px;
        height: 58px;
    }

    .cpb-gallery-left-layout .cpb-product-main-image {
        order: 1;
    }

    /* Classic thumbs smaller */
    .cpb-gallery-thumb { width: 58px; height: 58px; }

    /* Grid: single column on very small */
    .cpb-gallery-grid { grid-template-columns: 1fr; gap: 6px; }
    .cpb-gallery-grid-item--main { grid-column: auto; }

    /* Slider */
    .cpb-gallery-slide img,
    .cpb-product-main-image img,
    .cpb-main-product-img { max-height: 300px; }
    .cpb-gallery-arrow { width: 36px; height: 36px; font-size: 1rem; }
    .cpb-gallery-arrow--prev { left: 8px; }
    .cpb-gallery-arrow--next { right: 8px; }
    .cpb-gallery-dot { width: 8px; height: 8px; }

    /* Lightbox arrows – hide on very small (swipe instead) */
    .cpb-lightbox-arrow { display: none; }
    .cpb-lightbox-img { max-width: 96vw; max-height: 80vh; }
}

/* ── Product page trust bar, ETA, features, quick help ── */
.cpb-trust-bar {
    list-style: none;
    padding: 12px;
    margin: 14px 0;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px 14px;
    background: var(--cpb-bg-alt, #f5f8fb);
    border: 1px solid #e3eaf2;
    border-radius: var(--cpb-radius, 8px);
    font-size: 14px;
}
.cpb-trust-bar li {
    display: flex; align-items: center; gap: 8px;
    color: #1a2944;
    font-weight: 500;
}
.cpb-trust-ico {
    display: inline-flex; align-items: center; justify-content: center;
    width: 22px; height: 22px; font-size: 14px;
    color: var(--cpb-primary, #1a3a82);
}
@media (min-width: 700px) {
    .cpb-trust-bar { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

.cpb-product-eta {
    display: flex; align-items: center; gap: 8px;
    padding: 10px 12px;
    margin: 14px 0;
    background: #eaf6ec;
    border-left: 3px solid #2e8b57;
    border-radius: 6px;
    font-size: 14px;
    color: #1d3b2a;
}
.cpb-eta-dot {
    width: 9px; height: 9px; border-radius: 50%;
    background: #2e8b57;
    box-shadow: 0 0 0 4px rgba(46,139,87,0.18);
    flex: 0 0 auto;
}

.cpb-product-actions { display: flex; flex-wrap: wrap; gap: 10px; margin: 16px 0; }
.cpb-btn-outline {
    background: transparent;
    color: var(--cpb-primary, #1a3a82);
    border: 2px solid var(--cpb-primary, #1a3a82);
}
.cpb-btn-outline:hover { background: var(--cpb-primary, #1a3a82); color: #fff; }

.cpb-product-features {
    list-style: none;
    padding: 14px 16px;
    margin: 16px 0;
    background: #fff;
    border: 1px solid #e3eaf2;
    border-radius: var(--cpb-radius, 8px);
}
.cpb-product-features li {
    position: relative;
    padding: 6px 0 6px 26px;
    font-size: 14px;
    color: #2a3950;
    border-bottom: 1px dashed #eef1f6;
}
.cpb-product-features li:last-child { border-bottom: 0; }
.cpb-product-features li::before {
    content: "\2713";
    position: absolute; left: 0; top: 6px;
    width: 18px; height: 18px;
    display: inline-flex; align-items: center; justify-content: center;
    background: var(--cpb-primary, #1a3a82);
    color: #fff;
    border-radius: 50%;
    font-size: 11px;
    line-height: 1;
}

.cpb-quick-help {
    margin: 16px 0;
    padding: 12px 14px;
    background: var(--cpb-bg-alt, #f5f8fb);
    border-radius: var(--cpb-radius, 8px);
    border: 1px dashed #c8d4e3;
}
.cpb-quick-help-label {
    display: block;
    font-size: 13px; color: #56627a; margin-bottom: 8px;
    font-weight: 600;
}
.cpb-quick-help-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.cpb-quick-help-btn {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 8px 12px;
    background: #fff;
    border: 1px solid #d5deea;
    border-radius: 6px;
    font-size: 13px;
    color: #1a2944;
    text-decoration: none;
    transition: all 0.2s ease;
}
.cpb-quick-help-btn:hover {
    border-color: var(--cpb-primary, #1a3a82);
    color: var(--cpb-primary, #1a3a82);
}
.cpb-quick-help-btn--wa {
    background: #25d366; color: #fff; border-color: #25d366;
}
.cpb-quick-help-btn--wa:hover { background: #1da955; color: #fff; }
