/* ═══════════════════════════════════════════════ */
/* 老冯项目总控台 V1 — 样式表 */
/* ═══════════════════════════════════════════════ */

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

:root {
    --bg: #0f1117;
    --bg-panel: #1a1d27;
    --bg-input: #252836;
    --border: #2e3140;
    --text: #e4e6f0;
    --text-dim: #8b8fa3;
    --accent: #6c5ce7;
    --accent-hover: #7d6ff0;
    --green: #00d68f;
    --red: #ff6b6b;
    --yellow: #ffd93d;
    --orange: #ff9f43;
    --radius: 8px;
    --font: 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif;
    --font-mono: 'Cascadia Code', 'Fira Code', 'Consolas', monospace;
}

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
}

/* ── 顶部状态栏 ──────────────────────────────── */
#top-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 20px;
    background: var(--bg-panel);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
    flex-wrap: wrap;
    gap: 8px;
}

.bar-left h1 {
    font-size: 1.2em;
    font-weight: 700;
    white-space: nowrap;
}

.version {
    font-size: 0.7em;
    color: var(--accent);
    background: rgba(108, 92, 231, 0.15);
    padding: 2px 6px;
    border-radius: 4px;
}

.bar-center {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.9em;
}

.phase-badge {
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 0.8em;
    font-weight: 600;
    background: var(--bg-input);
    border: 1px solid var(--border);
    color: var(--text-dim);
}

.phase-badge.active {
    background: rgba(108, 92, 231, 0.2);
    color: var(--accent);
    border-color: var(--accent);
}

.phase-badge.frozen {
    background: rgba(0, 214, 143, 0.15);
    color: var(--green);
    border-color: var(--green);
}

.phase-badge.done {
    background: rgba(0, 214, 143, 0.2);
    color: var(--green);
    border-color: var(--green);
}

.bar-right {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.status-dot {
    font-size: 0.75em;
    padding: 3px 8px;
    border-radius: 10px;
    background: var(--bg-input);
    border: 2px solid var(--yellow);
    color: var(--yellow);
    cursor: default;
    white-space: nowrap;
    transition: border-color 0.3s, color 0.3s;
}

.status-dot.on { border-color: var(--green); color: var(--green); }
.status-dot.off { border-color: var(--red); color: var(--red); }
.status-dot.manual { border-color: var(--orange); color: var(--orange); }

/* ── 主布局 ──────────────────────────────────── */
#main-layout {
    display: flex;
    height: calc(100vh - 56px);
}

/* ── 左侧面板 ────────────────────────────────── */
#left-panel {
    width: 380px;
    min-width: 380px;
    overflow-y: auto;
    border-right: 1px solid var(--border);
    padding: 12px;
    background: var(--bg-panel);
}

/* ── 右侧主工作区 ────────────────────────────── */
#main-area {
    flex: 1;
    overflow-y: auto;
    padding: 16px 20px;
}

/* ── 面板区块 ────────────────────────────────── */
.panel-section {
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    margin-bottom: 16px;
}

.panel-section h2 {
    font-size: 1em;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border);
    color: var(--accent);
}

/* ── 表单 ────────────────────────────────────── */
label {
    display: block;
    font-size: 0.8em;
    color: var(--text-dim);
    margin-bottom: 4px;
    margin-top: 10px;
}

input, textarea, select {
    width: 100%;
    padding: 8px 10px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text);
    font-family: var(--font);
    font-size: 0.9em;
    transition: border-color 0.2s;
}

input:focus, textarea:focus, select:focus {
    outline: none;
    border-color: var(--accent);
}

textarea { resize: vertical; }

/* ── 按钮 ────────────────────────────────────── */
.btn-group {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin: 10px 0;
}

.btn {
    padding: 8px 16px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--bg-input);
    color: var(--text);
    cursor: pointer;
    font-size: 0.85em;
    font-family: var(--font);
    transition: all 0.2s;
    white-space: nowrap;
}

.btn:hover:not(:disabled) {
    border-color: var(--accent);
    color: var(--accent);
}

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

.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); }

.btn-danger { border-color: var(--red); color: var(--red); }
.btn-danger:hover:not(:disabled) { background: rgba(255, 107, 107, 0.1); }

