/* 礼品智能推荐系统 Web 版样式 */
* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --primary: #1a73e8;
  --secondary: #f0f6ff;
  --bg: #ffffff;
  --border: #e3e8ef;
  --text: #202124;
  --text-sub: #5f6368;
  --danger: #d93025;
  --ok: #34a853;
}

html, body { height: 100%; }
body {
  font-family: "Microsoft YaHei UI", "Microsoft YaHei", system-ui, sans-serif;
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
}
.hidden { display: none !important; }
button {
  font-family: inherit; cursor: pointer; border: none;
  border-radius: 8px; padding: 8px 16px; font-size: 14px;
}
button.primary { background: var(--primary); color: #fff; }
button.primary:hover { background: #1557b0; }
button.ghost { background: transparent; color: var(--primary); border: 1px solid var(--border); }
button.ghost:hover { background: var(--hover-bg); }


button.danger-text { background: transparent; color: var(--danger); padding: 4px 8px; }
button:disabled { opacity: .5; cursor: not-allowed; }
input, textarea, select {
  font-family: inherit; font-size: 14px; color: var(--text);
  border: 1px solid var(--border); border-radius: 8px; padding: 9px 12px; outline: none;
}
input:focus, textarea:focus, select:focus { border-color: var(--primary); }

/* ---------------- 登录页（浅色悬浮弹窗风） ---------------- */
#login-view {
  position: relative; height: 100%; overflow: hidden;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(165deg, #eaf2ff 0%, #f2f7ff 48%, #fbfdff 100%);
}
/* 顶部淡光斑 + 底部粒子装饰 */
#login-view::before {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background:
    radial-gradient(640px 360px at 82% 12%, rgba(96,165,250,.18), transparent 65%),
    radial-gradient(560px 320px at 12% 88%, rgba(129,140,248,.14), transparent 65%);
}
#login-view::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background-image: radial-gradient(rgba(59,130,246,.16) 1px, transparent 1.6px);
  background-size: 30px 30px; opacity: .2;
}
.login-top {
  position: absolute; top: 22px; right: 32px; z-index: 3;
  font-size: 13px; color: rgba(37,99,235,.75); letter-spacing: .5px;
}

