:root {
    --bg-primary: #262626;
    --bg-secondary: #30302e;
    --bg-tertiary: #3a3a38;
    --text-primary: #ffffff;
    --text-secondary: #cccccc;
    --text-tertiary: #999999;
    --border-color: #444;
    --accent-color: #c6613f;
    --accent-hover: #a54f30;
    --success-color: #2E7D32;
    --error-color: #C62828;
    --info-color: #2196F3;
    --scrollbar-track: #1a1a1a;
    --scrollbar-thumb: #888888;
    --scrollbar-hover: #aaaaaa;
    --badge-off: #555;
    --modal-bg: rgba(0,0,0,0.7);
    --time-btn-hover: #3d2622;
    --chart-success: #2E7D32;
    --chart-error: #C62828;
}

[data-theme="light"] {
    --bg-primary: #f5f5f5;
    --bg-secondary: #ffffff;
    --bg-tertiary: #f9f9f9;
    --text-primary: #333333;
    --text-secondary: #666666;
    --text-tertiary: #999999;
    --border-color: #eee;
    --accent-color: #2196F3;
    --accent-hover: #1976D2;
    --success-color: #4CAF50;
    --error-color: #f44336;
    --info-color: #2196F3;
    --scrollbar-track: #f0f0f0;
    --scrollbar-thumb: #c0c0c0;
    --scrollbar-hover: #a0a0a0;
    --badge-off: #999;
    --modal-bg: rgba(0,0,0,0.5);
    --time-btn-hover: #e3f2fd;
    --chart-success: #81C784;
    --chart-error: #E57373;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
body { 
    font-family: 'Microsoft YaHei', 'Cascadia Code', 'Consolas', 'Monaco', monospace; 
    background: var(--bg-primary); 
    color: var(--text-primary); 
    transition: background 0.3s, color 0.3s;
    padding-left: 260px;
    padding-top: 20px;
    padding-right: 20px;
    padding-bottom: 20px;
}

code, pre, .duration-cell, input[type="text"], input[type="number"] {
    font-family: 'Cascadia Code', 'Consolas', 'Monaco', monospace;
}

.sidebar {
    position: fixed;
    left: 0;
    top: 0;
    width: 240px;
    height: 100vh;
    background: var(--bg-secondary);
    border-right: 1px solid var(--border-color);
    padding: 20px;
    z-index: 1000;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.sidebar-header {
    margin-bottom: 30px;
    flex-shrink: 0;
}

.sidebar-header h1 {
    font-size: 20px;
    margin-bottom: 5px;
    color: var(--text-primary);
}

.sidebar-header .version {
    font-size: 12px;
    color: var(--text-tertiary);
}

.nav-menu {
    list-style: none;
    margin-bottom: 30px;
    flex: 1;
}

.nav-item {
    margin-bottom: 5px;
}

.nav-link {
    display: block;
    padding: 12px 15px;
    color: var(--text-secondary);
    text-decoration: none;
    border-radius: 6px;
    transition: all 0.2s;
}

.nav-link:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.nav-link.active {
    background: var(--accent-color);
    color: white;
}

.theme-toggle-container {
    padding: 15px;
    border-top: 1px solid var(--border-color);
    margin-top: auto;
    flex-shrink: 0;
}

.theme-toggle {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    user-select: none;
}

.theme-toggle input { display: none; }
.toggle-slider {
    position: relative;
    width: 50px;
    height: 24px;
    background: var(--badge-off);
    border-radius: 12px;
    transition: 0.3s;
}
.toggle-slider::before {
    content: '';
    position: absolute;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: white;
    top: 3px;
    left: 3px;
    transition: 0.3s;
}
.theme-toggle input:checked + .toggle-slider { background: var(--accent-color); }
.theme-toggle input:checked + .toggle-slider::before { transform: translateX(26px); }
.toggle-label { font-size: 14px; color: var(--text-secondary); }

.container { max-width: 1400px; margin: 0 auto; }

.stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 15px;
    margin-bottom: 20px;
}

.stat-card {
    background: var(--bg-secondary);
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.3);
}

.stat-card h3 {
    color: var(--text-secondary);
    font-size: 14px;
    margin-bottom: 10px;
}

.stat-card .value {
    font-size: 32px;
    font-weight: bold;
    color: var(--text-primary);
}