.btn-warning { border-color: var(--orange); color: var(--orange); }
.btn-warning:hover:not(:disabled) { background: rgba(255, 159, 67, 0.1); }

.btn-accent { border-color: var(--green); color: var(--green); }
.btn-accent:hover:not(:disabled) { background: rgba(0, 214, 143, 0.1); }

.btn-sm { padding: 4px 10px; font-size: 0.8em; }

.deliverables-status {
    font-size: 0.72em;
    font-weight: normal;
    color: var(--text-dim);
}
.deliverables-status.done { color: var(--green); }
.deliverables-status.error { color: var(--red); }
.deliverables-list { display: grid; gap: 8px; }
.deliverable-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 10px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--bg-input);
}
.deliverable-row.invalid { border-color: var(--red); }
.deliverable-main { min-width: 0; flex: 1; }
.deliverable-name { font-size: 0.9em; word-break: break-all; }
.deliverable-meta, .deliverable-error { margin-top: 3px; font-size: 0.76em; color: var(--text-dim); }
.deliverable-error { color: var(--red); }

/* ── 项目列表 ────────────────────────────────── */
#project-list {
    max-height: 200px;
    overflow-y: auto;
    margin-bottom: 8px;
}

.project-item {
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: 6px;
    margin-bottom: 6px;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 0.85em;
}

.project-item:hover {
    border-color: var(--accent);
    background: rgba(108, 92, 231, 0.05);
}

.project-item.active {
    border-color: var(--accent);
    background: rgba(108, 92, 231, 0.1);
}

.project-item .p-name {
    font-weight: 600;
    margin-bottom: 4px;
}

.project-item .p-meta {
    font-size: 0.8em;
    color: var(--text-dim);
    display: flex;
    justify-content: space-between;
}

/* ── 讨论区 ──────────────────────────────────── */
#discussion-area {
    margin-top: 12px;
}

.discussion-round {
    margin-bottom: 16px;
}

.discussion-round h3 {
    font-size: 0.9em;
    color: var(--accent);
    margin-bottom: 8px;
    padding: 6px 10px;
    background: rgba(108, 92, 231, 0.08);
    border-radius: 6px;
}

.role-speech {
    margin-bottom: 12px;
    padding: 12px;
    background: var(--bg-input);
    border-left: 3px solid var(--accent);
    border-radius: 0 6px 6px 0;
}

.role-speech .role-name {
    font-weight: 700;
    font-size: 0.9em;
    margin-bottom: 6px;
    color: var(--accent);
}

.role-speech .role-content {
    font-size: 0.85em;
    line-height: 1.6;
    white-space: pre-wrap;
}

/* ── 插话区 ──────────────────────────────────── */
#intervene-msg {
    width: 100%;
    margin-bottom: 8px;
}

/* ── 通用内容区 ──────────────────────────────── */
.markdown-content {
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 16px;
    margin-top: 12px;
    max-height: 500px;
    overflow-y: auto;
    font-size: 0.85em;
    line-height: 1.7;
    white-space: pre-wrap;
}

.markdown-content h1 { font-size: 1.3em; color: var(--accent); margin-bottom: 12px; }
.markdown-content h2 { font-size: 1.1em; color: var(--text); margin: 16px 0 8px; }
.markdown-content h3 { font-size: 1em; color: var(--text-dim); margin: 12px 0 6px; }
.markdown-content table { width: 100%; border-collapse: collapse; margin: 8px 0; font-size: 0.85em; }
.markdown-content th { background: var(--border); padding: 6px 8px; text-align: left; }
.markdown-content td { padding: 6px 8px; border-bottom: 1px solid var(--border); }
.markdown-content code { background: rgba(255,255,255,0.05); padding: 2px 6px; border-radius: 3px; font-family: var(--font-mono); font-size: 0.9em; }
.markdown-content pre { background: rgba(0,0,0,0.3); padding: 12px; border-radius: 6px; overflow-x: auto; }
.markdown-content blockquote { border-left: 3px solid var(--orange); padding-left: 12px; color: var(--orange); margin: 8px 0; }
.markdown-content hr { border: none; border-top: 1px solid var(--border); margin: 16px 0; }

