/* Scene Generator - Premium Dark Theme */

:root {
    /* Background colors */
    --bg-primary: #0a0a0f;
    --bg-secondary: #12121a;
    --bg-tertiary: #1a1a25;
    --bg-card: rgba(26, 26, 40, 0.8);
    --bg-glass: rgba(255, 255, 255, 0.03);

    /* Accent colors */
    --accent-primary: #8b5cf6;
    --accent-secondary: #a78bfa;
    --accent-glow: rgba(139, 92, 246, 0.3);
    --accent-gradient: linear-gradient(135deg, #8b5cf6 0%, #ec4899 100%);

    /* Text colors */
    --text-primary: #f4f4f5;
    --text-secondary: #a1a1aa;
    --text-muted: #71717a;

    /* Border colors */
    --border-color: rgba(255, 255, 255, 0.08);
    --border-hover: rgba(139, 92, 246, 0.4);

    /* Success/Error */
    --success: #22c55e;
    --error: #ef4444;
    --warning: #f59e0b;

    /* Shadows */
    --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.5);
    --shadow-glow: 0 0 40px rgba(139, 92, 246, 0.15);

    /* Spacing */
    --space-xs: 0.25rem;
    --space-sm: 0.5rem;
    --space-md: 1rem;
    --space-lg: 1.5rem;
    --space-xl: 2rem;
    --space-2xl: 3rem;

    /* Border radius */
    --radius-sm: 0.5rem;
    --radius-md: 0.75rem;
    --radius-lg: 1rem;
    --radius-xl: 1.5rem;

    /* Transitions */
    --transition-fast: 150ms ease;
    --transition-normal: 250ms ease;
    --transition-slow: 400ms ease;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html,
body {
    max-width: 100vw;
    overflow-x: hidden;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
}

.main-container {
    min-height: 100vh;
    background:
        radial-gradient(ellipse 80% 50% at 50% -20%, rgba(139, 92, 246, 0.15), transparent),
        radial-gradient(ellipse 60% 40% at 80% 100%, rgba(236, 72, 153, 0.1), transparent),
        var(--bg-primary);
}

.header {
    position: sticky;
    top: 0;
    z-index: 100;
    padding: var(--space-lg) var(--space-xl);
    background: rgba(10, 10, 15, 0.8);
    backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border-color);
}

.header-content {
    max-width: 1400px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo {
    font-size: 1.5rem;
    font-weight: 700;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: var(--space-xl);
}

.glass-card {
    background: var(--bg-card);
    backdrop-filter: blur(16px);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: var(--space-xl);
    box-shadow: var(--shadow-lg);
    transition: all var(--transition-normal);
    margin-bottom: var(--space-xl);
}

.glass-card:hover {
    border-color: var(--border-hover);
    box-shadow: var(--shadow-lg), var(--shadow-glow);
}

.error-card {
    border-color: var(--error) !important;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-sm);
    padding: var(--space-md) var(--space-xl);
    border: none;
    border-radius: var(--radius-md);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-fast);
    text-decoration: none;
}

.btn-primary {
    background: var(--accent-gradient);
    color: white;
    box-shadow: var(--shadow-md), 0 0 20px rgba(139, 92, 246, 0.3);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg), 0 0 40px rgba(139, 92, 246, 0.4);
}

.btn-primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.btn-secondary {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    background: var(--bg-card);
    border-color: var(--border-hover);
}

.btn-sm {
    padding: var(--space-sm) var(--space-md);
    font-size: 0.875rem;
}

.textarea {
    width: 100%;
    min-height: 200px;
    padding: var(--space-lg);
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 1rem;
    line-height: 1.7;
    resize: vertical;
    transition: all var(--transition-fast);
}

.textarea:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

.textarea::placeholder {
    color: var(--text-muted);
}

.input {
    width: 100%;
    padding: var(--space-md) var(--space-lg);
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 1rem;
    transition: all var(--transition-fast);
}

.input:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

.section-header {
    margin-bottom: var(--space-lg);
}

.section-title {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: var(--space-xs);
}

.section-subtitle {
    color: var(--text-secondary);
    font-size: 0.95rem;
}

/* Workflow Steps */
.workflow-steps {
    display: flex;
    gap: var(--space-md);
    margin-bottom: var(--space-2xl);
    flex-wrap: wrap;
}

.workflow-step {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-sm) var(--space-md);
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
    color: var(--text-muted);
    font-size: 0.875rem;
    border: 1px solid var(--border-color);
}

.workflow-step.active {
    background: var(--accent-glow);
    border-color: var(--accent-primary);
    color: var(--text-primary);
}

.workflow-step.completed {
    background: rgba(34, 197, 94, 0.1);
    border-color: var(--success);
    color: var(--success);
}

.step-number {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-secondary);
    border-radius: 50%;
    font-weight: 700;
    font-size: 0.75rem;
}

.workflow-step.active .step-number {
    background: var(--accent-gradient);
    color: white;
}

.workflow-step.completed .step-number {
    background: var(--success);
    color: white;
}

/* API Key Section */
.api-key-section {
    margin-bottom: var(--space-xl);
}

.api-key-input-wrapper {
    display: flex;
    gap: var(--space-md);
    align-items: center;
}

.api-key-input {
    flex: 1;
}

/* Scene Card */
.scene-card {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    overflow: hidden;
    transition: all var(--transition-normal);
    margin-bottom: var(--space-md);
}

.scene-card.expanded {
    border-color: var(--accent-primary);
}

.scene-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-lg);
    cursor: pointer;
    transition: background var(--transition-fast);
}

.scene-header:hover {
    background: var(--bg-glass);
}

.scene-number {
    display: flex;
    align-items: center;
    gap: var(--space-md);
}

