/* ===== doc-formatter 平台样式 ===== */

:root {
    --primary: #4f46e5;
    --primary-light: #818cf8;
    --primary-bg: #eef2ff;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-400: #9ca3af;
    --gray-500: #6b7280;
    --gray-600: #4b5563;
    --gray-700: #374151;
    --gray-800: #1f2937;
    --gray-900: #111827;
    --radius: 10px;
    --shadow: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.06);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,.1);
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Noto Sans SC', sans-serif;
    background: var(--gray-50);
    color: var(--gray-800);
    line-height: 1.6;
}

/* ===== Header ===== */
.header {
    background: linear-gradient(135deg, var(--primary) 0%, #7c3aed 100%);
    color: white;
    padding: 0;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow-lg);
}

.header-inner {
    max-width: 1200px;
    margin: 0 auto;
    padding: 16px 24px;
    display: flex;
    align-items: center;
    gap: 16px;
}

.header-icon {
    width: 40px; height: 40px;
    background: rgba(255,255,255,.2);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
}

.header h1 { font-size: 20px; font-weight: 600; }
.header .subtitle { font-size: 13px; opacity: .8; margin-top: 2px; }

/* ===== Container ===== */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 24px;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
}

@media (max-width: 900px) {
    .container { grid-template-columns: 1fr; }
}

/* ===== Cards ===== */
.card {
    background: white;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.card-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--gray-200);
    font-weight: 600;
    font-size: 15px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.card-body { padding: 20px; }

/* ===== Upload Zone ===== */
.upload-zone {
    border: 2px dashed var(--gray-300);
    border-radius: 8px;
    padding: 30px 20px;
    text-align: center;
    cursor: pointer;
    transition: all .2s;
    background: var(--gray-50);
    position: relative;
}

.upload-zone:hover,
.upload-zone.dragover {
    border-color: var(--primary);
    background: var(--primary-bg);
}

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

.upload-zone .icon {
    font-size: 36px;
    color: var(--gray-400);
    margin-bottom: 8px;
}

.upload-zone .text { color: var(--gray-500); font-size: 14px; }
.upload-zone .hint { color: var(--gray-400); font-size: 12px; margin-top: 4px; }

.upload-zone .file-info {
    display: none;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: white;
    border-radius: 6px;
    border: 1px solid var(--gray-200);
    margin-top: 8px;
    font-size: 13px;
}

.upload-zone.has-file .file-info { display: inline-flex; }
.upload-zone.has-file .icon,
.upload-zone.has-file .text,
.upload-zone.has-file .hint { display: none; }

.upload-zone input[type="file"] { display: none; }

.upload-status {
    font-size: 12px;
    margin-top: 6px;
    color: var(--gray-400);
}

/* ===== Tabs ===== */
.tabs {
    display: flex;
    gap: 4px;
    background: var(--gray-100);
    padding: 4px;
    border-radius: 8px;
    margin-bottom: 16px;
}

.tab-btn {
    flex: 1;
    padding: 8px 12px;
    border: none;
    background: transparent;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    color: var(--gray-500);
    transition: all .2s;
}

.tab-btn:hover { color: var(--gray-700); }

.tab-btn.active {
    background: white;
    color: var(--primary);
    box-shadow: var(--shadow);
}

.tab-content { display: none; }
.tab-content.active { display: block; }

/* ===== Textarea ===== */
textarea {
    width: 100%;
    min-height: 80px;
    padding: 10px 12px;
    border: 1px solid var(--gray-300);
    border-radius: 6px;
    font-size: 14px;
    font-family: inherit;
    resize: vertical;
    transition: border .2s;
}

textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79,70,229,.1);
}

textarea::placeholder { color: var(--gray-400); }

/* ===== Buttons ===== */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all .2s;
}

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

