/**
 * KAP Gallery Widget Styles
 */

/* ─── Main Image ─────────────────────────── */
.kap-gallery {
    direction: rtl;
    width: 100%;
}

.kap-gallery__main {
    position: relative;
    width: 100%;
    overflow: hidden;
    background: #f0f0f0;
    border-radius: 0;
    margin-bottom: 12px;
}

.kap-gallery__main-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: opacity 0.25s ease;
    border-radius: 0;
}

/* loading state — skeleton shimmer */
.kap-gallery__main-img.is-loading {
    opacity: 0;
}

.kap-gallery__main.is-loading::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: kap-skeleton 1.4s ease-in-out infinite;
}

/* ─── Zoom Button ────────────────────────── */
.kap-gallery__zoom {
    position: absolute;
    bottom: 12px;
    left: 12px;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.5);
    border: none;
    border-radius: 0;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.2s, background 0.2s;
    z-index: 2;
}

.kap-gallery__main:hover .kap-gallery__zoom {
    opacity: 1;
}

.kap-gallery__zoom svg {
    width: 20px;
    height: 20px;
    stroke: #ffffff;
}

.kap-gallery__zoom:hover {
    background: rgba(0, 0, 0, 0.75);
}

/* ─── Thumbs Grid (≤4 images) ────────────── */
.kap-gallery__thumbs-wrap {
    margin-top: 10px;
}

.kap-gallery__thumbs-grid {
    display: grid;
    grid-template-columns: repeat(var(--kap-cols, 4), 1fr);
    gap: 8px;
}

.kap-gallery__thumb-item {
    cursor: pointer;
    border-radius: 0;
    overflow: hidden;
    aspect-ratio: inherit !important;
    position: relative;
}

.kap-gallery__thumb-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    border: 2px solid transparent;
    border-radius: 0;
    transition: border-color 0.2s, opacity 0.2s;
}

.kap-gallery__thumb-item:hover img {
    opacity: 0.85;
}

.kap-gallery__thumb-item.is-active img {
    border-color: currentColor;
    opacity: 1;
}

/* ─── Thumbs Swiper (>4 images) ──────────── */
.kap-gallery__thumbs-swiper {
    overflow: hidden;
    position: relative;
    padding: 0 0 0 25px;
}

.kap-gallery__thumbs-swiper .swiper-slide {
    height: auto;
}

.kap-gallery__thumbs-swiper .kap-gallery__thumb-item {
    width: 100%;
    aspect-ratio: 1;
    height: auto;
}

/* ─── Swiper Nav ─────────────────────────── */
.kap-gallery__nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    z-index: 5;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(15, 23, 42, 0.85);
    border-radius: 0;
    cursor: pointer;
    transition: background 0.2s;
}

.kap-gallery__nav:hover {
    background: rgba(15, 23, 42, 1);
}

.kap-gallery__nav svg {
    width: 16px;
    height: 16px;
    stroke: #ffffff;
}

/* RTL: prev = راست، next = چپ */
.kap-gallery__nav-prev {
    right: 0;
}

.kap-gallery__nav-next {
    left: 0;
}

.kap-gallery__nav.swiper-button-disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

/* ─── Lightbox ───────────────────────────── */
.kap-lightbox {
    position: fixed;
    inset: 0;
    z-index: 99999;
    display: none;
    align-items: center;
    justify-content: center;
}

.kap-lightbox.is-open {
    display: flex;
}

.kap-lightbox__overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.92);
    animation: kap-fade-in 0.25s ease;
}

.kap-lightbox__content {
    position: relative;
    z-index: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    padding: 60px 80px;
    box-sizing: border-box;
}

.kap-lightbox__img-wrap {
    max-width: 100%;
    max-height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.kap-lightbox__img {
    max-width: 100%;
    max-height: calc(100vh - 120px);
    object-fit: contain;
    border-radius: 0;
    animation: kap-zoom-in 0.25s ease;
    display: block;
}

/* Close */
.kap-lightbox__close {
    position: absolute;
    top: 16px;
    right: 16px;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    border-radius: 0;
    cursor: pointer;
    transition: background 0.2s;
    z-index: 2;
}

.kap-lightbox__close:hover {
    background: rgba(255, 255, 255, 0.25);
}

.kap-lightbox__close svg {
    width: 20px;
    height: 20px;
    stroke: #ffffff;
}

/* Nav arrows */
.kap-lightbox__nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 52px;
    height: 52px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    border-radius: 0;
    cursor: pointer;
    transition: background 0.2s;
    z-index: 2;
}

.kap-lightbox__nav:hover {
    background: rgba(255, 255, 255, 0.25);
}

.kap-lightbox__nav svg {
    width: 24px;
    height: 24px;
    stroke: #ffffff;
}

/* RTL lightbox: prev = راست، next = چپ */
.kap-lightbox__prev {
    right: 20px;
}

.kap-lightbox__next {
    left: 20px;
}

.kap-lightbox__nav.is-hidden {
    opacity: 0.2;
    pointer-events: none;
}

/* Counter */
.kap-lightbox__counter {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    gap: 6px;
    color: rgba(255, 255, 255, 0.7);
    font-size: 14px;
    font-weight: 500;
    direction: ltr;
}

/* ─── Animations ─────────────────────────── */
@keyframes kap-fade-in {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes kap-zoom-in {
    from {
        opacity: 0;
        transform: scale(0.92);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes kap-skeleton {
    0% {
        background-position: 200% 0;
    }

    100% {
        background-position: -200% 0;
    }
}

/* ─── Responsive ─────────────────────────── */
@media (max-width: 768px) {
    .kap-lightbox__content {
        padding: 60px 16px;
    }

    .kap-lightbox__prev {
        right: 8px;
    }

    .kap-lightbox__next {
        left: 8px;
    }

    .kap-lightbox__nav {
        width: 40px;
        height: 40px;
    }

    .kap-gallery__thumbs-swiper .kap-gallery__thumb-item {
        height: auto;
    }
}