/* ============================================================
   豆包式首页改造（样式覆盖层）
   - 仅覆盖，不修改 portal.css / portal-workspace.css
   - 主题：默认浅色（豆包式白底），data-theme="dark" 深色
   - 结构：左侧会话栏 + 居中问候 + 大输入卡 + 建议卡片
   ============================================================ */

:root {
  /* 豆包式配色（默认浅色，避免首屏闪黑） */
  --bg-dark: #ffffff;
  --bg-panel: #f6f7f9;
  --bg-card: #f2f4f7;
  --bg-input: #f2f4f7;
  --border-dark: #e6e8ec;
  --text-primary: #1f2329;
  --text-secondary: #646a73;
  --text-muted: #8f959e;
  --accent-blue: #3370ff;
  --db-blue-soft: rgba(51, 112, 255, 0.08);
  --db-blue-hover: rgba(51, 112, 255, 0.14);
  --db-elevated: #ffffff;
  --db-hover: rgba(15, 23, 42, 0.05);
  --db-hover-strong: rgba(15, 23, 42, 0.08);
  --db-shadow: 0 6px 24px rgba(15, 23, 42, 0.06);
  --db-shadow-lg: 0 12px 40px rgba(15, 23, 42, 0.10);
  --primary-gradient: linear-gradient(135deg, #4d8bff, #2b5cf6);
  --db-radius-card: 18px;
}

[data-theme="light"] {
  --bg-dark: #ffffff;
  --bg-panel: #f6f7f9;
  --bg-card: #f2f4f7;
  --bg-input: #f2f4f7;
  --border-dark: #e6e8ec;
  --text-primary: #1f2329;
  --text-secondary: #646a73;
  --text-muted: #8f959e;
  --accent-blue: #3370ff;
  --db-elevated: #ffffff;
  --db-hover: rgba(15, 23, 42, 0.05);
  --db-hover-strong: rgba(15, 23, 42, 0.08);
}

[data-theme="dark"] {
  --bg-dark: #17181c;
  --bg-panel: #1e1f24;
  --bg-card: #26272c;
  --bg-input: #2a2b31;
  --border-dark: #33343a;
  --text-primary: #e8eaed;
  --text-secondary: #a8adb5;
  --text-muted: #7a8089;
  --accent-blue: #4d8bff;
  --db-blue-soft: rgba(77, 139, 255, 0.14);
  --db-blue-hover: rgba(77, 139, 255, 0.22);
  --db-elevated: #232429;
  --db-hover: rgba(255, 255, 255, 0.07);
  --db-hover-strong: rgba(255, 255, 255, 0.12);
  --db-shadow: 0 6px 24px rgba(0, 0, 0, 0.36);
  --db-shadow-lg: 0 12px 40px rgba(0, 0, 0, 0.45);
}

html, body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue",
               "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  -webkit-font-smoothing: antialiased;
}

/* ============================================================
   1. 轻顶栏
   ============================================================ */
.workspace-header {
  height: 54px;
  background: transparent;
  border-bottom: none;
  padding: 0 12px;
  gap: 10px;
}

.brand-icon {
  background: none;
  -webkit-background-clip: border-box;
  -webkit-text-fill-color: currentColor;
  background-clip: border-box;
  color: var(--accent-blue);
  font-size: 21px;
}

.brand-text { font-weight: 600; letter-spacing: 0.2px; }

.brand-badge {
  background: var(--db-blue-soft);
  color: var(--accent-blue);
  font-weight: 500;
}

.header-btn {
  border: none;
  background: transparent;
  color: var(--text-secondary);
  padding: 7px 11px;
  border-radius: 10px;
  font-size: 13px;
  gap: 6px;
}
.header-btn:hover {
  background: var(--db-hover);
  color: var(--text-primary);
  border-color: transparent;
}

.header-btn-primary {
  background: var(--accent-blue);
  color: #fff;
  padding: 7px 16px;
  border-radius: 999px;
  font-weight: 500;
}
.header-btn-primary:hover { background: #2860e6; color: #fff; opacity: 1; }

#sidebar-toggle { font-size: 14px; }

.workflow-indicator {
  background: var(--db-blue-soft);
  color: var(--accent-blue);
}
.workflow-progress { background: var(--db-hover-strong); }

.user-dropdown-toggle:hover { background: var(--db-hover); }
.user-avatar-img { border-color: var(--accent-blue); }

/* auth.js 用内联 style 把 #nav-login 写成 display:block，导致两个按钮竖排溢出顶栏 —— 强制横排 */
#nav-login {
  display: flex !important;
  gap: 8px !important;
  align-items: center !important;
}

.dropdown-menu {
  background: var(--db-elevated);
  border-color: var(--border-dark);
  border-radius: 12px;
  box-shadow: var(--db-shadow-lg);
}
.dropdown-menu .dropdown-item:hover { background: var(--db-hover); }

/* ============================================================
   2. 布局：会话栏移到左侧（豆包式）
   ============================================================ */
.workspace-body { background: var(--bg-dark); }

.workspace-sidebar {
  order: -1;
  width: 268px;
  margin: 0;
  border: none;
  border-right: 1px solid var(--border-dark);
  border-radius: 0;
  background: var(--bg-panel);
}

body.db-sidebar-collapsed .workspace-sidebar { display: none; }

.sidebar-tabs {
  padding: 10px 10px 6px;
  gap: 4px;
  border-bottom: none;
}
.sidebar-tab {
  padding: 7px 4px;
  border-radius: 9px;
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
}
.sidebar-tab:hover { color: var(--text-secondary); background: var(--db-hover); }
.sidebar-tab.active { color: var(--accent-blue); background: var(--db-blue-soft); }
.sidebar-tab.active::after { display: none; }

.sidebar-tab-content { padding: 6px 10px 12px; }

/* 新建对话按钮（豆包式主按钮） */
.history-toolbar {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 8px;
  margin-bottom: 10px !important;
}

.new-chat-btn {
  width: 100%;
  height: 40px;
  border: none;
  border-radius: 11px;
  background: var(--accent-blue);
  color: #fff;
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  transition: background 0.15s, transform 0.15s;
}
.new-chat-btn:hover { background: #2860e6; transform: translateY(-1px); }
.new-chat-btn:active { transform: translateY(0); }

/* 搜索框 */
.search-wrapper { width: 100%; }
.search-wrapper input.form-control,
.search-wrapper input {
  background: var(--bg-card);
  border: 1px solid transparent;
  border-radius: 10px;
  height: 34px;
  font-size: 13px;
  color: var(--text-primary);
  box-shadow: none;
}
.search-wrapper input:focus,
.search-wrapper input.form-control:focus {
  background: var(--db-elevated);
  border-color: var(--accent-blue);
  box-shadow: none;
  color: var(--text-primary);
}
.search-wrapper input::placeholder { color: var(--text-muted); }

/* 历史列表 */
.history-list-container::-webkit-scrollbar { width: 6px; }
.history-list-container::-webkit-scrollbar-thumb { background: transparent; border-radius: 3px; }
.history-list-container:hover::-webkit-scrollbar-thumb { background: var(--border-dark); }

.history-item {
  padding: 9px 10px;
  border-radius: 10px;
  margin-bottom: 2px;
  gap: 8px;
}
.history-item i { color: var(--text-muted); font-size: 13px; }
.history-item:hover { background: var(--db-hover); }
.history-item.active { background: var(--db-blue-soft); }
.history-item.active i { color: var(--accent-blue); }
.history-item-title { font-size: 13px; font-weight: 500; }
.history-item-meta { font-size: 11.5px; }
.btn-action { border-radius: 7px; }
.btn-action:hover { background: var(--db-hover-strong); }

.empty-hint { padding: 1.6rem 1rem; color: var(--text-muted); }
.empty-hint i { font-size: 1.6rem; }

/* ============================================================
   3. 主区：豆包式首页
   ============================================================ */
.workspace-main { background: var(--bg-dark); }

.chat-panel {
  margin: 0;
  border: none;
  border-radius: 0;
  background: transparent;
}

/* ---- 首屏问候 ---- */
.chat-hero { display: none; }

.chat-panel.is-empty .chat-hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 14px;
  margin-top: auto;
  padding: 24px 20px 24px;
}

.chat-hero-logo {
  width: 62px;
  height: 62px;
  border-radius: 21px;
  background: var(--primary-gradient);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  box-shadow: 0 10px 28px rgba(51, 112, 255, 0.30);
}

.chat-hero-title {
  font-size: 30px;
  font-weight: 600;
  letter-spacing: 0.5px;
  color: var(--text-primary);
  margin: 0;
  line-height: 1.35;
}

.chat-hero-sub {
  margin: 0;
  max-width: 640px;
  font-size: 14.5px;
  line-height: 1.75;
  color: var(--text-secondary);
}

/* ---- 首屏隐藏消息区，进入对话后反向切换 ---- */
.chat-panel.is-empty .chat-messages { display: none; }
.chat-panel:not(.is-empty) .chat-hero,
.chat-panel:not(.is-empty) .chat-suggest { display: none; }
.chat-panel:not(.is-empty) .welcome-message { display: none; }