.scene-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    background: var(--accent-gradient);
    border-radius: 50%;
    font-weight: 700;
    font-size: 0.875rem;
}

.scene-title {
    font-weight: 600;
    color: var(--text-primary);
}

.scene-toggle {
    color: var(--text-muted);
    transition: transform var(--transition-fast);
}

.scene-toggle.expanded {
    transform: rotate(180deg);
}

.scene-content {
    padding: 0 var(--space-lg) var(--space-lg);
    display: none;
}

.scene-card.expanded .scene-content {
    display: block;
}

.script-line {
    background: var(--bg-secondary);
    border-left: 3px solid var(--accent-primary);
    padding: var(--space-md) var(--space-lg);
    margin-bottom: var(--space-lg);
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    font-style: italic;
    color: var(--text-secondary);
}

.scene-description {
    color: var(--text-primary);
    line-height: 1.8;
    margin-bottom: var(--space-lg);
}

.image-prompt-box {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: var(--space-md);
    margin-bottom: var(--space-lg);
}

.image-prompt-label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--accent-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: var(--space-sm);
}

.image-prompt-text {
    font-size: 0.9rem;
    color: var(--text-secondary);
    line-height: 1.6;
}

.scene-image {
    width: 100%;
    border-radius: var(--radius-md);
    margin-bottom: var(--space-md);
}

/* Model Selector */
.model-selector {
    display: flex;
    gap: var(--space-md);
    margin-bottom: var(--space-lg);
}

.model-option {
    flex: 1;
    padding: var(--space-lg);
    background: var(--bg-tertiary);
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.model-option:hover {
    border-color: var(--border-hover);
}

.model-option.selected {
    border-color: var(--accent-primary);
    background: var(--accent-glow);
}

.model-name {
    font-weight: 600;
    margin-bottom: var(--space-xs);
}

.model-description {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

/* Progress Bar */
.progress-container {
    width: 100%;
    height: 8px;
    background: var(--bg-secondary);
    border-radius: var(--radius-sm);
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    background: var(--accent-gradient);
    border-radius: var(--radius-sm);
    transition: width var(--transition-normal);
}

/* Image Gallery */
.image-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: var(--space-lg);
}

.image-item {
    position: relative;
    border-radius: var(--radius-md);
    overflow: hidden;
    background: var(--bg-tertiary);
    aspect-ratio: 16/9;
}

.image-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform var(--transition-normal);
    cursor: pointer;
}

.image-item:hover img {
    transform: scale(1.05);
}

.image-overlay {
    position: absolute;
    inset: 0;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.8), transparent);
    opacity: 0;
    transition: opacity var(--transition-fast);
    display: flex;
    align-items: flex-end;
    padding: var(--space-md);
}

.image-item:hover .image-overlay {
    opacity: 1;
}

/* Status Badges */
.status-badge {
    display: inline-flex;
    align-items: center;
    gap: var(--space-xs);
    padding: var(--space-xs) var(--space-sm);
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    font-weight: 600;
}

.status-success {
    background: rgba(34, 197, 94, 0.15);
    color: var(--success);
}

.status-error {
    background: rgba(239, 68, 68, 0.15);
    color: var(--error);
}

/* Spinner */
.spinner {
    width: 20px;
    height: 20px;
    border: 2px solid var(--bg-tertiary);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    display: inline-block;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Lightbox */
.lightbox {
    position: fixed;
    inset: 0;
    z-index: 1000;
    background: rgba(0, 0, 0, 0.95);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--space-xl);
    animation: fadeIn var(--transition-fast);
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

.lightbox-content {
    max-width: 90vw;
    max-height: 90vh;
    object-fit: contain;
    border-radius: var(--radius-md);
}

.lightbox-close {
    position: absolute;
    top: var(--space-xl);
    right: var(--space-xl);
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-tertiary);
    border: none;
    border-radius: 50%;
    color: var(--text-primary);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.lightbox-close:hover {
    background: var(--bg-card);
    transform: scale(1.1);
}

/* History List */
.history-list {
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
    margin-top: var(--space-lg);
}

.history-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-md) var(--space-lg);
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    transition: all var(--transition-fast);
    cursor: pointer;
}

.history-item:hover {
    border-color: var(--border-hover);
    background: var(--bg-glass);
}

.history-info {
    flex: 1;
}

.history-title {
    font-weight: 600;
    margin-bottom: var(--space-xs);
}

.history-meta {
    font-size: 0.8rem;
    color: var(--text-muted);
    display: flex;
    gap: var(--space-md);
}

.history-actions {
    display: flex;
    gap: var(--space-sm);
}

.history-empty {
    text-align: center;
    padding: var(--space-xl);
    color: var(--text-muted);
}

.btn-danger {
    background: rgba(239, 68, 68, 0.15);
    color: var(--error);
    border: 1px solid var(--error);
}

.btn-danger:hover {
    background: rgba(239, 68, 68, 0.25);
}

/* Utilities */
.stack {
    display: flex;
    flex-direction: column;
    gap: var(--space-lg);
}

.flex {
    display: flex;
}

.flex-between {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.gap-sm {
    gap: var(--space-sm);
}

.text-sm {
    font-size: 0.875rem;
}

.text-muted {
    color: var(--text-muted);
}

/* Responsive */
@media (max-width: 768px) {
    .container {
        padding: var(--space-md);
    }

    .header {
        padding: var(--space-md);
    }

    .glass-card {
        padding: var(--space-lg);
    }

    .workflow-steps {
        flex-direction: column;
    }

    .model-selector {
        flex-direction: column;
    }

    .api-key-input-wrapper {
        flex-direction: column;
        align-items: stretch;
    }

    .image-grid {
        grid-template-columns: 1fr;
    }

    .section-title {
        font-size: 1.25rem;
    }
}