/**
 * Project Gallery Styles
 * Enhanced gallery functionality for single project pages
 */

/* Icon fallbacks for gallery controls */
.gallery-controls button:before,
.thumb-scroll-left:before,
.thumb-scroll-right:before,
.gallery-modal-nav:before,
.gallery-modal-close:before {
    display: inline-block;
    font-style: normal;
    font-weight: bold;
    text-rendering: auto;
    -webkit-font-smoothing: antialiased;
}

.gallery-prev:before,
.gallery-modal-prev:before,
.thumb-scroll-left:before {
    content: "‹";
    font-size: 24px;
}

.gallery-next:before,
.gallery-modal-next:before,
.thumb-scroll-right:before {
    content: "›";
    font-size: 24px;
}

.gallery-fullscreen:before {
    content: "⛶";
    font-size: 18px;
}

.gallery-modal-close:before {
    content: "×";
    font-size: 24px;
}

/* Hide icon fallbacks if real icons are present */
.gallery-controls button i,
.thumb-scroll-left i,
.thumb-scroll-right i,
.gallery-modal-nav i {
    font-size: 16px;
}

.gallery-controls button i + *,
.thumb-scroll-left i + *,
.thumb-scroll-right i + *,
.gallery-modal-nav i + * {
    display: none;
}

/* If icons are present, hide the fallback content */
.gallery-controls button:has(i):before,
.thumb-scroll-left:has(i):before,
.thumb-scroll-right:has(i):before,
.gallery-modal-nav:has(i):before {
    display: none;
}

/* Gallery Section Container */
.project-gallery-section {
    margin-bottom: 30px;
    background: #fff;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

/* Enhanced Gallery with Multiple Images */
.project-gallery-enhanced {
    position: relative;
}

/* Main Gallery Container */
.gallery-main-container {
    position: relative;
    background: #000;
    overflow: hidden;
}

.gallery-main-image {
    position: relative;
    display: block;
    width: 100%;
    height: 500px;
    overflow: hidden;
}

.main-gallery-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: opacity 0.3s ease;
    cursor: pointer;
}

/* Gallery Controls */
.gallery-controls {
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    transform: translateY(-50%);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 20px;
    pointer-events: none;
}

.gallery-controls button {
    background: rgba(255,255,255,0.9);
    border: none;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    pointer-events: auto;
    box-shadow: 0 2px 10px rgba(0,0,0,0.2);
}

.gallery-controls button:hover {
    background: #fff;
    transform: scale(1.1);
}

.gallery-controls button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.gallery-fullscreen {
    position: absolute !important;
    top: 20px !important;
    right: 20px !important;
    transform: none !important;
}

/* Gallery Counter */
.gallery-counter {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0,0,0,0.8);
    color: white;
    padding: 8px 15px;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 500;
}

/* Thumbnails Section */
.gallery-thumbnails {
    position: relative;
    background: var(--background-color);
    padding: 20px;
    border-top: 1px solid var(--background-color-200);
}

.thumbnails-container {
    display: flex;
    gap: 10px;
    overflow-x: auto;
    scroll-behavior: smooth;
    padding: 0 40px;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.thumbnails-container::-webkit-scrollbar {
    display: none;
}

.gallery-thumb {
    flex-shrink: 0;
    width: 80px;
    height: 80px;
    border-radius: 8px;
    overflow: hidden;
    cursor: pointer;
    transition: all 0.3s ease;
    border: 3px solid transparent;
    background: #fff;
}

.gallery-thumb:hover {
    border-color: var(--primary-color);
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
}

.gallery-thumb.active {
    border-color: var(--primary-color);
    box-shadow: 0 4px 15px rgba(75,156,181,0.3);
}

.gallery-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.gallery-thumb:hover img {
    transform: scale(1.1);
}

/* Thumbnail Scroll Buttons */
.thumb-scroll-left,
.thumb-scroll-right {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(255,255,255,0.9);
    border: none;
    width: 35px;
    height: 35px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
    z-index: 2;
}

.thumb-scroll-left {
    left: 5px;
}

.thumb-scroll-right {
    right: 5px;
}

.thumb-scroll-left:hover,
.thumb-scroll-right:hover {
    background: #fff;
    transform: translateY(-50%) scale(1.1);
}

/* Single Image Gallery */
.project-gallery-single .gallery-main {
    position: relative;
    background: #000;
    border-radius: 8px;
    overflow: hidden;
}

.single-gallery-image {
    width: 100%;
    height: 400px;
    object-fit: cover;
    cursor: pointer;
    transition: transform 0.3s ease;
}

.single-gallery-image:hover {
    transform: scale(1.05);
}

/* Fullscreen Modal */
.gallery-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0,0,0,0.95);
    z-index: 9999;
    display: none;
    align-items: center;
    justify-content: center;
}