/* ---- 消息区（内容居中成列） ---- */
.chat-messages {
  padding: 26px max(24px, calc((100% - 900px) / 2)) 14px;
  gap: 16px;
  background: transparent;
}

.message { max-width: 90%; gap: 0; }
.message-avatar { display: none; }

/* 消息列：占满内容列宽，气泡按内容收缩（portal.css 的 max-width:75% + margin 会让文字过早换行） */
.chat-messages .message { width: 100%; max-width: 100%; margin: 0; }
.chat-messages .message-content { margin: 0; box-shadow: none; }
.chat-messages .bot-message .message-content,
.chat-messages .assistant-message .message-content { flex: 1 1 auto; max-width: 100%; }
.chat-messages .user-message .message-content { max-width: min(74%, 640px); }

/* AI 回复：豆包式纯文本无气泡 */
.bot-message .message-content,
.assistant-message .message-content {
  background: transparent;
  padding: 2px 0;
  border-radius: 0;
  font-size: 14.5px;
  line-height: 1.75;
  color: var(--text-primary);
}

/* 用户消息：圆角气泡靠右 */
.user-message .message-content {
  background: var(--bg-card);
  color: var(--text-primary);
  border: 1px solid var(--border-dark);
  border-radius: 16px;
  border-bottom-right-radius: 5px;
  padding: 10px 14px;
  font-size: 14.5px;
  line-height: 1.7;
}
.user-message .message-content code {
  background: var(--bg-input);
  color: var(--text-primary);
}

/* ============================================================
   4. 输入卡（豆包式大圆角卡片）
   ============================================================ */
