/* ===== CSS Variables ===== */
:root {
    --bg-primary: #0f1117;
    --bg-secondary: #1a1d27;
    --bg-tertiary: #242836;
    --bg-hover: #2d3244;
    --border: #2d3244;
    --border-focus: #60a5fa;
    --text-primary: #f8fafc;
    --text-secondary: #cbd5e1;
    --text-muted: #64748b;
    --accent: #60a5fa;
    --accent-hover: #93bbfd;
    --accent-bg: rgba(96, 165, 250, 0.1);
    --success: #22c55e;
    --success-bg: rgba(34, 197, 94, 0.1);
    --error: #ef4444;
    --error-bg: rgba(239, 68, 68, 0.1);
    --radius: 12px;
    --radius-sm: 8px;
    --shadow: 0 4px 24px rgba(0, 0, 0, 0.3);
    --font: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
    --transition: 0.2s ease;
}

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

body {
    font-family: var(--font);
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

/* ===== Accessibility ===== */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

:focus-visible {
    outline: 2px solid var(--border-focus);
    outline-offset: 2px;
}

/* ===== Header ===== */
.header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border);
    background: var(--bg-secondary);
    flex-shrink: 0;
}

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

.logo-icon {
    font-size: 1.3rem;
}

.header-nav {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.85rem;
    color: var(--text-muted);
}

.header-nav a {
    color: var(--accent);
    text-decoration: none;
    transition: color var(--transition);
}

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

/* ===== Main ===== */
.main {
    flex: 1;
    max-width: 800px;
    width: 100%;
    margin: 0 auto;
    padding: 2rem 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

/* ===== Upload Zone ===== */
.upload-zone {
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    padding: 3rem 2rem;
    text-align: center;
    cursor: pointer;
    transition: all var(--transition);
    background: var(--bg-secondary);
    position: relative;
}

.upload-zone:hover,
.upload-zone.drag-over {
    border-color: var(--accent);
    background: var(--accent-bg);
}

.upload-zone.drag-over {
    transform: scale(1.01);
}

.upload-zone:focus-visible {
    outline: 2px solid var(--border-focus);
    outline-offset: 2px;
}

.upload-icon {
    color: var(--accent);
    margin-bottom: 1rem;
}

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

.upload-text strong { color: var(--text-primary); }

.upload-subtext {
    font-size: 0.85rem;
    color: var(--text-muted);
}

/* ===== Error Banner ===== */
.error-banner {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.875rem 1rem;
    background: var(--error-bg);
    border: 1px solid rgba(239, 68, 68, 0.3);
    border-radius: var(--radius-sm);
    color: #fca5a5;
    font-size: 0.9rem;
}

.error-icon { font-size: 1.2rem; flex-shrink: 0; }
.error-text { flex: 1; }

.error-dismiss {
    background: none;
    border: none;
    color: #fca5a5;
    font-size: 1.3rem;
    cursor: pointer;
    padding: 0 0.25rem;
    line-height: 1;
    transition: color var(--transition);
}

.error-dismiss:hover { color: #fff; }

/* ===== Preview Section ===== */
.preview-section {
    background: var(--bg-secondary);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    overflow: hidden;
}

.file-info {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border);
    gap: 0.75rem;
    flex-wrap: wrap;
}

.file-badge {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9rem;
    color: var(--text-primary);
    font-weight: 500;
    min-width: 0;
}

.badge-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--success);
    flex-shrink: 0;
}

.file-size {
    color: var(--text-muted);
    font-weight: 400;
    font-size: 0.8rem;
}

/* ===== Tabs ===== */
.preview-toolbar {
    display: flex;
    border-bottom: 1px solid var(--border);
}

.tab {
    flex: 1;
    padding: 0.65rem 1rem;
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 0.85rem;
    font-family: var(--font);
    cursor: pointer;
    transition: all var(--transition);
    border-bottom: 2px solid transparent;
    text-align: center;
}

.tab:hover { color: var(--text-secondary); }

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

/* ===== Preview Panes ===== */
.preview-pane {
    padding: 1.25rem;
    max-height: 400px;
    overflow-y: auto;
}

.rich-preview {
    font-size: 0.9rem;
    line-height: 1.7;
    color: var(--text-secondary);
}

.rich-preview h1,
.rich-preview h2,
.rich-preview h3,
.rich-preview h4 {
    color: var(--text-primary);
    margin: 1em 0 0.5em;
    line-height: 1.3;
}

