/* ===== Design System Variables ===== */
:root {
    --brand-primary: #6366f1;
    --brand-primary-hover: #4f46e5;
    --brand-secondary: #8b5cf6;
    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;

    --font-sans: 'Inter', sans-serif;
    --font-heading: 'Outfit', sans-serif;

    /* Light Theme Core */
    --bg-base: #f8fafc;
    --bg-surface: rgba(255, 255, 255, 0.7);
    --bg-surface-solid: #ffffff;
    --bg-surface-hover: rgba(255, 255, 255, 0.9);
    --border-glass: rgba(255, 255, 255, 0.5);
    --border-light: #e2e8f0;
    
    --text-main: #0f172a;
    --text-muted: #64748b;
    --text-invert: #ffffff;

    --shadow-glass: 0 8px 32px 0 rgba(31, 38, 135, 0.05);
    --mesh-gradient: radial-gradient(at 0% 0%, hsla(253,16%,7%,1) 0, transparent 50%), radial-gradient(at 50% 0%, hsla(225,39%,30%,1) 0, transparent 50%), radial-gradient(at 100% 0%, hsla(339,49%,30%,1) 0, transparent 50%);
}

.dark {
    /* Dark Theme Core */
    --bg-base: #020617;
    --bg-surface: rgba(15, 23, 42, 0.6);
    --bg-surface-solid: #0f172a;
    --bg-surface-hover: rgba(30, 41, 59, 0.8);
    --border-glass: rgba(255, 255, 255, 0.08);
    --border-light: #1e293b;
    
    --text-main: #f8fafc;
    --text-muted: #94a3b8;

    --shadow-glass: 0 8px 32px 0 rgba(0, 0, 0, 0.3);
    --mesh-gradient: radial-gradient(at 40% 20%, hsla(28,100%,74%,0.15) 0px, transparent 50%),
                     radial-gradient(at 80% 0%, hsla(189,100%,56%,0.15) 0px, transparent 50%),
                     radial-gradient(at 0% 50%, hsla(355,100%,93%,0.1) 0px, transparent 50%);
}

/* ===== Resets & Base ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--font-sans);
    background-color: var(--bg-base);
    color: var(--text-main);
    line-height: 1.5;
    min-height: 100vh;
    overflow-x: hidden;
    transition: background-color 0.4s ease, color 0.4s ease;
}

h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-heading);
    color: var(--text-main);
    margin-bottom: 0.5rem;
}

button, input, select {
    font-family: inherit;
    border: none;
    outline: none;
    background: none;
    color: inherit;
}

.hidden { display: none !important; }
.text-center { text-align: center; }
.text-muted { color: var(--text-muted); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.mt-4 { margin-top: 1rem; }
.mb-2 { margin-bottom: 0.5rem; }
.mb-4 { margin-bottom: 1rem; }
.mb-6 { margin-bottom: 1.5rem; }
.w-full { width: 100%; }
.mx-auto { margin-left: auto; margin-right: auto; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.gap-4 { display: flex; flex-direction: column; gap: 1rem; }
.truncate { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 200px; }

/* ===== Backgrounds ===== */
.bg-mesh {
    position: fixed;
    top: 0; left: 0; width: 100vw; height: 100vh;
    background-image: var(--mesh-gradient);
    z-index: -2;
    transition: background-image 0.5s ease;
}

.bg-particles {
    position: fixed;
    top: 0; left: 0; width: 100vw; height: 100vh;
    background: url('data:image/svg+xml;utf8,<svg width="20" height="20" xmlns="http://www.w3.org/2000/svg"><circle cx="2" cy="2" r="1" fill="rgba(255,255,255,0.05)"/></svg>');
    z-index: -1;
}

.dark .bg-particles {
    background: url('data:image/svg+xml;utf8,<svg width="20" height="20" xmlns="http://www.w3.org/2000/svg"><circle cx="2" cy="2" r="1" fill="rgba(255,255,255,0.03)"/></svg>');
}

/* ===== Layout ===== */
.app-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.main-content { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 2rem 0; }

