/**
 * Config Panel & Progress UI Styles
 * 
 * 配置面板和进度条样式
 */

/* ==================== 配置面板容器 ==================== */

.module-config-panel {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: none;
    z-index: 1000;
}

.module-config-panel.visible {
    display: flex;
    align-items: center;
    justify-content: center;
}

.config-panel-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(2px);
}

.config-panel-content {
    position: relative;
    background: var(--bg-card, #ffffff);
    border-radius: 16px;
    width: 90%;
    max-width: 500px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
}

/* ==================== 配置面板头部 ==================== */

.config-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color, #e0e0e0);
}

.config-panel-header h3 {
    margin: 0;
    font-size: 1.1rem;
    color: var(--text-primary, #2c3e50);
}

.config-close-btn {
    background: transparent;
    border: none;
    font-size: 1.2rem;
    cursor: pointer;
    color: var(--text-muted, #6c757d);
    padding: 4px 8px;
    border-radius: 4px;
}

.config-close-btn:hover {
    background: var(--bg-hover, #f0f0f0);
}

/* ==================== 配置面板主体 ==================== */

.config-panel-body {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
}

.config-field {
    margin-bottom: 16px;
}

.config-field label {
    display: block;
    margin-bottom: 6px;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-primary, #2c3e50);
}

.config-field input[type="text"],
.config-field input[type="password"],
.config-field input[type="number"],
.config-field select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border-color, #e0e0e0);
    border-radius: 8px;
    font-size: 0.9rem;
    background: var(--bg-input, #fafafa);
}

.config-field input:focus,
.config-field select:focus {
    outline: none;
    border-color: var(--primary, #3498db);
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.1);
}

.config-field input[type="checkbox"] {
    width: 18px;
    height: 18px;
    margin-right: 8px;
}

/* ==================== Range 输入 ==================== */

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

.range-input input[type="range"] {
    flex: 1;
    height: 6px;
    -webkit-appearance: none;
    background: var(--border-color, #e0e0e0);
    border-radius: 3px;
}

.range-input input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 18px;
    height: 18px;
    background: var(--primary, #3498db);
    border-radius: 50%;
    cursor: pointer;
}

.range-value {
    min-width: 36px;
    text-align: right;
    font-size: 0.9rem;
    color: var(--text-muted, #6c757d);
}

/* ==================== 多选 ==================== */

.multiselect-group {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.checkbox-option {
    display: flex;
    align-items: center;
    padding: 6px 12px;
    background: var(--bg-secondary, #f8f9fa);
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.85rem;
}

.checkbox-option:has(input:checked) {
    background: var(--primary-light, #e3f2fd);
    color: var(--primary, #3498db);
}

/* ==================== 配置面板底部 ==================== */

.config-panel-footer {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    padding: 16px 20px;
    border-top: 1px solid var(--border-color, #e0e0e0);
}

.btn-primary {
    padding: 10px 24px;
    background: var(--primary, #3498db);
    color: white;
    border: none;
    border-radius: 8px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s;
}

.btn-primary:hover {
    background: var(--primary-dark, #2980b9);
}

.btn-secondary {
    padding: 10px 24px;
    background: var(--bg-secondary, #f8f9fa);
    color: var(--text-primary, #2c3e50);
    border: 1px solid var(--border-color, #e0e0e0);
    border-radius: 8px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-secondary:hover {
    background: var(--bg-hover, #e8e8e8);
}

.btn-link {
    background: transparent;
    border: none;
    color: var(--primary, #3498db);
    cursor: pointer;
    font-size: 0.9rem;
}

/* ==================== 进度条 UI (简洁版) ==================== */

.progress-compact {
    background: #ffffff;
    border-radius: 10px;
    padding: 16px;
    margin-bottom: 16px;
    border: 1px solid #e5e7eb;
}

/* 头部 */
.progress-header-compact {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.progress-header-compact .progress-title {
    font-weight: 600;
    font-size: 0.95rem;
    color: #374151;
}

.progress-header-compact .progress-percent {
    font-weight: 700;
    font-size: 1rem;
    color: #3b82f6;
}

/* 进度条 */
.progress-bar-track-compact {
    height: 6px;
    background: #e5e7eb;
    border-radius: 6px;
    overflow: hidden;
    margin-bottom: 10px;
}

.progress-bar-fill-compact {
    height: 100%;
    background: linear-gradient(90deg, #3b82f6, #10b981);
    border-radius: 6px;
    transition: width 0.3s ease;
}

/* 🆕 进度条脉冲效果 - 表示任务正在进行 */
.progress-bar-fill-compact.processing {
    min-width: 10%;
    /* 多重背景：条纹叠加在渐变色之上 */
    background:
        linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent),
        linear-gradient(90deg, #3b82f6, #10b981);
    background-size: 20px 20px, 100% 100%;
    animation: stripes 0.8s linear infinite, pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.7;
    }
}

.progress-bar-fill-compact.animated {
    /* 多重背景：条纹叠加在渐变色之上 */
    background:
        linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent),
        linear-gradient(90deg, #3b82f6, #10b981);
    background-size: 20px 20px, 100% 100%;
    animation: stripes 0.8s linear infinite;
}

@keyframes stripes {
    from {
        background-position: 0 0;
    }

    to {
        background-position: 20px 0;
    }
}

.progress-bar-fill-compact.complete {
    background: #10b981;
    animation: none;
}

.progress-bar-fill-compact.failed {
    background: #ef4444;
    animation: none;
}

.progress-bar-fill-compact.partial {
    background: #f59e0b;
    animation: none;
}

/* 信息行：文件 · 步骤 (分片) */
.progress-info-line {
    font-size: 0.8rem;
    color: #6b7280;
    margin-bottom: 6px;
}

.progress-info-line .info-file {
    color: #374151;
}

.progress-info-line .info-sep {
    margin: 0 6px;
    color: #d1d5db;
}

.progress-info-line .info-step {
    color: #3b82f6;
    font-weight: 500;
}

.progress-info-line .info-chunk {
    color: #9ca3af;
}

/* 消息 */
.progress-msg {
    font-size: 0.8rem;
    color: #9ca3af;
    min-height: 1.2em;
}

/* 错误 */
.progress-err {
    margin-top: 8px;
    padding: 8px 10px;
    background: #fef2f2;
    border-radius: 6px;
    border: 1px solid #fecaca;
}

.err-line {
    font-size: 0.8rem;
    color: #991b1b;
    padding: 2px 0;
}

.err-line.warn {
    color: #92400e;
}

/* 旧版兼容 */
.progress-ui {
    display: none;
}

.progress-steps {
    display: none;
}

/* ==================== 错误报告 ==================== */

.error-report {
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: 12px;
    overflow: hidden;
}

.error-report-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background: #fee2e2;
}

.error-report-header h4 {
    margin: 0;
    color: #991b1b;
    font-size: 1rem;
}

.error-dismiss-btn {
    background: transparent;
    border: none;
    font-size: 1rem;
    cursor: pointer;
    color: #991b1b;
}

.error-section {
    padding: 12px 16px;
}

.section-title {
    font-size: 0.8rem;
    font-weight: 600;
    color: #991b1b;
    margin-bottom: 8px;
}

.error-section.warnings {
    background: #fffbeb;
}

.error-section.warnings .section-title {
    color: #92400e;
}

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

.error-item {
    display: flex;
    gap: 8px;
    padding: 8px;
    background: white;
    border-radius: 6px;
}

.error-bullet {
    flex-shrink: 0;
}

.error-content {
    flex: 1;
    min-width: 0;
}

.error-message {
    font-size: 0.9rem;
    color: #374151;
    word-break: break-word;
}

.error-details {
    margin-top: 4px;
}

.error-details summary {
    font-size: 0.8rem;
    color: #6b7280;
    cursor: pointer;
}

.error-details pre {
    font-size: 0.75rem;
    background: #f3f4f6;
    padding: 8px;
    border-radius: 4px;
    overflow-x: auto;
    margin: 4px 0 0 0;
}

.error-report-footer {
    padding: 12px 16px;
    border-top: 1px solid #fecaca;
    text-align: center;
}

/* ==================== 暗色主题 ==================== */

@media (prefers-color-scheme: dark) {
    .config-panel-content {
        background: #2a2a3e;
    }

    .config-panel-header {
        border-color: #404050;
    }

    .config-panel-header h3 {
        color: #e4e4e4;
    }

    .config-field label {
        color: #e4e4e4;
    }

    .config-field input,
    .config-field select {
        background: #1e1e2e;
        border-color: #404050;
        color: #e4e4e4;
    }

    .config-panel-footer {
        border-color: #404050;
    }

    .btn-secondary {
        background: #1e1e2e;
        color: #e4e4e4;
        border-color: #404050;
    }

    .progress-ui {
        background: #2a2a3e;
    }

    .progress-title {
        color: #e4e4e4;
    }

    .error-report {
        background: #3a2a2a;
        border-color: #5a3a3a;
    }

    .error-report-header {
        background: #4a2a2a;
    }

    .error-message {
        color: #e4e4e4;
    }

    /* 新增：文件进度和详细进度暗色主题 */
    .progress-file-info {
        background: #1e1e2e;
    }

    .file-name {
        color: #a0a0b0;
    }

    .step-display-name {
        color: #6db3f2;
    }

    .chunk-progress {
        color: #a0a0b0;
    }

    /* V2 进度条暗色主题 */
    .progress-ui-v2 {
        background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
        border-color: #334155;
    }

    .progress-title {
        color: #f1f5f9;
    }

    .progress-bar-track-v2 {
        background: #334155;
    }

    .progress-info-item {
        background: #1e293b;
        border-color: #334155;
    }

    .progress-info-item:hover {
        background: #334155;
        border-color: #475569;
    }

    .info-label {
        color: #94a3b8;
    }

    .info-value {
        color: #f1f5f9;
    }

    .file-name-text {
        color: #94a3b8;
    }

    .step-dot-v2 {
        background: #334155;
        color: #94a3b8;
    }

    .step-line {
        background: #334155;
    }

    .progress-message-v2 {
        color: #94a3b8;
    }
}

/* ==================== 模型检测 UI ==================== */

.model-field-wrapper {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.model-input-group {
    display: flex;
    gap: 8px;
    align-items: center;
}

.model-input-group .model-input,
.model-input-group .model-select {
    flex: 1;
    padding: 10px 12px;
    border: 1px solid var(--border-color, #e0e0e0);
    border-radius: 8px;
    font-size: 0.9rem;
    background: var(--bg-input, #fafafa);
}

.model-input-group .model-select.hidden,
.model-input-group .model-input.hidden {
    display: none;
}

.detect-model-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    padding: 0;
    background: var(--primary, #3498db);
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.2s, opacity 0.2s;
}

.detect-model-btn:hover {
    background: var(--primary-dark, #2980b9);
}

.detect-model-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.model-detect-status {
    font-size: 0.75rem;
    margin: 0;
    min-height: 1em;
}

.model-detect-status.text-success {
    color: #10b981;
}

.model-detect-status.text-warning {
    color: #f59e0b;
}

.model-detect-status.text-error {
    color: #ef4444;
}

.model-detect-status.text-info {
    color: #3b82f6;
}

/* 旋转动画 */
.animate-spin {
    animation: spin 1s linear infinite;
}

@keyframes spin {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}

/* ==================== V3: 日志面板样式 ==================== */

.progress-log-section {
    margin-top: 12px;
    border-top: 1px dashed #e5e7eb;
    padding-top: 10px;
}

.progress-log-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    padding: 6px 10px;
    border-radius: 6px;
    background: #f9fafb;
    transition: background 0.2s;
    user-select: none;
}

.progress-log-toggle:hover {
    background: #f3f4f6;
}

.log-toggle-icon {
    font-size: 0.7rem;
    color: #6b7280;
    transition: transform 0.2s;
}

.log-toggle-text {
    font-size: 0.8rem;
    color: #6b7280;
    flex: 1;
}

.log-count-badge {
    display: inline-block;
    min-width: 20px;
    padding: 2px 6px;
    background: #3b82f6;
    color: white;
    font-size: 0.7rem;
    font-weight: 600;
    border-radius: 10px;
    text-align: center;
}

.progress-log-panel {
    margin-top: 10px;
    background: #1e293b;
    border-radius: 8px;
    overflow: hidden;
}

.progress-log-entries {
    max-height: 200px;
    overflow-y: auto;
    padding: 10px;
    font-family: 'SF Mono', 'Menlo', 'Monaco', monospace;
    font-size: 0.75rem;
    line-height: 1.5;
}

/* 日志条目 */
.log-entry {
    display: flex;
    gap: 8px;
    padding: 3px 0;
    color: #e2e8f0;
}

.log-entry .log-time {
    color: #64748b;
    flex-shrink: 0;
}

.log-entry .log-category {
    flex-shrink: 0;
}

.log-entry .log-message {
    color: #e2e8f0;
    word-break: break-word;
}

/* 日志级别样式 */
.log-entry.log-normal .log-message {
    color: #e2e8f0;
}

.log-entry.log-verbose .log-message {
    color: #94a3b8;
    font-style: italic;
}

.log-entry.log-debug .log-message {
    color: #64748b;
    font-size: 0.7rem;
}

/* 错误日志高亮 */
.log-entry .log-category:has(+ .log-message:contains('❌')),
.log-entry:has(.log-message:contains('失败')) {
    background: rgba(239, 68, 68, 0.1);
}

/* 滚动条样式 */
.progress-log-entries::-webkit-scrollbar {
    width: 6px;
}

.progress-log-entries::-webkit-scrollbar-track {
    background: #0f172a;
}

.progress-log-entries::-webkit-scrollbar-thumb {
    background: #334155;
    border-radius: 3px;
}

.progress-log-entries::-webkit-scrollbar-thumb:hover {
    background: #475569;
}

/* 暗色主题下日志面板 */
@media (prefers-color-scheme: dark) {
    .progress-log-section {
        border-color: #404050;
    }

    .progress-log-toggle {
        background: #1e1e2e;
    }

    .progress-log-toggle:hover {
        background: #2a2a3e;
    }

    .log-toggle-text {
        color: #a0a0b0;
    }
}

/* ==================== 双轨进度面板 ==================== */

.dual-progress-panel {
    background: #ffffff;
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 16px;
    border: 1px solid #e5e7eb;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

/* 总体进度 */
.overall-progress {
    margin-bottom: 16px;
    padding-bottom: 16px;
    border-bottom: 1px dashed #e5e7eb;
}

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

.overall-title {
    font-weight: 600;
    font-size: 0.95rem;
    color: #374151;
}

.overall-percent {
    font-weight: 700;
    font-size: 1rem;
    color: #3b82f6;
}

.overall-bar-track {
    height: 8px;
    background: #e5e7eb;
    border-radius: 4px;
    overflow: hidden;
}

.overall-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, #3b82f6, #10b981);
    border-radius: 4px;
    transition: width 0.3s ease;
}

.overall-bar-fill.complete {
    background: #10b981;
}

.overall-bar-fill.error {
    background: #ef4444;
}

/* 双通道区域 */
.dual-channels {
    display: flex;
    gap: 12px;
    margin-bottom: 12px;
}

/* 通道卡片 */
.channel-card {
    flex: 1;
    background: #f9fafb;
    border-radius: 10px;
    padding: 12px;
    border: 1px solid #e5e7eb;
    transition: border-color 0.2s;
}

.channel-card:hover {
    border-color: #d1d5db;
}

.channel-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}

.channel-icon {
    font-size: 0.9rem;
}

.channel-name {
    flex: 1;
    font-size: 0.8rem;
    font-weight: 600;
    color: #374151;
}

.channel-percent {
    font-size: 0.85rem;
    font-weight: 700;
}

/* PDF 通道主题 */
.channel-pdf .channel-percent {
    color: #3b82f6;
}

.channel-pdf .channel-bar-fill {
    background: linear-gradient(90deg, #3b82f6, #60a5fa);
}

.channel-pdf .channel-bar-fill.complete {
    background: #10b981;
}

/* 文本通道主题 */
.channel-text .channel-percent {
    color: #059669;
}

.channel-text .channel-bar-fill {
    background: linear-gradient(90deg, #059669, #10b981);
}

.channel-text .channel-bar-fill.complete {
    background: #10b981;
}

/* 通道进度条 */
.channel-bar-track {
    height: 4px;
    background: #e5e7eb;
    border-radius: 2px;
    overflow: hidden;
    margin-bottom: 8px;
}

.channel-bar-fill {
    height: 100%;
    border-radius: 2px;
    transition: width 0.3s ease;
}

.channel-bar-fill.processing {
    animation: pulse 1.5s ease-in-out infinite;
}

/* 通道文件列表 */
.channel-files {
    min-height: 24px;
    margin-bottom: 4px;
}

.channel-file {
    font-size: 0.75rem;
    padding: 2px 0;
    color: #6b7280;
    display: flex;
    align-items: center;
    gap: 4px;
}

.channel-file.file-processing {
    color: #3b82f6;
    font-weight: 500;
}

.channel-file.file-complete {
    color: #10b981;
}

.channel-file.file-error {
    color: #ef4444;
}

/* 通道状态 */
.channel-status {
    font-size: 0.75rem;
    color: #9ca3af;
}

/* 响应式：小屏幕垂直排列 */
@media (max-width: 600px) {
    .dual-channels {
        flex-direction: column;
    }
}

/* 暗色主题 */
@media (prefers-color-scheme: dark) {
    .dual-progress-panel {
        background: #1e293b;
        border-color: #334155;
    }

    .overall-progress {
        border-color: #334155;
    }

    .overall-title {
        color: #f1f5f9;
    }

    .overall-bar-track {
        background: #334155;
    }

    .channel-card {
        background: #0f172a;
        border-color: #334155;
    }

    .channel-card:hover {
        border-color: #475569;
    }

    .channel-name {
        color: #f1f5f9;
    }

    .channel-bar-track {
        background: #334155;
    }

    .channel-file {
        color: #94a3b8;
    }

    .channel-status {
        color: #64748b;
    }
}

/* 日志通道标识 */
.log-entry .log-channel {
    flex-shrink: 0;
    width: 20px;
    text-align: center;
}