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

/* FFmpeg Status Bar */
.ffmpeg-status {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    background: linear-gradient(90deg, #4F46E5, #7C3AED);
    color: white;
    padding: 8px 20px;
    z-index: 1000;
    transform: translateY(0);
    transition: transform 0.3s ease, opacity 0.3s ease;
}

.ffmpeg-status.hidden {
    transform: translateY(-100%);
    opacity: 0;
    pointer-events: none;
}

.ffmpeg-status.ready {
    background: linear-gradient(90deg, #10B981, #059669);
}

.ffmpeg-status-content {
    max-width: 1100px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    gap: 16px;
    font-size: 0.875rem;
}

.ffmpeg-status-text {
    white-space: nowrap;
}

.ffmpeg-status-bar {
    flex: 1;
    max-width: 200px;
    height: 6px;
    background: rgba(255,255,255,0.3);
    border-radius: 100px;
    overflow: hidden;
}

.ffmpeg-status-fill {
    height: 100%;
    background: white;
    width: 0%;
    transition: width 0.3s ease;
    border-radius: 100px;
}

body.ffmpeg-loading {
    padding-top: 40px;
}

:root {
    --primary: #4F46E5;
    --primary-dark: #4338CA;
    --primary-light: #6366F1;
    --secondary: #10B981;
    --background: #F9FAFB;
    --surface: #FFFFFF;
    --text: #111827;
    --text-secondary: #6B7280;
    --border: #E5E7EB;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.1), 0 1px 2px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --radius: 12px;
    --radius-sm: 8px;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--background);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
}

.container {
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 20px;
}

/* Loading Screen */
.loading-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--surface);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.loading-content {
    text-align: center;
    max-width: 400px;
    padding: 40px;
}

.loading-logo {
    margin-bottom: 24px;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.05); opacity: 0.8; }
}

.loading-title {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 8px;
}

.loading-text {
    color: var(--text-secondary);
    margin-bottom: 24px;
}

.loading-bar {
    background: var(--border);
    border-radius: 100px;
    height: 8px;
    overflow: hidden;
    margin-bottom: 12px;
}

.loading-bar-fill {
    background: linear-gradient(90deg, var(--primary), var(--primary-light));
    height: 100%;
    width: 0%;
    transition: width 0.3s ease;
    border-radius: 100px;
}

.loading-percent {
    font-size: 0.875rem;
    color: var(--primary);
    font-weight: 600;
}

/* Header */
.header {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 16px 0;
    position: sticky;
    top: 0;
    z-index: 100;
}

.header .container {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 700;
    font-size: 1.25rem;
    color: var(--text);
    text-decoration: none;
}

.nav {
    display: flex;
    gap: 32px;
}

.nav a {
    color: var(--text-secondary);
    text-decoration: none;
    font-weight: 500;
    transition: color 0.2s;
}

.nav a:hover {
    color: var(--primary);
}

/* Main */
.main {
    padding: 48px 0 80px;
}

/* Hero */
.hero {
    text-align: center;
    margin-bottom: 48px;
}

.hero h1 {
    font-size: 2.5rem;
    font-weight: 800;
    color: var(--text);
    margin-bottom: 16px;
    line-height: 1.2;
}

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

/* Converter Card */
.converter-card {
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    padding: 32px;
    margin-bottom: 64px;
}

/* Upload Area */
.upload-area {
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    padding: 48px 24px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
}

.upload-area:hover {
    border-color: var(--primary);
    background: rgba(79, 70, 229, 0.02);
}

.upload-area.dragover {
    border-color: var(--primary);
    background: rgba(79, 70, 229, 0.05);
}

.upload-icon {
    color: var(--primary);
    margin-bottom: 16px;
}

.upload-area h3 {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 4px;
}

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

.file-types {
    font-size: 0.75rem;
    color: var(--text-secondary);
    background: var(--background);
    padding: 6px 12px;
    border-radius: 100px;
    display: inline-block;
}

/* Preview Section */
.preview-section {
    margin-bottom: 24px;
}

.video-info {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
    padding: 12px 16px;
    background: var(--background);
    border-radius: var(--radius-sm);
}

