/* ==========================================
   CSS Variables & Reset
   ========================================== */
:root {
    /* Dark Theme Colors */
    --bg-primary: #0a0e1a;
    --bg-secondary: #151b2e;
    --bg-card: rgba(25, 35, 60, 0.6);
    --bg-glass: rgba(255, 255, 255, 0.05);

    --text-primary: #ffffff;
    --text-secondary: #a0aec0;
    --text-muted: #64748b;

    --accent-primary: #6366f1;
    --accent-secondary: #8b5cf6;
    --accent-gradient: linear-gradient(135deg, #6366f1 0%, #8b5cf6 50%, #ec4899 100%);

    --success: #10b981;
    --error: #ef4444;
    --warning: #f59e0b;

    --border-color: rgba(255, 255, 255, 0.1);
    --glow-color: rgba(99, 102, 241, 0.3);

    /* Spacing */
    --spacing-xs: 0.5rem;
    --spacing-sm: 1rem;
    --spacing-md: 1.5rem;
    --spacing-lg: 2rem;
    --spacing-xl: 3rem;

    /* Border Radius */
    --radius-sm: 0.5rem;
    --radius-md: 1rem;
    --radius-lg: 1.5rem;
    --radius-full: 9999px;

    /* Shadows */
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.1);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.2);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.3);
    --shadow-glow: 0 0 40px rgba(99, 102, 241, 0.3);

    /* Transitions */
    --transition-fast: 0.2s ease;
    --transition-base: 0.3s ease;
    --transition-slow: 0.5s ease;
}

/* Light Theme */
[data-theme="light"] {
    --bg-primary: #f8fafc;
    --bg-secondary: #ffffff;
    --bg-card: rgba(255, 255, 255, 0.9);
    --bg-glass: rgba(0, 0, 0, 0.02);

    --text-primary: #1e293b;
    --text-secondary: #475569;
    --text-muted: #94a3b8;

    --accent-primary: #6366f1;
    --accent-secondary: #8b5cf6;
    --accent-gradient: linear-gradient(135deg, #6366f1 0%, #8b5cf6 50%, #ec4899 100%);

    --border-color: rgba(0, 0, 0, 0.1);
    --glow-color: rgba(99, 102, 241, 0.2);

    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.12);
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    transition: background-color var(--transition-base), color var(--transition-base);
    overflow-x: hidden;
    position: relative;
}

/* Background Effects */
body::before {
    content: '';
    position: fixed;
    top: -50%;
    right: -50%;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle, rgba(99, 102, 241, 0.1) 0%, transparent 70%);
    animation: pulse 8s ease-in-out infinite;
    pointer-events: none;
    z-index: 0;
}

body::after {
    content: '';
    position: fixed;
    bottom: -50%;
    left: -50%;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle, rgba(139, 92, 246, 0.08) 0%, transparent 70%);
    animation: pulse 12s ease-in-out infinite reverse;
    pointer-events: none;
    z-index: 0;
}

@keyframes pulse {

    0%,
    100% {
        transform: scale(1);
        opacity: 1;
    }

    50% {
        transform: scale(1.1);
        opacity: 0.8;
    }
}

/* ==========================================
   Layout
   ========================================== */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: var(--spacing-lg);
    position: relative;
    z-index: 1;
}

/* ==========================================
   Header
   ========================================== */
.header {
    text-align: center;
    margin-bottom: var(--spacing-xl);
    animation: fadeInDown 0.8s ease;
    position: relative;
}

/* Theme Toggle Button */
.theme-toggle {
    position: absolute;
    top: 0;
    right: 0;
    width: 48px;
    height: 48px;
    border: none;
    background: var(--bg-card);
    backdrop-filter: blur(10px);
    border-radius: var(--radius-full);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-base);
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border-color);
}

.theme-toggle:hover {
    transform: scale(1.1) rotate(10deg);
    box-shadow: var(--shadow-lg);
}

.theme-icon {
    width: 24px;
    height: 24px;
    color: var(--accent-primary);
    position: absolute;
    transition: all var(--transition-base);
}

.sun-icon {
    opacity: 0;
    transform: rotate(-90deg) scale(0.5);
}

.moon-icon {
    opacity: 1;
    transform: rotate(0deg) scale(1);
}

[data-theme="light"] .sun-icon {
    opacity: 1;
    transform: rotate(0deg) scale(1);
}

[data-theme="light"] .moon-icon {
    opacity: 0;
    transform: rotate(90deg) scale(0.5);
}

/* Language Toggle Button */
.lang-toggle {
    position: absolute;
    top: 0;
    right: 60px;
    width: 48px;
    height: 48px;
    border: none;
    background: var(--bg-card);
    backdrop-filter: blur(10px);
    border-radius: var(--radius-full);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-base);
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border-color);
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--accent-primary);
}

.lang-toggle:hover {
    transform: scale(1.1);
    box-shadow: var(--shadow-lg);
}

.logo {
    display: inline-flex;
    align-items: center;
    gap: var(--spacing-md);
    margin-bottom: var(--spacing-md);
}