.gallery-modal.active {
    display: flex;
}

.gallery-modal-content {
    position: relative;
    max-width: 90vw;
    max-height: 90vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.gallery-modal img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    border-radius: 4px;
}

.gallery-modal-close {
    position: absolute;
    top: 20px;
    right: 20px;
    background: rgba(255,255,255,0.9);
    border: none;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 20px;
    transition: all 0.3s ease;
    z-index: 10000;
}

.gallery-modal-close:hover {
    background: #fff;
    transform: scale(1.1);
}

.gallery-modal-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(255,255,255,0.9);
    border: none;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 18px;
}

.gallery-modal-nav:hover {
    background: #fff;
    transform: translateY(-50%) scale(1.1);
}

.gallery-modal-prev {
    left: 30px;
}

.gallery-modal-next {
    right: 30px;
}

.gallery-modal-counter {
    position: absolute;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0,0,0,0.8);
    color: white;
    padding: 10px 20px;
    border-radius: 25px;
    font-size: 16px;
    font-weight: 500;
}

/* RTL Support */
body.rtl .gallery-controls {
    direction: rtl;
}

body.rtl .gallery-controls .gallery-prev {
    order: 2;
}

body.rtl .gallery-controls .gallery-next {
    order: 1;
}

body.rtl .thumb-scroll-left {
    right: 5px;
    left: auto;
}

body.rtl .thumb-scroll-right {
    left: 5px;
    right: auto;
}

body.rtl .gallery-modal-prev {
    right: 30px;
    left: auto;
}

body.rtl .gallery-modal-next {
    left: 30px;
    right: auto;
}

/* Prevent body scroll when modal is open */
body.modal-open {
    overflow: hidden;
    height: 100vh;
}

/* Loading States */
.gallery-loading {
    position: relative;
    overflow: hidden;
}

.gallery-loading::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.4), transparent);
    animation: loading-shimmer 1.5s infinite;
}

@keyframes loading-shimmer {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

/* Responsive Design */
@media (max-width: 768px) {
    .gallery-main-image {
        height: 300px;
    }
    
    .gallery-controls button {
        width: 40px;
        height: 40px;
        font-size: 14px;
    }
    
    .gallery-controls {
        padding: 0 15px;
    }
    
    .gallery-fullscreen {
        top: 15px !important;
        right: 15px !important;
        width: 40px !important;
        height: 40px !important;
    }
    
    .gallery-thumbnails {
        padding: 15px;
    }
    
    .thumbnails-container {
        padding: 0 30px;
    }
    
    .gallery-thumb {
        width: 60px;
        height: 60px;
    }
    
    .thumb-scroll-left,
    .thumb-scroll-right {
        width: 30px;
        height: 30px;
        font-size: 12px;
    }
    
    .single-gallery-image {
        height: 250px;
    }
    
    .gallery-modal-nav {
        width: 50px;
        height: 50px;
        font-size: 16px;
    }
    
    .gallery-modal-prev {
        left: 15px;
    }
    
    .gallery-modal-next {
        right: 15px;
    }
    
    .gallery-modal-close {
        width: 40px;
        height: 40px;
        top: 15px;
        right: 15px;
        font-size: 18px;
    }
}

@media (max-width: 480px) {
    .gallery-main-image {
        height: 250px;
    }
    
    .gallery-controls {
        padding: 0 10px;
    }
    
    .gallery-controls button {
        width: 35px;
        height: 35px;
        font-size: 12px;
    }
    
    .gallery-counter {
        bottom: 15px;
        padding: 6px 12px;
        font-size: 12px;
    }
    
    .gallery-thumbnails {
        padding: 10px;
    }
    
    .thumbnails-container {
        padding: 0 25px;
    }
    
    .gallery-thumb {
        width: 50px;
        height: 50px;
    }
    
    .single-gallery-image {
        height: 200px;
    }
}
