/* Gallery Page Styles */

/* Gallery Hero */
.gallery-hero {
    height: clamp(320px, 50vh, 520px);
    background-image: linear-gradient(rgba(44, 95, 62, 0.35), rgba(44, 95, 62, 0.35)),
                      url('../images/hero/hero-main.jpg');
    /* Gradient covers, image contains so the whole picture is visible */
    background-size: cover, contain;
    background-position: center, center;
    background-repeat: no-repeat, no-repeat;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    text-align: center;
    margin-top: 70px;
}

.gallery-hero h1 {
    font-size: 3rem;
    font-weight: 700;
    margin-bottom: 1rem;
}

.gallery-hero p {
    font-size: 1.2rem;
    opacity: 0.9;
}

/* Ensure eco header texts are readable on hero image */
.gallery-hero .eco-section-title,
.gallery-hero .eco-section-subtitle {
    color: #fff !important;
    text-shadow: 0 2px 8px rgba(0,0,0,.35);
}

/* Give the hero container a subtle backdrop for readability on small screens */
@media (max-width: 768px) {
  .gallery-hero .eco-section-header { 
    background: rgba(0,0,0,0.15); 
    padding: .75rem 1rem; 
    border-radius: 12px; 
  }
}

/* Gallery Filters */
.gallery-filters {
    background: white;
    padding: 2rem 0;
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 70px;
    z-index: 100;
}

.filter-controls {
    display: flex;
    justify-content: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.filter-btn {
    padding: 10px 20px;
    border: 2px solid var(--border-color);
    background: white;
    color: var(--text-secondary);
    border-radius: 25px;
    cursor: pointer;
    font-weight: 500;
    transition: var(--transition);
}

.filter-btn:hover,
.filter-btn.active {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
    transform: translateY(-2px);
}

/* Gallery Section */
.gallery-section {
    padding: 4rem 0;
    background: var(--bg-secondary);
}

.gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 2rem;
}

/* Gallery Item */
.gallery-item {
    background: white;
    border-radius: var(--border-radius);
    overflow: hidden;
    box-shadow: var(--shadow);
    transition: var(--transition);
    cursor: pointer;
    opacity: 1;
    transform: scale(1);
}

.gallery-item:hover {
    transform: translateY(-5px) scale(1.02);
    box-shadow: var(--shadow-hover);
}

.gallery-item.hidden {
    opacity: 0;
    transform: scale(0.8);
    pointer-events: none;
    margin: 0;
    height: 0;
    overflow: hidden;
}

.gallery-item-image {
    position: relative;
    height: 250px;
    overflow: hidden;
}

.gallery-item-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: var(--transition);
}

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

.gallery-item-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(to bottom, transparent, rgba(0, 0, 0, 0.8));
    display: flex;
    align-items: flex-end;
    padding: 1.5rem;
    opacity: 0;
    transition: var(--transition);
}

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

.overlay-content {
    color: white;
}