.logo-icon {
    width: 64px;
    height: 64px;
    color: var(--accent-primary);
    filter: drop-shadow(0 0 20px var(--glow-color));
    animation: float 3s ease-in-out infinite;
}

@keyframes float {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-10px);
    }
}

.logo-text h1 {
    font-size: 2.5rem;
    font-weight: 700;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    margin: 0;
}

.logo-subtitle {
    display: block;
    font-size: 1rem;
    color: var(--text-secondary);
    font-weight: 500;
    letter-spacing: 0.1em;
    text-transform: uppercase;
}

.tagline {
    font-size: 1.125rem;
    color: var(--text-secondary);
    max-width: 600px;
    margin: 0 auto;
}

/* ==========================================
   Upload Section
   ========================================== */
.upload-section {
    animation: fadeIn 1s ease;
}

.upload-area {
    background: var(--bg-card);
    backdrop-filter: blur(20px);
    border: 2px dashed var(--accent-primary);
    border-radius: var(--radius-lg);
    padding: var(--spacing-xl);
    text-align: center;
    transition: all var(--transition-base);
    cursor: pointer;
    position: relative;
    overflow: hidden;
}

.upload-area::before {
    content: '';
    position: absolute;
    inset: 0;
    background: var(--accent-gradient);
    opacity: 0;
    transition: opacity var(--transition-base);
}

.upload-area:hover {
    border-color: var(--accent-primary);
    box-shadow: var(--shadow-glow);
    transform: translateY(-4px);
}

.upload-area:hover::before {
    opacity: 0.05;
}

.upload-area.drag-over {
    border-color: var(--accent-primary);
    background: rgba(99, 102, 241, 0.1);
    transform: scale(1.02);
}

.upload-icon {
    width: 80px;
    height: 80px;
    margin: 0 auto var(--spacing-md);
    color: var(--accent-primary);
    animation: bounce 2s ease-in-out infinite;
}

@keyframes bounce {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-10px);
    }
}

.upload-icon svg {
    width: 100%;
    height: 100%;
}

.upload-area h2 {
    font-size: 1.5rem;
    margin-bottom: var(--spacing-sm);
    color: var(--text-primary);
}

.upload-area p {
    color: var(--text-secondary);
    margin-bottom: var(--spacing-md);
}

/* ==========================================
   Buttons
   ========================================== */
.btn {
    display: inline-flex;
    align-items: center;
    gap: var(--spacing-xs);
    padding: 0.875rem 1.75rem;
    font-size: 1rem;
    font-weight: 600;
    border: none;
    border-radius: var(--radius-full);
    cursor: pointer;
    transition: all var(--transition-base);
    font-family: inherit;
    position: relative;
    overflow: hidden;
}

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

.btn::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(45deg, transparent, rgba(255, 255, 255, 0.1), transparent);
    transform: translateX(-100%);
    transition: transform var(--transition-base);
}

.btn:hover::before {
    transform: translateX(100%);
}

.btn-primary {
    background: var(--accent-gradient);
    color: white;
    box-shadow: 0 4px 16px rgba(99, 102, 241, 0.4);
}

.btn-primary:hover {
    box-shadow: 0 6px 24px rgba(99, 102, 241, 0.6);
    transform: translateY(-2px);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-secondary {
    background: var(--bg-glass);
    color: var(--text-primary);
    border: 1px solid rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
}

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

.btn-download {
    font-size: 1.125rem;
    padding: 1rem 2rem;
}

/* ==========================================
   Preview Section
   ========================================== */
.preview-section {
    animation: fadeInUp 0.6s ease;
}

.controls-card,
.preview-card,
.actions-card,
.progress-card,
.download-card {
    transition: all var(--transition-base);
    background: var(--bg-card);
    backdrop-filter: blur(20px);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: var(--spacing-lg);
    margin-bottom: var(--spacing-lg);
    box-shadow: var(--shadow-md);
}

.controls-card h3,
.preview-card h3,
.download-card h3 {
    font-size: 1.25rem;
    margin-bottom: var(--spacing-md);
    color: var(--text-primary);
}

.controls-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: var(--spacing-md);
    margin-bottom: var(--spacing-md);
}

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

.input-field {
    width: 100%;
    padding: 0.75rem 1rem;
    font-size: 1rem;
    background: var(--bg-glass);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: inherit;
    transition: all var(--transition-fast);
}

.input-field:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
}

.quick-presets {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    flex-wrap: wrap;
}

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

.btn-preset {
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    font-weight: 600;
    background: var(--bg-glass);
    border: 1px solid rgba(99, 102, 241, 0.3);
    border-radius: var(--radius-sm);
    color: var(--accent-primary);
    cursor: pointer;
    transition: all var(--transition-fast);
    font-family: inherit;
}

.btn-preset:hover {
    background: rgba(99, 102, 241, 0.1);
    border-color: var(--accent-primary);
    transform: scale(1.05);
}