.rich-preview h1 { font-size: 1.5rem; }
.rich-preview h2 { font-size: 1.3rem; }
.rich-preview h3 { font-size: 1.15rem; }
.rich-preview h4 { font-size: 1rem; }

.rich-preview p { margin: 0.5em 0; }

.rich-preview ul, .rich-preview ol {
    margin: 0.5em 0;
    padding-left: 1.5em;
}

.rich-preview li { margin: 0.25em 0; }

.rich-preview strong { color: var(--text-primary); font-weight: 600; }
.rich-preview em { font-style: italic; }
.rich-preview u { text-decoration: underline; }

.rich-preview blockquote {
    border-left: 3px solid var(--accent);
    padding-left: 1em;
    margin: 0.75em 0;
    color: var(--text-muted);
    font-style: italic;
}

.rich-preview hr {
    border: none;
    border-top: 1px solid var(--border);
    margin: 1em 0;
}

.html-source {
    font-family: 'Cascadia Code', 'Fira Code', 'Consolas', monospace;
    font-size: 0.8rem;
    line-height: 1.5;
    color: var(--text-muted);
    white-space: pre-wrap;
    word-break: break-word;
}

/* ===== Buttons ===== */
.action-bar {
    padding: 1.25rem;
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
    justify-content: center;
}

.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    border-radius: var(--radius-sm);
    font-size: 0.95rem;
    font-family: var(--font);
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition);
    text-decoration: none;
    border: none;
    white-space: nowrap;
}

.btn-primary {
    background: var(--accent);
    color: #0f1117;
}

.btn-primary:hover { background: var(--accent-hover); }
.btn-primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

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

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

/* ===== Progress Bar ===== */
.progress-bar {
    position: relative;
    height: 40px;
    background: var(--bg-secondary);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

.progress-fill {
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 0%;
    background: linear-gradient(90deg, var(--accent), #3b82f6);
    opacity: 0.2;
    transition: width 0.3s ease;
}

.progress-label {
    position: relative;
    z-index: 1;
    font-size: 0.85rem;
    color: var(--accent);
    font-weight: 500;
}

/* ===== Success Section ===== */
.success-section {
    text-align: center;
    background: var(--bg-secondary);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    padding: 2.5rem 1.5rem;
}

.success-icon { margin-bottom: 1rem; }

.success-title {
    font-size: 1.5rem;
    color: var(--success);
    margin-bottom: 0.5rem;
}

.success-sub {
    color: var(--text-muted);
    margin-bottom: 1.5rem;
    font-size: 0.9rem;
}

/* ===== Features ===== */
.features {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
    margin-top: 1rem;
}

.feature {
    background: var(--bg-secondary);
    border-radius: var(--radius);
    padding: 1.5rem 1rem;
    text-align: center;
    border: 1px solid var(--border);
}

.feature-icon {
    font-size: 1.8rem;
    margin-bottom: 0.5rem;
}

.feature h3 {
    font-size: 0.95rem;
    margin-bottom: 0.35rem;
    color: var(--text-primary);
}

.feature p {
    font-size: 0.8rem;
    color: var(--text-muted);
    line-height: 1.4;
}

/* ===== Footer ===== */
.footer {
    text-align: center;
    padding: 1.25rem;
    border-top: 1px solid var(--border);
    color: var(--text-muted);
    font-size: 0.8rem;
    background: var(--bg-secondary);
}

/* ===== Mobile Responsive ===== */
@media (max-width: 640px) {
    .main { padding: 1.25rem 1rem; }

    .upload-zone { padding: 2rem 1rem; }
    .upload-icon svg { width: 36px; height: 36px; }
    .upload-text { font-size: 1rem; }

    .features {
        grid-template-columns: 1fr;
        gap: 0.75rem;
    }

    .feature { padding: 1.25rem 1rem; }

    .action-bar { padding: 1rem; }

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

    .file-info {
        flex-direction: column;
        align-items: flex-start;
    }

    .preview-pane { max-height: 300px; }
}

@media (max-width: 400px) {
    .header { padding: 0.75rem 1rem; }
    .header-nav { font-size: 0.8rem; }
    .main { padding: 1rem 0.75rem; }
}

/* ===== Scrollbar ===== */
.preview-pane::-webkit-scrollbar { width: 6px; }
.preview-pane::-webkit-scrollbar-track { background: var(--bg-primary); }
.preview-pane::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 3px;
}
.preview-pane::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }
