/* ============================================
   Lightbox Container
   ============================================ */

.space22-lightbox {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 9999;
    display: none;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    will-change: opacity;
}

.space22-lightbox.lightbox-active {
    display: flex;
    opacity: 1;
}

/* ============================================
   Lightbox Overlay
   ============================================ */

.lightbox-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(20, 20, 20, 0.95);
    cursor: default;
}

/* ============================================
   Lightbox Content
   ============================================ */

.lightbox-content {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px 20px 120px;
}

@media (max-width: 768px) {
    .lightbox-content {
        padding: 30px 15px 140px;
    }
}

/* ============================================
   Navigation Arrows
   ============================================ */

.lightbox-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 56px;
    height: 56px;
    background-color: rgba(184, 152, 90, 0.12);
    border: 2px solid rgba(184, 152, 90, 0.3);
    border-radius: 50%;
    color: var(--color-gold, #B8985A);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 10002;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.lightbox-nav:hover {
    background-color: var(--color-gold, #B8985A);
    border-color: var(--color-gold, #B8985A);
    color: #FFFFFF;
    transform: translateY(-50%) scale(1.1);
}

.lightbox-nav:active {
    transform: translateY(-50%) scale(0.95);
}

.lightbox-prev {
    left: 20px;
}

.lightbox-next {
    right: 20px;
}

@media (max-width: 768px) {
    .lightbox-nav {
        width: 44px;
        height: 44px;
    }

    .lightbox-nav svg {
        width: 24px;
        height: 24px;
    }

    .lightbox-prev {
        left: 10px;
    }

    .lightbox-next {
        right: 10px;
    }
}

/* ============================================
   Image Container
   ============================================ */

.lightbox-image-container {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: default;
}

.lightbox-image-wrapper {
    position: relative;
    max-width: 90vw;
    max-height: 75vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.lightbox-image {
    max-width: 100%;
    max-height: 75vh;
    width: auto;
    height: auto;
    object-fit: contain;
    opacity: 0;
    transition: opacity 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    border-radius: 6px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    cursor: default;
}

.lightbox-image.loaded {
    opacity: 1;
}

@media (max-width: 768px) {
    .lightbox-image {
        max-height: 60vh;
    }
}

/* ============================================
   Loading Spinner
   ============================================ */

.lightbox-loader {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
    z-index: 10001;
}

.lightbox-loader.active {
    opacity: 1;
}

.loader-spinner {
    width: 44px;
    height: 44px;
    border: 3px solid rgba(184, 152, 90, 0.2);
    border-top-color: var(--color-gold, #B8985A);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ============================================
   Bottom Bar (Counter + Thumbnails)
   ============================================ */

.lightbox-bottom {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 12px 20px 16px;
    background: linear-gradient(transparent, rgba(0,0,0,0.6));
    z-index: 10002;
}

.lightbox-counter {
    font-family: var(--font-body, Inter, sans-serif);
    font-size: 13px;
    font-weight: 500;
    color: rgba(255,255,255,0.7);
    letter-spacing: 0.5px;
    margin-bottom: 10px;
    display: none;
}

/* ============================================
   Thumbnails Strip
   ============================================ */

.lightbox-thumbnails {
    display: flex;
    gap: 6px;
    overflow-x: auto;
    max-width: 90vw;
    padding: 4px 0;
    scrollbar-width: none;
    -ms-overflow-style: none;
    scroll-behavior: smooth;
}

.lightbox-thumbnails::-webkit-scrollbar {
    display: none;
}

.lightbox-thumb {
    flex-shrink: 0;
    width: 56px;
    height: 56px;
    border-radius: 6px;
    overflow: hidden;
    cursor: pointer;
    border: 2px solid transparent;
    opacity: 0.5;
    transition: all 0.2s ease;
}

.lightbox-thumb:hover {
    opacity: 0.8;
}

.lightbox-thumb.active {
    opacity: 1;
    border-color: var(--color-gold, #B8985A);
}

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

@media (max-width: 768px) {
    .lightbox-thumb {
        width: 48px;
        height: 48px;
    }

    .lightbox-bottom {
        padding: 10px 12px 12px;
    }

    .lightbox-counter {
        font-size: 12px;
        margin-bottom: 8px;
    }
}

/* ============================================
   Screen Reader Only
   ============================================ */

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* ============================================
   Focus Styles
   ============================================ */

.lightbox-nav:focus {
    outline: 2px solid var(--color-gold, #B8985A);
    outline-offset: 4px;
}

.lightbox-nav:focus:not(:focus-visible) {
    outline: none;
}

/* ============================================
   Touch Device Optimizations
   ============================================ */

@media (hover: none) and (pointer: coarse) {
    .lightbox-nav {
        width: 48px;
        height: 48px;
    }
}

/* ============================================
   RTL Support
   ============================================ */

.rtl .lightbox-prev,
body.lang-ar .lightbox-prev {
    left: auto;
    right: 20px;
}

.rtl .lightbox-next,
body.lang-ar .lightbox-next {
    right: auto;
    left: 20px;
}

.rtl .lightbox-prev svg,
body.lang-ar .lightbox-prev svg {
    transform: scaleX(-1);
}

.rtl .lightbox-next svg,
body.lang-ar .lightbox-next svg {
    transform: scaleX(-1);
}

/* ============================================
   Print & Performance
   ============================================ */

@media print {
    .space22-lightbox {
        display: none !important;
    }
}

.space22-lightbox * {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.lightbox-image,
.lightbox-overlay,
.lightbox-nav {
    will-change: transform, opacity;
}

@media (prefers-reduced-motion: reduce) {
    .space22-lightbox,
    .lightbox-image,
    .lightbox-nav,
    .lightbox-loader {
        transition: none;
        animation: none;
    }

    .loader-spinner {
        animation: none;
    }
}

@media (prefers-contrast: high) {
    .lightbox-nav {
        border-width: 3px;
    }
}
