* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #667eea;
    --primary-dark: #5a6fd8;
    --secondary-color: #764ba2;
    --accent-color: #f093fb;
    --success-color: #10b981;
    --error-color: #ef4444;
    --warning-color: #f59e0b;
    --text-primary: #1f2937;
    --text-secondary: #6b7280;
    --bg-primary: #ffffff;
    --bg-secondary: #f9fafb;
    --bg-accent: #f3f4f6;
    --border-color: #e5e7eb;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    --border-radius: 12px;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    line-height: 1.6;
    color: var(--text-primary);
    background: linear-gradient(135deg, var(--bg-secondary) 0%, #e0e7ff 100%);
    min-height: 100vh;
}

/* Container */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 2rem;
}

/* Header */
.header {
    background: var(--bg-primary);
    box-shadow: var(--shadow-md);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 2rem;
}

.header h1 {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    font-size: 1.75rem;
    font-weight: 700;
}

.nav {
    display: flex;
    gap: 2rem;
}

.nav-link {
    text-decoration: none;
    color: var(--text-secondary);
    font-weight: 500;
    padding: 0.5rem 1rem;
    border-radius: var(--border-radius);
    transition: var(--transition);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.nav-link:hover,
.nav-link.active {
    color: var(--primary-color);
    background: var(--bg-accent);
}

/* Main */
.main {
    flex: 1;
    padding: 2rem 0;
}

/* Alerts */
.alert {
    padding: 1rem 1.5rem;
    border-radius: var(--border-radius);
    margin-bottom: 2rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-weight: 500;
}

.alert-success {
    background: #dcfce7;
    color: #065f46;
    border: 1px solid #bbf7d0;
}

.alert-error {
    background: #fef2f2;
    color: #991b1b;
    border: 1px solid #fecaca;
}

/* Hero Section */
.hero {
    text-align: center;
    margin-bottom: 3rem;
}

.hero-content h2 {
    font-size: 3rem;
    font-weight: 800;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 1rem;
}

.hero-content p {
    font-size: 1.25rem;
    color: var(--text-secondary);
    max-width: 600px;
    margin: 0 auto;
}

/* Upload Section */
.upload-section {
    margin-bottom: 4rem;
}

.upload-card {
    background: var(--bg-primary);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-lg);
    padding: 3rem;
    max-width: 800px;
    margin: 0 auto;
}

.upload-form {
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

/* File Input */
.file-input-wrapper {
    position: relative;
}

.file-input {
    position: absolute;
    opacity: 0;
    width: 100%;
    height: 100%;
    cursor: pointer;
}

.file-label {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem;
    border: 2px dashed var(--border-color);
    border-radius: var(--border-radius);
    background: var(--bg-secondary);
    cursor: pointer;
    transition: var(--transition);
    min-height: 200px;
}

.file-label:hover {
    border-color: var(--primary-color);
    background: #f0f4ff;
}

.file-label i {
    font-size: 3rem;
    color: var(--primary-color);
    margin-bottom: 1rem;
}

.file-text {
    font-size: 1.125rem;
    font-weight: 500;
    color: var(--text-primary);
}

/* File Preview */
.file-preview {
    margin-top: 1rem;
    display: none;
}

.file-preview.show {
    display: block;
}

.file-preview img {
    max-width: 100%;
    max-height: 300px;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-md);
    margin: 0 auto;
    display: block;
}

.file-preview-info {
    text-align: center;
    margin-top: 1rem;
    padding: 1rem;
    background: var(--bg-accent);
    border-radius: var(--border-radius);
}

/* Instruction Input */
.instruction-input {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.instruction-input label {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 1.125rem;
}

.instruction-input textarea {
    padding: 1rem;
    border: 2px solid var(--border-color);
    border-radius: var(--border-radius);
    font-size: 1rem;
    font-family: inherit;
    resize: vertical;
    transition: var(--transition);
    background: var(--bg-primary);
}

.instruction-input textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.instruction-input textarea::placeholder {
    color: var(--text-secondary);
}

/* Buttons */
.btn, .submit-btn {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: white;
    border: none;
    padding: 1rem 2rem;
    border-radius: var(--border-radius);
    font-size: 1.125rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    text-decoration: none;
    justify-content: center;
}

.btn:hover, .submit-btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
}

.btn-secondary {
    background: linear-gradient(135deg, var(--text-secondary), #4b5563);
}

/* Examples Section */
.examples {
    margin-bottom: 3rem;
}

.examples h3 {
    text-align: center;
    font-size: 2rem;
    margin-bottom: 2rem;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
}

.examples-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 2rem;
    max-width: 1000px;
    margin: 0 auto;
}

.example-card {
    background: var(--bg-primary);
    padding: 2rem;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-md);
    text-align: center;
    transition: var(--transition);
}

.example-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-lg);
}

.example-card i {
    font-size: 2.5rem;
    color: var(--primary-color);
    margin-bottom: 1rem;
}

.example-card h4 {
    font-size: 1.25rem;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}

.example-card p {
    color: var(--text-secondary);
    line-height: 1.5;
}

/* Processing Page */
.processing-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 60vh;
}

.processing-card {
    background: var(--bg-primary);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-lg);
    padding: 3rem;
    text-align: center;
    max-width: 600px;
    width: 100%;
}

.loading-spinner {
    font-size: 4rem;
    color: var(--primary-color);
    margin-bottom: 2rem;
}

.processing-card h2 {
    font-size: 2rem;
    margin-bottom: 1rem;
    color: var(--text-primary);
}

.processing-card p {
    color: var(--text-secondary);
    font-size: 1.125rem;
    margin-bottom: 2rem;
}