.chat-input-area {
  width: min(900px, 100%);
  margin: 0 auto;
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 4px 6px;
  padding: 10px 12px 10px;
  background: var(--db-elevated);
  border: 1px solid var(--border-dark);
  border-radius: var(--db-radius-card);
  box-shadow: var(--db-shadow);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.chat-input-area:focus-within {
  border-color: rgba(51, 112, 255, 0.55);
  box-shadow: 0 8px 28px rgba(51, 112, 255, 0.12);
}

.chat-input-field {
  flex: 1 0 100%;
  order: 1;
}
.chat-input-field textarea {
  width: 100%;
  background: transparent;
  border: none;
  box-shadow: none;
  border-radius: 12px;
  padding: 4px 4px 6px;
  font-size: 15px;
  line-height: 1.55;
  color: var(--text-primary);
  min-height: 30px;
  max-height: 160px;
  resize: none;
}
.chat-input-field textarea:focus {
  background: transparent;
  border: none;
  box-shadow: none;
  color: var(--text-primary);
}
.chat-input-field textarea::placeholder { color: var(--text-muted); }

.chat-input-tools {
  order: 2;
  padding-bottom: 0;
  gap: 2px;
}
.chat-input-actions {
  order: 3;
  margin-left: auto;
  padding-bottom: 0;
  gap: 4px;
}

.input-tool-btn {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  color: var(--text-muted);
  font-size: 15px;
}
.input-tool-btn:hover { background: var(--db-hover); color: var(--text-primary); }

.send-btn {
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 50%;
  font-size: 15px;
  background: var(--accent-blue);
  color: #fff;
}
.send-btn:hover { filter: brightness(0.94); }
/* workspace.js 只在状态切换时写入 state-*，以下为各状态色（覆盖 portal-workspace 的旧值） */
.send-btn.state-idle { background: var(--accent-blue); color: #fff; }
.send-btn.state-idle:hover { background: #2860e6; filter: none; }
.send-btn.state-sending {
  background: var(--accent-orange);
  color: #fff;
  animation: pulse-orange 1s infinite;
}
.send-btn.state-queued { background: var(--accent-yellow); color: #1a1a2e; animation: none; }
.send-btn.state-error { background: var(--accent-red); color: #fff; animation: none; }
.send-btn.state-success { background: var(--accent-green); color: #fff; animation: none; }
.send-btn:disabled { opacity: 0.45; cursor: not-allowed; }

.voice-btn:hover { color: var(--accent-blue) !important; }

/* 文件预览（进入卡片首行） */
.file-preview-area {
  flex: 1 0 100%;
  order: 0;
  padding: 0 2px 8px;
  gap: 8px;
}
.file-preview-item {
  background: var(--bg-card);
  border: 1px solid var(--border-dark);
  border-radius: 10px;
}
.file-preview-item .file-remove:hover { background: var(--db-hover-strong); }

/* 状态行 / 反馈条：与输入卡同宽居中 */
.chat-input-status {
  width: min(900px, 100%);
  margin: 8px auto 14px;
  padding: 0 6px;
}
.chat-input-status small { font-size: 11px; color: var(--text-muted); }

.feedback-bar {
  width: min(900px, 100%);
  margin: 0 auto;
  padding: 0 6px;
  border-top: none;
}
.feedback-toggle {
  color: var(--text-muted);
  border-radius: 8px;
}
.feedback-toggle:hover { color: var(--text-primary); background: var(--db-hover); }
.feedback-panel {
  background: var(--db-elevated);
  border-color: var(--border-dark);
  border-radius: 14px;
  box-shadow: var(--db-shadow-lg);
}
.feedback-header { background: var(--db-hover); }
.feedback-input {
  background: var(--bg-input);
  border-color: var(--border-dark);
  color: var(--text-primary);
}
.rating-btn { border-color: var(--border-dark); color: var(--text-muted); }

/* 首屏时收起这些次要元素，保持豆包式干净首页 */
.chat-panel.is-empty .feedback-bar,
.chat-panel.is-empty .chat-input-status { display: none; }

/* ============================================================
   5. 首屏建议卡片
   ============================================================ */
.chat-suggest { display: none; }

.chat-panel.is-empty .chat-suggest {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  width: min(900px, 100%);
  margin: 0 auto auto;
  padding: 22px 16px 30px;
}

.suggest-card {
  display: flex;
  align-items: center;
  gap: 10px;
  width: calc(50% - 5px);
  max-width: 430px;
  min-width: 220px;
  text-align: left;
  padding: 11px 14px;
  background: var(--bg-panel);
  border: 1px solid var(--border-dark);
  border-radius: 14px;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s, border-color 0.15s, background 0.15s;
  font-family: inherit;
}
.suggest-card:hover {
  transform: translateY(-2px);
  border-color: rgba(51, 112, 255, 0.45);
  box-shadow: var(--db-shadow);
  background: var(--db-elevated);
}

.suggest-icon {
  width: 32px;
  height: 32px;
  flex-shrink: 0;
  border-radius: 10px;
  background: var(--db-blue-soft);
  color: var(--accent-blue);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
}

.suggest-body { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1; }
.suggest-title { font-size: 13.5px; font-weight: 600; color: var(--text-primary); }
.suggest-desc {
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.suggest-arrow { font-size: 11px; color: var(--text-muted); transition: transform 0.15s, color 0.15s; }
.suggest-card:hover .suggest-arrow { color: var(--accent-blue); transform: translateX(3px); }

/* ============================================================
   6. 其它面板/卡片沿用同一套观感
   ============================================================ */
.agent-card, .media-card, .dag-templates-panel {
  background: var(--bg-card);
  border-color: var(--border-dark);
}

/* ============================================================
   7. 响应式
   ============================================================ */
@media (max-width: 900px) {
  .workspace-sidebar { width: 100%; border-right: none; }
  .chat-hero-title { font-size: 24px; }
  .chat-messages { padding: 18px 14px 10px; gap: 14px; }
  .suggest-card { width: 100%; max-width: none; min-width: 0; }
  .chat-panel.is-empty .chat-hero { padding: 16px 16px 14px; gap: 10px; }
  .chat-panel.is-empty .chat-suggest { padding: 16px 14px 22px; }
}

/* 窄屏顶栏：让位，避免「登录/注册」被挤出屏幕 */
@media (max-width: 720px) {
  .workspace-header { padding: 0 8px; gap: 4px; }
  #sidebar-toggle { display: none; }
  .brand-badge { display: none; }
  #nav-login .header-btn:first-child { display: none; } /* 「下载App」 */
  .header-btn-primary { padding: 7px 12px; }
}

/* ===== 立人AI助手 · 闪光标识（mask 版：颜色随 currentColor，渐变头像内自动变白，深色模式免配） ===== */
.logo-mark {
    display: inline-block;
    width: 1em;
    height: 1em;
    flex: 0 0 auto;
    vertical-align: -0.14em;
    background-color: currentColor;
    -webkit-mask: url("../media/logo-mark.svg") no-repeat center / contain;
    mask: url("../media/logo-mark.svg") no-repeat center / contain;
}
.brand-icon.logo-mark { font-size: 21px; width: 21px; height: 21px; }
.chat-hero-logo .logo-mark { font-size: 38px; width: 38px; height: 38px; color: #fff; }
.message-avatar .logo-mark,
.agent-avatar .logo-mark { color: #fff; }
