/* ===================================
   Lightbox Gallery Styles
   =================================== */

/* Gallery Grid Layout */
.lightbox-gallery {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    padding: 20px 0;
}

/* Gallery Items */
.gallery-item {
    position: relative;
    overflow: hidden;
    border-radius: 8px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
    cursor: pointer;
    aspect-ratio: 1/1;
}

.gallery-item:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.2);
}

.gallery-item a {
    display: block;
    position: relative;
    width: 100%;
    height: 100%;
}

.gallery-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform 0.4s ease;
}

.gallery-item:hover img {
    transform: scale(1.1);
}

/* Gallery Overlay */
.gallery-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.gallery-item:hover .gallery-overlay {
    opacity: 1;
}

.gallery-overlay i {
    color: #fff;
    font-size: 32px;
    animation: zoomIcon 0.6s ease;
}

@keyframes zoomIcon {
    0% {
        transform: scale(0);
    }
    50% {
        transform: scale(1.2);
    }
    100% {
        transform: scale(1);
    }
}

/* ===================================
   Lightbox Modal
   =================================== */

.lightbox-modal {
    display: none;
    position: fixed;
    z-index: 9999;
    padding-top: 60px;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0, 0, 0, 0.95);
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.lightbox-modal.active {
    display: block;
}

/* Modal Content (Image) */
.lightbox-content {
    margin: auto;
    display: block;
    max-width: 90%;
    max-height: 80vh;
    object-fit: contain;
    animation: zoomIn 0.3s ease;
}

@keyframes zoomIn {
    from {
        transform: scale(0.8);
        opacity: 0;
    }
    to {
        transform: scale(1);
        opacity: 1;
    }
}

/* Caption */
.lightbox-caption {
    margin: auto;
    display: block;
    width: 80%;
    max-width: 700px;
    text-align: center;
    color: #ccc;
    padding: 15px 0;
    font-size: 16px;
}

/* Close Button */
.lightbox-close {
    position: absolute;
    top: 20px;
    right: 40px;
    color: #fff;
    font-size: 45px;
    font-weight: bold;
    transition: 0.3s;
    cursor: pointer;
    z-index: 10000;
}

.lightbox-close:hover,
.lightbox-close:focus {
    color: #bbb;
    text-decoration: none;
    cursor: pointer;
}

/* Navigation Arrows */
.lightbox-prev,
.lightbox-next {
    cursor: pointer;
    position: absolute;
    top: 50%;
    width: auto;
    padding: 16px;
    margin-top: -50px;
    color: white;
    font-weight: bold;
    font-size: 40px;
    transition: 0.3s ease;
    border-radius: 0 3px 3px 0;
    user-select: none;
    background-color: rgba(0, 0, 0, 0.5);
}

.lightbox-next {
    right: 0;
    border-radius: 3px 0 0 3px;
}

.lightbox-prev {
    left: 0;
    border-radius: 0 3px 3px 0;
}

.lightbox-prev:hover,
.lightbox-next:hover {
    background-color: rgba(0, 0, 0, 0.8);
}

/* ===================================
   Responsive Design
   =================================== */

/* Tablets */
@media screen and (max-width: 992px) {
    .lightbox-gallery {
        grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
        gap: 15px;
    }

    .lightbox-content {
        max-width: 95%;
    }

    .lightbox-prev,
    .lightbox-next {
        font-size: 30px;
        padding: 12px;
    }
}

/* Mobile Phones */
@media screen and (max-width: 768px) {
    .lightbox-gallery {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }

    .gallery-item {
        aspect-ratio: 1/1;
    }

    .lightbox-modal {
        padding-top: 40px;
    }

    .lightbox-content {
        max-width: 100%;
        max-height: 70vh;
    }

    .lightbox-close {
        top: 10px;
        right: 20px;
        font-size: 35px;
    }

    .lightbox-prev,
    .lightbox-next {
        font-size: 25px;
        padding: 10px;
        margin-top: -40px;
    }

    .gallery-overlay i {
        font-size: 24px;
    }

    .lightbox-caption {
        font-size: 14px;
        width: 90%;
    }
}

/* Small Mobile Phones */
@media screen and (max-width: 480px) {
    .lightbox-gallery {
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
    }

    .gallery-item {
        border-radius: 5px;
    }

    .lightbox-prev,
    .lightbox-next {
        font-size: 20px;
        padding: 8px;
    }
}

/* ===================================
   Loading Animation
   =================================== */

.lightbox-content.loading {
    opacity: 0.5;
}

.lightbox-modal::before {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 50px;
    height: 50px;
    border: 5px solid #f3f3f3;
    border-top: 5px solid #3498db;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    display: none;
}

.lightbox-modal.loading::before {
    display: block;
}

@keyframes spin {
    0% {
        transform: translate(-50%, -50%) rotate(0deg);
    }
    100% {
        transform: translate(-50%, -50%) rotate(360deg);
    }
}

/* ===================================
   Accessibility
   =================================== */

.gallery-item:focus-within {
    outline: 3px solid #3498db;
    outline-offset: 2px;
}

.lightbox-close:focus,
.lightbox-prev:focus,
.lightbox-next:focus {
    outline: 2px solid #fff;
    outline-offset: 2px;
}

/* Keyboard Navigation Indicator */
.keyboard-nav .gallery-item:focus {
    box-shadow: 0 0 0 3px #3498db;
}
