:root {
    --bg-color: #030305;
    --surface-light: rgba(255, 255, 255, 0.03);
    --surface-border: rgba(255, 255, 255, 0.08);
    --text-primary: #ffffff;
    --text-secondary: #8a8a93;
    --accent-glow: rgba(99, 102, 241, 0.5);
    --gradient-1: linear-gradient(135deg, #6366f1 0%, #a855f7 100%);
    --gradient-hover: linear-gradient(135deg, #4f46e5 0%, #9333ea 100%);
    --error-color: #ef4444;
    --success-color: #22c55e;
    --font-sans: 'Outfit', system-ui, -apple-system, sans-serif;
}

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

body {
    font-family: var(--font-sans);
    background-color: var(--bg-color);
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
    position: relative;
}

/* Background Atmosphere */
.bg-glow {
    position: fixed;
    top: -20%;
    left: -10%;
    width: 60vw;
    height: 60vw;
    background: radial-gradient(circle, rgba(99, 102, 241, 0.15) 0%, rgba(0, 0, 0, 0) 70%);
    z-index: -1;
    pointer-events: none;
}

.bg-glow-secondary {
    top: auto;
    bottom: -20%;
    left: auto;
    right: -10%;
    background: radial-gradient(circle, rgba(168, 85, 247, 0.1) 0%, rgba(0, 0, 0, 0) 70%);
}

/* Glassmorphism Panel */
.glass-panel {
    background: var(--surface-light);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--surface-border);
}

/* Header */
.app-header {
    padding: 1.25rem 2rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 40;
    border-bottom: 1px solid var(--surface-border);
    border-radius: 0 0 24px 24px;
}

.logo {
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -0.03em;
    background: var(--gradient-1);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.logo span {
    color: var(--text-secondary);
    font-weight: 300;
    -webkit-text-fill-color: var(--text-secondary);
}

.header-controls {
    display: flex;
    align-items: center;
}

.nav-group {
    display: flex;
    align-items: center;
    gap: 1.25rem;
}

/* Tokens */
.token-badge {
    padding: 0.5rem 1rem;
    border-radius: 20px;
    font-size: 0.875rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: inset 0 1px 1px rgba(255, 255, 255, 0.05);
}

.token-badge.usage {
    opacity: 0.6;
}

.token-label {
    color: var(--text-secondary);
    font-weight: 300;
}

.token-value {
    font-weight: 700;
    color: var(--text-primary);
}

/* Buttons */
button {
    font-family: inherit;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.btn-gradient {
    background: var(--gradient-1);
    color: white;
    border: none;
    border-radius: 12px;
    padding: 0.6rem 1.5rem;
    font-size: 0.875rem;
    font-weight: 600;
    box-shadow: 0 4px 15px var(--accent-glow);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.btn-gradient:hover {
    background: var(--gradient-hover);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px var(--accent-glow);
}

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

.btn-secondary {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
    border: 1px solid var(--surface-border);
    border-radius: 12px;
    padding: 0.6rem 1.5rem;
    font-size: 0.875rem;
    font-weight: 500;
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.1);
}

.btn-text {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 0.875rem;
    font-weight: 500;
    padding: 0.5rem;
}

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

.full-width { width: 100%; padding: 0.875rem; }
.pointer-events-none { pointer-events: none; }
.gradient-text {
    background: var(--gradient-1);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

/* Main Stage */
.main-stage {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem 2rem;
    max-width: 1200px;
    margin: 0 auto;
    width: 100%;
}

/* Video Container */
.video-container {
    width: 100%;
    max-width: 1024px;
    aspect-ratio: 21 / 9;
    border-radius: 24px;
    overflow: hidden;
    position: relative;
    box-shadow: 0 30px 60px -15px rgba(0, 0, 0, 0.8);
    margin-bottom: 3rem;
    transition: all 0.4s ease;
}

.placeholder, .loading-state {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.5s ease;
}

.placeholder.active {
    opacity: 1;
    pointer-events: auto;
}

.placeholder svg { 
    margin-bottom: 1.5rem; 
    opacity: 0.4;
    transition: all 0.3s ease;
}

.placeholder:hover svg {
    opacity: 0.8;
    transform: scale(1.05);
}

.placeholder p {
    font-size: 1rem;
    font-weight: 300;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

.placeholder-glow {
    position: absolute;
    width: 150px;
    height: 150px;
    background: var(--accent-glow);
    filter: blur(80px);
    border-radius: 50%;
    opacity: 0.5;
}

.loading-state {
    z-index: 10;
}

.loading-state:not(.hidden) {
    opacity: 1;
    pointer-events: auto;
}

.spinner-modern {
    width: 48px;
    height: 48px;
    border: 3px solid rgba(255,255,255,0.1);
    border-radius: 50%;
    border-top-color: #a855f7;
    border-right-color: #6366f1;
    animation: spin 1s cubic-bezier(0.6, 0.2, 0.4, 0.8) infinite;
    margin-bottom: 2rem;
}

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

.loading-state p {
    font-size: 1.125rem;
    font-weight: 600;
    margin-bottom: 1.5rem;
    letter-spacing: 0.02em;
}

.progress-bar-container {
    width: 250px;
    height: 6px;
    background-color: rgba(0,0,0,0.5);
    border-radius: 3px;
    overflow: hidden;
    border: 1px solid rgba(255,255,255,0.05);
}

.progress-bar {
    height: 100%;
    width: 0%;
    background: var(--gradient-1);
    transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 0 10px var(--accent-glow);
}

#video-player {
    width: 100%;
    height: 100%;
    object-fit: cover;
    opacity: 0;
    transition: opacity 0.8s ease;
}

#video-player:not(.hidden) { opacity: 1; }

/* Input Section */
.input-section {
    width: 100%;
    max-width: 800px;
}

.input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    border-radius: 100px;
    padding: 0.5rem 0.5rem 0.5rem 1.5rem;
    transition: all 0.3s ease;
}

.input-wrapper:focus-within {
    border-color: rgba(168, 85, 247, 0.5);
    box-shadow: 0 0 0 1px rgba(168, 85, 247, 0.3), 0 10px 30px rgba(0,0,0,0.5);
    background: rgba(255, 255, 255, 0.05);
}

#prompt-input {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-family: inherit;
    font-size: 1.05rem;
    padding: 0.75rem 1rem 0.75rem 0;
    outline: none;
    font-weight: 300;
}

#prompt-input::placeholder { color: var(--text-secondary); }

.enhancer-selector {
    margin-right: 0.5rem;
    position: relative;
    display: flex;
    align-items: center;
}

.glass-select {
    appearance: none;
    background: rgba(0,0,0,0.4);
    border: 1px solid rgba(255,255,255,0.1);
    color: var(--text-primary);
    padding: 0.5rem 2rem 0.5rem 1rem;
    border-radius: 100px;
    font-family: inherit;
    font-size: 0.875rem;
    font-weight: 400;
    outline: none;
    cursor: pointer;
    transition: all 0.3s ease;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='rgba(255,255,255,0.7)' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.5rem center;
    background-size: 1rem;
}

.glass-select:focus, .glass-select:hover {
    border-color: rgba(168, 85, 247, 0.5);
    background-color: rgba(0,0,0,0.6);
}

.glass-select option {
    background-color: var(--surface-light);
    color: var(--bg-color); /* Note: native select dropdown styling is limited, using dark text for contrast if OS forces light BG */
}

#generate-btn {
    border-radius: 100px;
    padding: 0.875rem 2rem;
    font-size: 1rem;
}

.error-message {
    color: var(--error-color);
    font-size: 0.875rem;
    margin-top: 1.5rem;
    text-align: center;
    padding: 1rem;
    background-color: rgba(239, 68, 68, 0.1);
    border-radius: 12px;
    border: 1px solid rgba(239, 68, 68, 0.2);
    backdrop-filter: blur(4px);
}

/* Modals */
.modal-overlay {
    position: fixed;
    inset: 0;
    background-color: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    z-index: 50;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 1;
    transition: opacity 0.3s ease;
}

.modal-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

.modal {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -45%);
    border-radius: 24px;
    padding: 2.5rem;
    width: 90%;
    max-width: 420px;
    z-index: 51;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.8), 0 0 0 1px rgba(255,255,255,0.05);
    opacity: 1;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.modal.hidden {
    opacity: 0;
    transform: translate(-50%, -40%) scale(0.95);
    pointer-events: none;
}

