/* ============================================
   Gallery Page Styles
   ============================================ */

.gallery-header {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: var(--white);
    padding: 4rem 0;
    text-align: center;
}

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

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

/* Filter Section */
.filter-section {
    background: var(--light-color);
    padding: 2rem 0;
    position: sticky;
    top: 70px;
    z-index: 100;
    box-shadow: var(--shadow-sm);
    transition: transform 0.3s ease, opacity 0.3s ease;
    will-change: transform, opacity;
    backface-visibility: hidden;
    transform: translateZ(0);
}

.products-section {
    transition: transform 0.3s ease, opacity 0.3s ease;
}

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

.filter-tab {
    padding: 0.8rem 2rem;
    background: var(--white);
    border: 2px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-dark);
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    font-family: 'Cairo', sans-serif;
}

.filter-tab:hover {
    border-color: var(--primary-color);
    color: var(--primary-color);
}

.filter-tab.active {
    background: var(--primary-color);
    color: var(--white);
    border-color: var(--primary-color);
}

/* Products Section */
.products-section {
    padding: 4rem 0;
}

.products-section:nth-child(even) {
    background: var(--light-color);
}

.products-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    grid-auto-rows: auto;
    gap: 2rem;
    margin-top: 2rem;
    contain: layout;
}

.product-card {
    background: var(--white);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: var(--shadow-md);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    position: relative;
    will-change: transform;
    contain: layout style paint;
}

.product-card:hover {
    transform: translateY(-5px) translateZ(0);
    box-shadow: var(--shadow-xl);
}

.product-card.hidden {
    display: none;
}

.product-image {
    position: relative;
    width: 100%;
    height: 300px;
    overflow: hidden;
    background: linear-gradient(135deg, #f5f5f5 0%, #ffffff 100%);
    aspect-ratio: 1 / 1;
    will-change: transform;
    contain: layout style paint;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 10px;
    box-sizing: border-box;
}

.product-image img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    object-position: center;
    transition: transform 0.3s ease, opacity 0.3s ease;
    image-rendering: -webkit-optimize-contrast;
    image-rendering: auto;
    will-change: transform;
    backface-visibility: hidden;
    transform: translateZ(0);
    max-width: 100%;
    max-height: 100%;
}

.product-card:hover .product-image img {
    transform: scale(1.08) translateZ(0);
}

.product-img-clickable {
    cursor: pointer;
    transition: var(--transition);
}

.product-img-clickable:hover {
    opacity: 0.9;
}

/* Image Modal Styles */
.image-modal {
    display: none;
    position: fixed;
    z-index: 3000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.95);
    backdrop-filter: blur(10px);
    animation: fadeIn 0.3s ease;
    overflow: auto;
}

.image-modal.active {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
}

.modal-close {
    position: absolute;
    top: 20px;
    left: 20px;
    color: var(--white);
    font-size: 3rem;
    font-weight: bold;
    cursor: pointer;
    z-index: 3001;
    width: 50px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 50%;
    transition: var(--transition);
    backdrop-filter: blur(10px);
}

.modal-close:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: rotate(90deg);
}

.modal-image-content {
    max-width: 90%;
    max-height: 90vh;
    width: auto;
    height: auto;
    object-fit: contain;
    border-radius: 12px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    animation: zoomIn 0.3s ease;
}

.modal-caption {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    color: var(--white);
    text-align: center;
    padding: 1rem 2rem;
    background: rgba(0, 0, 0, 0.5);
    border-radius: 8px;
    backdrop-filter: blur(10px);
}

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

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

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

/* Performance Optimizations */
.product-image img[loading="lazy"] {
    opacity: 0;
    animation: fadeInImage 0.3s ease forwards;
}

@keyframes fadeInImage {
    to {
        opacity: 1;
    }
}

/* Ensure images are fully visible and clear */
.product-image img {
    filter: brightness(1) contrast(1.02);
    -webkit-filter: brightness(1) contrast(1.02);
}

.product-card:hover .product-image img {
    filter: brightness(1.05) contrast(1.05);
    -webkit-filter: brightness(1.05) contrast(1.05);
}

/* Responsive */
@media (max-width: 768px) {
    .gallery-header h1 {
        font-size: 2rem;
    }

    .filter-tabs {
        gap: 0.5rem;
    }

    .filter-tab {
        padding: 0.6rem 1.5rem;
        font-size: 0.9rem;
    }

    .products-grid {
        grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
        gap: 1.5rem;
    }

    .product-image {
        height: 250px;
    }
}

@media (max-width: 480px) {
    .products-grid {
        grid-template-columns: 1fr;
    }

    .filter-tab {
        padding: 0.5rem 1rem;
        font-size: 0.85rem;
    }
}