/* ── 日志 ────────────────────────────────────── */
.log-entry {
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 12px;
    margin-bottom: 10px;
    font-size: 0.85em;
}

.log-entry .log-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 8px;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--border);
    font-weight: 600;
}

.log-entry pre {
    background: rgba(0,0,0,0.3);
    padding: 8px;
    border-radius: 4px;
    overflow-x: auto;
    font-size: 0.8em;
    max-height: 200px;
    overflow-y: auto;
    margin: 6px 0;
}

.log-entry .log-label {
    font-size: 0.8em;
    color: var(--text-dim);
    margin-top: 6px;
}

/* ── placeholder ─────────────────────────────── */
.placeholder {
    color: var(--text-dim);
    font-style: italic;
    font-size: 0.9em;
    text-align: center;
    padding: 20px;
}

/* ── 滚动条 ──────────────────────────────────── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-dim); }

/* ── Toast ───────────────────────────────────── */
.toast {
    position: fixed;
    bottom: 20px;
    right: 20px;
    padding: 12px 20px;
    border-radius: 8px;
    color: #fff;
    font-size: 0.9em;
    z-index: 999;
    animation: slideUp 0.3s ease;
    max-width: 400px;
}

.toast.info { background: var(--accent); }
.toast.success { background: var(--green); color: #000; }
.toast.error { background: var(--red); }
.toast.warning { background: var(--orange); color: #000; }

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

/* ── 原始想法区 ──────────────────────────────── */
#raw-idea {
    width: 100%;
    min-height: 160px;
    font-family: var(--font);
    font-size: 0.9em;
    line-height: 1.6;
}

.idea-summary {
    margin-top: 10px;
    padding: 12px;
    background: rgba(108, 92, 231, 0.06);
    border: 1px solid var(--accent);
    border-radius: 6px;
    font-size: 0.85em;
    line-height: 1.7;
    max-height: 300px;
    overflow-y: auto;
}

.idea-summary h2, .idea-summary h3 { color: var(--accent); margin: 8px 0 4px; font-size: 0.95em; }
.idea-summary blockquote {
    border-left: 3px solid var(--orange);
    padding-left: 10px;
    color: var(--orange);
    margin: 6px 0;
    font-size: 0.85em;
}

.idea-meta {
    font-size: 0.8em;
    color: var(--text-dim);
    margin-bottom: 6px;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--border);
}

/* ── 状态灯增强 ──────────────────────────────── */
.status-dot {
    cursor: pointer;
    position: relative;
}

.status-dot:hover::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: calc(100% + 6px);
    left: 50%;
    transform: translateX(-50%);
    background: #1a1d27;
    color: #e4e6f0;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 0.8em;
    white-space: nowrap;
    border: 1px solid var(--border);
    z-index: 200;
    box-shadow: 0 4px 12px rgba(0,0,0,0.5);
}

/* ── 状态说明浮层 ────────────────────────────── */
.legend-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.6);
    z-index: 300;
    display: flex;
    align-items: center;
    justify-content: center;
}

.legend-box {
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 24px;
    max-width: 500px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
}

.legend-box h3 {
    margin-bottom: 16px;
    color: var(--accent);
    font-size: 1.1em;
}

.legend-item {
    padding: 6px 0;
    font-size: 0.85em;
    line-height: 1.6;
    border-bottom: 1px solid rgba(255,255,255,0.05);
}

.dot-demo {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    margin-right: 6px;
}

.dot-demo.on { background: var(--green); }
.dot-demo.off { background: var(--red); }

/* ── API Provider 列表 ───────────────────────── */
.api-provider-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 10px;
    border-bottom: 1px solid rgba(255,255,255,0.05);
    font-size: 0.85em;
    gap: 8px;
    flex-wrap: wrap;
}

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

/* ── 模型标签 ────────────────────────────────── */
.model-badge {
    font-size: 0.7em;
    padding: 1px 6px;
    border-radius: 8px;
    background: rgba(108, 92, 231, 0.15);
    color: var(--accent);
    margin-left: 6px;
    font-weight: normal;
}