/* ===== Components: Glassmorphism ===== */
.glass {
    background: var(--bg-surface);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--border-glass);
    border-radius: 1.5rem;
    box-shadow: var(--shadow-glass);
}

.glass-inner {
    background: rgba(0, 0, 0, 0.03);
    border-radius: 1rem;
    padding: 1rem;
    border: 1px solid var(--border-glass);
}
.dark .glass-inner {
    background: rgba(255, 255, 255, 0.03);
}

.panel-shadow {
    box-shadow: 0 10px 40px -10px rgba(0,0,0,0.1);
}
.dark .panel-shadow {
    box-shadow: 0 10px 40px -10px rgba(0,0,0,0.5);
}

/* ===== Navbar ===== */
.navbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    border-radius: 1rem;
}

.brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 1.25rem;
}

.logo-icon { color: var(--brand-primary); }

.icon-btn {
    width: 2.5rem;
    height: 2.5rem;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    background: var(--bg-surface-hover);
    border: 1px solid var(--border-glass);
    transition: all 0.2s ease;
}
.icon-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.dark .moon-icon { display: none; }
.sun-icon { display: none; }
.dark .sun-icon { display: block; color: #fbbf24; }
.moon-icon { color: #475569; }

/* ===== Hero ===== */
.hero { margin-bottom: 3rem; max-width: 800px; }
.badge {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    background: rgba(99, 102, 241, 0.1);
    color: var(--brand-primary);
    border-radius: 2rem;
    font-size: 0.875rem;
    font-weight: 600;
    margin-bottom: 1rem;
    border: 1px solid rgba(99, 102, 241, 0.2);
}
.hero-title { font-size: 3.5rem; font-weight: 700; line-height: 1.1; margin-bottom: 1rem; }
.text-gradient {
    background: linear-gradient(135deg, var(--brand-primary), var(--brand-secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}
.hero-subtitle { font-size: 1.125rem; color: var(--text-muted); }

/* ===== Workspace ===== */
.workspace-grid {
    display: grid;
    grid-template-columns: 1fr 320px;
    gap: 2rem;
    width: 100%;
    max-width: 900px;
}

@media (max-width: 768px) {
    .workspace-grid { grid-template-columns: 1fr; }
    .hero-title { font-size: 2.5rem; }
}

/* ===== Converter Card ===== */
.converter-card {
    padding: 2.5rem;
    position: relative;
    overflow: hidden;
    min-height: 400px;
}

.state-panel {
    animation: slideIn 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

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

/* Dropzone */
.dropzone {
    border: 2px dashed var(--border-light);
    border-radius: 1rem;
    padding: 3rem 1.5rem;
    text-align: center;
    transition: all 0.3s ease;
    cursor: pointer;
    background: rgba(255,255,255,0.02);
    position: relative;
}
.dropzone:hover, .dropzone.dragover {
    border-color: var(--brand-primary);
    background: rgba(99, 102, 241, 0.05);
}
.dropzone.dragover {
    transform: scale(1.02);
}

.hidden-input {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    opacity: 0; cursor: pointer;
}

.dropzone-icon-ring {
    width: 4rem; height: 4rem;
    border-radius: 50%;
    background: rgba(99, 102, 241, 0.1);
    color: var(--brand-primary);
    display: flex; align-items: center; justify-content: center;
    margin: 0 auto 1.5rem auto;
    transition: transform 0.3s ease;
}
.dropzone:hover .dropzone-icon-ring { transform: translateY(-5px); }
.upload-icon { width: 2rem; height: 2rem; }
.highlight { color: var(--brand-primary); font-weight: 600; }
.file-limits { display: block; font-size: 0.8rem; color: var(--text-muted); margin-top: 1rem; }

.error-msg {
    margin-top: 1rem;
    padding: 0.75rem 1rem;
    background: rgba(239, 68, 68, 0.1);
    color: var(--danger);
    border-radius: 0.5rem;
    display: flex; align-items: center; gap: 0.5rem;
    font-size: 0.875rem;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; } to { opacity: 1; }
}

/* Configure State */
.file-preview-card {
    display: flex;
    align-items: center;
    padding: 1rem;
    background: var(--bg-surface-solid);
    border: 1px solid var(--border-light);
    border-radius: 1rem;
    margin-bottom: 2rem;
    gap: 1rem;
}
.file-icon-box {
    width: 3rem; height: 3rem;
    border-radius: 0.75rem;
    background: rgba(99, 102, 241, 0.1);
    color: var(--brand-primary);
    display: flex; align-items: center; justify-content: center;
}
.file-info { flex: 1; }

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

.select-wrapper { position: relative; }
.modern-input {
    width: 100%;
    padding: 0.75rem 1rem;
    border-radius: 0.75rem;
    border: 1px solid var(--border-light);
    background: var(--bg-surface-solid);
    color: var(--text-main);
    font-size: 1rem;
    appearance: none;
    transition: border-color 0.2s ease;
    cursor: pointer;
}
.modern-input:focus { border-color: var(--brand-primary); }
.select-icon {
    position: absolute; right: 1rem; top: 50%; transform: translateY(-50%);
    pointer-events: none; color: var(--text-muted);
}

.modern-slider {
    width: 100%;
    accent-color: var(--brand-primary);
    cursor: pointer;
}

/* Buttons */
.btn-primary {
    background: linear-gradient(135deg, var(--brand-primary), var(--brand-secondary));
    color: white;
    padding: 1rem 1.5rem;
    border-radius: 0.75rem;
    font-weight: 600;
    font-size: 1rem;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center; gap: 0.5rem;
    transition: transform 0.2s, box-shadow 0.2s;
    border: none;
}
.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 20px -10px var(--brand-primary);
}

.btn-secondary {
    background: var(--bg-surface-solid);
    color: var(--text-main);
    padding: 1rem 1.5rem;
    border-radius: 0.75rem;
    font-weight: 600;
    font-size: 1rem;
    cursor: pointer;
    border: 1px solid var(--border-light);
    transition: background 0.2s;
}
.btn-secondary:hover { background: var(--bg-surface-hover); }

/* Processing State */
.spinner-ring {
    width: 4rem; height: 4rem; margin: 2rem auto;
    position: relative;
}
.spinner {
    width: 100%; height: 100%;
    border: 3px solid var(--border-light);
    border-top-color: var(--brand-primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.progress-bar-container {
    width: 100%; height: 0.5rem;
    background: var(--border-light);
    border-radius: 1rem; overflow: hidden;
}
.progress-bar {
    height: 100%; width: 0%;
    background: linear-gradient(90deg, var(--brand-primary), var(--brand-secondary));
    transition: width 0.3s ease;
}

/* Result State */
.success-icon-ring {
    width: 4rem; height: 4rem;
    background: rgba(16, 185, 129, 0.1);
    color: var(--success);
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
}
.stat-label { display: block; font-size: 0.75rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 0.25rem;}

/* Sidebar */
.history-panel { padding: 1.5rem; }
.history-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1.5rem; border-bottom: 1px solid var(--border-light); padding-bottom: 0.75rem; }
.history-header h3 { font-size: 1.125rem; display: flex; align-items: center; gap: 0.5rem; margin: 0; }
.text-btn { font-size: 0.875rem; color: var(--text-muted); cursor: pointer; }
.text-btn:hover { color: var(--text-main); }

.history-item {
    padding: 0.75rem;
    border-radius: 0.5rem;
    background: var(--bg-surface-solid);
    border: 1px solid var(--border-light);
    margin-bottom: 0.75rem;
    font-size: 0.875rem;
    display: flex; flex-direction: column; gap: 0.25rem;
}
.history-item-header { display: flex; justify-content: space-between; align-items: center;}
.history-item-name { font-weight: 500; }
.history-item-meta { display: flex; justify-content: space-between; color: var(--text-muted); font-size: 0.75rem;}
.history-item-action { margin-top: 0.5rem; color: var(--brand-primary); cursor: pointer; display: flex; align-items: center; gap: 0.25rem; font-weight: 500; font-size: 0.75rem;}

/* Footer */
.footer { margin-top: 3rem; padding: 2rem 0; font-size: 0.875rem; border-top: 1px solid var(--border-glass); }
