/* ═══════════════ Agent 平台 — 样式 ═══════════════ */
:root {
  --bg: #0f0f1a;
  --bg-2: #16162a;
  --bg-3: #1e1e38;
  --bg-hover: #26264a;
  --border: #2a2a4a;
  --text: #e8e8f0;
  --text-dim: #9a9ab0;
  --text-faint: #6a6a85;
  --accent: #6c5ce7;
  --accent-2: #8b7cf0;
  --green: #2ecc71;
  --red: #e74c3c;
  --yellow: #f1c40f;
  --blue: #3498db;
  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 4px 24px rgba(0,0,0,.4);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  --mono: "SF Mono", "JetBrains Mono", Consolas, monospace;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }
.muted { color: var(--text-dim); }
.mono { font-family: var(--mono); font-size: 12px; }

/* ─── 屏幕 ─── */
.screen { height: 100vh; width: 100vw; overflow: hidden; }
.screen-center { display: flex; align-items: center; justify-content: center; }

/* ─── 登录 ─── */
.login-card {
  width: 400px; max-width: 92vw;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 40px 36px;
  text-align: center;
  box-shadow: var(--shadow);
}
.login-logo { font-size: 48px; margin-bottom: 8px; }
.login-title { font-size: 24px; font-weight: 700; }
.login-sub { color: var(--text-dim); margin: 4px 0 24px; font-size: 13px; }

