/* t.ggg.pet 客户聊天页 —— 共享样式
   颜色沿用工作区已定的规范：
     #07c160 品牌绿，只作**填充**（按钮底、我方气泡、在线点）
     #0a6e3d 深绿，承载文字时用它（白字 6.34:1，过 AA）
   输入框字号不小于 16px：低于 16px 时 iOS Safari 聚焦会整页放大（T-026/T-035 踩过）。 */

:root {
  --c-fill: #07c160;
  --c-fill-hover: #06ad56;
  --c-accent: #0a6e3d;
  --c-accent-hover: #086641;

  --c-text: #1d1d1f;
  --c-text-2: #5f6772;
  --c-text-3: #86868b;

  --c-bg: #f5f6f7;
  --c-surface: #ffffff;
  --c-border: #e3e6ea;
  --c-hover: #f2f3f5;
  --c-danger: #b3261e;

  --radius: 8px;
  --radius-sm: 6px;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.06), 0 8px 24px rgba(0, 0, 0, 0.06);

  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
}

body {
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.6;
  color: var(--c-text);
  background: var(--c-bg);
  -webkit-text-size-adjust: 100%;
}

/* 焦点可见：键盘用户必须看得见焦点在哪（T-026 补过这条） */
:focus-visible {
  outline: 2px solid var(--c-accent);
  outline-offset: 2px;
}

/* ─────────────────────────────── 登录页 */

.login-wrap {
  min-height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  padding-bottom: calc(24px + env(safe-area-inset-bottom, 0px));
}

.login-card {
  width: 100%;
  max-width: 360px;
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: 12px;
  box-shadow: var(--shadow);
  padding: 28px 24px 24px;
}

.login-card h1 {
  margin: 0 0 4px;
  font-size: 20px;
  font-weight: 600;
  letter-spacing: 0;
}

.login-card .sub {
  margin: 0 0 20px;
  font-size: 13px;
  color: var(--c-text-2);
}

.field {
  margin-bottom: 14px;
}

.field label {
  display: block;
  margin-bottom: 6px;
  font-size: 13px;
  font-weight: 500;
  color: var(--c-text-2);
}

.field input {
  width: 100%;
  height: 44px;
  padding: 0 12px;
  font-family: inherit;
  font-size: 16px; /* 不能小于 16px */
  color: var(--c-text);
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-sm);
}

.field input:hover {
  border-color: #cfd4da;
}

.field input:focus {
  border-color: var(--c-accent);
  outline: none;
  box-shadow: 0 0 0 3px rgba(10, 110, 61, 0.15);
}

.field input:disabled {
  background: #f7f8f9;
  color: var(--c-text-3);
}

.btn {
  width: 100%;
  height: 44px;
  margin-top: 6px;
  font-family: inherit;
  font-size: 15px;
  font-weight: 500;
  color: #fff;
  background: var(--c-accent);
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
}

.btn:hover:not(:disabled) {
  background: var(--c-accent-hover);
}

.btn:disabled {
  background: #a9b3ad;
  cursor: default;
}

.alert {
  margin: 0 0 14px;
  padding: 9px 12px;
  font-size: 13px;
  color: var(--c-danger);
  background: #fdf0ef;
  border: 1px solid #f5d4d1;
  border-radius: var(--radius-sm);
}

.alert[hidden] {
  display: none;
}

.foot {
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid var(--c-border);
  font-size: 12px;
  color: var(--c-text-3);
  text-align: center;
}

/* ─────────────────────────────── 聊天页 */

.chat-app {
  display: flex;
  flex-direction: column;
  height: 100%;
  max-width: 820px;
  margin: 0 auto;
  background: var(--c-surface);
  border-left: 1px solid var(--c-border);
  border-right: 1px solid var(--c-border);
}

.chat-head {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  padding-top: calc(10px + env(safe-area-inset-top, 0px));
  border-bottom: 1px solid var(--c-border);
  background: var(--c-surface);
}

.avatar {
  flex: 0 0 auto;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 600;
  color: #fff;
  background: var(--c-accent);
  border-radius: 50%;
}

.chat-head .who {
  min-width: 0;
  flex: 1 1 auto;
}

.chat-head .who .name {
  font-size: 15px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-head .who .state {
  font-size: 12px;
  color: var(--c-text-2);
}

.chat-head .state .dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  margin-right: 5px;
  border-radius: 50%;
  background: var(--c-text-3);
  vertical-align: 1px;
}

.chat-head .state .dot.on {
  background: var(--c-fill);
}

.chat-body {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 16px 14px;
  background: var(--c-bg);
}

.notice {
  max-width: 520px;
  margin: 8px auto;
  padding: 14px 16px;
  font-size: 13px;
  line-height: 1.7;
  color: var(--c-text-2);
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
}

.notice h2 {
  margin: 0 0 8px;
  font-size: 14px;
  font-weight: 600;
  color: var(--c-text);
}

.notice dl {
  margin: 0;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 4px 12px;
}

.notice dt {
  color: var(--c-text-3);
}

.notice dd {
  margin: 0;
  word-break: break-all;
}

