/* ================================
   MinerU WebUI - Modern CSS
   ================================ */

:root {
    --primary: #6366f1;
    --primary-dark: #4f46e5;
    --primary-light: #818cf8;
    --success: #10b981;
    --warning: #f59e0b;
    --error: #ef4444;
    --bg-dark: #0f172a;
    --bg-card: #1e293b;
    --bg-card-hover: #334155;
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --border: #334155;
    --radius: 12px;
    --radius-sm: 8px;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.3), 0 2px 4px -2px rgba(0, 0, 0, 0.2);
}

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

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

/* ================================
   Layout
   ================================ */

.app {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

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

/* ================================
   Header
   ================================ */

.header {
    background: rgba(30, 41, 59, 0.8);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-content {
    max-width: 900px;
    margin: 0 auto;
    padding: 16px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo-icon {
    font-size: 28px;
}

.logo-text {
    font-size: 20px;
    font-weight: 700;
    color: var(--text-primary);
}

.logo-sub {
    font-weight: 400;
    color: var(--primary-light);
}

.header-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.badge {
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
}

.badge-cpu {
    background: rgba(99, 102, 241, 0.2);
    color: var(--primary-light);
    border: 1px solid rgba(99, 102, 241, 0.3);
}

.badge-gpu {
    background: rgba(16, 185, 129, 0.2);
    color: var(--success);
    border: 1px solid rgba(16, 185, 129, 0.3);
}

.version {
    color: var(--text-muted);
    font-size: 13px;
}

/* ================================
   Main
   ================================ */

.main {
    flex: 1;
    padding: 40px 0;
}

/* ================================
   Hero
   ================================ */

.hero {
    text-align: center;
    margin-bottom: 40px;
}

.hero h1 {
    font-size: 32px;
    font-weight: 700;
    margin-bottom: 12px;
    background: linear-gradient(135deg, var(--text-primary) 0%, var(--primary-light) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.hero p {
    color: var(--text-secondary);
    font-size: 16px;
    max-width: 500px;
    margin: 0 auto;
}

/* ================================
   Upload Section
   ================================ */

.upload-section {
    margin-bottom: 40px;
}

.upload-zone {
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    padding: 48px 24px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    background: rgba(30, 41, 59, 0.5);
    margin-bottom: 24px;
}

.upload-zone:hover, .upload-zone.dragover {
    border-color: var(--primary);
    background: rgba(99, 102, 241, 0.1);
}

.upload-zone.has-file {
    border-color: var(--success);
    border-style: solid;
}

.upload-icon {
    font-size: 48px;
    margin-bottom: 16px;
}

.upload-content h3 {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 8px;
}

.upload-content p {
    color: var(--text-muted);
    font-size: 14px;
}

.upload-buttons {
    display: flex;
    gap: 12px;
    justify-content: center;
    margin-top: 16px;
}

.upload-buttons .btn {
    min-width: 120px;
}

.file-name {
    color: var(--success);
    font-weight: 500;
    margin-top: 8px;
}

/* ================================
   Selected Files List
   ================================ */

.selected-files {
    background: var(--bg-card);
    border-radius: var(--radius);
    margin-bottom: 24px;
    overflow: hidden;
}

.selected-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background: rgba(99, 102, 241, 0.15);
    border-bottom: 1px solid var(--border);
    font-size: 14px;
    color: var(--text-secondary);
}

.selected-list {
    max-height: 300px;
    overflow-y: auto;
}

.selected-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    border-bottom: 1px solid var(--border);
    font-size: 14px;
}

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

.selected-item .file-icon {
    font-size: 18px;
}

.selected-item .file-name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--text-primary);
    font-weight: 500;
    margin-top: 0;
}

.selected-item .file-size {
    color: var(--text-muted);
    font-size: 12px;
}

.selected-item .btn {
    padding: 4px 8px;
    font-size: 12px;
}

/* ================================
   Backend Selector
   ================================ */

.backend-selector {
    margin-bottom: 24px;
}

.backend-label {
    display: block;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 12px;
}

.backend-options {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 12px;
}

.backend-option {
    background: var(--bg-card);
    border: 2px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
}

.backend-option:hover {
    border-color: var(--primary-light);
    background: var(--bg-card-hover);
}

.backend-option.active {
    border-color: var(--primary);
    background: rgba(99, 102, 241, 0.1);
}

.backend-option input {
    position: absolute;
    opacity: 0;
}

.backend-name {
    display: block;
    font-weight: 600;
    font-size: 15px;
    margin-bottom: 4px;
}

.backend-desc {
    display: block;
    font-size: 13px;
    color: var(--text-muted);
}

/* ================================
   Buttons
   ================================ */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 24px;
    border-radius: var(--radius-sm);
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    border: none;
    transition: all 0.2s ease;
    font-family: inherit;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

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

.btn-primary:hover:not(:disabled) {
    background: var(--primary-dark);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.4);
}

