.becar-gallery {
    display: block;
    max-width: 720px;
    margin: 0 auto;
    background: white;
    padding: 15px;
    border-radius: 12px;
}
.becar-gallery-main {
    position: relative;
    overflow: hidden;
    background: #fff;
    border-radius: 6px;
    text-align: center;
}
.becar-main-image {
    cursor: zoom-in;
    user-select: none;
    -webkit-user-drag: none;
    display: inline-block;
    max-width: 100%;
    padding: 8px;
}
.becar-main-image img {
    max-width: 100%;
    height: auto;
    display: block;
    transition: transform 0.15s ease;
    margin: 0 auto;
}
.becar-gallery-counter {
    position: absolute;
    right: 8px;
    bottom: 8px;
    background: rgba(0,0,0,0.6);
    color: #fff;
    padding: 6px 10px;
    border-radius: 16px;
    font-size: 13px;
    font-weight: 600;
}
.becar-gallery-thumbs {
    display: flex;
    gap: 8px;
    margin-top: 10px;
    overflow-x: auto;
    padding: 6px;
    -webkit-overflow-scrolling: touch;
}
.becar-thumb {
    border: none;
    background: transparent;
    padding: 0;
    cursor: pointer;
    flex: 0 0 auto;
    margin: 0;
}
.becar-thumb img {
    width: 56px;
    height: 56px;
    object-fit: cover;
    border-radius: 6px;
    border: 1px solid #e6e6e6;
}
.becar-thumb.active img {
    box-shadow: 0 0 0 3px rgba(24, 119, 242, 0.12);
    border-color: #1877f2;
}

/* Overlay */
.becar-gallery-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 99999;
    display: flex;
    align-items: stretch;
    justify-content: center;
}
.becar-gallery-overlay-inner {
    width: 70vw;
    height: 100vh;
    background: #ffffff;
    position: relative;
    color: #333;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 8px 40px rgba(0,0,0,0.12);
}
.becar-gallery-overlay-close {
    position: absolute;
    right: 12px;
    top: 12px;
    background: transparent;
    color: #333;
    border: none;
    font-size: 14px;
    padding: 8px 12px;
    cursor: pointer;
    z-index: 20;
}
.becar-overlay-main {
    text-align: center;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}
.becar-overlay-main img.becar-overlay-image {
    /* Constrain image to the white box (70vw) leaving space for outside controls */
    max-width: calc(70vw - 160px);
    max-height: calc(100vh - 160px);
    width: auto;
    height: auto;
    display: inline-block;
    margin: 0 auto;
    object-fit: contain;
}
.becar-overlay-main button {
    margin: 0;
    padding: 0;
}
.becar-overlay-thumbs {
    position: absolute;
    bottom: 12px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 8px;
    justify-content: center;
    overflow-x: auto;
    padding: 6px;
    max-width: 90%;

}
.becar-overlay-thumb img {
    width: 72px;
    height: 72px;
    object-fit: cover;
    border-radius: 6px;
    border: 2px solid rgba(0,0,0,0.06);
}
.becar-overlay-counter {
    color: rgba(0,0,0,0.85);
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    font-weight: 600;
    z-index: 20;
    background: rgba(255,255,255,0.9);
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 14px;
}

/* overlay prev/next positioned outside white box (left/right) */
.becar-gallery-overlay-prev,
.becar-gallery-overlay-next {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: transparent;
    border: none;
    color: #333;
    font-size: 32px;
    width: 44px;
    height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    z-index: 25;
    cursor: pointer;
}
.becar-gallery-overlay-prev {
    left: calc(15vw - 48px);
}
.becar-gallery-overlay-next {
    right: calc(15vw - 48px);
}

/* make prev/next visible on dark background outside white box */
.becar-gallery-overlay-prev,
.becar-gallery-overlay-next {
    background: rgba(255,255,255,0.95);
    color: #222;
    border-radius: 50%;
    box-shadow: 0 8px 24px rgba(0,0,0,0.18);
    width: 48px;
    height: 48px;
    font-size: 26px;
    align-items: center;
    justify-content: center;
    display: inline-flex;
    z-index: 30;
}

/* Small screens */
@media (max-width: 600px) {
    .becar-main-image img { max-height: 320px; }
    .becar-thumb img { width: 46px; height: 46px; }
    .becar-overlay-thumb img { width: 56px; height: 56px; }
}

/* When overlay opened, prevent body scroll */
body.becar-gallery-open {
    overflow: hidden;
}