.chat-foot {
  flex: 0 0 auto;
  padding: 10px 14px;
  padding-bottom: calc(10px + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid var(--c-border);
  background: var(--c-surface);
}

.composer {
  display: flex;
  align-items: flex-end;
  gap: 8px;
}

.composer textarea {
  flex: 1 1 auto;
  min-height: 44px;
  max-height: 132px;
  padding: 11px 12px;
  font-family: inherit;
  font-size: 16px; /* 不能小于 16px */
  line-height: 1.5;
  color: var(--c-text);
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: 22px;
  resize: none;
}

.composer textarea:disabled {
  background: #f7f8f9;
  color: var(--c-text-3);
}

.composer .send {
  flex: 0 0 auto;
  height: 44px;
  padding: 0 18px;
  font-family: inherit;
  font-size: 15px;
  font-weight: 500;
  color: #fff;
  background: var(--c-accent);
  border: none;
  border-radius: 22px;
  cursor: pointer;
}

.composer .send:disabled {
  background: #a9b3ad;
  cursor: default;
}

.hint {
  margin: 6px 2px 0;
  font-size: 12px;
  color: var(--c-text-3);
}

/* ─────────────────────────────── 消息气泡
   客户视角：自己发的在右（深绿 + 白字，白字 6.34:1 过 AA），客服在左（浅灰）。
   注意不能用品牌绿 #07c160 做文字底色 —— 白字对比度不够。 */

.msg-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  margin-bottom: 14px;
}

.msg-row.mine {
  flex-direction: row-reverse;
}

.msg-col {
  max-width: min(72%, 520px);
  display: flex;
  flex-direction: column;
}

.msg-row.mine .msg-col {
  align-items: flex-end;
}

.msg-sender {
  margin: 0 4px 4px;
  font-size: 12px;
  color: var(--c-text-3);
}

.bubble {
  padding: 9px 13px;
  border-radius: 14px;
  font-size: 15px;
  line-height: 1.55;
  word-break: break-word;
  white-space: pre-wrap;
}

.msg-row.theirs .bubble {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-bottom-left-radius: 4px;
}

.msg-row.mine .bubble {
  background: var(--c-accent);
  color: #fff;
  border-bottom-right-radius: 4px;
}

.bubble-text + .bubble-img,
.bubble-text + .bubble-file,
.bubble-img + .bubble-img {
  margin-top: 6px;
}

.bubble-img {
  display: block;
  max-width: 100%;
  max-height: 280px;
  border-radius: 8px;
}

.bubble-file {
  display: inline-block;
  color: inherit;
  text-decoration: underline;
  word-break: break-all;
}

.msg-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 4px 4px 0;
  font-size: 12px;
  color: var(--c-text-3);
}

.msg-state {
  color: var(--c-text-3);
}

.msg-row.failed .bubble {
  background: #fdf0ef;
  color: var(--c-danger);
  border: 1px solid #f5d4d1;
}

.retry {
  padding: 0;
  font: inherit;
  font-size: 12px;
  color: var(--c-danger);
  background: none;
  border: none;
  text-decoration: underline;
  cursor: pointer;
}

.avatar-sm {
  width: 28px;
  height: 28px;
  font-size: 12px;
  overflow: hidden;
}

.avatar-sm img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* 活动消息（仅 THREAD_ACTIVITY=all 时出现） */
.activity-row {
  display: flex;
  justify-content: center;
  margin: 10px 0;
}

.activity-pill {
  max-width: 80%;
  padding: 4px 12px;
  font-size: 12px;
  color: var(--c-text-2);
  background: #e9ebee;
  border-radius: 10px;
}

/* 正在输入 */
.typing {
  flex: 0 0 auto;
  padding: 0 16px 6px;
  font-size: 12px;
  color: var(--c-text-2);
  background: var(--c-bg);
}

.typing[hidden] {
  display: none;
}

/* 会话已结束提示条 */
.status-bar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 14px;
  font-size: 12px;
  color: var(--c-text-2);
  background: #fbf7ec;
  border-top: 1px solid #efe4c9;
}

.status-bar[hidden] {
  display: none;
}

.link-btn {
  padding: 0;
  font: inherit;
  font-size: 12px;
  color: var(--c-accent);
  background: none;
  border: none;
  text-decoration: underline;
  cursor: pointer;
  white-space: nowrap;
}

.hint-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}

.hint-row .hint {
  flex: 1 1 auto;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ─────────────────────────────── 附件 */

.attach {
  flex: 0 0 auto;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--c-text-2);
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: 50%;
  cursor: pointer;
}

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

.attach:disabled {
  color: #c3c8cd;
  cursor: default;
}

.attach-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 8px;
}

.attach-chips[hidden] {
  display: none;
}

.chip {
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: 240px;
  padding: 6px 8px;
  background: var(--c-hover);
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
}

.chip img {
  width: 32px;
  height: 32px;
  object-fit: cover;
  border-radius: 4px;
}

.chip-doc {
  width: 32px;
  text-align: center;
  font-size: 18px;
}

.chip-meta {
  min-width: 0;
  flex: 1 1 auto;
}

.chip-name {
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chip-size {
  font-size: 11px;
  color: var(--c-text-3);
}

.chip-del {
  flex: 0 0 auto;
  width: 22px;
  height: 22px;
  font-size: 16px;
  line-height: 1;
  color: var(--c-text-2);
  background: none;
  border: none;
  border-radius: 50%;
  cursor: pointer;
}

.chip-del:hover {
  color: var(--c-danger);
  background: #fdf0ef;
}

/* 拖拽高亮 */
.chat-body.dragging {
  outline: 2px dashed var(--c-accent);
  outline-offset: -8px;
}

.bubble-img {
  cursor: zoom-in;
}

@media (max-width: 560px) {
  .chat-app {
    border-left: none;
    border-right: none;
  }
}