#topup-modal { max-width: 700px; }

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

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

.close-btn {
    background: rgba(255,255,255,0.05);
    border: 1px solid rgba(255,255,255,0.1);
    color: var(--text-secondary);
    font-size: 1rem;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.close-btn:hover { 
    color: var(--text-primary); 
    background: rgba(255,255,255,0.1);
}

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

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

.form-group input {
    width: 100%;
    background-color: rgba(0,0,0,0.3);
    border: 1px solid rgba(255,255,255,0.1);
    color: var(--text-primary);
    border-radius: 12px;
    padding: 1rem;
    outline: none;
    font-family: inherit;
    font-size: 1rem;
    transition: all 0.3s ease;
}

.form-group input:focus {
    border-color: #a855f7;
    box-shadow: 0 0 0 2px rgba(168, 85, 247, 0.2);
}

.form-error {
    color: var(--error-color);
    font-size: 0.875rem;
    margin-bottom: 1.5rem;
    background-color: rgba(239, 68, 68, 0.1);
    padding: 0.75rem;
    border-radius: 8px;
    border: 1px solid rgba(239, 68, 68, 0.2);
}

.form-success {
    color: var(--success-color);
    font-size: 0.875rem;
    margin-top: 1.5rem;
    text-align: center;
    background-color: rgba(34, 197, 94, 0.1);
    padding: 0.75rem;
    border-radius: 8px;
    border: 1px solid rgba(34, 197, 94, 0.2);
}

.modal-hint {
    font-size: 0.875rem;
    margin-bottom: 1.5rem;
    text-align: center;
    font-weight: 500;
}

/* Pricing Tiers */
.pricing-tiers {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
}

.tier {
    border-radius: 20px;
    padding: 2rem;
    text-align: center;
    position: relative;
    cursor: pointer;
    transition: all 0.3s ease;
}

.tier:hover {
    border-color: rgba(168, 85, 247, 0.5);
    transform: translateY(-5px);
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
}

.tier.popular {
    border-color: rgba(99, 102, 241, 0.5);
    background: linear-gradient(180deg, rgba(99, 102, 241, 0.1) 0%, transparent 100%);
}

.tier.popular:hover {
    border-color: #6366f1;
}

.popular-badge {
    position: absolute;
    top: -12px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--gradient-1);
    color: white;
    font-size: 0.75rem;
    font-weight: 700;
    padding: 4px 12px;
    border-radius: 100px;
    box-shadow: 0 4px 10px var(--accent-glow);
}

.tier h3 {
    font-weight: 500;
    color: var(--text-secondary);
    font-size: 1.125rem;
}

.tier-price {
    font-size: 2.5rem;
    font-weight: 700;
    margin: 1rem 0 0.5rem 0;
    color: var(--text-primary);
}

.tier-tokens {
    color: var(--text-secondary);
    font-size: 1rem;
    margin-bottom: 2rem;
    font-weight: 300;
}

.hidden { display: none !important; }
