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

:root {
    --primary: #6366f1;
    --primary-dark: #4f46e5;
    --primary-light: #818cf8;
    --secondary: #8b5cf6;
    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
    --bg-primary: #ffffff;
    --bg-secondary: #f9fafb;
    --bg-tertiary: #f3f4f6;
    --text-primary: #111827;
    --text-secondary: #6b7280;
    --text-tertiary: #9ca3af;
    --border: #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);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    color: var(--text-primary);
    line-height: 1.6;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 2rem 1rem;
}

/* Header */
header {
    margin-bottom: 2rem;
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.logo {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.logo h1 {
    font-size: 2rem;
    font-weight: 700;
    color: white;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.tagline {
    color: rgba(255, 255, 255, 0.9);
    font-size: 1.125rem;
    font-weight: 300;
    text-align: center;
}

/* User Profile */
.user-section {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    background: rgba(255, 255, 255, 0.95);
    padding: 0.5rem 1rem;
    border-radius: 50px;
    box-shadow: var(--shadow-md);
}

.user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
}

.logout-btn {
    padding: 0.375rem 0.75rem;
    background: var(--danger);
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.875rem;
    font-weight: 500;
    transition: all 0.2s;
}

.logout-btn:hover {
    background: #dc2626;
}

/* Layout */
.layout {
    display: grid;
    grid-template-columns: 280px 1fr;
    gap: 1.5rem;
}

/* Sidebar */
.sidebar {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 16px;
    padding: 1.5rem;
    max-height: calc(100vh - 200px);
    overflow-y: auto;
    box-shadow: var(--shadow-xl);
}

.sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.sidebar-header h3 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
}

.new-chat-btn {
    padding: 0.375rem 0.75rem;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.875rem;
    font-weight: 500;
    transition: all 0.2s;
}

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

.chat-history, .video-history {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.chat-item, .video-item {
    padding: 0.75rem;
    background: var(--bg-secondary);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    border: 2px solid transparent;
}

.chat-item:hover, .video-item:hover {
    background: var(--bg-tertiary);
    border-color: var(--primary-light);
}

.chat-item.active {
    background: rgba(99, 102, 241, 0.1);
    border-color: var(--primary);
}

.chat-item-title, .video-item-title {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.chat-item-date, .video-item-date {
    font-size: 0.75rem;
    color: var(--text-tertiary);
}

.sidebar-section {
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border);
}

.sidebar-section h3 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 1rem;
}

/* Main Content */
.main-content {
    position: relative;
    max-width: 100%;
    overflow-x: hidden;
}

.form-container {
    background: var(--bg-primary);
    border-radius: 16px;
    padding: 2.5rem;
    box-shadow: var(--shadow-xl);
}

/* Steps Indicator */
.steps-indicator {
    display: flex;
    justify-content: center;
    gap: 2rem;
    margin-bottom: 2.5rem;
    padding-bottom: 1.5rem;
    border-bottom: 2px solid var(--border);
}

.step {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    opacity: 0.5;
    transition: all 0.3s;
}

.step.active {
    opacity: 1;
}

.step-number {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--bg-tertiary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    color: var(--text-secondary);
    transition: all 0.3s;
}

.step.active .step-number {
    background: var(--primary);
    color: white;
}

.step-label {
    font-weight: 500;
    color: var(--text-secondary);
}

.step.active .step-label {
    color: var(--text-primary);
}

/* Step Content */
.step-content {
    display: none;
}

.step-content.active {
    display: block;
}

.form-section {
    margin-bottom: 2rem;
}

.form-section:last-of-type {
    margin-bottom: 0;
}

label {
    display: block;
    margin-bottom: 0.75rem;
}

.label-text {
    display: block;
    font-weight: 600;
    font-size: 0.875rem;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
}

.label-hint {
    display: block;
    font-size: 0.75rem;
    color: var(--text-secondary);
}

textarea,
input[type="text"],
input[type="password"],
select {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 2px solid var(--border);
    border-radius: 8px;
    font-size: 0.9375rem;
    font-family: inherit;
    transition: all 0.2s;
    background: var(--bg-primary);
}

textarea:focus,
input:focus,
select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

textarea {
    resize: vertical;
    min-height: 120px;
}

/* Deployment tag (bottom-right, subtle) */
.deployment-tag {
    font-size: 0.7rem;
    color: rgba(148, 163, 184, 0.7);
    text-align: right;
    margin-top: 0.25rem;
}

.deployment-tag a {
    color: inherit;
    text-decoration: none;
}

.deployment-tag a:hover {
    text-decoration: underline;
    color: rgba(148, 163, 184, 0.95);
}

.login-placeholder-btn {
    padding: 0.5rem 1rem;
    border-radius: 4px;
    border: 1px solid #d1d5db;
    background: white;
    color: #374151;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: default;
    opacity: 0.8;
}

/* Template Grid */
.template-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
}

