/* 综区通 · 一屏沉浸式 AI 对话 */
* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

:root {
  --bg: #0d0f14;
  --bg-soft: #161a22;
  --bg-card: rgba(28,33,44,.82);
  --line: rgba(255,255,255,.08);
  --text: #e8ecf3;
  --text-dim: #8b93a5;
  --accent: #ff5c8a;
  --accent-2: #22d3ee;
  --radius: 14px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  --dragon-aura: #ef4444;
}

html, body { height: 100%; overscroll-behavior: none; }
body {
  font-family: -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg); color: var(--text);
}

#app {
  display: flex; flex-direction: column;
  width: 100%; height: 100dvh; overflow: hidden;
  background: radial-gradient(ellipse at 50% 20%, #1e2635 0%, #0a0c12 70%);
}

/* ═══════════════════ 顶部信息栏 ═══════════════════ */
.top-bar {
  flex: 0 0 auto;
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 12px 4px;
  padding-top: calc(6px + var(--safe-t));
  z-index: 10;
}
.avatar-badge {
  display: flex; align-items: center; gap: 8px;
  background: rgba(13,15,20,.65); border: 1px solid var(--line);
  border-radius: 999px; padding: 4px 12px 4px 4px;
  backdrop-filter: blur(10px);
}
.avatar-pic {
  width: 30px; height: 30px; border-radius: 50%;
  background: linear-gradient(135deg, #ef4444, #b91c1c);
  display: flex; align-items: center; justify-content: center; font-size: 16px;
  flex: 0 0 30px;
}
.avatar-meta { line-height: 1.2; }
.avatar-meta b { font-size: 13px; }
.avatar-meta small { display: block; font-size: 9px; color: var(--text-dim); }
.avatar-online {
  font-size: 9px; color: #34d399; background: rgba(52,211,153,.15);
  padding: 1px 6px; border-radius: 999px; margin-left: 2px;
}
.avatar-setting {
  width: 32px; height: 32px; border-radius: 50%;
  background: rgba(13,15,20,.65); border: 1px solid var(--line);
  color: var(--text); font-size: 14px; cursor: pointer;
  backdrop-filter: blur(10px); display: flex; align-items: center; justify-content: center;
}

/* ═══════════════════ 小龙人形象区 ═══════════════════ */
.dragon-area {
  flex: 1 1 auto;
  display: flex; align-items: center; justify-content: center;
  position: relative;
  min-height: 0;
  overflow: hidden;
}
/* 情绪光晕 */
.dragon-area::before {
  content: ""; position: absolute; left: 50%; top: 50%;
  width: 80vmin; height: 80vmin; transform: translate(-50%, -50%);
  background: var(--dragon-aura); opacity: .12;
  filter: blur(70px); border-radius: 50%;
  transition: background-color 1.2s ease;
}
.dragon-mount {
  position: relative; z-index: 1;
  display: flex; align-items: center; justify-content: center;
  width: 100%; height: 100%;
}
.dragon-mount svg.dragon-svg {
  height: min(100%, 480px); width: auto; max-width: 88vw;
  filter: drop-shadow(0 12px 28px rgba(0,0,0,.45));
}

/* ═══════════════════ 对话气泡区 ═══════════════════ */
/* 历史气泡全部保留，气泡列表本身可上下滑动回看 */
.chat-area {
  flex: 0 0 auto;
  padding: 0 14px 4px;
  overflow: hidden;
  z-index: 5;
}
.chat-bubbles {
  display: flex; flex-direction: column; gap: 6px;
  width: 100%; max-width: 480px; margin: 0 auto;
  min-height: 64px; max-height: 30vh;      /* 内容多时区域内滚动，不再顶掉小龙人 */
  overflow-y: auto;
  overscroll-behavior: contain;            /* 滑到头不带动整页 */
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;                   /* 滚动条隐藏，保持沉浸式观感 */
}
.chat-bubbles::-webkit-scrollbar { display: none; }
.chat-bubbles::after { content: ""; flex: 0 0 4px; }

/* 气泡 */
.bubble {
  max-width: 88%; padding: 7px 11px; border-radius: 14px; font-size: 13px;
  line-height: 1.45; white-space: pre-wrap; word-break: break-word;
  backdrop-filter: blur(12px);
  animation: bubbleIn .3s ease both;
}
@keyframes bubbleIn { from { opacity: 0; transform: translateY(6px) scale(.96);} to { opacity: 1; transform: translateY(0) scale(1);} }
.bubble.ai {
  align-self: flex-start;
  background: rgba(28,33,44,.78); border: 1px solid rgba(255,255,255,.08);
  color: var(--text); border-bottom-left-radius: 3px;
}
.bubble.user {
  align-self: flex-end;
  background: linear-gradient(135deg, var(--accent), #ff7ba3); color: #fff;
  border-bottom-right-radius: 3px;
}
.bubble .who { display: block; font-size: 10px; margin-bottom: 2px; opacity: .65; }

/* 打字动画 */
.typing { display: inline-flex; gap: 3px; }
.typing i { width: 5px; height: 5px; background: var(--text-dim); border-radius: 50%; animation: blink 1.2s infinite; }
.typing i:nth-child(2){ animation-delay:.2s } .typing i:nth-child(3){ animation-delay:.4s }
@keyframes blink { 0%,80%,100%{opacity:.25} 40%{opacity:1} }

/* ═══════════════════ 底部控制栏 ═══════════════════ */
.control-area {
  flex: 0 0 auto;
  padding: 6px 16px 8px;
  padding-bottom: calc(6px + var(--safe-b));
  z-index: 20;
}
.control-inner {
  display: flex; align-items: center; justify-content: center; gap: 16px;
}
.control-hint {
  text-align: center; font-size: 10px; color: var(--text-dim); margin-top: 5px; opacity: .7;
}

/* 控制按钮 */
.ctrl-btn {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  background: rgba(255,255,255,.10); border: 1px solid rgba(255,255,255,.12);
  border-radius: 50%; width: 46px; height: 46px; color: var(--text);
  cursor: pointer; transition: all .2s; backdrop-filter: blur(4px);
  -webkit-touch-callout: none; -webkit-tap-highlight-color: transparent;
}
.ctrl-btn:active { transform: scale(.92); }
.ctrl-icon { font-size: 18px; line-height: 1; }
.ctrl-label { font-size: 8px; color: var(--text-dim); }

.ctrl-btn.mode { width: 50px; height: 50px; background: rgba(34,211,238,.12); border-color: rgba(34,211,238,.25); }
.ctrl-btn.mode .ctrl-icon { font-size: 20px; }
.ctrl-btn.mode .ctrl-label { color: var(--accent-2); }

.ctrl-btn.mic {
  width: 58px; height: 58px;
  background: linear-gradient(135deg, var(--accent), #ff7ba3);
  border: none; box-shadow: 0 4px 18px rgba(255,92,138,.3);
  touch-action: none; -webkit-user-select: none; user-select: none;
  -webkit-touch-callout: none;
}
.ctrl-btn.mic.pressing, .ctrl-btn.mic:active { transform: scale(1.08); }
.ctrl-btn.mic .mic-icon { font-size: 24px; }
.ctrl-btn.mic.listening {
  animation: micPulse 1.2s infinite;
  background: linear-gradient(135deg, #ff3d7a, var(--accent));
}
@keyframes micPulse {
  0% { box-shadow: 0 0 0 0 rgba(255,92,138,.4); }
  70% { box-shadow: 0 0 0 14px rgba(255,92,138,0); }
  100% { box-shadow: 0 0 0 0 rgba(255,92,138,0); }
}

.ctrl-btn.end {
  background: rgba(239,68,68,.18); border-color: rgba(239,68,68,.35); color: #ef4444;
}
.ctrl-btn.end .ctrl-icon { font-size: 20px; }

/* ═══════════════════ 数字员工办公室（底部抽屉） ═══════════════════ */
.office-drawer {
  flex: 0 0 auto;
  background: var(--bg-soft); border-top: 1px solid var(--line);
  border-radius: 12px 12px 0 0;
  transition: flex-basis .35s cubic-bezier(.32,.72,.35,1);
  overflow: hidden;
  display: flex; flex-direction: column;
}
.office-drawer { flex-basis: 34px; }
.office-drawer.open { flex-basis: 50%; min-height: 300px; }
.office-drawer.dragging { transition: none; }
.office-drawer-handle {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 8px 12px; cursor: pointer; flex: 0 0 auto;
  touch-action: none; -webkit-user-select: none; user-select: none;
  -webkit-touch-callout: none; -webkit-tap-highlight-color: transparent;
}
.handle-bar { width: 32px; height: 3px; background: var(--text-dim); border-radius: 999px; opacity: .5; }
.handle-text { font-size: 10px; color: var(--text-dim); }
/* 办公室抽屉内容区：整段可上下滚动，作业模块（员工面板/日志）全部能看到 */
.office-zone {
  flex: 1; min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding: 0 12px 10px;
}

/* ═══════════════════ 文字输入面板（底部滑出） ═══════════════════ */
.input-panel {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 30;
  height: 60vh; max-height: 480px;
  background: rgba(13,15,20,.95); border-top: 1px solid var(--line);
  border-radius: 16px 16px 0 0;
  display: flex; flex-direction: column;
  backdrop-filter: blur(16px);
  animation: panelUp .25s ease both;
}
@keyframes panelUp { from { transform: translateY(100%);} to { transform: translateY(0);} }
.input-panel.hidden { display: none !important; }

.input-panel-header {
  display: flex; align-items: center; justify-content: center;
  padding: 10px 12px; border-bottom: 1px solid var(--line); position: relative;
}
.panel-close {
  position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
  background: none; border: none; color: var(--text-dim); font-size: 16px; cursor: pointer;
}
.panel-title { font-size: 13px; color: var(--text-dim); }
.panel-title b { color: var(--text); }

.chat-history {
  flex: 1; overflow-y: auto; padding: 10px 12px; display: flex; flex-direction: column; gap: 8px;
}
.chat-history .bubble { animation: none; }

.input-panel-bar {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 12px; border-top: 1px solid var(--line); background: var(--bg-soft);
}
#msg-input {
  flex: 1; background: var(--bg-card); border: 1px solid var(--line);
  border-radius: 999px; padding: 9px 14px; color: var(--text); font-size: 13px; outline: none;
}
#msg-input:focus { border-color: var(--accent); }
.btn-send {
  width: 38px; height: 38px; border-radius: 50%; border: none;
  background: linear-gradient(135deg, var(--accent), #ff7ba3); color: #fff;
  font-size: 14px; cursor: pointer; flex: 0 0 auto;
}

.quick-asks {
  display: flex; gap: 6px; padding: 6px 12px; overflow-x: auto; scrollbar-width: none;
  border-top: 1px solid var(--line);
}
.quick-asks::-webkit-scrollbar { display: none; }
.quick-asks button {
  flex: 0 0 auto; background: var(--bg-card); color: var(--accent-2);
  border: 1px solid var(--line); border-radius: 999px; padding: 5px 12px; font-size: 11px; cursor: pointer;
}

/* ═══════════════════ 设置弹窗 ═══════════════════ */
.modal {
  position: absolute; inset: 0; background: rgba(0,0,0,.65); z-index: 60;
  display: flex; align-items: center; justify-content: center; padding: 16px; backdrop-filter: blur(6px);
}
.modal.hidden { display: none !important; }
.modal-card {
  width: 100%; max-width: 400px; max-height: 78vh; overflow-y: auto;
  background: var(--bg-soft); border: 1px solid var(--line);
  border-radius: 16px; padding: 16px;
}
.modal-card h3 { margin-bottom: 12px; font-size: 16px; }
.modal-card label { display: block; font-size: 11px; color: var(--text-dim); margin: 8px 0 4px; }
.modal-card input[type=text], .modal-card input[type=password] {
  width: 100%; background: var(--bg-card); border: 1px solid var(--line);
  border-radius: 10px; padding: 9px 11px; color: var(--text); font-size: 12px; outline: none;
}
.switch-row { display: flex; justify-content: space-between; align-items: center; margin-top: 8px; }
.switch-row input { width: 16px; height: 16px; accent-color: var(--accent); }
.tips { font-size: 10px; color: var(--text-dim); margin-top: 10px; line-height: 1.5; }
.modal-actions { display: flex; gap: 8px; margin-top: 14px; }
.btn-ghost, .btn-primary {
  flex: 1; padding: 10px; border-radius: 10px; font-size: 13px; cursor: pointer; border: none;
}
.btn-ghost { background: var(--bg-card); color: var(--text); border: 1px solid var(--line); }
.btn-primary { background: linear-gradient(135deg, var(--accent), #ff7ba3); color: #fff; }

.hidden { display: none !important; }

/* ═══════════════════ 桌面端适配 ═══════════════════ */
@media (min-width: 900px) {
  #app { max-width: 420px; margin: 0 auto; border-left: 1px solid var(--line); border-right: 1px solid var(--line); }
  .dragon-mount svg.dragon-svg { height: min(100%, 520px); }
}
