/* ===== VARIABLES ===== */
:root {
    --primary-color: #4361ee;
    --secondary-color: #3a0ca3;
    --accent-color: #f72585;
    --dark-color: #1a1a2e;
    --light-color: #f8f9fa;
    --shadow-3d: 0 20px 40px rgba(0,0,0,0.3);
    --transition-smooth: all 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ===== RESET & BASE ===== */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

/* ===== GALLERY CONTAINER ===== */
.gallery-container {
    padding: 3rem 1rem;
    min-height: 80vh;
    background: #fff;
}

/* ===== GRID VIEW ===== */
.gallery-grid {
    max-width: 1400px;
    margin: 0 auto;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 30px;
    opacity: 0;
    animation: gridAppear 0.8s ease forwards;
}

@keyframes gridAppear {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.grid-item {
    height: 320px;
    perspective: 1200px;
    cursor: pointer;
    position: relative;
    will-change: transform;
    transform-style: preserve-3d;
    backface-visibility: hidden;
}

.card-3d {
    width: 100%;
    height: 100%;
    position: relative;
    transform-style: preserve-3d;
    transition: transform 0.8s cubic-bezier(0.4, 0, 0.2, 1);
    border-radius: 16px;
    will-change: transform;
    backface-visibility: hidden;
}

.grid-item:hover .card-3d {
    transform: rotateY(180deg);
}

/* Card front */
.card-front {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    border-radius: 16px;
    overflow: hidden;
    box-shadow: var(--shadow-3d);
    transform: translateZ(1px);
    will-change: transform;
}

.card-front::before {
    content: '';
    position: absolute;
    inset: 0;
    /* background: linear-gradient(45deg, var(--primary-color), var(--secondary-color)); */
    opacity: 0.8;
    z-index: 1;
    transition: opacity 0.6s ease;
}

.grid-item:hover .card-front::before {
    opacity: 0.6;
}

.card-front img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 1.2s cubic-bezier(0.4, 0, 0.2, 1);
    will-change: transform;
}

.grid-item:hover .card-front img {
    transform: scale(1.08);
}

.card-label {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(to top, rgba(0,0,0,0.9), transparent);
    color: white;
    padding: 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    z-index: 2;
    transform: translateY(0);
    transition: transform 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

.grid-item:hover .card-label {
    transform: translateY(100%);
}

.card-label i {
    font-size: 1.2rem;
    color: #fff;
}

/* Card back */
.card-back {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    border-radius: 16px;
    overflow: hidden;
    box-shadow: var(--shadow-3d);
    background: linear-gradient(135deg, var(--dark-color) 0%, #16213e 100%);
    transform: rotateY(180deg);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    will-change: transform;
}

.back-content {
    text-align: center;
    color: white;
    opacity: 0;
    transform: translateY(30px) scale(0.95);
    transition: all 0.7s cubic-bezier(0.4, 0, 0.2, 1) 0.2s;
    will-change: transform, opacity;
}

.grid-item:hover .back-content {
    opacity: 1;
    transform: translateY(0) scale(1);
}

.back-content h4 {
    margin-bottom: 1rem;
    color: #fff;
    font-size: 1.5rem;
    font-weight: 700;
}

.view-btn {
    background: #10a0a6;
    color: white;
    border: none;
    padding: 0.9rem 2rem;
    border-radius: 30px;
    cursor: pointer;
    font-weight: 600;
    margin-top: 1.5rem;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgb(7, 67, 76);
}

.view-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgb(7, 67, 76);
}

/* ===== LIGHTBOX ===== */
.lightbox {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.98);
    backdrop-filter: blur(20px);
    display: none;
    flex-direction: column;
    z-index: 9999;
    opacity: 0;
    transition: opacity 0.4s ease;
}

.lightbox.active {
    display: flex;
    opacity: 1;
    animation: lightboxEnter 0.5s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

@keyframes lightboxEnter {
    from {
        opacity: 0;
        transform: scale(0.95);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.lightbox-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem 2rem;
    background: rgba(255,255,255,0.03);
    border-bottom: 1px solid rgba(255,255,255,0.08);
}

.lightbox-header h3 {
    color: white;
    font-weight: 400;
    font-size: 1.1rem;
}

.lightbox-header .close-btn {
    background: none;
    border: none;
    color: rgba(255,255,255,0.8);
    font-size: 1.8rem;
    cursor: pointer;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.lightbox-header .close-btn:hover {
    background: rgba(255,255,255,0.1);
    color: var(--accent-color);
    transform: rotate(90deg);
}

.lightbox-body {
    flex: 1;
    display: flex;
    padding: 2rem;
    gap: 2rem;
    overflow: hidden;
}

.lightbox-content {
    flex: 3;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 0;
}

.lightbox-image {
    max-width: 100%;
    max-height: 75vh;
    object-fit: contain;
    border-radius: 12px;
    box-shadow: 0 25px 50px rgba(0,0,0,0.5);
    animation: imageFloat 4s ease-in-out infinite;
    will-change: transform;
    transition: opacity 0.4s ease, transform 0.4s ease;
}

@keyframes imageFloat {
    0%, 100% { 
        transform: translateY(0) scale(1) rotateX(0.5deg); 
    }
    50% { 
        transform: translateY(-15px) scale(1.01) rotateX(0.5deg); 
    }
}

.lightbox-info {
    flex: 1;
    background: rgba(255,255,255,0.04);
    border-radius: 16px;
    padding: 2rem;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255,255,255,0.05);
    animation: slideIn 0.6s cubic-bezier(0.4, 0, 0.2, 1) 0.2s both;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateX(40px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.info-content h4 {
    color: #fff;
    margin-bottom: 0.8rem;
    font-size: 1.4rem;
}

.exif-data {
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
    margin-top: 1.5rem;
    color: rgba(255,255,255,0.7);
}

.exif-data span {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9rem;
}

.exif-data i {
    color: #10a0a6;
    width: 20px;
}

/* ===== LIGHTBOX NAV ===== */
.lightbox-nav {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    background: rgba(255,255,255,0.03);
    gap: 2rem;
}

.thumbnails {
    display: flex;
    gap: 0.8rem;
    padding: 0.5rem;
    max-width: 500px;
    overflow-x: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--primary-color) rgba(255,255,255,0.1);
}

.thumbnails::-webkit-scrollbar {
    height: 4px;
}

.thumbnails::-webkit-scrollbar-track {
    background: rgba(255,255,255,0.1);
    border-radius: 2px;
}

.thumbnails::-webkit-scrollbar-thumb {
    background: var(--primary-color);
    border-radius: 2px;
}

.thumbnails img {
    width: 70px;
    height: 70px;
    object-fit: cover;
    border-radius: 8px;
    cursor: pointer;
    opacity: 0.5;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border: 2px solid transparent;
    flex-shrink: 0;
    will-change: transform, opacity;
}

.thumbnails img.active,
.thumbnails img:hover {
    opacity: 1;
    transform: scale(1.15);
    border-color: var(--accent-color);
    box-shadow: 0 0 20px rgba(247, 37, 133, 0.4);
}

.nav-btn {
    background: rgba(255,255,255,0.08);
    border: none;
    color: white;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1.3rem;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    align-items: center;
    justify-content: center;
}

.nav-btn:hover {
    background: #10a0a6;
    transform: scale(1.1);
    box-shadow: 0 0 20px #10a0a6;
}

.lightbox-actions {
    display: flex;
    justify-content: center;
    gap: 1rem;
    padding: 1.5rem;
    border-top: 1px solid rgba(255,255,255,0.05);
}

.action-btn {
    padding: 0.9rem 1.8rem;
    background: rgba(255,255,255,0.08);
    border: 1px solid rgba(255,255,255,0.1);
    color: white;
    border-radius: 30px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.6rem;
    font-size: 0.95rem;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.action-btn:hover {
    background: #10a0a6;
    transform: translateY(-3px);
    box-shadow: 0 5px 15px #10a0a6;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 1200px) {
    .gallery-grid {
        max-width: 1000px;
    }
}

@media (max-width: 1024px) {
    .lightbox-body {
        flex-direction: column;
        gap: 1.5rem;
    }
    
    .lightbox-info {
        order: -1;
        max-width: 600px;
        margin: 0 auto;
        width: 100%;
    }
    
    .gallery-grid {
        grid-template-columns: repeat(3, 1fr);
    }
    
    .lightbox-content {
        max-height: 60vh;
    }
}

@media (max-width: 768px) {
    .gallery-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 20px;
    }
    
    .grid-item {
        height: 280px;
    }
    
    .lightbox-nav {
        flex-wrap: wrap;
        gap: 1rem;
        padding: 1rem;
    }
    
    .thumbnails {
        order: 1;
        width: 100%;
        justify-content: flex-start;
        max-width: 100%;
    }
    
    .lightbox-actions {
        flex-wrap: wrap;
    }
    
    .lightbox-body {
        padding: 1rem;
    }
}

@media (max-width: 480px) {
    .gallery-grid {
        grid-template-columns: 1fr;
        max-width: 320px;
    }
    
    .grid-item {
        height: 260px;
    }
    
    .lightbox-header {
        padding: 1rem;
    }
    
    .thumbnails img {
        width: 60px;
        height: 60px;
    }
    
    .action-btn {
        padding: 0.8rem 1.2rem;
        font-size: 0.9rem;
    }
}

/* ===== NO IMAGES MESSAGE ===== */
.no-images {
    text-align: center;
    color: rgba(255,255,255,0.6);
    font-size: 1.2rem;
    padding: 4rem;
    grid-column: 1 / -1;
    background: rgba(255,255,255,0.05);
    border-radius: 12px;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255,255,255,0.1);
}

/* ===== PERFORMANCE OPTIMIZATIONS ===== */
@media (prefers-reduced-motion: reduce) {
    .card-3d,
    .card-3d:hover,
    .lightbox-image,
    .grid-item,
    .nav-btn,
    .action-btn,
    .thumbnails img {
        transition: none !important;
        animation: none !important;
    }
    
    .grid-item:hover .card-3d {
        transform: rotateY(180deg);
    }
}