.overlay-content h4 {
    font-size: 1.2rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.overlay-content p {
    font-size: 0.9rem;
    opacity: 0.9;
}

.gallery-item-info {
    padding: 1.5rem;
}

.gallery-item-info h3 {
    font-size: 1.3rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}

.gallery-item-info p {
    color: var(--text-secondary);
    margin-bottom: 1rem;
    line-height: 1.5;
}

.gallery-item-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.gallery-tag {
    background: var(--bg-secondary);
    color: var(--text-secondary);
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 0.8rem;
    font-weight: 500;
}

.gallery-item-details {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.project-location {
    display: flex;
    align-items: center;
    gap: 0.3rem;
}

.project-date {
    font-weight: 500;
}

/* Lightbox Styles */
.lightbox {
    display: none;
    position: fixed;
    z-index: 2000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    backdrop-filter: blur(5px);
}

.lightbox.active {
    display: flex;
    align-items: center;
    justify-content: center;
}

.lightbox-content {
    display: grid;
    grid-template-columns: 2fr 1fr;
    max-width: 1200px;
    max-height: 90vh;
    width: 90%;
    background: white;
    border-radius: var(--border-radius);
    overflow: hidden;
    position: relative;
    animation: lightboxSlideIn 0.3s ease-out;
}

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

.lightbox-close {
    position: absolute;
    top: 20px;
    right: 20px;
    width: 50px;
    height: 50px;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    border: none;
    border-radius: 50%;
    font-size: 24px;
    cursor: pointer;
    z-index: 2001;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
}

.lightbox-close:hover {
    background: var(--accent-color);
    transform: scale(1.1);
}

.lightbox-image-container {
    position: relative;
    height: 600px;
    background: var(--bg-secondary);
}

.lightbox-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.lightbox-nav {
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    display: flex;
    justify-content: space-between;
    padding: 0 20px;
    transform: translateY(-50%);
}

.lightbox-prev,
.lightbox-next {
    width: 50px;
    height: 50px;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    border: none;
    border-radius: 50%;
    font-size: 18px;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
}

.lightbox-prev:hover,
.lightbox-next:hover {
    background: var(--primary-color);
    transform: scale(1.1);
}

.lightbox-info {
    padding: 2rem;
    overflow-y: auto;
    background: white;
}

.lightbox-info h3 {
    font-size: 1.8rem;
    font-weight: 700;
    margin-bottom: 1rem;
    color: var(--text-primary);
}

.lightbox-info p {
    color: var(--text-secondary);
    line-height: 1.6;
    margin-bottom: 2rem;
}

.lightbox-details {
    margin-bottom: 2rem;
}

.detail-item {
    display: flex;
    justify-content: space-between;
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--border-color);
}

.detail-item:last-child {
    border-bottom: none;
}

.detail-label {
    font-weight: 600;
    color: var(--text-primary);
}

.detail-value {
    color: var(--text-secondary);
}

.lightbox-actions {
    padding-top: 2rem;
    border-top: 2px solid var(--border-color);
}

.lightbox-actions .btn {
    width: 100%;
    justify-content: center;
}

/* Gallery CTA */
.gallery-cta {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    color: white;
    padding: 4rem 0;
}

.cta-content {
    text-align: center;
    max-width: 600px;
    margin: 0 auto;
}

.cta-content h2 {
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 1rem;
}

.cta-content p {
    font-size: 1.2rem;
    opacity: 0.9;
    margin-bottom: 2rem;
    line-height: 1.6;
}

.cta-buttons {
    display: flex;
    justify-content: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.cta-buttons .btn {
    min-width: 180px;
}

.cta-buttons .btn-secondary {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border-color: white;
}

.cta-buttons .btn-secondary:hover {
    background: white;
    color: var(--primary-color);
}

/* Loading States */
.gallery-loading {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 200px;
    font-size: 1.2rem;
    color: var(--text-secondary);
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid var(--border-color);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-right: 1rem;
}

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

/* Responsive Design */
@media (max-width: 768px) {
    .gallery-hero {
        height: 250px;
    }
    
    .gallery-hero h1 {
        font-size: 2.2rem;
    }
    
    .filter-controls {
        gap: 0.5rem;
    }
    
    .filter-btn {
        padding: 8px 16px;
        font-size: 0.9rem;
    }
    
    .gallery-grid {
        grid-template-columns: 1fr;
        gap: 1.5rem;
        padding: 0 10px;
    }
    
    .gallery-item {
        max-width: 100%;
    }
    
    .gallery-item-image {
        height: 200px;
    }
    
    .lightbox-content {
        grid-template-columns: 1fr;
        max-width: 95%;
        max-height: 95vh;
    }
    
    .lightbox-image-container {
        height: 300px;
    }
    
    .lightbox-info {
        padding: 1.5rem;
        max-height: 300px;
    }
    
    .cta-content h2 {
        font-size: 2rem;
    }
    
    .cta-buttons {
        flex-direction: column;
        align-items: center;
    }
    
    .cta-buttons .btn {
        width: 100%;
        max-width: 300px;
    }
}

@media (max-width: 480px) {
    .gallery-hero {
        height: 200px;
        padding: 0 20px;
    }
    
    .gallery-hero h1 {
        font-size: 1.8rem;
    }
    
    .gallery-filters {
        padding: 1.5rem 0;
    }
    
    .filter-controls {
        padding: 0 20px;
    }
    
    .gallery-section {
        padding: 3rem 0;
    }
    
    .gallery-item-info {
        padding: 1rem;
    }
    
    .gallery-item-tags {
        gap: 0.3rem;
    }
    
    .gallery-tag {
        font-size: 0.75rem;
        padding: 3px 6px;
    }
    
    .lightbox-close {
        top: 15px;
        right: 15px;
        width: 40px;
        height: 40px;
        font-size: 20px;
    }
    
    .lightbox-nav {
        padding: 0 15px;
    }
    
    .lightbox-prev,
    .lightbox-next {
        width: 40px;
        height: 40px;
        font-size: 16px;
    }
    
    .lightbox-info {
        padding: 1rem;
    }
    
    .lightbox-info h3 {
        font-size: 1.5rem;
    }
}

/* Gallery Item Animations */
.gallery-item {
    animation: fadeInUp 0.6s ease-out;
}

.gallery-item:nth-child(1) { animation-delay: 0.1s; }
.gallery-item:nth-child(2) { animation-delay: 0.2s; }
.gallery-item:nth-child(3) { animation-delay: 0.3s; }
.gallery-item:nth-child(4) { animation-delay: 0.4s; }
.gallery-item:nth-child(5) { animation-delay: 0.5s; }
.gallery-item:nth-child(6) { animation-delay: 0.6s; }

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Filter Transition */
.gallery-item {
    transition: all 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

.gallery-item.filtering-out {
    opacity: 0;
    transform: scale(0.8) translateY(-20px);
}

.gallery-item.filtering-in {
    opacity: 1;
    transform: scale(1) translateY(0);
}

/* Masonry Layout Enhancement */
@supports (display: grid) {
    .gallery-grid {
        display: grid;
        grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
        grid-auto-rows: auto;
        gap: 2rem;
    }
    
    .gallery-item {
        break-inside: avoid;
    }
}

/* Gallery page cart sidebar - ensure it's properly hidden */
.cart-sidebar {
    position: fixed !important;
    top: 0 !important;
    right: -400px !important;
    width: 400px !important;
    height: 100vh !important;
    background: white !important;
    box-shadow: -5px 0 20px rgba(0, 0, 0, 0.1) !important;
    z-index: 1500 !important;
    transition: right 0.3s ease !important;
    display: flex !important;
    flex-direction: column !important;
}

.cart-sidebar.active {
    right: 0 !important;
}

/* Print Styles */
@media print {
    .gallery-filters,
    .lightbox,
    .gallery-cta,
    .whatsapp-float,
    .cart-sidebar {
        display: none !important;
    }
    
    .gallery-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 1rem;
    }
    
    .gallery-item {
        break-inside: avoid;
        box-shadow: none;
        border: 1px solid #ddd;
    }
}
