/* Aurenqo 客服浮窗 V1.1（storefront 全站常驻，移动端优先）。

   设计边界（本轮）：
   * 气泡**固定右下角**，不可拖动（拖动与位置记忆已删除）；
     位置基于 mobile shell 的底部导航高度 + safe-area，页面滚动时视口位置不变。
   * 面板是严格的三段式 flex 布局：HEADER / MESSAGES / COMPOSER；
     MESSAGES 负责收缩，COMPOSER 永远留在面板内。
   * 键盘/standalone 的几何计算全部由 support-chat.js 的 layoutSupportPanel() 决定
     （inline top+height，只在键盘可见时生效），这里只提供无键盘状态的默认外观。

   注意：这里不写 position:absolute/fixed/transform 到 composer 上——composer 必须
   始终参与面板的正常布局。 */

.aurenqo-support {
  position: fixed;                 /* 视口固定：页面滚动时位置不变 */
  z-index: 1150;                   /* 在底部导航之上、页面浮层之下 */
  inset-inline-end: 14px;
  /* 始终位于底部导航上方（--shell-tabbar-h 由 mobile-shell-v2.css 提供；桌面为 0） */
  inset-block-end: calc(var(--shell-tabbar-h, 0px) + var(--shell-safe-bottom, 0px) + 14px);
  display: flex; flex-direction: column; align-items: flex-end;
}
.aurenqo-support[hidden] { display: none; }
/* Checkout 没有底部导航，但底部有 sticky 主操作：留出更高的安全间距。 */
body[data-page="checkout"] .aurenqo-support {
  inset-block-end: calc(var(--shell-safe-bottom, 0px) + 84px);
}
@media (min-width: 900px) {
  .aurenqo-support { inset-inline-end: 20px; inset-block-end: 20px; }
  body[data-page="checkout"] .aurenqo-support { inset-block-end: 20px; }
}

.aurenqo-support-button {
  position: relative; width: 52px; height: 52px; padding: 0; border: 0; border-radius: 16px;
  background: linear-gradient(135deg, #2563eb, #7c3aed); color: #fff; cursor: pointer;
  box-shadow: 0 10px 24px rgba(37, 99, 235, .32);
  display: grid; place-items: center; font-size: 22px; line-height: 1;
  -webkit-tap-highlight-color: transparent;
}
.aurenqo-support-button:focus-visible { outline: 3px solid #a5b4fc; outline-offset: 2px; }
.aurenqo-support-badge {
  position: absolute; inset-block-start: -6px; inset-inline-end: -6px;
  min-width: 20px; padding: 0 5px; border-radius: 99px; background: #dc2626; color: #fff;
  font-size: 11.5px; font-weight: 800; line-height: 18px; text-align: center;
}
.aurenqo-support-badge[hidden] { display: none; }

.aurenqo-support-panel {
  width: min(92vw, 420px);
  height: min(62vh, 560px);
  max-height: 100%;
  margin-block-end: 10px;
  display: flex; flex-direction: column;   /* HEADER / MESSAGES / COMPOSER */
  min-height: 0; overflow: hidden;
  background: #fff; border: 1px solid #e2e8f0; border-radius: 16px;
  box-shadow: 0 24px 60px rgba(15, 23, 42, .28);
}
.aurenqo-support-panel[hidden] { display: none; }
/* 键盘打开：JS 给出明确坐标系（top + height），不再叠加 bottom。 */
.aurenqo-support.is-keyboard .aurenqo-support-panel {
  position: fixed; inset-inline-end: 12px; inset-block-end: auto;
  width: min(94vw, 420px);
}

.aurenqo-support-head {
  flex: 0 0 auto;
  display: flex; align-items: center; gap: 8px; padding: 10px 12px;
  background: linear-gradient(135deg, #2563eb, #7c3aed); color: #fff;
}
.aurenqo-support-head strong { font-size: 15px; }
.aurenqo-support-head span { font-size: 12px; opacity: .9; }
.aurenqo-support-head .aurenqo-support-close {
  margin-inline-start: auto; width: 36px; height: 36px; flex: 0 0 auto;
  border: 0; border-radius: 10px; background: rgba(255, 255, 255, .16); color: #fff;
  font-size: 18px; cursor: pointer;
}

.aurenqo-support-log {
  flex: 1 1 auto; min-height: 0; overflow-y: auto; overflow-x: hidden;
  padding: 12px; background: #f8fafc;
}
.aurenqo-support-messages { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.aurenqo-support-row { display: flex; }
.aurenqo-support-row.is-customer { justify-content: flex-end; }
/* 气泡容器：宽度来自内容，最多占一行的 82%；短消息绝不因为 flex 收缩被压成一字宽。 */
.aurenqo-support-row > div { max-width: 82%; min-width: 0; display: flex; flex-direction: column; align-items: flex-start; }
.aurenqo-support-row.is-customer > div { align-items: flex-end; }
.aurenqo-support-bubble {
  width: fit-content;               /* 短消息保持一行 */
  inline-size: fit-content;
  min-inline-size: min(4em, 100%);  /* 一字宽的兜底保护（中文短句） */
  max-inline-size: 100%;
  padding: 8px 11px; border-radius: 12px; font-size: 14px; line-height: 1.5;
  writing-mode: horizontal-tb; text-orientation: mixed;
  white-space: pre-wrap; word-break: normal; overflow-wrap: break-word;
}
.aurenqo-support-row.is-staff .aurenqo-support-bubble { background: #fff; border: 1px solid #e2e8f0; color: #0f172a; }
.aurenqo-support-row.is-customer .aurenqo-support-bubble { background: #2563eb; color: #fff; }
.aurenqo-support-meta { margin-top: 3px; font-size: 11px; color: #94a3b8; }
.aurenqo-support-row.is-customer .aurenqo-support-meta { text-align: end; }
.aurenqo-support-empty { margin: 0; padding: 18px 6px; color: #64748b; font-size: 13px; text-align: center; }
.aurenqo-support-empty[hidden] { display: none; }

/* COMPOSER：永远留在面板内（正常文档流，无 absolute/fixed/transform）。 */
.aurenqo-support-compose {
  flex: 0 0 auto;
  display: grid; grid-template-columns: 40px minmax(0, 1fr) auto; gap: 6px; align-items: end;
  padding: 10px; border-top: 1px solid #e2e8f0; background: #fff;
  padding-block-end: calc(10px + env(safe-area-inset-bottom, 0px) / 3);
}
.aurenqo-support-compose textarea {
  min-width: 0; min-height: 44px; max-height: 120px; resize: none; padding: 10px 12px;
  border: 1px solid #cbd5e1; border-radius: 12px; font: inherit; font-size: 16px;
}
.aurenqo-support-compose button {
  flex-shrink: 0; white-space: nowrap;
  min-height: 44px; min-width: 64px; padding: 0 14px; border: 0; border-radius: 12px;
  background: #2563eb; color: #fff; font-weight: 700; cursor: pointer;
}
.aurenqo-support-compose button[disabled] { opacity: .6; cursor: not-allowed; }
.aurenqo-support-status { flex: 0 0 auto; padding: 0 12px 8px; color: #b91c1c; font-size: 12px; }
.aurenqo-support-status[hidden] { display: none; }
.aurenqo-support-log { overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }

@media (max-width: 360px) {
  .aurenqo-support { inset-inline-end: 10px; }
}
