/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: #f5f5f5;
    color: #333;
    line-height: 1.6;
}

/* Header */
header {
    background: white;
    padding: 2rem;
    text-align: center;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    margin-bottom: 2rem;
}

header h1 {
    font-size: 2.5rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: #2c3e50;
}

header p {
    font-size: 1.1rem;
    color: #7f8c8d;
}

/* Main container */
main {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 1rem 3rem;
}

/* Gallery grid */
#gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 1.5rem;
    margin-bottom: 3rem;
}

/* Gallery item card */
.gallery-item {
    position: relative;
    aspect-ratio: 1;
    cursor: pointer;
    overflow: hidden;
    border-radius: 12px;
    background: white;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.gallery-item:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.15);
}

.gallery-item img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: opacity 0.3s ease;
}

.gallery-item .original-image {
    opacity: 1;
    z-index: 1;
}

.gallery-item .ai-image {
    opacity: 0;
    z-index: 2;
}

.gallery-item:hover .ai-image {
    opacity: 1;
}

/* Load More button */
.load-more-btn {
    display: block;
    margin: 0 auto;
    padding: 1rem 3rem;
    font-size: 1rem;
    font-weight: 600;
    color: white;
    background: #3498db;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.3s ease, transform 0.2s ease;
    box-shadow: 0 4px 12px rgba(52, 152, 219, 0.3);
}

.load-more-btn:hover {
    background: #2980b9;
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(52, 152, 219, 0.4);
}

.load-more-btn:active {
    transform: translateY(0);
}

/* Modal */
.modal {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.modal.hidden {
    display: none;
}

.modal-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.9);
    backdrop-filter: blur(4px);
}

.modal-content {
    position: relative;
    background: white;
    border-radius: 16px;
    padding: 2rem;
    max-width: 1200px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    z-index: 1001;
}

.close-btn {
    position: absolute;
    top: 1rem;
    right: 1rem;
    width: 40px;
    height: 40px;
    font-size: 2rem;
    color: #7f8c8d;
    background: #ecf0f1;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s ease, color 0.2s ease;
    z-index: 10;
}

.close-btn:hover {
    background: #e74c3c;
    color: white;
}

/* Modal title */
.modal-title {
    font-size: 1.5rem;
    font-weight: 600;
    color: #2c3e50;
    margin-bottom: 1.5rem;
    padding-right: 3rem;
}

/* Image comparison section */
.image-comparison {
    display: flex;
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.image-container {
    flex: 1;
    min-width: 0;
}

.image-container h3 {
    font-size: 1.2rem;
    margin-bottom: 0.75rem;
    color: #2c3e50;
}

.image-container img {
    width: 100%;
    height: auto;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

/* Model container */
.model-container {
    margin-top: 2rem;
}

.model-container h3 {
    font-size: 1.2rem;
    margin-bottom: 1rem;
    color: #2c3e50;
}

model-viewer {
    width: 100%;
    height: 500px;
    background: #fafafa;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

/* Model unavailable message */
.model-unavailable {
    margin-top: 2rem;
    padding: 2rem;
    background: #ecf0f1;
    border-radius: 8px;
    text-align: center;
}

.model-unavailable h3 {
    font-size: 1.2rem;
    margin-bottom: 0.75rem;
    color: #2c3e50;
}

.unavailable-message {
    color: #7f8c8d;
    font-size: 1rem;
}

.hidden {
    display: none;
}

/* Responsive design */
@media (max-width: 1024px) {
    #gallery-grid {
        grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
        gap: 1.25rem;
    }

    model-viewer {
        height: 400px;
    }
}

@media (max-width: 768px) {
    header h1 {
        font-size: 2rem;
    }

    header p {
        font-size: 1rem;
    }

    #gallery-grid {
        grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
        gap: 1rem;
    }

    .image-comparison {
        flex-direction: column;
    }

    .modal-content {
        padding: 1.5rem;
    }

    .modal-title {
        font-size: 1.25rem;
    }

    model-viewer {
        height: 350px;
    }
}

@media (max-width: 480px) {
    header {
        padding: 1.5rem 1rem;
    }

    header h1 {
        font-size: 1.5rem;
    }

    #gallery-grid {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
        gap: 0.75rem;
    }

    .modal-content {
        padding: 1rem;
        border-radius: 12px;
    }

    .modal-title {
        font-size: 1.1rem;
    }

    .load-more-btn {
        padding: 0.875rem 2rem;
        font-size: 0.95rem;
    }

    model-viewer {
        height: 300px;
    }
}

/* Loading animation for images */
.gallery-item img {
    animation: fadeIn 0.3s ease-in;
}

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

/* Smooth scroll behavior */
html {
    scroll-behavior: smooth;
}
