
/* ==================================================
   JPARTS Shared Product Gallery V1
   PC: vertical thumbnails on the left
   Mobile: horizontal thumbnails below
   ================================================== */

.jp-gallery {
    --gallery-border: var(--jp-border, #d8e0e6);
    --gallery-primary: var(--jp-primary, #28627a);

    display: grid;
    grid-template-columns: 76px minmax(0, 1fr);
    grid-template-areas:
        "thumbs main"
        "controls controls";
    gap: 12px;
    width: 100%;
    min-width: 0;
}

/* Main image */

.jp-gallery__main {
    grid-area: main;
    min-width: 0;
    aspect-ratio: 1 / 1;
    background: #fff;
    border: 1px solid var(--gallery-border);
    border-radius: 10px;
    overflow: hidden;
}

.jp-gallery__open {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    padding: 12px;
    border: 0;
    background: transparent;
    cursor: zoom-in;
}

.jp-gallery__open img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.jp-gallery__zoom {
    position: absolute;
    right: 8px;
    bottom: 8px;
    padding: 5px 8px;
    background: rgba(255, 255, 255, .94);
    border: 1px solid var(--gallery-border);
    border-radius: 6px;
    color: #243746;
    font-size: 12px;
}

/* Thumbnails */

.jp-gallery__thumbs {
    grid-area: thumbs;
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-width: 0;
    max-height: 360px;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 2px;
}

.jp-gallery__thumb {
    flex: 0 0 68px;
    width: 68px;
    height: 68px;
    padding: 5px;
    background: #fff;
    border: 1px solid var(--gallery-border);
    border-radius: 8px;
    cursor: pointer;
}

.jp-gallery__thumb[aria-pressed="true"] {
    border: 2px solid var(--gallery-primary);
}

.jp-gallery__thumb img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

/* Previous / next controls */

.jp-gallery__controls {
    grid-area: controls;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 16px;
    color: #526675;
    font-size: 13px;
}

.jp-gallery__controls button {
    width: 38px;
    height: 38px;
    border: 1px solid var(--gallery-border);
    border-radius: 8px;
    background: #fff;
    color: #243746;
    font-size: 24px;
    cursor: pointer;
}

/* Lightbox */

.jp-gallery__dialog {
    position: fixed;
    width: min(94vw, 1000px);
    max-width: 1000px;
    max-height: 94vh;
    padding: 44px 16px 16px;
    border: 0;
    border-radius: 12px;
    background: #fff;
    box-sizing: border-box;
}

.jp-gallery__dialog::backdrop {
    background: rgba(0, 0, 0, .78);
}

.jp-gallery__dialog img {
    display: block;
    width: 100%;
    max-height: calc(94vh - 70px);
    object-fit: contain;
}

.jp-gallery__close {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 36px;
    height: 36px;
    border: 1px solid var(--gallery-border);
    border-radius: 8px;
    background: #fff;
    font-size: 25px;
    cursor: pointer;
}

.jp-gallery__empty {
    grid-column: 1 / -1;
    display: grid;
    place-items: center;
    min-height: 220px;
    background: #f5f7f9;
    border: 1px solid var(--gallery-border);
    border-radius: 10px;
    color: #71808b;
}

.jp-gallery button:focus-visible {
    outline: 3px solid var(--gallery-primary);
    outline-offset: 2px;
}

/* Narrow containers and mobile screens */

@media (max-width: 767px) {
    .jp-gallery {
        grid-template-columns: minmax(0, 1fr);
        grid-template-areas:
            "main"
            "thumbs"
            "controls";
        gap: 10px;
    }

    .jp-gallery__thumbs {
        flex-direction: row;
        max-height: none;
        overflow-x: auto;
        overflow-y: hidden;
        padding: 4px 2px;
    }

    .jp-gallery__thumb {
        flex: 0 0 64px;
        width: 64px;
        height: 64px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .jp-gallery *,
    .jp-gallery *::before,
    .jp-gallery *::after {
        scroll-behavior: auto;
    }
}


/* Single image: use the full gallery width */
.jp-gallery:not(:has(.jp-gallery__thumbs)) {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas: "main";
}

.jp-gallery:not(:has(.jp-gallery__thumbs)) .jp-gallery__main {
    width: 100%;
}