/* Preview Canvas */
.preview-container {
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
    padding: var(--spacing-md);
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 300px;
    margin-bottom: var(--spacing-md);
    overflow: auto;
}

#previewCanvas {
    max-width: 100%;
    height: auto;
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-lg);
}

.preview-info {
    display: flex;
    justify-content: space-between;
    gap: var(--spacing-md);
    font-size: 0.875rem;
    color: var(--text-secondary);
    flex-wrap: wrap;
}

/* Actions */
.actions-card {
    display: flex;
    gap: var(--spacing-md);
    justify-content: center;
    flex-wrap: wrap;
}

/* Progress */
.progress-card {
    text-align: center;
}

.progress-info {
    display: flex;
    justify-content: space-between;
    margin-bottom: var(--spacing-sm);
    color: var(--text-secondary);
}

.progress-bar {
    width: 100%;
    height: 8px;
    background: var(--bg-glass);
    border-radius: var(--radius-full);
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: var(--accent-gradient);
    border-radius: var(--radius-full);
    transition: width var(--transition-base);
    box-shadow: 0 0 10px rgba(99, 102, 241, 0.5);
}

/* Download Card */
.download-card {
    text-align: center;
}

.success-icon {
    width: 64px;
    height: 64px;
    margin: 0 auto var(--spacing-md);
    color: var(--success);
    animation: scaleIn 0.5s ease;
}

.success-icon svg {
    width: 100%;
    height: 100%;
}

@keyframes scaleIn {
    from {
        transform: scale(0);
        opacity: 0;
    }

    to {
        transform: scale(1);
        opacity: 1;
    }
}

.download-card p {
    color: var(--text-secondary);
    margin-bottom: var(--spacing-md);
}

/* ==========================================
   Footer
   ========================================== */
.footer {
    text-align: center;
    margin-top: var(--spacing-xl);
    padding-top: var(--spacing-lg);
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    color: var(--text-muted);
    font-size: 0.875rem;
}

.footer p {
    margin-bottom: var(--spacing-xs);
}

.copyright {
    opacity: 0.6;
}

/* ==========================================
   Toast Notifications
   ========================================== */
.toast {
    position: fixed;
    bottom: var(--spacing-lg);
    right: var(--spacing-lg);
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    background: rgba(239, 68, 68, 0.95);
    backdrop-filter: blur(10px);
    color: white;
    padding: 1rem 1.5rem;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    z-index: 1000;
    animation: slideInRight 0.3s ease;
    max-width: 400px;
}

.toast-icon {
    width: 24px;
    height: 24px;
    flex-shrink: 0;
}

@keyframes slideInRight {
    from {
        transform: translateX(100%);
        opacity: 0;
    }

    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* ==========================================
   Utility Classes
   ========================================== */
.hidden {
    display: none !important;
}

/* ==========================================
   Animations
   ========================================== */
@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes fadeInDown {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ==========================================
   Responsive Design
   ========================================== */
@media (max-width: 768px) {
    .container {
        padding: var(--spacing-md);
    }

    .header {
        padding-top: 65px;
    }

    /* Larger touch targets for mobile */
    .theme-toggle {
        top: 8px;
        right: 8px;
        width: 52px;
        height: 52px;
    }

    .lang-toggle {
        top: 8px;
        right: 68px;
        width: 52px;
        height: 52px;
    }

    .logo {
        flex-direction: column;
        gap: var(--spacing-sm);
    }

    .logo-icon {
        width: 48px;
        height: 48px;
    }

    .logo-text h1 {
        font-size: 2rem;
    }

    .tagline {
        font-size: 1rem;
    }

    .upload-area {
        padding: var(--spacing-lg);
    }

    .upload-icon {
        width: 60px;
        height: 60px;
    }

    .controls-grid {
        grid-template-columns: 1fr;
    }

    .actions-card {
        flex-direction: column;
    }

    .actions-card .btn {
        width: 100%;
        justify-content: center;
    }

    .toast {
        bottom: var(--spacing-sm);
        right: var(--spacing-sm);
        left: var(--spacing-sm);
        max-width: none;
    }
}

@media (max-width: 480px) {
    .logo-text h1 {
        font-size: 1.75rem;
    }

    .quick-presets {
        justify-content: center;
    }

    .preview-info {
        flex-direction: column;
        text-align: center;
    }

    /* Better mobile typography */
    .upload-area h2 {
        font-size: 1.25rem;
    }

    .upload-area p {
        font-size: 0.875rem;
    }

    /* Ensure minimum touch target size (48px) */
    .btn {
        min-height: 48px;
        padding: 1rem 1.5rem;
    }

    .btn-preset {
        min-height: 44px;
        padding: 0.75rem 1rem;
    }

    /* Canvas touch optimization */
    .preview-container {
        min-height: 200px;
        -webkit-overflow-scrolling: touch;
    }

    /* Smaller buttons on very small screens */
    .theme-toggle,
    .lang-toggle {
        width: 48px;
        height: 48px;
    }

    .lang-toggle {
        right: 60px;
    }
}