.stat-card.processing .value { color: var(--info-color); }
.stat-card.completed .value { color: var(--success-color); }
.stat-card.failed .value { color: var(--error-color); }

.warning-banner {
    background: #3d1a1a;
    border-left: 4px solid var(--accent-color);
    padding: 20px;
    margin-bottom: 20px;
    border-radius: 8px;
    display: none;
}

.warning-banner h3 {
    color: var(--accent-color);
    margin-bottom: 10px;
}

.warning-banner p {
    color: var(--text-secondary);
}

.badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
    margin-left: 8px;
}

.badge.on { background: var(--accent-color); color: white; }
.badge.off { background: var(--badge-off); color: white; }

.status-badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
}

.status-badge.success { background: var(--success-color); color: white; }
.status-badge.failed { background: var(--error-color); color: white; }
.status-badge.processing { background: var(--info-color); color: white; }

.modal {
    display: none;
    position: fixed;
    z-index: 2000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background: var(--modal-bg);
    overflow: auto;
}

.modal-content {
    background: var(--bg-secondary);
    margin: 50px auto;
    padding: 30px;
    width: 80%;
    max-width: 800px;
    border-radius: 8px;
    max-height: 80vh;
    overflow-y: auto;
    position: relative;
    color: var(--text-primary);
}