.mode-tabs {
  display: flex; background: var(--bg-3);
  border-radius: var(--radius); padding: 4px; margin-bottom: 20px;
}
.mode-tab {
  flex: 1; padding: 8px; border: none; border-radius: var(--radius-sm);
  background: transparent; color: var(--text-dim); cursor: pointer;
  font-size: 14px; transition: all .15s;
}
.mode-tab.active { background: var(--accent); color: #fff; }

.login-panel { text-align: left; }
.panel-hint { color: var(--text-faint); font-size: 12px; margin-bottom: 12px; }

.qr-image {
  width: 200px; height: 200px; margin: 12px auto;
  background: #fff; border-radius: var(--radius);
  display: block; object-fit: contain; padding: 8px;
}
.qr-status { text-align: center; color: var(--text-dim); font-size: 13px; margin-bottom: 8px; }
#qr-login-area { display: flex; flex-direction: column; align-items: center; }

/* ─── 主布局 ─── */
#screen-app { display: flex; }
.sidebar {
  width: 220px; min-width: 220px;
  background: var(--bg-2);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  padding: 12px;
}
.sidebar-header { margin-bottom: 12px; }
.sidebar-nav { flex: 1; display: flex; flex-direction: column; gap: 2px; overflow-y: auto; }
.nav-item {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 12px; border: none; border-radius: var(--radius-sm);
  background: transparent; color: var(--text-dim);
  cursor: pointer; font-size: 14px; text-align: left; transition: all .12s;
}
.nav-item:hover { background: var(--bg-hover); color: var(--text); }
.nav-item.active { background: var(--bg-3); color: var(--text); font-weight: 600; }

.sidebar-footer { border-top: 1px solid var(--border); padding-top: 10px; display: flex; align-items: center; gap: 8px; }
.user-badge {
  flex: 1; font-size: 12px; color: var(--text-dim);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.main-area { flex: 1; display: flex; flex-direction: column; overflow: hidden; }
.view { flex: 1; display: flex; flex-direction: column; overflow: hidden; }

.view-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 20px; border-bottom: 1px solid var(--border);
}
.view-header h2 { font-size: 17px; font-weight: 600; }

/* ─── 会话列表 ─── */
.session-list { flex: 1; overflow-y: auto; padding: 12px; display: flex; flex-direction: column; gap: 6px; }
.session-item {
  padding: 12px 14px; border-radius: var(--radius);
  background: var(--bg-2); border: 1px solid var(--border);
  cursor: pointer; transition: all .12s; position: relative;
}
.session-item:hover { background: var(--bg-3); border-color: var(--accent); }
.session-item.active { border-color: var(--accent); }
.session-item-title { font-weight: 600; font-size: 14px; display: flex; align-items: center; gap: 6px; }
.session-item-meta { color: var(--text-faint); font-size: 12px; margin-top: 4px; display: flex; gap: 10px; }
.session-item .pin-icon { position: absolute; top: 10px; right: 12px; font-size: 12px; }
.session-item .del-icon { position: absolute; top: 30px; right: 12px; font-size: 11px; color: var(--text-faint); opacity: 0; transition: opacity .12s; }
.session-item:hover .del-icon { opacity: 1; }
.session-item .del-icon:hover { color: var(--red); }

.type-badge {
  font-size: 10px; padding: 1px 6px; border-radius: 4px;
  background: var(--bg-3); color: var(--text-dim); font-weight: 500;
}
.type-badge.project { background: rgba(108,92,231,.2); color: var(--accent-2); }

/* ─── 聊天 ─── */
.chat-header {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 16px; border-bottom: 1px solid var(--border);
}
.chat-title { flex: 1; font-weight: 600; font-size: 15px; }
.chat-header-actions { display: flex; gap: 8px; align-items: center; }
.agent-toggle {
  display: flex; align-items: center; gap: 4px;
  font-size: 12px; color: var(--text-dim); cursor: pointer;
  padding: 4px 8px; border: 1px solid var(--border); border-radius: var(--radius-sm);
}
.agent-toggle input { accent-color: var(--accent); }
.agent-toggle:has(input:checked) { color: var(--accent-2); border-color: var(--accent); }

.chat-messages { flex: 1; overflow-y: auto; padding: 20px; display: flex; flex-direction: column; gap: 16px; }

.msg { display: flex; gap: 10px; max-width: 85%; }
.msg.user { align-self: flex-end; flex-direction: row-reverse; }
.msg-avatar {
  width: 32px; height: 32px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; flex-shrink: 0;
}
.msg.user .msg-avatar { background: var(--accent); }
.msg.assistant .msg-avatar { background: var(--bg-3); }
.msg-bubble {
  padding: 10px 14px; border-radius: var(--radius);
  background: var(--bg-2); border: 1px solid var(--border);
  word-break: break-word; min-width: 60px;
}
.msg.user .msg-bubble { background: var(--accent); border-color: var(--accent); }
.msg-bubble pre {
  background: var(--bg); border-radius: var(--radius-sm);
  padding: 10px; overflow-x: auto; margin: 8px 0;
  font-family: var(--mono); font-size: 12px;
}
.msg-bubble code { font-family: var(--mono); font-size: 12px; }
.msg-bubble :not(pre) > code { background: var(--bg-3); padding: 1px 5px; border-radius: 4px; }
.msg-bubble table { border-collapse: collapse; margin: 8px 0; width: 100%; }
.msg-bubble th, .msg-bubble td { border: 1px solid var(--border); padding: 5px 8px; font-size: 12px; }
.msg-bubble th { background: var(--bg-3); }
.msg-bubble ul, .msg-bubble ol { padding-left: 20px; margin: 6px 0; }
.msg-bubble a { color: var(--accent-2); }

/* 工具调用卡片 */
.tool-card {
  background: var(--bg-3); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 8px 12px;
  margin: 6px 0; font-size: 12px;
}
.tool-card-header { display: flex; align-items: center; gap: 6px; cursor: pointer; }
.tool-card-name { font-weight: 600; color: var(--accent-2); }
.tool-card-status { font-size: 11px; }
.tool-card-status.running { color: var(--yellow); }
.tool-card-status.done { color: var(--green); }
.tool-card-status.error { color: var(--red); }
.tool-card-body { margin-top: 6px; color: var(--text-dim); white-space: pre-wrap; word-break: break-all; font-family: var(--mono); font-size: 11px; max-height: 150px; overflow-y: auto; }
.tool-card-body.collapsed { display: none; }

/* 流式光标 */
.stream-cursor::after { content: "▊"; animation: blink 1s infinite; color: var(--accent-2); }
@keyframes blink { 50% { opacity: 0; } }

.chat-input-area {
  display: flex; gap: 10px; padding: 12px 16px;
  border-top: 1px solid var(--border); background: var(--bg-2);
  align-items: flex-end;
}
.chat-input-area textarea {
  flex: 1; resize: none; background: var(--bg-3);
  border: 1px solid var(--border); border-radius: var(--radius);
  color: var(--text); padding: 10px 12px; font-family: var(--font);
  font-size: 14px; outline: none; transition: border-color .15s;
}
.chat-input-area textarea:focus { border-color: var(--accent); }

/* ─── 看板 ─── */
.kanban {
  flex: 1; display: flex; gap: 12px; padding: 16px;
  overflow-x: auto; align-items: flex-start;
}
.kanban-col {
  min-width: 260px; width: 260px;
  background: var(--bg-2); border: 1px solid var(--border);
  border-radius: var(--radius); display: flex; flex-direction: column;
  max-height: 100%;
}
.kanban-col-header {
  padding: 10px 14px; font-weight: 600; font-size: 13px;
  border-bottom: 1px solid var(--border);
  display: flex; justify-content: space-between; align-items: center;
}
.kanban-col-count { background: var(--bg-3); border-radius: 10px; padding: 0 8px; font-size: 11px; color: var(--text-dim); }
.kanban-col-body { padding: 8px; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; flex: 1; min-height: 60px; }
.kanban-col-body.drag-over { background: var(--bg-hover); border-radius: var(--radius-sm); }

.task-card {
  background: var(--bg-3); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 10px 12px;
  cursor: grab; transition: all .12s;
}
.task-card:hover { border-color: var(--accent); }
.task-card:active { cursor: grabbing; }
.task-card.dragging { opacity: .5; }
.task-card-title { font-weight: 500; font-size: 13px; }
.task-card-meta { display: flex; gap: 6px; margin-top: 6px; flex-wrap: wrap; }
.tag { font-size: 10px; padding: 1px 6px; border-radius: 4px; background: var(--bg-hover); color: var(--text-dim); }
.priority-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.priority-low { background: var(--blue); }
.priority-medium { background: var(--yellow); }
.priority-high { background: #e67e22; }
.priority-urgent { background: var(--red); }
.task-card-desc { font-size: 11px; color: var(--text-faint); margin-top: 4px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.task-card-agent { font-size: 10px; color: var(--accent-2); margin-top: 4px; }

/* ─── 卡片列表 ─── */
.card-list { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 10px; }
.card {
  background: var(--bg-2); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px 16px;
}
.card-header { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.card-title { font-weight: 600; font-size: 14px; display: flex; align-items: center; gap: 8px; }
.card-desc { color: var(--text-dim); font-size: 12px; margin-top: 4px; }
.card-actions { display: flex; gap: 6px; }
.card-footer { margin-top: 8px; font-size: 11px; color: var(--text-faint); display: flex; gap: 12px; flex-wrap: wrap; }

/* ─── 文件 ─── */
.file-toolbar { display: flex; align-items: center; gap: 8px; }
.file-path { font-size: 12px; color: var(--text-dim); font-family: var(--mono); }
.file-crumb { padding: 8px 16px 0; font-size: 12px; }
.file-crumb a { color: var(--accent-2); text-decoration: none; margin: 0 2px; }
.file-crumb a:hover { text-decoration: underline; }

/* ─── 文件网格 ─── */
.files-grid { flex: 1; overflow-y: auto; padding: 16px; display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; align-content: start; }
.file-item {
  background: var(--bg-2); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px; text-align: center;
  cursor: pointer; transition: all .12s;
}
.file-item:hover { border-color: var(--accent); background: var(--bg-3); }
.file-icon { font-size: 28px; }
.file-name { font-size: 12px; margin-top: 6px; word-break: break-all; overflow: hidden; text-overflow: ellipsis; }
.file-size { font-size: 10px; color: var(--text-faint); margin-top: 2px; }

/* ─── 按钮 ─── */
.btn {
  padding: 8px 14px; border: none; border-radius: var(--radius-sm);
  cursor: pointer; font-size: 13px; font-family: var(--font);
  transition: all .12s; display: inline-flex; align-items: center; gap: 6px;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-2); }
.btn-primary:disabled { opacity: .5; cursor: not-allowed; }
.btn-ghost { background: transparent; color: var(--text-dim); border: 1px solid var(--border); }
.btn-ghost:hover { background: var(--bg-hover); color: var(--text); }
.btn-danger { background: var(--red); color: #fff; }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-block { width: 100%; justify-content: center; }
.btn-icon { padding: 6px 8px; }

/* ─── 表单 ─── */
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 12px; color: var(--text-dim); margin-bottom: 5px; }
.input, .select, textarea.input {
  width: 100%; padding: 9px 12px;
  background: var(--bg-3); border: 1px solid var(--border);
  border-radius: var(--radius-sm); color: var(--text);
  font-family: var(--font); font-size: 13px; outline: none;
  transition: border-color .15s;
}
.input:focus, .select:focus { border-color: var(--accent); }
.select-sm, .input-sm { width: auto; padding: 6px 10px; font-size: 12px; }
.select option { background: var(--bg-3); }

/* ─── 模态框 ─── */
.modal-root {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(0,0,0,.6);
  display: flex; align-items: center; justify-content: center;
  backdrop-filter: blur(2px);
}
.modal {
  background: var(--bg-2); border: 1px solid var(--border);
  border-radius: 12px; width: 520px; max-width: 94vw;
  max-height: 88vh; display: flex; flex-direction: column;
  box-shadow: var(--shadow);
}
.modal-lg { width: 680px; }
.modal-header {
  padding: 16px 20px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.modal-header h3 { font-size: 16px; }
.modal-body { padding: 20px; overflow-y: auto; }
.modal-footer { padding: 14px 20px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 8px; }
.modal-close { background: none; border: none; color: var(--text-dim); font-size: 20px; cursor: pointer; }
.modal-close:hover { color: var(--text); }

/* ─── Toast ─── */
.toast-root { position: fixed; bottom: 20px; right: 20px; z-index: 200; display: flex; flex-direction: column; gap: 8px; }
.toast {
  background: var(--bg-3); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 10px 16px;
  font-size: 13px; box-shadow: var(--shadow);
  animation: slideIn .2s ease;
  max-width: 320px;
}
.toast.success { border-left: 3px solid var(--green); }
.toast.error { border-left: 3px solid var(--red); }
.toast.info { border-left: 3px solid var(--blue); }
@keyframes slideIn { from { transform: translateX(30px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ─── 任务详情 ─── */
.task-detail-section { margin-bottom: 18px; }
.task-detail-section h4 { font-size: 13px; color: var(--text-dim); margin-bottom: 8px; }
.activity-item { padding: 8px 0; border-bottom: 1px solid var(--border); font-size: 12px; }
.activity-item:last-child { border-bottom: none; }
.activity-action { color: var(--accent-2); font-weight: 500; }
.activity-time { color: var(--text-faint); font-size: 11px; float: right; }
.comment-item { background: var(--bg-3); border-radius: var(--radius-sm); padding: 8px 12px; margin-bottom: 6px; font-size: 12px; }

/* ─── 工作流步骤 ─── */
.wf-step { display: flex; gap: 10px; align-items: flex-start; margin-bottom: 8px; }
.wf-step-num {
  width: 22px; height: 22px; border-radius: 50%;
  background: var(--accent); color: #fff; font-size: 11px;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.wf-step-body { flex: 1; }

/* ─── 记忆 ─── */
.memory-importance { display: flex; gap: 2px; }
.memory-star { font-size: 12px; }
.memory-star.on { color: var(--yellow); }
.memory-star.off { color: var(--text-faint); }

/* ─── 滚动条 ─── */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--bg-hover); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-faint); }

/* ─── 响应式 ─── */
@media (max-width: 768px) {
  .sidebar { width: 64px; min-width: 64px; padding: 8px; }
  .sidebar .nav-item span, .sidebar-header .btn, .user-badge, #btn-logout { display: none; }
  .nav-item { justify-content: center; padding: 12px; }
  .sidebar-header { display: flex; justify-content: center; }
  .sidebar-header .btn { display: flex; }
  .msg { max-width: 95%; }
  .kanban-col { min-width: 220px; width: 220px; }
  .login-card { padding: 28px 22px; }
}