.file-name {
    font-weight: 500;
    color: var(--text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.btn-remove {
    background: none;
    border: none;
    color: #EF4444;
    cursor: pointer;
    font-weight: 500;
    padding: 4px 8px;
}

.btn-remove:hover {
    text-decoration: underline;
}

#videoPreview {
    width: 100%;
    max-height: 400px;
    border-radius: var(--radius-sm);
    background: #000;
}

/* Convert Options */
.convert-options {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.format-selector label {
    display: block;
    font-weight: 600;
    margin-bottom: 12px;
}

.format-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

/* Format Categories */
.format-categories {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.category-btn {
    padding: 8px 16px;
    border: none;
    background: var(--background);
    border-radius: 100px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    color: var(--text-secondary);
}

.category-btn:hover {
    background: var(--border);
}

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

.format-group {
    margin-bottom: 16px;
}

.format-btn {
    padding: 12px 16px;
    border: 2px solid var(--border);
    background: var(--surface);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.2s;
    text-align: left;
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 100px;
}

.format-btn strong {
    font-weight: 600;
    font-size: 0.95rem;
}

.format-btn span {
    font-size: 0.7rem;
    color: var(--text-secondary);
}

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

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

.format-btn.active span {
    color: rgba(255,255,255,0.8);
}

.format-note {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-top: 12px;
    padding: 8px 12px;
    background: #FEF3C7;
    border-radius: var(--radius-sm);
    color: #92400E;
}

/* Advanced Options */
.advanced-options {
    margin-top: 8px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0;
}

.advanced-options summary {
    padding: 12px 16px;
    cursor: pointer;
    font-weight: 500;
    color: var(--text-secondary);
    list-style: none;
}

.advanced-options summary::-webkit-details-marker {
    display: none;
}

.advanced-options summary::before {
    content: '+ ';
}

.advanced-options[open] summary::before {
    content: '- ';
}

.options-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 16px;
    padding: 0 16px 16px;
}

.option-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

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

.option-group select,
.option-group input {
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    background: var(--surface);
}

.option-group select:focus,
.option-group input:focus {
    outline: none;
    border-color: var(--primary);
}

/* Formats Section */
.formats-section {
    margin-bottom: 64px;
}

.formats-section h2 {
    text-align: center;
    font-size: 1.75rem;
    margin-bottom: 40px;
}

.formats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 20px;
}

.format-card {
    background: var(--surface);
    padding: 20px;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.format-card h3 {
    font-size: 1rem;
    margin-bottom: 8px;
    color: var(--primary);
}

.format-card p {
    font-size: 0.85rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

/* Output Files List */
.output-files {
    background: var(--background);
    border-radius: var(--radius-sm);
    padding: 16px;
    margin-bottom: 20px;
    text-align: left;
}

.output-files h4 {
    margin-bottom: 12px;
    font-size: 0.9rem;
}

.output-files ul {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.output-files li {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px;
    background: var(--surface);
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
}

.output-files li a {
    color: var(--primary);
    text-decoration: none;
}

.btn-convert {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background: var(--primary);
    color: white;
    border: none;
    padding: 14px 32px;
    border-radius: var(--radius-sm);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    align-self: flex-start;
}

.btn-convert:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
}

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

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

.progress-section h3 {
    margin-bottom: 20px;
    color: var(--text);
}

.progress-bar {
    background: var(--border);
    border-radius: 100px;
    height: 12px;
    overflow: hidden;
    margin-bottom: 12px;
}

.progress-fill {
    background: linear-gradient(90deg, var(--primary), var(--secondary));
    height: 100%;
    width: 0%;
    transition: width 0.3s ease;
    border-radius: 100px;
}

.progress-text {
    font-weight: 600;
    color: var(--primary);
}

.log-details {
    margin-top: 20px;
    text-align: left;
}

.log-details summary {
    cursor: pointer;
    color: var(--text-secondary);
    font-size: 0.875rem;
}

#logOutput {
    margin-top: 12px;
    padding: 16px;
    background: var(--background);
    border-radius: var(--radius-sm);
    max-height: 200px;
    overflow-y: auto;
    font-size: 0.75rem;
    font-family: 'Monaco', 'Menlo', monospace;
    color: var(--text-secondary);
    white-space: pre-wrap;
    word-break: break-all;
}

/* Output Section */
.output-section {
    text-align: center;
}

.output-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
}

.output-header h3 {
    color: var(--secondary);
}

.btn-new {
    background: none;
    border: 1px solid var(--border);
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-weight: 500;
    transition: all 0.2s;
}

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

#outputVideo, #outputAudio {
    width: 100%;
    max-height: 400px;
    border-radius: var(--radius-sm);
    margin-bottom: 20px;
}

#outputGif {
    max-width: 100%;
    border-radius: var(--radius-sm);
    margin-bottom: 20px;
}

.btn-download {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: var(--secondary);
    color: white;
    padding: 14px 32px;
    border-radius: var(--radius-sm);
    text-decoration: none;
    font-weight: 600;
    transition: all 0.2s;
}

.btn-download:hover {
    background: #059669;
    transform: translateY(-1px);
}

/* Features Section */
.features {
    margin-bottom: 64px;
}

.features h2 {
    text-align: center;
    font-size: 1.75rem;
    margin-bottom: 40px;
}

.features-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 24px;
}

.feature-card {
    background: var(--surface);
    padding: 24px;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    transition: all 0.2s;
}

.feature-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
}

.feature-icon {
    width: 48px;
    height: 48px;
    background: rgba(79, 70, 229, 0.1);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--primary);
    margin-bottom: 16px;
}

.feature-card h3 {
    font-size: 1.125rem;
    margin-bottom: 8px;
}

.feature-card p {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

/* How It Works */
.how-it-works {
    text-align: center;
    margin-bottom: 64px;
}

.how-it-works h2 {
    font-size: 1.75rem;
    margin-bottom: 40px;
}

.steps {
    display: flex;
    justify-content: center;
    gap: 48px;
    flex-wrap: wrap;
}

.step {
    max-width: 200px;
}

.step-number {
    width: 48px;
    height: 48px;
    background: var(--primary);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1.25rem;
    margin: 0 auto 16px;
}

.step h3 {
    font-size: 1.125rem;
    margin-bottom: 8px;
}

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

/* Footer */
.footer {
    background: var(--surface);
    border-top: 1px solid var(--border);
    padding: 32px 0;
    text-align: center;
}

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

.footer a {
    color: var(--primary);
    text-decoration: none;
}

.footer a:hover {
    text-decoration: underline;
}

.copyright {
    margin-top: 8px;
    font-size: 0.75rem;
}

/* Responsive */
@media (max-width: 768px) {
    .hero h1 {
        font-size: 1.75rem;
    }

    .hero-subtitle {
        font-size: 1rem;
    }

    .nav {
        display: none;
    }

    .converter-card {
        padding: 20px;
    }

    .upload-area {
        padding: 32px 16px;
    }

    .format-buttons {
        justify-content: center;
    }

    .btn-convert {
        width: 100%;
    }

    .output-header {
        flex-direction: column;
        gap: 12px;
        text-align: center;
    }

    .steps {
        flex-direction: column;
        align-items: center;
    }
}