.becar-gallery {
    --bg: transparent;
    display: block;
    max-width: 920px;
    margin: 0 auto;
}
.becar-gallery-main {
    position: relative;
    overflow: hidden;
    background: var(--bg);
    border-radius: 8px;
}
.becar-gallery-slide {
    display: none;
    text-align: center;
    padding: 12px;
}
.becar-gallery-slide.active {
    display: block;
}
.becar-gallery-slide img {
    max-width: 100%;
    height: auto;
    transition: transform 0.2s ease;
}
.becar-gallery-counter {
    position: absolute;
    right: 8px;
    bottom: 8px;
    background: #eaecf0;
    color: #344054;
    border-radius: 12px;
    font-size: 12px;
    padding: 2px 10px;
}
.becar-gallery-thumbs {
    display: flex;
    gap: 8px;
    justify-content: center;
    margin-top: 8px;
    flex-wrap: wrap;
}
.becar-thumb-btn {
    border: 0;
    background: transparent;
    padding: 4px;
    border-radius: 6px;
    cursor: pointer;
    box-sizing: border-box;
}
.becar-thumb-btn img {
    width: 48px;
    height: 48px;
    object-fit: cover;
    display: block;
    border-radius: 4px;
}
.becar-thumb-btn.active {
    outline: 2px solid #1877f2;
}

/* Lightbox overlay */
.becar-gallery-overlay {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0,0,0,0.85);
    z-index: 999999;
}
.becar-gallery-overlay-content {
    position: relative;
    max-width: 90%;
    max-height: 90%;
}
.becar-gallery-overlay-image {
    max-width: 100%;
    max-height: 80vh;
    display: block;
    margin: 0 auto;
}
.becar-gallery-overlay-close,
.becar-gallery-overlay-prev,
.becar-gallery-overlay-next {
    position: absolute;
    top: 8px;
    background: rgba(255,255,255,0.08);
    color: white;
    border: 0;
    padding: 8px 10px;
    border-radius: 6px;
    cursor: pointer;
}
.becar-gallery-overlay-close {
    right: 8px;
}
.becar-gallery-overlay-prev {
    left: -40px;
    top: 50%;
    transform: translateY(-50%);
}
.becar-gallery-overlay-next {
    right: -40px;
    top: 50%;
    transform: translateY(-50%);
}

@media (max-width: 768px) {
    .becar-gallery-overlay-prev { left: 8px; }
    .becar-gallery-overlay-next { right: 8px; }
    .becar-gallery { padding: 0 !important; }
}



/* ===== Overrides and new layout for Becar Gallery main image, arrows, and thumb track ===== */
.becar-main-image {
    position: relative;
    width: 100%;
    padding-top: 56.25%; /* 16:9 aspect ratio */
    background: #ffffff;
    border-radius: 8px;
    overflow: hidden;
    box-sizing: border-box;
}
.becar-main-image-inner {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 8px;
}
.becar-main-image-inner img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    display: block;
    background: transparent;
}
.becar-gallery-arrow {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgb(255 255 255 / 51%) !important;
    color: #101828;
    border: none;
    width: 34px;
    height: 44px;
    font-size: 24px;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 6;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    margin: 0;
    padding: 0;
}