.modal-content.wide {
    max-width: 1200px;
    width: 90%;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.modal-header h2 { color: var(--text-primary); }

.close {
    font-size: 28px;
    cursor: pointer;
    color: var(--text-tertiary);
}

.close:hover { color: var(--text-primary); }

.detail-section {
    margin-bottom: 20px;
}

.detail-section h3 {
    color: var(--text-secondary);
    margin-bottom: 10px;
    font-size: 14px;
}

.detail-section .content {
    background: var(--bg-primary);
    padding: 15px;
    border-radius: 4px;
    white-space: pre-wrap;
    word-wrap: break-word;
    max-height: 400px;
    overflow-y: auto;
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.error-content {
    background: #3d1a1a !important;
    border-color: var(--error-color) !important;
    color: #ffcccc !important;
}

.streaming-content {
    background: var(--bg-primary);
    padding: 15px;
    border-radius: 4px;
    white-space: pre-wrap;
    word-wrap: break-word;
    max-height: 400px;
    overflow-y: auto;
    color: var(--text-primary);
    border: 1px solid var(--info-color);
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { border-color: var(--info-color); }
    50% { border-color: var(--accent-color); }
}

.modal-content::-webkit-scrollbar,
.detail-section .content::-webkit-scrollbar {
    width: 12px;
}

.modal-content::-webkit-scrollbar-track,
.detail-section .content::-webkit-scrollbar-track {
    background: var(--scrollbar-track);
    border-radius: 6px;
}

.modal-content::-webkit-scrollbar-thumb,
.detail-section .content::-webkit-scrollbar-thumb {
    background: var(--scrollbar-thumb);
    border-radius: 6px;
    border: 2px solid var(--scrollbar-track);
}

.modal-content::-webkit-scrollbar-thumb:hover,
.detail-section .content::-webkit-scrollbar-thumb:hover {
    background: var(--scrollbar-hover);
}

table {
    width: 100%;
    border-collapse: collapse;
    background: var(--bg-secondary);
    border-radius: 8px;
    overflow: hidden;
}

th, td {
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

th {
    background: var(--bg-tertiary);
    font-weight: 600;
    color: var(--text-secondary);
}

tr:hover {
    background: var(--bg-tertiary);
    cursor: pointer;
}

.copy-btn {
    margin-right: 10px;
    padding: 4px 12px;
    background: var(--accent-color);
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.copy-btn:hover { background: var(--accent-hover); }
.copy-btn::before { content: "📋"; font-size: 12px; }

.btn {
    padding: 10px 20px;
    background: var(--accent-color);
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    font-family: 'Microsoft YaHei', sans-serif;
}

.btn:hover { background: var(--accent-hover); }
.btn:disabled { background: var(--badge-off); cursor: not-allowed; }

.two-column-layout {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

@media (max-width: 900px) {
    .two-column-layout {
        grid-template-columns: 1fr;
    }
}

/* SSE 连接状态指示器 */
.sse-status-container,
.ws-status-container {
    padding: 15px;
    border-top: 1px solid var(--border-color);
    margin-bottom: 0;
    flex-shrink: 0;
}

.sse-status-label,
.ws-status-label {
    font-size: 12px;
    color: var(--text-tertiary);
    margin-bottom: 8px;
    font-weight: 500;
}

.sse-status,
.ws-status {
    padding: 10px 12px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.3s ease;
}

.sse-status .status-dot,
.ws-status .status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    animation: pulse-dot 2s infinite;
}

.sse-status.connecting,
.ws-status.connecting {
    background: rgba(255, 193, 7, 0.15);
    color: #FFC107;
    border: 1px solid rgba(255, 193, 7, 0.3);
}

.sse-status.connecting .status-dot,
.ws-status.connecting .status-dot {
    background: #FFC107;
}

.sse-status.connected,
.ws-status.connected {
    background: rgba(76, 175, 80, 0.15);
    color: #4CAF50;
    border: 1px solid rgba(76, 175, 80, 0.3);
}

.sse-status.connected .status-dot,
.ws-status.connected .status-dot {
    background: #4CAF50;
    animation: none;
}

.sse-status.error,
.ws-status.error {
    background: rgba(244, 67, 54, 0.15);
    color: #f44336;
    border: 1px solid rgba(244, 67, 54, 0.3);
}

.sse-status.error .status-dot,
.ws-status.error .status-dot {
    background: #f44336;
}

.sse-status.disconnected,
.ws-status.disconnected {
    background: rgba(158, 158, 158, 0.15);
    color: #9E9E9E;
    border: 1px solid rgba(158, 158, 158, 0.3);
}

.sse-status.disconnected .status-dot,
.ws-status.disconnected .status-dot {
    background: #9E9E9E;
}

@keyframes pulse-dot {
    0%, 100% {
        opacity: 1;
        transform: scale(1);
    }
    50% {
        opacity: 0.6;
        transform: scale(1.2);
    }
}

/* 浅色主题调整 */
[data-theme="light"] .sse-status.connecting,
[data-theme="light"] .ws-status.connecting {
    background: rgba(255, 193, 7, 0.2);
    color: #F57C00;
}

[data-theme="light"] .sse-status.connecting .status-dot,
[data-theme="light"] .ws-status.connecting .status-dot {
    background: #F57C00;
}

[data-theme="light"] .sse-status.connected,
[data-theme="light"] .ws-status.connected {
    background: rgba(76, 175, 80, 0.2);
    color: #2E7D32;
}

[data-theme="light"] .sse-status.connected .status-dot,
[data-theme="light"] .ws-status.connected .status-dot {
    background: #2E7D32;
}

[data-theme="light"] .sse-status.error,
[data-theme="light"] .ws-status.error {
    background: rgba(244, 67, 54, 0.2);
    color: #C62828;
}

[data-theme="light"] .sse-status.error .status-dot,
[data-theme="light"] .ws-status.error .status-dot {
    background: #C62828;
}

/* SSE 重连对话框样式 */
.sse-reconnect-dialog,
.ws-reconnect-dialog {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.dialog-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
}

.dialog-content {
    position: relative;
    background: var(--bg-secondary);
    border-radius: 12px;
    padding: 30px;
    max-width: 400px;
    width: 90%;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
    border: 1px solid var(--border-color);
    text-align: center;
    animation: dialogFadeIn 0.3s ease-out;
}

@keyframes dialogFadeIn {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.dialog-icon {
    font-size: 48px;
    margin-bottom: 15px;
}

.dialog-title {
    color: var(--text-primary);
    font-size: 20px;
    margin: 0 0 15px 0;
    font-weight: 600;
}

.dialog-message {
    color: var(--text-secondary);
    font-size: 14px;
    line-height: 1.6;
    margin: 0 0 25px 0;
}

.dialog-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
}

.dialog-actions button {
    padding: 10px 24px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    border: none;
    outline: none;
}

.btn-cancel {
    background: var(--bg-primary);
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
}

.btn-cancel:hover {
    background: var(--hover-bg);
    color: var(--text-primary);
}

.btn-confirm {
    background: var(--accent-color);
    color: white;
}

.btn-confirm:hover {
    opacity: 0.9;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(33, 150, 243, 0.3);
}
