/* ── Codeixer Product Gallery Widget v2 ─────────────────────── */

/* ── Wrapper ─────────────────────────────────────────────────── */
.cgw-wrapper {
    display: flex;
    gap: 12px;
    align-items: flex-start;
    width: 100%;
    position: relative;
}

.cgw-pos-left   { flex-direction: row; }
.cgw-pos-right  { flex-direction: row-reverse; }
.cgw-pos-bottom { flex-direction: column; }

/* ── Thumbnail strip container ───────────────────────────────── */
.cgw-thumbs-side {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    width: 88px;
    min-width: 88px;
    flex-shrink: 0;
}

.cgw-thumbs-bottom {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 4px;
    width: 100%;
    overflow: hidden;
}

/* ── Thumb inner scroll area ─────────────────────────────────── */
.cgw-thumbs-side   .cgw-thumbs-inner {
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: 100%;
    max-height: 520px;
    overflow-y: auto;
    overflow-x: hidden;
    scrollbar-width: thin;
    scrollbar-color: #ccc transparent;
    padding: 2px;           /* room so box-shadow / border not clipped */
}

.cgw-thumbs-bottom .cgw-thumbs-inner {
    display: flex;
    flex-direction: row;
    gap: 8px;
    flex: 1;
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: thin;
    scrollbar-color: #ccc transparent;
    padding: 2px;
}

.cgw-thumbs-inner::-webkit-scrollbar { width: 3px; height: 3px; }
.cgw-thumbs-inner::-webkit-scrollbar-thumb { background: #ccc; border-radius: 3px; }

/* ── Single thumbnail ────────────────────────────────────────── */
.cgw-thumb {
    flex-shrink: 0;
    width: 80px;
    height: 80px;
    border: 2px solid #e0e0e0;  /* default border — always visible */
    border-style: solid;
    border-radius: 6px;
    overflow: hidden;
    cursor: pointer;
    opacity: 0.55;
    outline: none;
    box-sizing: border-box;
    transition: border-color 0.2s ease, opacity 0.2s ease, transform 0.15s ease;
}

.cgw-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    pointer-events: none;
}

.cgw-thumb:hover {
    opacity: 1;
    border-color: #888;
    transform: scale(1.04);
}

/* Active state — solid visible border */
.cgw-thumb.active {
    border-color: #111;
    border-width: 2px;
    opacity: 1;
    transform: none;
}

.cgw-thumb:focus-visible {
    box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.25);
}

/* ── Main image area ─────────────────────────────────────────── */
.cgw-main-wrap {
    flex: 1;
    position: relative;
    background: #f5f5f3;
    border-radius: 10px;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 480px;
}

.cgw-main-img {
    max-width: 100%;
    max-height: 520px;
    object-fit: contain;
    display: block;
    transition: opacity 0.18s ease;
    will-change: opacity;
    cursor: pointer;
}

.cgw-main-img.cgw-fade { opacity: 0; }

/* Zoom */
.cgw-zoom .cgw-main-img {
    transition: opacity 0.18s ease, transform 0.35s cubic-bezier(0.25, 0.8, 0.25, 1);
}
.cgw-zoom:hover .cgw-main-img { transform: scale(1.06); }

/* ── Arrow buttons (shared base) ─────────────────────────────── */
.cgw-arrow {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border: none;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.45);
    color: #fff;
    cursor: pointer;
    flex-shrink: 0;
    transition: background 0.2s ease, opacity 0.2s ease;
    padding: 0;
    line-height: 1;
}

.cgw-arrow svg { stroke: currentColor; display: block; }

.cgw-arrow:hover { background: rgba(0, 0, 0, 0.75); }

.cgw-arrow:disabled,
.cgw-arrow.cgw-disabled {
    opacity: 0.25;
    cursor: default;
    pointer-events: none;
}

/* Main image arrows — positioned absolute inside .cgw-main-wrap */
.cgw-main-prev,
.cgw-main-next {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    z-index: 2;
}

.cgw-main-prev { left: 12px; }
.cgw-main-next { right: 12px; }

/* Thumbnail strip arrows */
.cgw-thumb-prev,
.cgw-thumb-next {
    flex-shrink: 0;
}

/* ── Lightbox overlay ────────────────────────────────────────── */
.cgw-lightbox-overlay {
    position: fixed;
    inset: 0;
    z-index: 999999;
    background: rgba(0, 0, 0, 0.88);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    padding: 20px;
    box-sizing: border-box;
}

.cgw-lightbox-overlay[hidden] { display: none; }

.cgw-lb-img-wrap {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    max-width: calc(100vw - 180px);
    max-height: calc(100vh - 80px);
}

.cgw-lb-img {
    max-width: 100%;
    max-height: calc(100vh - 80px);
    object-fit: contain;
    border-radius: 4px;
    transition: opacity 0.18s ease;
}

.cgw-lb-img.cgw-fade { opacity: 0; }

/* Close button */
.cgw-lb-close {
    position: absolute;
    top: 16px;
    right: 16px;
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 50%;
    background: rgba(255,255,255,0.12);
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
    padding: 0;
}
.cgw-lb-close:hover { background: rgba(255,255,255,0.25); }
.cgw-lb-close svg { stroke: currentColor; display: block; }

/* Lightbox arrows */
.cgw-lb-prev,
.cgw-lb-next {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: rgba(255,255,255,0.15);
    flex-shrink: 0;
}
.cgw-lb-prev:hover,
.cgw-lb-next:hover { background: rgba(255,255,255,0.3); }

/* Counter */
.cgw-lb-counter {
    position: absolute;
    bottom: 16px;
    left: 50%;
    transform: translateX(-50%);
    color: rgba(255,255,255,0.7);
    font-size: 13px;
    font-family: inherit;
    letter-spacing: 0.5px;
}

/* ── Editor placeholder ──────────────────────────────────────── */
.cgw-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 200px;
    background: #f9f9f9;
    border: 2px dashed #ddd;
    border-radius: 10px;
    color: #999;
    text-align: center;
    padding: 2rem;
    gap: 8px;
}
.cgw-placeholder-icon { font-size: 40px; }
.cgw-placeholder p    { font-size: 15px; font-weight: 600; color: #555; margin: 0; }
.cgw-placeholder small { font-size: 12px; }

.cgw-no-product { color: #999; font-size: 14px; padding: 1rem; }

/* ── Responsive ──────────────────────────────────────────────── */
@media (max-width: 600px) {
    .cgw-pos-left,
    .cgw-pos-right {
        flex-direction: column;
    }

    .cgw-thumbs-side {
        flex-direction: row !important;
        width: 100% !important;
        min-width: unset !important;
    }

    .cgw-thumbs-side .cgw-thumbs-inner {
        flex-direction: row !important;
        max-height: none;
        overflow-x: auto;
        overflow-y: hidden;
        width: 100%;
    }

    .cgw-thumb {
        width: 60px !important;
        height: 60px !important;
    }

    .cgw-main-wrap { min-height: 280px; }

    .cgw-lb-img-wrap { max-width: calc(100vw - 100px); }
}