/* 3D 粒子背景层 */
#particle-bg {
  position: absolute; inset: 0; z-index: 1;
  overflow: hidden; pointer-events: none;
}
#particle-bg canvas { display: block; width: 100%; height: 100%; }
.login-main {
  position: relative; z-index: 2;
  display: flex; align-items: center; gap: 64px;
  width: min(1120px, 94vw);
}
/* 左侧品牌区（浅底深字） */
.login-intro { flex: 1; min-width: 0; color: var(--text); }
.intro-brand { display: flex; align-items: center; gap: 16px; margin-bottom: 36px; }
.intro-logo {
  width: 60px; height: 60px; object-fit: contain; border-radius: 14px;
  background: #fff; padding: 8px;
  box-shadow: 0 8px 24px rgba(30,64,175,.14);
}
.intro-name h1 { font-size: 28px; font-weight: 700; letter-spacing: 1px; color: #1f2d5a; }
.intro-sub { margin-top: 6px; color: #5f6f9e; font-size: 14px; }
.intro-features { list-style: none; display: flex; flex-direction: row; gap: 20px; }
.intro-features li { display: flex; align-items: flex-start; gap: 14px; }
.intro-features .f-icon {
  flex: none; width: 30px; height: 30px; margin-top: 2px;
  display: flex; align-items: center; justify-content: center;
  background: #e8f0ff; color: #2563eb; border-radius: 9px; font-size: 14px;
}
.intro-features b { display: block; font-size: 15px; margin-bottom: 3px; color: #25345f; }
.intro-features p { color: #7b86a8; font-size: 13px; line-height: 1.55; }
/* 右侧悬浮登录弹窗 + 二维码 */
.login-panel { display: flex; align-items: stretch; gap: 0; }
.login-card {
  width: 420px; background: #fff; border-radius: 20px;
  padding: 42px 40px 30px;
  box-shadow: 0 28px 80px rgba(30,64,175,.16), 0 4px 16px rgba(30,64,175,.06);
}
.login-card h1 { font-size: 22px; text-align: center; margin-bottom: 6px; color: #1f2d5a; }
.login-card .sub { text-align: center; color: var(--text-sub); margin-bottom: 24px; }
.login-card .field label { display: block; margin: 14px 0 6px; color: var(--text-sub); font-size: 13px; }
.login-card input[type=text], .login-card input[type=password] {
  width: 100%; padding: 11px 12px; background: #f7f9fc; border-color: #e6ecf5;
}
.login-card input[type=text]:focus, .login-card input[type=password]:focus { background: #fff; }
.login-card input[type=text]::placeholder, .login-card input[type=password]::placeholder { color: #a6adb8; }
.login-card .row { display: flex; justify-content: space-between; align-items: center; margin-top: 14px; font-size: 13px; }
.login-card .row a { color: var(--primary); cursor: pointer; text-decoration: none; }
.login-card .row a:hover { text-decoration: underline; }
.login-card button.submit { width: 100%; margin-top: 24px; padding: 12px; font-size: 15px; border-radius: 10px; letter-spacing: 4px; }
.login-error { color: var(--danger); font-size: 13px; min-height: 18px; margin-top: 12px; text-align: center; }
/* 页脚 */
.login-footer {
  position: absolute; left: 0; right: 0; bottom: 22px; z-index: 2;
  display: flex; justify-content: center; align-items: center;
  flex-wrap: wrap; gap: 10px; padding: 0 16px;
  color: #8a95b3; font-size: 12px;
}
.login-footer .sep { opacity: .5; }
.login-footer a { color: #7b86a8; text-decoration: none; }
.login-footer a:hover { color: #2563eb; text-decoration: underline; }
@media (max-width: 900px) {
  .login-intro { display: none; }
  .login-top { display: none; }
  .login-main { justify-content: center; gap: 0; }
  .login-card { width: min(420px, 92vw); }
}

/* ---------------- 主布局 ---------------- */
#app-view { display: flex; height: 100vh; overflow: hidden; }

#sidebar {
  width: 260px; min-width: 260px; display: flex; flex-direction: column;
  background: #f7f9fc; border-right: 1px solid var(--border);
}
.sidebar-head { display:flex; align-items:center; gap:8px; padding: 14px 14px 8px; }
.sidebar-head img { width: 26px; height: 26px; }
.sidebar-head b { font-size: 15px; }
.sidebar-actions { padding: 8px 14px; display:flex; gap:8px; }
.sidebar-actions button { flex: 1; padding: 8px 4px; font-size: 13px; }
.session-search-wrap { padding: 0 14px 8px; }
.session-search-wrap input { width: 100%; font-size: 13px; padding: 7px 10px; }
#session-list { flex: 1; overflow-y: auto; padding: 4px 8px; }
.session-item {
  padding: 9px 10px; border-radius: 8px; cursor: pointer; position: relative;
  display:flex; flex-direction:column; gap:2px; margin-bottom: 2px;
}
.session-item:hover { background: #eef3fb; }
.session-item.active { background: var(--secondary); }
.session-item .t { font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding-right: 34px; }
.session-item .m { font-size: 11px; color: var(--text-sub); }
.session-item .ops { position:absolute; right:6px; top:8px; display:none; gap:2px; }
.session-item:hover .ops { display:flex; }
.session-item .ops button { padding: 2px 6px; font-size: 11px; border-radius: 6px; background:#fff; border:1px solid var(--border); color:var(--text-sub); }
.sidebar-foot { padding: 10px 14px; border-top: 1px solid var(--border); font-size: 13px; color: var(--text-sub); }

main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
#topbar {
  display:flex; align-items:center; gap: 10px; padding: 10px 18px;
  border-bottom: 1px solid var(--border); background: #fff;
}
#topbar .title { font-weight: bold; font-size: 15px; flex: 1; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
#topbar .user { color: var(--text-sub); font-size: 13px; }
.role-badge { display:inline-block; background: var(--secondary); color: var(--primary); font-size:11px; border-radius: 6px; padding: 1px 6px; margin-left:4px; }
.toggles { display:flex; align-items:center; gap: 10px; font-size: 12px; color: var(--text-sub); }
.toggles label { display:flex; align-items:center; gap:4px; cursor:pointer; }

/* ---------------- 聊天区 ---------------- */
#chat-view { flex: 1; display: flex; flex-direction: column; min-height: 0; }
#chat-search-wrap { padding: 8px 18px; background: #fbfcfe; border-bottom: 1px solid var(--border); }
#chat-search-wrap input { width: 280px; font-size: 13px; padding: 6px 10px; }
#chat-scroll { flex: 1; overflow-y: auto; padding: 18px; scroll-behavior: smooth; }
#chat-scroll.streaming { scroll-behavior: auto; }  /* 流式期间关闭平滑动画, 避免滚动打架 */

.msg-row { display: flex; flex-direction: column; align-items: flex-start; margin-bottom: 14px; position: relative; }
.msg-row.user { align-items: flex-end; }
.bubble {
  max-width: 76%; border-radius: 12px; padding: 10px 14px; position: relative;
  line-height: 1.65; word-break: break-word; white-space: pre-wrap;
  box-shadow: 0 1px 2px rgba(0,0,0,.05);
}
.msg-row.user .bubble { background: var(--primary); color: #fff; border-bottom-right-radius: 4px; }
.msg-row.assistant .bubble { background: #f5f7fa; border-bottom-left-radius: 4px; }
.msg-row.system { justify-content: center; align-items: center; }
.msg-row.system .bubble { background: transparent; box-shadow:none; color: var(--text-sub); font-size: 12px; max-width:100%; text-align:center; }
.bubble .ts { display:block; font-size: 11px; opacity: .65; margin-top: 6px; }
.bubble mark { background: #ffe58f; }
/* ⋯ 触发按钮: 始终显示, 避免悬停时布局跳动; 菜单绝对定位弹出, 不挤占布局 */
.msg-ops { display: flex; margin-top: 2px; }
.msg-dots {
  padding: 0 10px; height: 22px; line-height: 20px; font-size: 16px;
  letter-spacing: 2px; background: transparent; color: var(--text-sub);
  border-radius: 6px; user-select: none;
}
.msg-dots:hover { background: var(--secondary); color: var(--primary); }
.msg-menu {
  position: absolute; top: 100%; z-index: 30;
  display: flex; flex-direction: column; min-width: 76px; padding: 4px; gap: 2px;
  background: #fff; border: 1px solid var(--border); border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0,0,0,.14);
}
.msg-row.user .msg-menu { right: 0; }
.msg-row.assistant .msg-menu { left: 0; }
.msg-menu button {
  text-align: left; padding: 6px 12px; font-size: 13px;
  background: transparent; color: var(--text); border-radius: 6px;
}
.msg-menu button:hover { background: var(--secondary); color: var(--primary); }
.msg-menu button[data-op="del"] { color: var(--danger); }

.thinking-box { margin-bottom: 8px; border: 1px dashed var(--border); border-radius: 8px; background: #fffdf5; }
.thinking-box summary { cursor:pointer; font-size: 12px; color: var(--text-sub); padding: 5px 10px; user-select:none; }
.thinking-box .body { font-size: 12px; color: var(--text-sub); padding: 2px 10px 8px; max-height: 220px; overflow-y:auto; white-space: pre-wrap; }

.loading-dots::after { content: ""; animation: dots 1.2s steps(4, end) infinite; }
@keyframes dots { 0%{content:"";} 25%{content:".";} 50%{content:"..";} 75%{content:"...";} }

#quick-options { display:flex; flex-wrap:wrap; gap:8px; padding: 6px 18px; }
#quick-options button {
  background: #fff; color: var(--primary); border: 1px solid var(--primary);
  border-radius: 16px; padding: 5px 14px; font-size: 13px;
}
#quick-options button:hover { background: var(--secondary); }

.input-bar { display:flex; gap:10px; padding: 12px 18px 16px; border-top: 1px solid var(--border); background:#fff; }
#input-text { flex:1; resize:none; height: 64px; line-height:1.5; }
.input-bar .send-col { display:flex; flex-direction:column; justify-content:flex-end; }
#btn-send { padding: 10px 26px; }

/* ---------------- 数据可视化 ---------------- */
#dataview-view { flex: 1; display:flex; flex-direction:column; min-height:0; padding: 12px 18px; gap: 10px; }
.dv-toolbar { display:flex; align-items:center; gap:8px; flex-wrap:wrap; }
.dv-toolbar select, .dv-toolbar input { padding: 7px 10px; font-size: 13px; }
.dv-filters { display:flex; align-items:center; gap:8px; flex-wrap:wrap; font-size: 13px; }
.dv-filters .chip { background: var(--secondary); color: var(--primary); border-radius: 12px; padding: 3px 10px; font-size: 12px; }
.dv-status { color: var(--text-sub); font-size: 12px; margin-left:auto; }
.dv-table-wrap { flex:1; overflow:auto; border:1px solid var(--border); border-radius:10px; }
table.grid { border-collapse: collapse; width: max-content; font-size: 13px; table-layout: fixed; }
table.grid th, table.grid td {
  border-bottom: 1px solid var(--border); border-right: 1px solid #f0f2f5;
  padding: 7px 10px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
table.grid th {
  background: #f5f7fa; position: sticky; top: 0; user-select: none; z-index:1;
}
table.grid th.sortable { cursor: pointer; }
table.grid th.sortable:hover { background: #ecf1f8; }
table.grid th .sort-arrow { font-size: 11px; margin-left: 2px; }
table.grid th .sort-arrow.muted { opacity: .4; }
table.grid th .col-resizer {
  position: absolute; top: 0; right: -4px; width: 8px; height: 100%;
  cursor: col-resize; z-index: 2;
}
table.grid th .col-resizer:hover { background: rgba(26,115,232,.30); }
table.grid tr:hover td { background: #fafcff; }
.dv-pager { display:flex; align-items:center; gap:10px; }
.dv-empty { color: var(--text-sub); padding: 40px; text-align:center; }

/* ---------------- 弹窗 ---------------- */
dialog {
  border: none; border-radius: 14px; padding: 0; width: 420px;
  box-shadow: 0 20px 60px rgba(0,0,0,.18);
}
dialog::backdrop { background: rgba(0,0,0,.35); }
.dialog-body { padding: 22px 24px; }
.dialog-body h3 { margin-bottom: 14px; }
.dialog-body label { display:block; margin: 12px 0 4px; font-size: 13px; color: var(--text-sub); }
.dialog-body input, .dialog-body select { width: 100%; }
.dialog-actions { display:flex; justify-content:flex-end; gap:10px; margin-top: 20px; }
.dialog-error { color: var(--danger); font-size: 12px; min-height: 16px; margin-top: 8px; }

.detail-grid { display:grid; grid-template-columns: 140px 1fr; gap: 6px 12px; font-size: 13px; max-height: 60vh; overflow:auto; }
.detail-grid dt { color: var(--text-sub); }
.detail-grid dd { word-break: break-all; white-space: pre-wrap; }

/* 行详情窗口: 默认加大, 右下角可拖拽放大缩小 */
#dlg-row-detail { width: min(880px, 92vw); max-width: 92vw; }
#dlg-row-detail[open] { resize: both; overflow: auto; }

.toast {
  position: fixed; bottom: 30px; left: 50%; transform: translateX(-50%);
  background: rgba(32,33,36,.92); color: #fff; padding: 10px 20px; border-radius: 10px;
  font-size: 13px; z-index: 999; pointer-events:none; transition: opacity .25s;
}