.btn-parse {
    width: 100%;
    padding: 14px 24px;
    font-size: 16px;
}

.btn-sm {
    padding: 8px 16px;
    font-size: 13px;
}

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

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

.btn-loading .spinner {
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255,255,255,0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* ================================
   Status Section
   ================================ */

.status-section {
    margin-bottom: 32px;
}

.status-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 24px;
    border: 1px solid var(--border);
}

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

.status-header h3 {
    font-size: 16px;
    font-weight: 600;
}

.status-time {
    color: var(--primary-light);
    font-size: 14px;
    font-weight: 500;
}

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

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary) 0%, var(--primary-light) 100%);
    border-radius: 4px;
    transition: width 0.3s ease;
    width: 0%;
    animation: progress indeterminate 2s ease-in-out infinite;
}

@keyframes progress {
    0% { width: 0%; }
    50% { width: 70%; }
    100% { width: 100%; }
}

.status-msg {
    font-size: 14px;
    color: var(--text-secondary);
}

/* ================================
   Result Section
   ================================ */

.result-section {
    margin-bottom: 40px;
}

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

.result-header h2 {
    font-size: 20px;
    font-weight: 600;
}

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

.result-meta {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 16px;
    margin-bottom: 20px;
    font-size: 14px;
    color: var(--text-secondary);
    display: flex;
    gap: 24px;
    flex-wrap: wrap;
}

.result-meta span {
    display: flex;
    align-items: center;
    gap: 6px;
}

.result-meta .success {
    color: var(--success);
}

.result-meta .error {
    color: var(--error);
}

/* Tabs */
.result-tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 16px;
    border-bottom: 1px solid var(--border);
}

.tab-btn {
    padding: 10px 16px;
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    transition: all 0.2s;
    font-family: inherit;
}

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

.tab-btn.active {
    color: var(--primary-light);
    border-bottom-color: var(--primary);
}

.tab-content {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 20px;
    border: 1px solid var(--border);
    max-height: 500px;
    overflow-y: auto;
}

.preview-content {
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 13px;
    line-height: 1.7;
    white-space: pre-wrap;
    word-break: break-word;
    color: var(--text-secondary);
}

.file-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.file-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: var(--bg-dark);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
}

.file-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.file-icon {
    font-size: 20px;
}

.file-name {
    font-size: 14px;
    font-weight: 500;
}

.file-size {
    font-size: 12px;
    color: var(--text-muted);
}

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

.file-actions .btn {
    padding: 6px 12px;
    font-size: 12px;
}

/* ================================
   History Section
   ================================ */

.history-section {
    margin-bottom: 40px;
}

.history-section h2 {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 16px;
}

.history-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.empty-state {
    text-align: center;
    padding: 32px;
    color: var(--text-muted);
    font-size: 14px;
}

.history-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: var(--bg-card);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    font-size: 14px;
}

.history-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.history-info .name {
    font-weight: 500;
}

/* ================================
   Features Section
   ================================ */

.features-section {
    margin-bottom: 40px;
}

.features-section h2 {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 16px;
    text-align: center;
}

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

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

.feature-icon {
    font-size: 32px;
    margin-bottom: 12px;
}

.feature-card h3 {
    font-size: 15px;
    font-weight: 600;
    margin-bottom: 8px;
}

.feature-card p {
    font-size: 13px;
    color: var(--text-muted);
}

/* ================================
   Footer
   ================================ */

.footer {
    text-align: center;
    padding: 24px;
    color: var(--text-muted);
    font-size: 13px;
    border-top: 1px solid var(--border);
}

/* ================================
   Responsive
   ================================ */

@media (max-width: 640px) {
    .hero h1 {
        font-size: 24px;
    }
    
    .upload-zone {
        padding: 32px 16px;
    }
    
    .header-content {
        flex-direction: column;
        gap: 12px;
    }
    
    .result-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }
}

/* ================================
   Scrollbar
   ================================ */

::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-dark);
}

::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}