/* CSS Variables */
:root {
    --bg-primary: #0a0a0f;
    --bg-secondary: #12121a;
    --bg-tertiary: #1a1a25;
    --bg-card: #15151f;
    --bg-hover: #1f1f2e;
    
    --text-primary: #f0f0f5;
    --text-secondary: #a0a0b0;
    --text-muted: #606070;
    
    --accent-primary: #00d9ff;
    --accent-secondary: #00ffaa;
    --accent-gradient: linear-gradient(135deg, #00d9ff 0%, #00ffaa 100%);
    
    --success: #00ff88;
    --warning: #ffaa00;
    --error: #ff4466;
    
    --border-color: #2a2a3a;
    --border-radius: 12px;
    --border-radius-sm: 8px;
    --border-radius-lg: 16px;
    
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.5);
    --shadow-glow: 0 0 20px rgba(0, 217, 255, 0.3);
    
    --font-primary: 'Outfit', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-mono: 'JetBrains Mono', monospace;
    
    --transition: all 0.3s ease;
}

/* Reset & Base */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-primary);
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    overflow-x: hidden;
}

/* Background Effect */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: 
        radial-gradient(ellipse at 20% 20%, rgba(0, 217, 255, 0.08) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 80%, rgba(0, 255, 170, 0.06) 0%, transparent 50%);
    pointer-events: none;
    z-index: -1;
}

#app {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Typography */
h1, h2, h3, h4, h5, h6 {
    font-weight: 600;
    line-height: 1.3;
}

h1 { font-size: 2.5rem; }
h2 { font-size: 1.75rem; }
h3 { font-size: 1.25rem; }

a {
    color: var(--accent-primary);
    text-decoration: none;
    transition: var(--transition);
}

a:hover {
    color: var(--accent-secondary);
}

/* Navbar */
.navbar {
    position: sticky;
    top: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 2rem;
    background: rgba(10, 10, 15, 0.9);
    backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border-color);
}

.nav-brand {
    display: flex;
    align-items: center;
}

.nav-brand a {
    display: flex;
    align-items: center;
    text-decoration: none;
}

.brand-logo {
    height: 45px;
    width: auto;
    object-fit: contain;
    transition: opacity 0.3s ease;
}

.brand-logo:hover {
    opacity: 0.8;
}

.brand-text {
    font-size: 1.5rem;
    font-weight: 700;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.nav-links {
    display: flex;
    gap: 0.5rem;
}

.nav-link {
    padding: 0.5rem 1rem;
    border-radius: var(--border-radius-sm);
    color: var(--text-secondary);
    font-weight: 500;
    transition: var(--transition);
}

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

.nav-link.active {
    color: var(--accent-primary);
    background: rgba(0, 217, 255, 0.1);
}

.admin-only {
    display: none;
}

.admin-only.visible {
    display: block;
}

.nav-user {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.credits-display {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: var(--bg-tertiary);
    border-radius: var(--border-radius);
    border: 1px solid var(--border-color);
}

.credits-icon {
    font-size: 1.1rem;
}

.credits-value {
    font-weight: 600;
    font-family: var(--font-mono);
    color: var(--accent-primary);
}

.user-menu {
    position: relative;
}

.user-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    color: var(--text-primary);
    cursor: pointer;
    transition: var(--transition);
}

.user-btn:hover {
    background: var(--bg-hover);
    border-color: var(--accent-primary);
}

.dropdown-icon {
    width: 16px;
    height: 16px;
}

.user-dropdown {
    position: absolute;
    top: calc(100% + 0.5rem);
    right: 0;
    min-width: 150px;
    padding: 0.5rem;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-lg);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: var(--transition);
}

.user-dropdown.show {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.user-dropdown a {
    display: block;
    padding: 0.5rem 1rem;
    color: var(--text-secondary);
    border-radius: var(--border-radius-sm);
}

.user-dropdown a:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

/* Main Content */
.main-content {
    flex: 1;
    padding: 2rem;
}

.page {
    max-width: 1200px;
    margin: 0 auto;
    animation: fadeIn 0.3s ease;
}

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

.hidden {
    display: none !important;
}

/* Auth Page */
.auth-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: calc(100vh - 80px);
}

