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

:root {
    --bg: #f8f9fc;
    --surface: #ffffff;
    --surface-hover: #f1f3f8;
    --text: #1a1d29;
    --text-secondary: #6b7280;
    --accent: #6c5ce7;
    --accent-hover: #5a4bd1;
    --accent-light: #e8e5ff;
    --border: #e2e5ed;
    --shadow: 0 2px 12px rgba(0,0,0,0.06);
    --shadow-lg: 0 8px 30px rgba(0,0,0,0.08);
    --radius: 16px;
    --radius-sm: 10px;
    --transition: 0.2s ease;
    --success: #00b894;
    --error: #e74c3c;
    --warning: #f39c12;
    --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

[data-theme="dark"] {
    --bg: #0f0f1a;
    --surface: #1a1a2e;
    --surface-hover: #232340;
    --text: #e8e8f0;
    --text-secondary: #9a9ab0;
    --accent: #7c6cf0;
    --accent-hover: #6a5ad8;
    --accent-light: #2a2040;
    --border: #2a2a44;
    --shadow: 0 2px 12px rgba(0,0,0,0.3);
    --shadow-lg: 0 8px 30px rgba(0,0,0,0.4);
}

/* ─── Base ────────────────────────────────────────────────── */
html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    line-height: 1.6;
    transition: background var(--transition), color var(--transition);
}

.app {
    max-width: 700px;
    margin: 0 auto;
    padding: 16px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ─── Header ──────────────────────────────────────────────── */
.header {
    text-align: center;
    padding: 24px 0 16px;
    position: relative;
}

.logo {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

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

h1 {
    font-size: 1.8rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--accent), #a29bfe);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.tagline {
    color: var(--text-secondary);
    font-size: 0.95rem;
    margin-top: 4px;
}

.theme-toggle {
    position: absolute;
    top: 20px;
    right: 0;
}

#themeBtn {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    font-size: 1.2rem;
    cursor: pointer;
    transition: all var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
}

#themeBtn:hover {
    background: var(--surface-hover);
    transform: scale(1.05);
}

/* ─── Upload Zone ─────────────────────────────────────────── */
.upload-section {
    margin: 12px 0;
}

.upload-zone {
    background: var(--surface);
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    padding: 40px 20px;
    text-align: center;
    cursor: pointer;
    transition: all var(--transition);
}

.upload-zone:hover,
.upload-zone.drag-over {
    border-color: var(--accent);
    background: var(--accent-light);
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.upload-icon {
    font-size: 3.5rem;
    margin-bottom: 12px;
}

.upload-zone h2 {
    font-size: 1.2rem;
    font-weight: 600;
    margin-bottom: 6px;
}

.upload-hint {
    color: var(--text-secondary);
    font-size: 0.85rem;
    margin-bottom: 12px;
}

.formats {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 6px;
    margin-bottom: 20px;
}

.formats span {
    background: var(--accent-light);
    color: var(--accent);
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 500;
}

.upload-btn {
    display: inline-block;
    background: var(--accent);
    color: #fff;
    padding: 12px 32px;
    border-radius: 30px;
    font-weight: 600;
    font-size: 0.95rem;
    cursor: pointer;
    transition: all var(--transition);
    border: none;
}

.upload-btn:hover {
    background: var(--accent-hover);
    transform: scale(1.03);
}

.or-divider {
    color: var(--text-secondary);
    font-size: 0.8rem;
    margin-top: 12px;
}

/* ─── Progress ────────────────────────────────────────────── */
.progress-section {
    margin: 12px 0;
}

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

.progress-status {
    display: flex;
    align-items: center;
    gap: 12px;
    font-weight: 500;
    margin-bottom: 16px;
}

.spinner {
    width: 24px;
    height: 24px;
    border: 3px solid var(--border);
    border-top: 3px solid var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    flex-shrink: 0;
}

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

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

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

.progress-details {
    display: flex;
    justify-content: space-between;
    font-size: 0.8rem;
    color: var(--text-secondary);
}

/* ─── Result ──────────────────────────────────────────────── */
.result-section {
    margin: 12px 0;
}

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

.result-header h2 {
    font-size: 1.1rem;
    font-weight: 600;
}

.result-actions {
    display: flex;
    gap: 8px;
}

.btn-icon {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 8px 12px;
    font-size: 1.1rem;
    cursor: pointer;
    transition: all var(--transition);
}

.btn-icon:hover {
    background: var(--surface-hover);
    transform: scale(1.05);
}

.result-content {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 24px;
    box-shadow: var(--shadow);
    white-space: pre-wrap;
    word-wrap: break-word;
    line-height: 1.7;
    font-size: 0.92rem;
    min-height: 100px;
}

.result-content strong {
    color: var(--accent);
}

.result-meta {
    text-align: center;
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-top: 8px;
}

/* ─── History ─────────────────────────────────────────────── */
.history-section {
    margin: 12px 0 24px;
}

details {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 16px 20px;
    box-shadow: var(--shadow);
}

summary {
    font-weight: 600;
    cursor: pointer;
    color: var(--text-secondary);
    font-size: 0.9rem;
    user-select: none;
}

summary:hover {
    color: var(--text);
}

.history-item {
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.85rem;
}

.history-item:last-child {
    border-bottom: none;
}

.history-item .h-name {
    font-weight: 500;
}

.history-item .h-date {
    color: var(--text-secondary);
    font-size: 0.78rem;
}

.hint {
    color: var(--text-secondary);
    font-size: 0.85rem;
    text-align: center;
    padding: 12px 0;
}

/* ─── Footer ──────────────────────────────────────────────── */
.footer {
    margin-top: auto;
    text-align: center;
    padding: 20px 0;
    color: var(--text-secondary);
    font-size: 0.75rem;
}

/* ─── Toast ───────────────────────────────────────────────── */
.toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: var(--text);
    color: var(--bg);
    padding: 12px 24px;
    border-radius: 30px;
    font-size: 0.85rem;
    font-weight: 500;
    opacity: 0;
    transition: all 0.3s ease;
    z-index: 1000;
    box-shadow: var(--shadow-lg);
    pointer-events: none;
}

.toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.toast.error {
    background: var(--error);
    color: #fff;
}

.toast.success {
    background: var(--success);
    color: #fff;
}

/* ─── Error state in result ──────────────────────────────── */
.result-content.error {
    color: var(--error);
    border-left: 4px solid var(--error);
}

/* ─── Mobile Adaptations ─────────────────────────────────── */
@media (max-width: 480px) {
    .app {
        padding: 10px;
    }

    .upload-zone {
        padding: 28px 16px;
    }

    .upload-icon {
        font-size: 2.5rem;
    }

    .upload-zone h2 {
        font-size: 1rem;
    }

    .formats span {
        font-size: 0.7rem;
        padding: 2px 8px;
    }

    .upload-btn {
        padding: 10px 24px;
        font-size: 0.85rem;
    }

    .result-content {
        padding: 16px;
        font-size: 0.85rem;
    }

    .progress-card {
        padding: 16px;
    }

    details {
        padding: 12px 16px;
    }
}

/* Ensure details works on mobile */
@media (max-width: 768px) {
    .app {
        max-width: 100%;
    }
}

/* ─── Animations ─────────────────────────────────────────── */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.result-section:not([hidden]),
.progress-section:not([hidden]) {
    animation: fadeIn 0.3s ease;
}