.becar-gallery-arrow svg {
    width: 25px !important;
    height: 25px !important;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

.becar-gallery-prev { left: 8px; box-shadow: 6px 0 4px rgba(0, 0, 0, .05), 4px 0 4px rgba(0, 0, 0, .09);border-radius: 0 4px 4px 0; }
.becar-gallery-next { right: 8px;box-shadow: -6px 0 4px rgba(0, 0, 0, .05), -4px 0 4px rgba(0, 0, 0, .09);border-radius: 4px 0px 0px 4px;  }
/* Show arrows on hover over main image */
.becar-main-image:hover .becar-gallery-arrow {
    opacity: 1;
    visibility: visible;
}

/* Show arrows when they are enabled via JavaScript */
.becar-gallery-arrow.visible {
    opacity: 1;
    visibility: visible;
}

.becar-thumbs-nav {
    border: none;
    background: transparent;
    color: #333;
    font-size: 20px;
    width: 36px;
    height: 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}
.becar-thumb-track {
    display: flex;
    gap: 8px;
    transition: transform 0.25s ease;
    will-change: transform;
    overflow: visible;
    align-items: center;
    padding-right: 120px; /* Increase padding to ensure all last thumbnails are fully visible */
}
.becar-gallery-thumbs {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 10px;
    padding: 6px;
    /* default: allow native horizontal scroll on mobile; on desktop we hide overflow and use transform */
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

@media (min-width: 769px) {
    .becar-gallery-thumbs {
        overflow: hidden; /* desktop: hide overflow and use translateX on track */
    }
}
.becar-thumb {
    border: none;
    background: transparent;
    padding: 0;
    cursor: pointer;
    flex: 0 0 auto;
    width: 50px !important;
    height: 50px !important;
    box-sizing: border-box;
}
.becar-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 6px;
    border: 1px solid #e6e6e6;
}
.becar-thumb.active img {
    box-shadow: 0 0 0 3px rgba(24, 119, 242, 0.12);
    border-color: #1877f2;
}

/* Default feature icon styling */
.becar-thumb-default {
    cursor: pointer !important;
    pointer-events: auto !important;
}

.becar-thumb-default img {
    border: none !important;
}

.becar-thumb-default.active img {
    box-shadow: none;
    border: none !important;
}

.becar-thumb-default:hover {
    opacity: 0.8;
    transition: opacity 0.3s ease;
}

/* Overlay styling */
.becar-gallery-overlay-close {
    display: block !important;
    position: absolute;
    right: 20px !important;
    top: 20px !important;
    background: #eaecf0 !important;
    color: #344054 !important;
    border: none !important;
    font-size: 14px !important;
    padding: 8px 16px !important;
    border-radius: 8px !important;
    cursor: pointer !important;
    z-index: 30 !important;
    font-weight: 500 !important;
}

/* Mobile close button - hide text and show × */
@media (max-width: 768px) {
    .becar-gallery-overlay-close {
        color: transparent !important;
        padding: 8px !important;
        margin: 0;
    }

    .becar-gallery-overlay-close::before {
        content: "×";
        color: #333 !important;
        position: absolute;
    }
}

.becar-overlay-image {
    display: block !important;
    max-width: 80vw;
    max-height: 70vh;
    width: auto;
    height: auto;
    object-fit: contain;
    margin: 0 auto;
}

.becar-default-feature-icon {
    border: none !important;
    box-shadow: none !important;
}

/* Hide wheel-zoom cursor */
.becar-main-image { cursor: default; }

/* Mobile Optimizations */
@media (max-width: 768px) {
    /* Mobile main gallery - enable touch scrolling */
    .becar-gallery {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .becar-thumb-track {
        padding-right: 20px; /* Extra space for mobile scrolling */
    }

    /* Mobile main image touch feedback */
    .becar-main-image {
        cursor: grab;
    }

    .becar-main-image:active {
        cursor: grabbing;
    }
    /* Mobile overlay - full screen white background */
    .becar-gallery-overlay {
        position: fixed;
        top: 0;
        left: 0;
        width: 100vw;
        height: 100vh;
        background: white !important;
        z-index: 999999;
    }

    .becar-gallery-overlay-inner {
        width: 100%;
        height: 100%;
        background: white;
        position: relative;
        display: flex;
        flex-direction: column;
    }

    /* Mobile close button - X icon */
    .becar-gallery-overlay-close {
        position: absolute;
        top: 15px;
        right: 15px;
        width: 35px;
        height: 35px;
        background: rgba(0,0,0,0.1) !important;
        color: transparent !important; /* Hide any text content */
        border: none !important;
        border-radius: 50%;
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 18px;
        font-weight: bold;
        z-index: 30;
        cursor: pointer;
    }

    .becar-gallery-overlay-close::before {
        content: "×";
        color: #333 !important;
        font-size: 20px;
        line-height: 1;
        position: absolute;
    }

    /* Mobile overlay main image */
    .becar-overlay-main {
        flex: 1;
        display: flex;
        align-items: center;
        justify-content: center;
        position: relative;
        padding: 60px 20px 140px 20px; /* More space at bottom for grid thumbnails */
    }

    .becar-overlay-image {
        max-width: 90vw !important;
        max-height: 60vh !important;
        width: auto;
        height: auto;
        object-fit: contain;
    }

    /* Mobile overlay arrows */
    .becar-gallery-arrow {
        width: 40px !important;
        height: 40px !important;
    }

    .becar-gallery-arrow svg {
        width: 20px !important;
        height: 20px !important;
    }

    /* Mobile overlay thumbnails - grid layout */
    .becar-overlay-thumbs {
        position: absolute;
        bottom: 90px;
        right: 20px;
        display: flex;
        flex-wrap: wrap; /* Allow wrapping to next row */
        gap: 8px;
        justify-content: flex-start;
        align-content: flex-start;
        overflow-y: auto; /* Enable vertical scrolling if needed */
        overflow-x: hidden; /* Disable horizontal scrolling */
        padding: 8px;
        scrollbar-width: thin; /* Firefox */
        -ms-overflow-style: auto; /* IE/Edge */
        z-index: 25;
        background: rgba(255, 255, 255, 0.9);
        border-radius: 8px;
        backdrop-filter: blur(4px);
        width: 100%;
    }

    .becar-overlay-thumbs::-webkit-scrollbar {
        display: none; /* Chrome/Safari */
    }

    .becar-overlay-thumb {
        flex: 0 0 auto;
        width: 50px;
        height: 50px;
        border: 2px solid transparent;
        border-radius: 6px;
        overflow: hidden;
        flex-shrink: 0; /* Prevent shrinking */
    }

    .becar-overlay-thumb img {
        width: 100%;
        height: 100%;
        object-fit: cover;
    }

    /* Mobile overlay counter - position above image */
    .becar-overlay-counter {
        position: absolute;
        left: 50%;
        transform: translateX(-50%);
        background: rgba(0,0,0,0.7);
        color: white;
        padding: 6px 12px;
        border-radius: 15px;
        font-size: 12px;
        font-weight: 500;
        z-index: 30;
        display: inline-block; /* Prevent stretching to full height */
        box-sizing: border-box;
        line-height: 1;
        white-space: nowrap;
        min-width: 44px;
        max-width: 90%;
        height: auto;
        max-height: none;
    }
}