.processing-details {
    background: var(--bg-accent);
    padding: 1.5rem;
    border-radius: var(--border-radius);
    margin-bottom: 2rem;
    text-align: left;
}

.detail-item {
    margin-bottom: 0.5rem;
    word-wrap: break-word;
}

.detail-item:last-child {
    margin-bottom: 0;
}

/* Progress Bar */
.progress-bar {
    width: 100%;
    height: 8px;
    background: var(--bg-accent);
    border-radius: 4px;
    margin-bottom: 1rem;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    border-radius: 4px;
    width: 0%;
    transition: width 0.5s ease;
}

.processing-status {
    color: var(--text-secondary);
    font-style: italic;
    margin-bottom: 2rem;
}

/* Result Containers */
.result-container {
    margin-top: 2rem;
}

.result-success,
.result-error {
    padding: 2rem;
    border-radius: var(--border-radius);
    text-align: center;
}

.result-success {
    background: #dcfce7;
    border: 1px solid #bbf7d0;
    color: #065f46;
}

.result-error {
    background: #fef2f2;
    border: 1px solid #fecaca;
    color: #991b1b;
}

.result-success i {
    font-size: 3rem;
    margin-bottom: 1rem;
}

.result-error i {
    font-size: 3rem;
    margin-bottom: 1rem;
}

.processed-images {
    display: grid;
    gap: 2rem;
    margin: 2rem 0;
}

.processed-image {
    background: var(--bg-primary);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-md);
    overflow: hidden;
}

.processed-image img {
    width: 100%;
    height: auto;
    display: block;
}

.image-info {
    padding: 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--bg-primary);
}

.image-filename {
    font-weight: 500;
    color: var(--text-primary);
}

.download-btn {
    background: var(--primary-color);
    color: white;
    text-decoration: none;
    padding: 0.5rem 1rem;
    border-radius: 6px;
    font-size: 0.875rem;
    transition: var(--transition);
}

.download-btn:hover {
    background: var(--primary-dark);
}

.result-actions {
    display: flex;
    gap: 1rem;
    justify-content: center;
    margin-top: 2rem;
}

/* Gallery */
.gallery-header {
    text-align: center;
    margin-bottom: 3rem;
}

.gallery-header h2 {
    font-size: 2.5rem;
    margin-bottom: 1rem;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
}

.gallery-header p {
    font-size: 1.25rem;
    color: var(--text-secondary);
}

.empty-gallery {
    text-align: center;
    padding: 4rem 2rem;
    background: var(--bg-primary);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-md);
}

.empty-gallery i {
    font-size: 4rem;
    color: var(--text-secondary);
    margin-bottom: 1rem;
}

.empty-gallery h3 {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}

.empty-gallery p {
    color: var(--text-secondary);
    margin-bottom: 2rem;
}

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

.gallery-item {
    background: var(--bg-primary);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-md);
    overflow: hidden;
    transition: var(--transition);
}

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

.gallery-image {
    position: relative;
    aspect-ratio: 1;
    overflow: hidden;
}

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

.gallery-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: var(--transition);
}

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

.gallery-actions {
    display: flex;
    gap: 1rem;
}

.action-btn {
    background: var(--bg-primary);
    color: var(--text-primary);
    border: none;
    padding: 0.75rem;
    border-radius: 50%;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 50px;
    height: 50px;
}

.action-btn:hover {
    background: var(--primary-color);
    color: white;
}

.gallery-info {
    padding: 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.gallery-filename {
    font-weight: 500;
    color: var(--text-primary);
    font-size: 0.875rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 200px;
}

.gallery-date {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    justify-content: center;
    align-items: center;
    padding: 2rem;
}

.modal-content {
    position: relative;
    max-width: 90vw;
    max-height: 90vh;
    text-align: center;
}

.modal-close {
    position: absolute;
    top: -40px;
    right: 0;
    color: white;
    font-size: 2rem;
    font-weight: bold;
    cursor: pointer;
    z-index: 1001;
}

.modal-close:hover {
    color: var(--accent-color);
}

.modal img {
    max-width: 100%;
    max-height: 70vh;
    border-radius: var(--border-radius);
}

.modal-info {
    background: var(--bg-primary);
    padding: 1.5rem;
    border-radius: var(--border-radius);
    margin-top: 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-info h4 {
    color: var(--text-primary);
    margin: 0;
}

/* Footer */
.footer {
    background: var(--bg-primary);
    padding: 2rem 0;
    text-align: center;
    color: var(--text-secondary);
    border-top: 1px solid var(--border-color);
}

/* Responsive Design */
@media (max-width: 768px) {
    .container {
        padding: 0 1rem;
    }
    
    .header .container {
        flex-direction: column;
        gap: 1rem;
    }
    
    .nav {
        gap: 1rem;
    }
    
    .hero-content h2 {
        font-size: 2rem;
    }
    
    .upload-card {
        padding: 2rem 1rem;
    }
    
    .examples-grid {
        grid-template-columns: 1fr;
    }
    
    .gallery-grid {
        grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
        gap: 1rem;
    }
    
    .result-actions {
        flex-direction: column;
    }
    
    .modal-content {
        padding: 1rem;
    }
    
    .modal-info {
        flex-direction: column;
        gap: 1rem;
        align-items: stretch;
    }
}

@media (max-width: 480px) {
    .hero-content h2 {
        font-size: 1.5rem;
    }
    
    .hero-content p {
        font-size: 1rem;
    }
    
    .upload-card {
        padding: 1.5rem 1rem;
    }
    
    .file-label {
        padding: 2rem 1rem;
        min-height: 150px;
    }
    
    .file-label i {
        font-size: 2rem;
    }
    
    .processing-card {
        padding: 2rem 1rem;
    }
    
    .gallery-grid {
        grid-template-columns: 1fr;
    }
}