.auth-container {
    width: 100%;
    max-width: 420px;
    padding: 1rem;
}

.auth-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-lg);
    padding: 2.5rem;
    box-shadow: var(--shadow-lg);
}

.auth-header {
    text-align: center;
    margin-bottom: 2rem;
}

.auth-header h1 {
    font-size: 1.75rem;
    margin-bottom: 0.5rem;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.auth-header p {
    color: var(--text-secondary);
}

.auth-tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
}

.auth-tab {
    flex: 1;
    padding: 0.75rem;
    background: transparent;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition);
    font-size: 0.95rem;
    font-weight: 500;
}

.auth-tab:hover {
    background: var(--bg-hover);
}

.auth-tab.active {
    background: var(--accent-primary);
    color: var(--bg-primary);
    border-color: var(--accent-primary);
}

.auth-form {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

/* Email Verification Form */
.verify-header {
    text-align: center;
    margin-bottom: 1rem;
}

.verify-icon {
    font-size: 3rem;
    margin-bottom: 0.5rem;
}

.verify-header h3 {
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}

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

.verify-header span {
    color: var(--accent-primary);
    font-weight: 600;
}

.verify-code-input {
    text-align: center;
    font-size: 1.5rem;
    letter-spacing: 0.5rem;
    font-weight: 600;
    font-family: var(--font-mono);
}

.resend-section {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    margin-top: 1rem;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.btn-link {
    background: none;
    border: none;
    color: var(--accent-primary);
    cursor: pointer;
    font-size: 0.9rem;
    text-decoration: underline;
    padding: 0;
}

.btn-link:hover {
    color: var(--accent-secondary);
}

.btn-secondary {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    margin-top: 0.5rem;
}

.btn-secondary:hover {
    border-color: var(--accent-primary);
    color: var(--text-primary);
}

.auth-footer {
    margin-top: 1.5rem;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.85rem;
}

/* Form Elements */
.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.form-group label {
    font-weight: 500;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.form-group label .required {
    color: var(--error);
}

.form-group input,
.form-group textarea,
.form-group select {
    padding: 0.875rem 1rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 1rem;
    transition: var(--transition);
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(0, 217, 255, 0.15);
}

.form-group input::placeholder,
.form-group textarea::placeholder {
    color: var(--text-muted);
}

.form-group textarea {
    resize: vertical;
    min-height: 100px;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
}

.char-count {
    text-align: right;
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: var(--border-radius-sm);
    font-family: inherit;
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
}

.btn svg {
    width: 18px;
    height: 18px;
}

.btn-primary {
    background: var(--accent-gradient);
    color: var(--bg-primary);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-glow);
}

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

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

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

.btn-danger:hover {
    background: #ff2244;
}

.btn-full {
    width: 100%;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* Generate Page */
.generate-container {
    max-width: 800px;
    margin: 0 auto;
}

.generate-header {
    text-align: center;
    margin-bottom: 2.5rem;
}

.generate-header h2 {
    margin-bottom: 0.5rem;
}

.generate-header p {
    color: var(--text-secondary);
}

.generate-form {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-lg);
    padding: 2rem;
}

.generate-form .form-group {
    margin-bottom: 1.5rem;
}

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

.duration-selector input[type="range"] {
    flex: 1;
    -webkit-appearance: none;
    height: 6px;
    background: var(--bg-tertiary);
    border-radius: 3px;
    cursor: pointer;
}

.duration-selector input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 20px;
    height: 20px;
    background: var(--accent-primary);
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 0 10px rgba(0, 217, 255, 0.5);
}

.duration-display {
    min-width: 60px;
    padding: 0.5rem 1rem;
    background: var(--bg-tertiary);
    border-radius: var(--border-radius-sm);
    text-align: center;
    font-weight: 600;
    font-family: var(--font-mono);
}

.credits-estimate {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    background: var(--bg-tertiary);
    border-radius: var(--border-radius-sm);
    font-weight: 600;
    font-family: var(--font-mono);
    color: var(--accent-primary);
}

.btn-generate {
    width: 100%;
    padding: 1rem;
    font-size: 1.1rem;
    margin-top: 1rem;
}

.btn-loading {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.spinner {
    width: 20px;
    height: 20px;
    animation: spin 1s linear infinite;
}

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

/* Active Tasks Section */
.active-tasks {
    margin-top: 2rem;
    padding: 1.5rem;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
}

.active-tasks h3 {
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.active-tasks h3::before {
    content: '⚡';
}

.tasks-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.task-item {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    padding: 1rem;
    transition: all 0.3s ease;
    will-change: transform;
}

.task-item:hover {
    border-color: var(--accent-primary);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 217, 255, 0.15);
}

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

.task-header-right {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.task-time {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.btn-delete {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    padding: 0;
    background: transparent;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-delete:hover {
    background: rgba(239, 68, 68, 0.1);
    border-color: #ef4444;
    color: #ef4444;
}

.btn-delete svg {
    flex-shrink: 0;
}

.task-status {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 500;
}

.task-status .spinner {
    width: 12px;
    height: 12px;
    border: 2px solid rgba(0, 217, 255, 0.3);
    border-top-color: var(--accent-primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.task-status.pending {
    background: rgba(255, 170, 0, 0.15);
    color: var(--warning);
}

.task-status.pending .spinner {
    border-color: rgba(255, 170, 0, 0.3);
    border-top-color: var(--warning);
}

.task-status.processing {
    background: rgba(0, 217, 255, 0.15);
    color: var(--accent-primary);
}

.task-status.completed {
    background: rgba(16, 185, 129, 0.15);
    color: #10b981;
}

.task-status.failed {
    background: rgba(239, 68, 68, 0.15);
    color: #ef4444;
}

.task-prompt {
    font-size: 0.95rem;
    color: var(--text-primary);
    margin-bottom: 0.75rem;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.task-meta {
    display: flex;
    gap: 1.5rem;
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 0.75rem;
}

.task-meta span {
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

/* Progress Bar */
.task-progress {
    width: 100%;
    height: 6px;
    background: var(--bg-primary);
    border-radius: 3px;
    overflow: hidden;
    position: relative;
}

.task-progress {
    width: 100%;
    height: 8px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 3px;
    overflow: hidden;
    position: relative;
}

.task-progress-bar {
    height: 100%;
    background: var(--accent-gradient);
    border-radius: 3px;
    transition: width 0.5s ease;
}

.task-progress-text {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 11px;
    font-weight: 600;
    color: var(--text-primary);
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
    z-index: 2;
}

.task-progress-bar.processing {
    background: linear-gradient(90deg, 
        var(--accent-primary) 0%, 
        var(--accent-secondary) 50%, 
        var(--accent-primary) 100%);
    background-size: 200% 100%;
    animation: progressSlide 1.5s ease-in-out infinite;
}

.task-progress-bar.pending {
    background: var(--text-muted);
}

.task-progress-bar.completed {
    background: #10b981;
}

.task-progress-bar.failed {
    background: #ef4444;
}

@keyframes progressSlide {
    0% { background-position: 100% 0; }
    100% { background-position: -100% 0; }
}

.no-tasks {
    text-align: center;
    padding: 2rem;
    color: var(--text-muted);
}

.no-tasks .icon {
    font-size: 2rem;
    margin-bottom: 0.5rem;
}

.current-generation {
    margin-top: 2rem;
    padding: 1.5rem;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
}

.current-generation h3 {
    margin-bottom: 1rem;
}

.status-indicator {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.status-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    animation: pulse 2s infinite;
}

.status-dot.pending {
    background: var(--warning);
}

.status-dot.processing {
    background: var(--accent-primary);
}

.status-dot.completed {
    background: var(--success);
    animation: none;
}

.status-dot.failed {
    background: var(--error);
    animation: none;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* History Page */
.history-container {
    max-width: 1000px;
    margin: 0 auto;
}

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

.history-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-bottom: 1rem;
}

.loading-more {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.75rem;
    padding: 2rem;
    color: var(--text-secondary);
}

.loading-more .spinner {
    width: 24px;
    height: 24px;
    border: 3px solid var(--border-color);
    border-top-color: var(--accent-primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.no-more-data {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 2rem;
    color: var(--text-tertiary);
    font-size: 0.9rem;
}

/* Hide scrollbar but keep scroll functionality */
#historyPage {
    overflow-y: auto;
    scrollbar-width: none; /* Firefox */
    -ms-overflow-style: none; /* IE and Edge */
}

#historyPage::-webkit-scrollbar {
    display: none; /* Chrome, Safari, Opera */
}

.history-item {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 1.5rem;
    transition: var(--transition);
}

.history-item:hover {
    border-color: var(--accent-primary);
}

.history-item-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 1rem;
}

.history-header-right {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.history-item-status {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 500;
}

.history-item-status.pending {
    background: rgba(255, 170, 0, 0.1);
    color: var(--warning);
}

.history-item-status.processing {
    background: rgba(0, 217, 255, 0.1);
    color: var(--accent-primary);
}

.history-item-status.completed {
    background: rgba(0, 255, 136, 0.1);
    color: var(--success);
}

.history-item-status.failed {
    background: rgba(255, 68, 102, 0.1);
    color: var(--error);
}

.history-item-prompt {
    color: var(--text-secondary);
    margin-bottom: 1rem;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.history-item-meta {
    display: flex;
    gap: 2rem;
    color: var(--text-muted);
    font-size: 0.85rem;
}

.history-item-meta span {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.history-item-video {
    margin-top: 1rem;
}

.history-item-video video {
    width: 100%;
    max-width: 560px;
    aspect-ratio: 16 / 9;
    object-fit: contain;
    border-radius: var(--border-radius-sm);
    background: #000;
    display: block;
    margin-bottom: 0.75rem;
}

.task-video {
    margin-top: 1rem;
}

.task-video video {
    width: 100%;
    max-width: 400px;
    aspect-ratio: 16 / 9;
    object-fit: contain;
    border-radius: var(--border-radius-sm);
    background: #000;
    display: block;
    margin-bottom: 0.75rem;
}

.btn-download {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: var(--accent-gradient);
    color: var(--text-primary);
    border: none;
    border-radius: var(--border-radius-sm);
    font-size: 0.9rem;
    font-weight: 500;
    text-decoration: none;
    cursor: pointer;
    transition: var(--transition);
}

.btn-download:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 217, 255, 0.3);
}

.btn-download.btn-sm {
    padding: 0.4rem 0.8rem;
    font-size: 0.85rem;
}

.history-error {
    color: var(--error);
    margin-top: 0.75rem;
    font-size: 0.9rem;
    padding: 0.75rem;
    background: rgba(239, 68, 68, 0.1);
    border-radius: var(--border-radius-sm);
    border-left: 3px solid var(--error);
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 4rem 2rem;
    color: var(--text-muted);
}

.empty-state svg {
    width: 64px;
    height: 64px;
    margin-bottom: 1rem;
    opacity: 0.5;
}

.empty-state p {
    font-size: 1.1rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

/* API Keys Page */
.api-keys-container {
    max-width: 900px;
    margin: 0 auto;
}

.api-info-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 1.5rem;
    margin-bottom: 2rem;
}

.api-info-card h3 {
    margin-bottom: 0.5rem;
}

.api-info-card > p {
    color: var(--text-secondary);
    margin-bottom: 1rem;
}

.api-endpoint {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--border-color);
}

.api-endpoint:last-of-type {
    border-bottom: none;
}

.api-endpoint code {
    font-family: var(--font-mono);
    background: var(--bg-tertiary);
    padding: 0.25rem 0.75rem;
    border-radius: var(--border-radius-sm);
    color: var(--accent-primary);
    font-size: 0.9rem;
}

.api-note {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
    font-size: 0.9rem;
}

.api-note code {
    background: var(--bg-tertiary);
    padding: 0.125rem 0.5rem;
    border-radius: 4px;
    font-family: var(--font-mono);
}

/* Detailed API Documentation */
.api-section {
    margin-top: 1.5rem;
    padding: 1.25rem;
    background: var(--bg-tertiary);
    border-radius: var(--border-radius-sm);
    border-left: 3px solid var(--accent-primary);
}

.api-section h4 {
    font-size: 1.1rem;
    margin-bottom: 1rem;
    color: var(--text-primary);
}

.api-endpoint-detail {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.api-endpoint-detail code.method {
    padding: 0.35rem 0.75rem;
    border-radius: 6px;
    font-family: var(--font-mono);
    font-size: 0.85rem;
    font-weight: 600;
    text-transform: uppercase;
}

.api-endpoint-detail code.method.post {
    background: rgba(0, 217, 255, 0.2);
    color: var(--accent-primary);
}

.api-endpoint-detail code.method.get {
    background: rgba(0, 255, 136, 0.2);
    color: var(--accent-secondary);
}

.api-endpoint-detail code.path {
    padding: 0.35rem 0.75rem;
    background: var(--bg-primary);
    border-radius: 6px;
    font-family: var(--font-mono);
    font-size: 0.9rem;
    color: var(--text-primary);
}

.api-params {
    margin-bottom: 1rem;
}

.api-params p {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.api-params ul {
    list-style: none;
    padding-left: 0;
}

.api-params li {
    padding: 0.35rem 0;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.api-params li code {
    background: var(--bg-primary);
    padding: 0.15rem 0.5rem;
    border-radius: 4px;
    font-family: var(--font-mono);
    color: var(--accent-primary);
    font-size: 0.85rem;
}

.api-example {
    margin-top: 1rem;
}

.api-example p {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
    margin-top: 1rem;
}

.api-example p:first-child {
    margin-top: 0;
}

.api-example pre {
    background: var(--bg-primary);
    border-radius: var(--border-radius-sm);
    padding: 1rem;
    overflow-x: auto;
    margin: 0.5rem 0;
}

.api-example pre code {
    font-family: var(--font-mono);
    font-size: 0.85rem;
    color: var(--text-primary);
    line-height: 1.5;
    white-space: pre;
}

.api-errors {
    margin-top: 1.5rem;
    padding: 1.25rem;
    background: rgba(255, 68, 102, 0.1);
    border-radius: var(--border-radius-sm);
    border-left: 3px solid var(--error);
}

.api-errors h4 {
    font-size: 1rem;
    margin-bottom: 0.75rem;
    color: var(--text-primary);
}

.api-errors ul {
    list-style: none;
    padding-left: 0;
}

.api-errors li {
    padding: 0.35rem 0;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.api-errors li code {
    background: rgba(255, 68, 102, 0.2);
    padding: 0.15rem 0.5rem;
    border-radius: 4px;
    font-family: var(--font-mono);
    color: var(--error);
    font-size: 0.85rem;
    margin-right: 0.5rem;
}

.api-keys-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.api-key-item {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 1.25rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.api-key-info h4 {
    margin-bottom: 0.25rem;
}

.api-key-value {
    font-family: var(--font-mono);
    font-size: 0.85rem;
    color: var(--text-muted);
    background: var(--bg-tertiary);
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    margin-bottom: 0.5rem;
}

.api-key-meta {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.api-key-actions {
    display: flex;
    gap: 0.5rem;
}

.api-key-actions button {
    padding: 0.5rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition);
}

.api-key-actions button:hover {
    color: var(--text-primary);
    border-color: var(--accent-primary);
}

.api-key-actions button.delete:hover {
    color: var(--error);
    border-color: var(--error);
}

/* Admin Page */
.admin-container {
    max-width: 1100px;
    margin: 0 auto;
}

.admin-tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 2rem;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 1rem;
}

.admin-tab {
    padding: 0.75rem 1.5rem;
    background: transparent;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition);
    font-weight: 500;
}

.admin-tab:hover {
    background: var(--bg-hover);
}

.admin-tab.active {
    background: var(--accent-primary);
    color: var(--bg-primary);
    border-color: var(--accent-primary);
}

.admin-panel {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 1.5rem;
}

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

.search-box input {
    padding: 0.5rem 1rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    color: var(--text-primary);
    width: 250px;
}

.search-box input:focus {
    outline: none;
    border-color: var(--accent-primary);
}

/* Users Table */
.users-table-container {
    overflow-x: auto;
}

.users-table {
    width: 100%;
    border-collapse: collapse;
}

.users-table th,
.users-table td {
    padding: 1rem;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

.users-table th {
    color: var(--text-muted);
    font-weight: 500;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.users-table tr:hover {
    background: var(--bg-hover);
}

.users-table .status-badge {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 500;
}

.users-table .status-badge.active {
    background: rgba(0, 255, 136, 0.1);
    color: var(--success);
}

.users-table .status-badge.inactive {
    background: rgba(255, 68, 102, 0.1);
    color: var(--error);
}

.users-table .role-badge {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 500;
}

.users-table .role-badge.admin {
    background: rgba(0, 255, 170, 0.1);
    color: var(--accent-secondary);
}

.users-table .role-badge.user {
    background: rgba(0, 217, 255, 0.1);
    color: var(--accent-primary);
}

.users-table .actions {
    display: flex;
    gap: 0.5rem;
}

.users-table .actions button {
    padding: 0.375rem 0.75rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 0.85rem;
    transition: var(--transition);
}

.users-table .actions button:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.users-table .actions button.delete-btn:hover {
    background: var(--error);
    color: white;
    border-color: var(--error);
}

/* SMTP Form */
.smtp-form {
    max-width: 600px;
}

.smtp-form .form-group {
    margin-bottom: 1.25rem;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    padding-top: 1.5rem;
}

.checkbox-label input[type="checkbox"] {
    width: 20px;
    height: 20px;
    accent-color: var(--accent-primary);
}

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

.stat-card {
    background: var(--bg-tertiary);
    border-radius: var(--border-radius);
    padding: 1.5rem;
    text-align: center;
}

.stat-value {
    font-size: 2.5rem;
    font-weight: 700;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 0.5rem;
    font-family: var(--font-mono);
}

.stat-label {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

/* Works Management */
.works-filters {
    display: flex;
    gap: 1rem;
    align-items: center;
    flex-wrap: wrap;
}

.batch-actions {
    display: flex;
    gap: 0.5rem;
    margin-left: auto;
}

.works-filters select {
    padding: 0.5rem 1rem;
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    cursor: pointer;
    font-size: 0.9rem;
}

.works-filters select:focus {
    outline: none;
    border-color: var(--accent-primary);
}

.works-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1.5rem;
    margin-top: 1.5rem;
}

.work-card {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    overflow: hidden;
    transition: transform 0.2s ease, border-color 0.2s ease;
    position: relative;
}

.work-card:hover {
    transform: translateY(-2px);
    border-color: var(--accent-primary);
}

.work-card.selected {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(0, 123, 255, 0.3);
}

.work-checkbox {
    position: absolute;
    top: 0.75rem;
    left: 0.75rem;
    z-index: 10;
    width: 24px;
    height: 24px;
    cursor: pointer;
}

.work-video-container {
    position: relative;
    width: 100%;
    padding-top: 56.25%; /* 16:9 */
    background: #000;
}

.work-video-container video {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.work-status-badge {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    padding: 0.25rem 0.75rem;
    border-radius: var(--border-radius);
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
}

.work-status-badge.completed {
    background: var(--success-color);
    color: white;
}

.work-status-badge.processing {
    background: var(--warning-color);
    color: white;
}

.work-status-badge.failed {
    background: var(--error-color);
    color: white;
}

.work-status-badge.pending {
    background: var(--bg-secondary);
    color: var(--text-secondary);
}

.work-featured-badge {
    position: absolute;
    top: 0.5rem;
    left: 0.5rem;
    padding: 0.25rem 0.5rem;
    background: rgba(255, 215, 0, 0.9);
    color: #000;
    border-radius: var(--border-radius);
    font-size: 0.75rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.work-info {
    padding: 1rem;
}

.work-prompt {
    font-size: 0.9rem;
    color: var(--text-primary);
    margin-bottom: 0.75rem;
    max-height: 4.5em;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
}

.work-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.work-actions {
    display: flex;
    gap: 0.5rem;
}

.work-actions .btn {
    flex: 1;
    padding: 0.5rem 0.75rem;
    font-size: 0.85rem;
}

.btn-feature {
    background: linear-gradient(135deg, #FFD700, #FFA500);
    color: #000;
    font-weight: 600;
}

.btn-feature:hover {
    background: linear-gradient(135deg, #FFC700, #FF9500);
}

.btn-unfeature {
    background: var(--bg-secondary);
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
}

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

/* Modal */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 200;
    padding: 1rem;
}

.modal {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-lg);
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    overflow: auto;
    animation: modalIn 0.3s ease;
}

.modal-small {
    max-width: 450px;
}

.modal-body {
    padding: 1.5rem;
}

.modal-body .form-group {
    margin-bottom: 1.25rem;
}

.modal-body .form-group:last-of-type {
    margin-bottom: 0;
}

.modal-body label {
    display: block;
    margin-bottom: 0.5rem;
    color: var(--text-secondary);
    font-size: 0.875rem;
    font-weight: 500;
}

.modal-body input[type="password"] {
    width: 100%;
    padding: 0.75rem 1rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    color: var(--text-primary);
    font-size: 0.9375rem;
    transition: var(--transition);
}

.modal-body input[type="password"]:focus {
    outline: none;
    border-color: var(--accent-primary);
    background: var(--bg-primary);
    box-shadow: 0 0 0 3px rgba(14, 165, 233, 0.1);
}

.modal-body input[type="password"]::placeholder {
    color: var(--text-muted);
}

.modal-actions {
    display: flex;
    gap: 0.75rem;
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border-color);
}

.modal-actions .btn {
    flex: 1;
    justify-content: center;
}

@keyframes modalIn {
    from {
        opacity: 0;
        transform: scale(0.95) translateY(-20px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

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

.modal-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0;
    line-height: 1;
    transition: var(--transition);
}

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


/* Toast Notifications */
.toast-container {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    z-index: 300;
}

.toast {
    padding: 1rem 1.5rem;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-lg);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    animation: toastIn 0.3s ease;
    min-width: 280px;
    max-width: 400px;
}

@keyframes toastIn {
    from {
        opacity: 0;
        transform: translateX(100%);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.toast.success {
    border-left: 3px solid var(--success);
}

.toast.error {
    border-left: 3px solid var(--error);
}

.toast.warning {
    border-left: 3px solid var(--warning);
}

.toast.info {
    border-left: 3px solid var(--accent-primary);
}

/* Responsive */
@media (max-width: 768px) {
    .navbar {
        padding: 1rem;
        flex-wrap: wrap;
        gap: 1rem;
    }
    
    .nav-links {
        order: 3;
        width: 100%;
        justify-content: center;
        flex-wrap: wrap;
    }
    
    .nav-user {
        gap: 1rem;
    }
    
    .main-content {
        padding: 1rem;
    }
    
    .form-row {
        grid-template-columns: 1fr;
    }
    
    .auth-card {
        padding: 1.5rem;
    }
    
    .generate-form {
        padding: 1.5rem;
    }
    
    .history-item-header {
        flex-direction: column;
        gap: 0.75rem;
    }
    
    .history-item-meta {
        flex-wrap: wrap;
        gap: 1rem;
    }
    
    .api-key-item {
        flex-direction: column;
        gap: 1rem;
        align-items: flex-start;
    }
    
    .admin-tabs {
        flex-wrap: wrap;
    }
    
    .users-table th:nth-child(3),
    .users-table td:nth-child(3) {
        display: none;
    }
}

@media (max-width: 480px) {
    h1 { font-size: 1.75rem; }
    h2 { font-size: 1.5rem; }
    
    .nav-link {
        padding: 0.375rem 0.75rem;
        font-size: 0.9rem;
    }
    
    .credits-display {
        padding: 0.375rem 0.75rem;
    }
    
    .user-btn {
        padding: 0.375rem 0.75rem;
    }
    
    .page-header {
        flex-direction: column;
        gap: 1rem;
        align-items: flex-start;
    }
    
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .stat-value {
        font-size: 1.75rem;
    }
}


/* Inspiration Page Styles */
.inspiration-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 2rem;
}

.inspiration-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(380px, 1fr));
    gap: 2rem;
    margin-top: 2rem;
    align-items: stretch;
}

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

.inspiration-card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    overflow: hidden;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    display: flex;
    flex-direction: column;
    height: 100%;
}

.inspiration-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 24px rgba(0, 217, 255, 0.15);
}

.inspiration-video-container {
    position: relative;
    width: 100%;
    background: #000;
    padding-top: 56.25%; /* 16:9 Aspect Ratio */
    overflow: hidden;
}

.inspiration-video {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.inspiration-loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: var(--text-secondary);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
}

.inspiration-loading .spinner {
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
}

.inspiration-content {
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    flex-grow: 1;
}

.inspiration-title {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 0.75rem;
    color: var(--text-primary);
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
    min-height: 2.8em; /* 2 lines height */
}

.inspiration-prompt {
    background: var(--input-bg);
    padding: 1rem;
    border-radius: var(--border-radius-sm);
    margin-bottom: 1rem;
    color: var(--text-secondary);
    font-size: 0.9rem;
    line-height: 1.6;
    max-height: 120px;
    overflow-y: auto;
    flex-grow: 1;
    display: -webkit-box;
    -webkit-line-clamp: 5;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
}

.inspiration-meta {
    display: flex;
    gap: 1rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.inspiration-tag {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.25rem 0.75rem;
    background: rgba(0, 217, 255, 0.1);
    color: var(--accent-color);
    border-radius: 12px;
    font-size: 0.85rem;
}

.inspiration-actions {
    display: flex;
    gap: 0.75rem;
    margin-top: auto; /* Push actions to bottom */
}

.btn-copy-prompt {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem;
    background: var(--input-bg);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.3s ease;
}

.btn-copy-prompt:hover {
    background: var(--border-color);
    border-color: var(--accent-color);
    transform: translateY(-2px);
}

.btn-generate-same {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem;
    background: var(--accent-gradient);
    color: var(--bg-primary);
    font-weight: 600;
    border: none;
    border-radius: var(--border-radius-sm);
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.3s ease;
}

.btn-generate-same:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(0, 217, 255, 0.4);
}

.inspiration-status {
    position: absolute;
    top: 1rem;
    right: 1rem;
    padding: 0.5rem 1rem;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 500;
    backdrop-filter: blur(10px);
}

.inspiration-status.generating {
    background: rgba(255, 193, 7, 0.9);
    color: #000;
}

.inspiration-status.completed {
    background: rgba(76, 175, 80, 0.9);
    color: #fff;
}

.inspiration-status.failed {
    background: rgba(244, 67, 54, 0.9);
    color: #fff;
}

@media (max-width: 768px) {
    .inspiration-grid {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }
    
    .inspiration-container {
        padding: 1rem;
    }
}
