/* 全局样式 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Microsoft YaHei', sans-serif;
    background-color: #f5f5f5;
    color: #333;
    line-height: 1.6;
}

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

/* 头部 */
.header {
    background: white;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    margin-bottom: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.header h1 {
    color: #2c3e50;
    font-size: 24px;
}

.status-bar {
    display: flex;
    align-items: center;
    gap: 16px;
    font-size: 14px;
    flex-wrap: wrap;
}

.status-bar .status-main {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.status-bar #status {
    color: #3498db;
    font-weight: bold;
}

.status-bar #progress.status-detail {
    color: #7f8c8d;
    max-width: 420px;
    line-height: 1.4;
}

/* Gemini 等待时的加载动画 */
.status-spinner {
    width: 16px;
    height: 16px;
    border: 2px solid #e0e0e0;
    border-top-color: #3498db;
    border-radius: 50%;
    animation: status-spin 0.8s linear infinite;
    flex-shrink: 0;
}

.status-spinner.hidden {
    display: none !important;
}

.copy-hint {
    margin-left: 10px;
    font-size: 12px;
    color: #27ae60;
}
.copy-hint.hidden {
    display: none;
}

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

/* 调用 Gemini 时的状态高亮 */
.status-bar.gemini-waiting #status {
    color: #2980b9;
}

.status-bar.gemini-waiting #progress.status-detail {
    color: #5d6d7e;
    font-size: 13px;
}

/* 配置区域 */
.config-section {
    background: white;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    margin-bottom: 20px;
}

.config-section h2 {
    margin-bottom: 20px;
    color: #2c3e50;
    border-bottom: 2px solid #3498db;
    padding-bottom: 10px;
}

/* Gemini API Key 折叠 */
.gemini-keys-summary-row {
    margin-bottom: 8px;
    display: flex;
    align-items: center;
}
.gemini-keys-summary {
    color: #5d6d7e;
    font-size: 14px;
}
.gemini-keys-collapsible {
    max-height: 2000px;
    overflow: hidden;
    transition: max-height 0.2s ease-out;
}
.gemini-keys-collapsible.collapsed {
    max-height: 0 !important;
    margin-top: 0;
    margin-bottom: 0;
    padding-top: 0;
    padding-bottom: 0;
}

/* 调用大模型状态提示（配置下方、内容区上方） */
.llm-progress-section {
    background: #f8f9fa;
    padding: 10px 16px;
    margin-bottom: 16px;
    border-radius: 6px;
    border-left: 3px solid transparent;
    transition: all 0.3s ease;
}
.llm-progress-section.llm-progress-empty {
    padding-top: 0;
    padding-bottom: 0;
    margin-bottom: 0;
    min-height: 0;
    overflow: hidden;
}
.llm-progress-section #llm-progress-text {
    color: #5d6d7e;
    font-size: 14px;
    line-height: 1.8;
    white-space: pre-line;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}
.llm-progress-section.llm-progress-active {
    border-left-color: #3498db;
    background: linear-gradient(135deg, #f0f7ff 0%, #f8f9fa 100%);
    box-shadow: 0 2px 8px rgba(52, 152, 219, 0.1);
    animation: pulse-border 2s ease-in-out infinite;
}
.llm-progress-section.llm-progress-active #llm-progress-text {
    color: #2980b9;
    font-weight: 500;
}

/* Gemini 等待状态的动画效果 */
@keyframes pulse-border {
    0%, 100% {
        border-left-color: #3498db;
        box-shadow: 0 2px 8px rgba(52, 152, 219, 0.1);
    }
    50% {
        border-left-color: #5dade2;
        box-shadow: 0 2px 12px rgba(52, 152, 219, 0.2);
    }
}

/* 等待状态中的信息行样式 */
.llm-progress-section.llm-progress-active #llm-progress-text {
    display: block;
}

.llm-progress-section.llm-progress-active #llm-progress-text::first-line {
    font-size: 15px;
    font-weight: 600;
    color: #2980b9;
}

.config-group {
    margin-bottom: 20px;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 4px;
}

.config-group label {
    display: inline-block;
    margin-right: 10px;
    font-weight: bold;
    min-width: 100px;
}

.config-group input[type="text"],
.config-group input[type="password"] {
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    margin-right: 10px;
    width: 300px;
}

.config-group button {
    padding: 8px 16px;
    background: #3498db;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    margin-right: 10px;
}

.config-group button:hover {
    background: #2980b9;
}

.model-selection {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 15px;
    margin-top: 15px;
}

.model-item {
    display: flex;
    align-items: center;
    gap: 10px;
}

.model-item label {
    min-width: 150px;
}

.model-item select {
    flex: 1;
    padding: 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
}