.btn-primary:hover { background: #4338ca; }
.btn-primary:disabled { opacity: .5; cursor: not-allowed; }

.btn-outline {
    background: white;
    color: var(--gray-600);
    border: 1px solid var(--gray-300);
}

.btn-outline:hover { background: var(--gray-50); }

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

.btn-success:hover { background: #059669; }

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

/* ===== Process button area ===== */
.process-area {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--gray-200);
}

/* ===== KB Select ===== */
.kb-selector {
    margin-top: 12px;
    padding: 12px;
    background: var(--gray-50);
    border-radius: 6px;
    border: 1px solid var(--gray-200);
}

.kb-selector label {
    font-size: 12px;
    color: var(--gray-500);
    display: block;
    margin-bottom: 4px;
}

.kb-selector select {
    width: 100%;
    padding: 6px 8px;
    border: 1px solid var(--gray-300);
    border-radius: 4px;
    font-size: 13px;
    background: white;
}

.kb-selector .hint {
    font-size: 11px;
    color: var(--gray-400);
    margin-top: 4px;
}

/* ===== Checkbox ===== */
.checkbox-group {
    margin-top: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--gray-600);
}

.checkbox-group input[type="checkbox"] {
    width: 16px; height: 16px;
    accent-color: var(--primary);
}

/* ===== Results ===== */
.result-area { display: none; }

.result-area.show { display: block; }

.report-card {
    background: var(--gray-50);
    border-radius: 8px;
    padding: 16px;
    font-size: 13px;
    line-height: 1.8;
    white-space: pre-wrap;
    font-family: 'SF Mono', 'Cascadia Code', monospace;
    border: 1px solid var(--gray-200);
    max-height: 400px;
    overflow-y: auto;
}

.report-card .success { color: var(--success); }
.report-card .warning { color: var(--warning); }
.report-card .info { color: var(--primary); }
.report-card .section-title { font-weight: 600; color: var(--gray-700); margin-top: 8px; }

.download-area {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: #ecfdf5;
    border: 1px solid #a7f3d0;
    border-radius: 8px;
    margin-top: 12px;
}

.download-area .label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    font-weight: 500;
    color: #065f46;
}

/* ===== Status ===== */
.status-bar {
    position: fixed;
    bottom: 24px;
    right: 24px;
    padding: 12px 20px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    box-shadow: var(--shadow-lg);
    display: none;
    z-index: 200;
    animation: slideUp .3s ease;
}

.status-bar.show { display: flex; align-items: center; gap: 8px; }
.status-bar.loading { background: var(--primary-bg); color: var(--primary); }
.status-bar.success { background: #ecfdf5; color: #065f46; }
.status-bar.error { background: #fef2f2; color: #991b1b; }

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

/* ===== Spinner ===== */
.spinner {
    display: inline-block;
    width: 16px; height: 16px;
    border: 2px solid currentColor;
    border-right-color: transparent;
    border-radius: 50%;
    animation: spin .6s linear infinite;
}

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

/* ===== Loading overlay ===== */
.loading-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(255,255,255,.7);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 150;
    backdrop-filter: blur(2px);
}

.loading-overlay.show { display: flex; }

.loading-box {
    background: white;
    border-radius: 12px;
    padding: 32px 40px;
    box-shadow: var(--shadow-lg);
    text-align: center;
}

.loading-box .spinner-big {
    width: 40px; height: 40px;
    border: 3px solid var(--gray-200);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin .8s linear infinite;
    margin: 0 auto 12px;
}

.loading-box .text { font-size: 15px; color: var(--gray-600); }
.loading-box .hint { font-size: 12px; color: var(--gray-400); margin-top: 4px; }

/* ===== KB Modal ===== */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,.4);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 300;
}

.modal-overlay.show { display: flex; }

.modal {
    background: white;
    border-radius: 12px;
    padding: 24px;
    width: 560px;
    max-width: 90vw;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
}

.modal h3 { font-size: 16px; margin-bottom: 16px; }

.kb-list { list-style: none; }

.kb-list li {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    border: 1px solid var(--gray-200);
    border-radius: 6px;
    margin-bottom: 8px;
}

.kb-list .name { font-size: 13px; font-weight: 500; }
.kb-list .meta { font-size: 11px; color: var(--gray-400); }
.kb-list .badge {
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 4px;
    background: var(--primary-bg);
    color: var(--primary);
}

/* ===== Empty state ===== */
.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--gray-400);
}

.empty-state .icon { font-size: 48px; margin-bottom: 12px; }
.empty-state .text { font-size: 14px; }