.fb-badge {
    font-size: 0.7em;
    padding: 1px 6px;
    border-radius: 8px;
    background: rgba(255, 159, 67, 0.15);
    color: var(--orange);
    margin-left: 6px;
    font-weight: normal;
    cursor: help;
}

/* ── 执行驾驶舱 ──────────────────────────────── */
.dashboard-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.dash-card { background: var(--bg-input); border: 1px solid var(--border); border-radius: 6px; padding: 10px; font-size: 0.85em; }
.dash-card h4 { font-size: 0.8em; color: var(--text-dim); margin-bottom: 6px; }
.dash-card .val { font-size: 1.1em; font-weight: 600; }
.dash-card .val.running { color: var(--accent); }
.dash-card .val.done { color: var(--green); }
.dash-card .val.error { color: var(--red); }

.role-progress-item { display: flex; align-items: center; justify-content: space-between; padding: 4px 0; border-bottom: 1px solid rgba(255,255,255,0.03); font-size: 0.8em; gap: 6px; }
.role-progress-item .rp-status { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.role-progress-item .rp-status.pending { background: var(--text-dim); }
.role-progress-item .rp-status.running { background: var(--accent); animation: pulse 1s ease-in-out infinite; }
.role-progress-item .rp-status.done { background: var(--green); }
.role-progress-item .rp-status.failed { background: var(--red); }
.role-progress-item .rp-status.fallback { background: var(--orange); }
@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:0.4} }

.token-row { display: flex; justify-content: space-between; font-size: 0.8em; padding: 2px 0; }
.token-total { font-weight: 700; border-top: 1px solid var(--border); margin-top: 4px; padding-top: 4px; }

/* ── 六阶段指示器 ────────────────────────────── */
.stage-dot { padding: 2px 8px; border-radius: 10px; border: 1px solid var(--border); white-space: nowrap; }
.stage-dot.stage-done { background: rgba(0,214,143,0.1); border-color: var(--green); color: var(--green); }
.stage-dot.stage-current { background: rgba(108,92,231,0.15); border-color: var(--accent); color: var(--accent); font-weight: 600; }
.stage-dot.stage-pending { color: var(--text-dim); }

/* ── 字段标签 ────────────────────────────────── */
.field-group { margin-bottom: 8px; }
.field-tag { font-size: 0.65em; padding: 1px 5px; border-radius: 6px; margin-left: 4px; vertical-align: middle; }
.field-tag.ai { background: rgba(108,92,231,0.15); color: var(--accent); }
.field-tag.required { background: rgba(255,107,107,0.12); color: var(--red); }
.field-tag.optional { background: rgba(139,143,163,0.12); color: var(--text-dim); }

.fold-section { margin-top: 8px; font-size: 0.85em; color: var(--text-dim); }
.fold-section summary { cursor: pointer; padding: 4px 0; }
.fold-section textarea { margin-top: 4px; }

/* ── 讨论统计 ────────────────────────────────── */
.discussion-stats {
    padding: 8px 12px;
    margin-bottom: 12px;
    background: rgba(108,92,231,0.08);
    border: 1px solid var(--accent);
    border-radius: 6px;
    font-size: 0.85em;
    color: var(--text);
    line-height: 1.6;
}

/* ── ChatGPT 步骤 ────────────────────────────── */
.chatgpt-steps { display: flex; gap: 4px; margin-bottom: 4px; flex-wrap: wrap; }
.cg-step { font-size: 0.72em; padding: 2px 8px; border-radius: 10px; background: var(--bg-input); border: 1px solid var(--border); color: var(--text-dim); }
.cg-step.done { background: rgba(0,214,143,0.1); border-color: var(--green); color: var(--green); }
.cg-step.active { background: rgba(108,92,231,0.15); border-color: var(--accent); color: var(--accent); }

/* ── 打开文件夹按钮 ──────────────────────────── */
.btn-open-folder {
    margin-left: 4px;
    padding: 2px 8px;
    font-size: 0.75em;
}

/* ── 响应式 ──────────────────────────────────── */
@media (max-width: 900px) {
    #main-layout { flex-direction: column; }
    #left-panel { width: 100%; min-width: unset; max-height: 50vh; }
    #top-bar { font-size: 0.8em; }
    .bar-right { display: none; }
}