.file-upload {
    margin-bottom: 15px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.file-upload input[type="file"] {
    flex: 1;
}

.file-upload input[type="text"] {
    flex: 1;
    padding: 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
}

/* 标签页 */
.tabs-section {
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    margin-bottom: 20px;
}

.tabs {
    display: flex;
    border-bottom: 2px solid #e0e0e0;
    padding: 0 20px;
}

.tab-button {
    padding: 12px 20px;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 14px;
    color: #7f8c8d;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: all 0.3s;
}

.tab-button:hover {
    color: #3498db;
}

.tab-button.active {
    color: #3498db;
    border-bottom-color: #3498db;
    font-weight: bold;
}

.tab-content {
    padding: 20px;
    min-height: 400px;
}

.tab-pane {
    display: none;
}

.tab-pane.active {
    display: block;
}

.log-container {
    background: #1e1e1e;
    color: #d4d4d4;
    padding: 15px;
    border-radius: 4px;
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 12px;
    max-height: 500px;
    overflow-y: auto;
    white-space: pre-wrap;
    line-height: 1.6;
}

.log-entry {
    margin-bottom: 2px;
    padding: 1px 0;
    border-left: 3px solid transparent;
    padding-left: 8px;
    line-height: 1.4;
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
}

.log-entry.log-error {
    border-left-color: #dc3545;
    background: rgba(220, 53, 69, 0.1);
}

.log-entry.log-warning {
    border-left-color: #ffc107;
    background: rgba(255, 193, 7, 0.1);
}

.log-entry.log-success {
    border-left-color: #28a745;
    background: rgba(40, 167, 69, 0.1);
}

.log-entry.log-info {
    border-left-color: #4a9eff;
}

.log-timestamp {
    color: #888;
    margin-right: 6px;
    font-size: 12px;
    flex-shrink: 0;
}

.log-level {
    font-weight: 600;
    margin-right: 6px;
    font-size: 12px;
    flex-shrink: 0;
}

.log-category {
    color: #aaa;
    font-size: 11px;
    margin-right: 6px;
    flex-shrink: 0;
}

.log-message {
    color: #d4d4d4;
    flex: 1;
    min-width: 0;
    word-break: break-word;
}

.log-toolbar {
    padding: 8px;
    background: #f8f9fa;
    border-radius: 4px;
    border: 1px solid #e0e0e0;
}

.log-filter {
    border: 1px solid #ccc;
    border-radius: 4px;
    background: white;
}
    word-wrap: break-word;
}

.stage-content {
    background: #f8f9fa;
    padding: 15px;
    border-radius: 4px;
    white-space: pre-wrap;
    word-wrap: break-word;
    max-height: 500px;
    overflow-y: auto;
}

#metadata-content {
    background: #f8f9fa;
    padding: 15px;
    border-radius: 4px;
    max-height: 500px;
    overflow-y: auto;
}

/* 控制按钮 */
.control-section {
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin-bottom: 20px;
}

.control-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.control-group-label {
    color: #2c3e50;
    font-size: 14px;
    font-weight: 600;
}

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

.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.3s;
}

.btn-primary {
    background: #3498db;
    color: white;
}

.btn-primary:hover:not(:disabled) {
    background: #2980b9;
}

.btn-primary-combo {
    background: #2ecc71;
    color: white;
}

.btn-primary-combo:hover:not(:disabled) {
    background: #27ae60;
}

.btn-secondary {
    background: #95a5a6;
    color: white;
}

.btn-secondary:hover:not(:disabled) {
    background: #7f8c8d;
}

.btn-danger {
    background: #e74c3c;
    color: white;
}

.btn-danger:hover:not(:disabled) {
    background: #c0392b;
}

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

/* 模态框 */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.5);
}

.modal-content {
    background-color: white;
    margin: 5% auto;
    padding: 20px;
    border-radius: 8px;
    width: 80%;
    max-width: 800px;
    max-height: 80vh;
    overflow-y: auto;
}

.close {
    color: #aaa;
    float: right;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
}

.close:hover {
    color: #000;
}

#output-list {
    margin-top: 20px;
}

.output-item {
    padding: 10px;
    border-bottom: 1px solid #e0e0e0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.output-item:hover {
    background: #f8f9fa;
}

.output-item .file-info {
    flex: 1;
}

.output-item .file-actions {
    display: flex;
    gap: 10px;
}

.output-item button {
    padding: 5px 10px;
    font-size: 12px;
}

/* 测试连接结果弹窗（可滚动，完整显示所有 Key 结果） */
.test-connection-modal {
    position: fixed;
    inset: 0;
    z-index: 1100;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    box-sizing: border-box;
}
.test-connection-modal.hidden {
    display: none !important;
}
.test-connection-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.5);
    cursor: pointer;
}
.test-connection-modal-content {
    position: relative;
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.2);
    max-width: 560px;
    width: 100%;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
}
.test-connection-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid #eee;
}
.test-connection-modal-header h3 {
    margin: 0;
    font-size: 18px;
    color: #2c3e50;
}
.test-connection-modal-close {
    background: none;
    border: none;
    font-size: 24px;
    line-height: 1;
    color: #999;
    cursor: pointer;
    padding: 0 4px;
}
.test-connection-modal-close:hover {
    color: #333;
}
.test-connection-report {
    flex: 1;
    margin: 0;
    padding: 16px 20px;
    overflow: auto;
    font-size: 14px;
    line-height: 1.6;
    white-space: pre-wrap;
    word-break: break-word;
    color: #333;
    border: none;
    background: #fafafa;
}
.test-connection-modal-footer {
    padding: 12px 20px;
    border-top: 1px solid #eee;
}

/* 响应式设计 */
@media (max-width: 768px) {
    .model-selection {
        grid-template-columns: 1fr;
    }
    
    .control-section {
        flex-direction: column;
    }
    
    .btn {
        width: 100%;
    }
}