.template-btn {
    padding: 1rem;
    background: var(--bg-secondary);
    border: 2px solid var(--border);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    text-align: left;
}

.template-btn:hover {
    border-color: var(--primary);
    background: rgba(99, 102, 241, 0.05);
}

.template-btn strong {
    display: block;
    font-size: 0.9375rem;
    margin-bottom: 0.25rem;
    color: var(--text-primary);
}

.template-btn span {
    display: block;
    font-size: 0.8125rem;
    color: var(--text-secondary);
}

.image-preview-item.highlight {
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.6);
    transition: box-shadow 0.3s ease;
}

/* Duration Selector */
.duration-selector {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.duration-btn {
    flex: 1;
    min-width: 80px;
    padding: 0.75rem 1rem;
    border: 2px solid var(--border);
    background: var(--bg-primary);
    border-radius: 8px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 0.875rem;
}

.duration-btn:hover {
    border-color: var(--primary-light);
    background: var(--bg-secondary);
}

.duration-btn.active {
    border-color: var(--primary);
    background: var(--primary);
    color: white;
}

/* Provider Selector */
.provider-selector {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.provider-option {
    flex: 1;
    min-width: 180px;
    padding: 0.9rem 1rem;
    border-radius: 10px;
    border: 2px solid var(--border);
    background: var(--bg-secondary);
    cursor: pointer;
    text-align: left;
    transition: all 0.2s;
}

.provider-option .provider-name {
    display: block;
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text-primary);
}

.provider-option .provider-sub {
    display: block;
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-top: 0.15rem;
}

.provider-option .provider-status {
    display: inline-block;
    margin-top: 0.4rem;
    padding: 0.15rem 0.5rem;
    border-radius: 999px;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    background: rgba(16, 185, 129, 0.08);
    color: var(--success);
}

.provider-option.active {
    border-color: var(--primary);
    background: rgba(99, 102, 241, 0.06);
}

.provider-option.disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.provider-option.disabled .provider-status {
    background: var(--bg-tertiary);
    color: var(--text-tertiary);
}

.provider-option.error {
    border-color: var(--danger);
    background: rgba(239, 68, 68, 0.03);
}

.provider-option.error .provider-status {
    background: rgba(239, 68, 68, 0.12);
    color: var(--danger);
}

/* Upload Area */
.upload-area {
    border: 2px dashed var(--border);
    border-radius: 12px;
    padding: 3rem 2rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
    background: var(--bg-secondary);
}

.upload-area:hover {
    border-color: var(--primary);
    background: var(--bg-primary);
}

.upload-area p {
    margin-top: 1rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.upload-hint {
    font-size: 0.875rem;
    color: var(--text-tertiary) !important;
    margin-top: 0.5rem !important;
}

/* Image Preview */
.image-preview {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 1rem;
    margin-top: 1rem;
}

.image-preview-item {
    position: relative;
    aspect-ratio: 1;
    border-radius: 8px;
    overflow: hidden;
    border: 2px solid var(--border);
}

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

.image-preview-item .remove-btn {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
}

.image-preview-item .remove-btn:hover {
    background: var(--danger);
}

/* Prompt Tweaker */
.prompt-tweaker h2 {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
}

.prompt-tweaker .hint {
    color: var(--text-secondary);
    margin-bottom: 2rem;
}

.input-summary {
    background: var(--bg-secondary);
    padding: 1.5rem;
    border-radius: 8px;
    border-left: 4px solid var(--primary);
}

.input-summary strong {
    display: block;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}

.input-summary p {
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.prompt-suggestions {
    background: var(--bg-secondary);
    padding: 1.5rem;
    border-radius: 8px;
    margin-top: 1rem;
}

.prompt-suggestions h4 {
    margin-bottom: 1rem;
    font-size: 0.9375rem;
}

.suggestion-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.chip {
    padding: 0.5rem 1rem;
    background: white;
    border: 1px solid var(--border);
    border-radius: 20px;
    cursor: pointer;
    font-size: 0.875rem;
    transition: all 0.2s;
}

.chip:hover {
    background: var(--primary-light);
    color: white;
    border-color: var(--primary-light);
}

/* Buttons */
.button-row {
    display: flex;
    gap: 1rem;
    margin-top: 2rem;
}

.next-step-btn,
.generate-btn,
.back-btn {
    padding: 1rem 2rem;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.next-step-btn,
.generate-btn {
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    color: white;
    flex: 1;
    box-shadow: var(--shadow-md);
}

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

.back-btn {
    background: var(--bg-secondary);
    color: var(--text-primary);
    border: 2px solid var(--border);
}

.back-btn:hover {
    background: var(--bg-tertiary);
}

/* Result Container */
.result-container {
    display: none;
    background: var(--bg-primary);
    border-radius: 16px;
    padding: 2rem;
    margin-top: 2rem;
    box-shadow: var(--shadow-xl);
}

.result-container.show {
    display: block;
    animation: slideIn 0.3s ease-out;
}

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

.result-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 2px solid var(--border);
}

.result-header h2 {
    font-size: 1.5rem;
    font-weight: 600;
}

.close-btn {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: none;
    background: var(--bg-secondary);
    font-size: 1.5rem;
    cursor: pointer;
    transition: all 0.2s;
}

.close-btn:hover {
    background: var(--danger);
    color: white;
}

.result-content {
    line-height: 1.8;
}

/* Loading Overlay */
.loading-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    z-index: 1000;
}

.loading-overlay.show {
    display: flex;
    align-items: center;
    justify-content: center;
}

.spinner {
    width: 60px;
    height: 60px;
    border: 4px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 1.5rem;
}

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

.loading-content {
    text-align: center;
    color: white;
}

.loading-text {
    font-size: 1.25rem;
    font-weight: 600;
}

.loading-subtext {
    font-size: 0.875rem;
    color: rgba(255, 255, 255, 0.8);
}

/* Messages */
.message {
    padding: 1rem;
    border-radius: 8px;
    margin-bottom: 1rem;
    font-weight: 500;
}

.message.success {
    background: rgba(16, 185, 129, 0.1);
    color: var(--success);
    border: 1px solid var(--success);
}

.message.error {
    background: rgba(239, 68, 68, 0.1);
    color: var(--danger);
    border: 1px solid var(--danger);
}

/* Footer */
footer {
    text-align: center;
    margin-top: 3rem;
    color: rgba(255, 255, 255, 0.8);
    font-size: 0.875rem;
}

.deployment-tag {
    margin-top: 0.25rem;
    font-size: 0.55rem; /* very small, well under 2% of viewport height */
    opacity: 0.6;
}

/* Responsive */
@media (max-width: 1024px) {
    .layout {
        grid-template-columns: 1fr;
    }
    
    .sidebar {
        max-height: 300px;
    }
}

@media (max-width: 640px) {
    .container {
        padding: 1rem;
    }
    
    .header-content {
        flex-direction: column;
        gap: 1rem;
    }
    
    .form-container {
        padding: 1.5rem;
    }
    
    .template-grid {
        grid-template-columns: 1fr;
    }
    
    .duration-selector {
        flex-direction: column;
    }
    
    .button-row {
        flex-direction: column;
    }
}

