/* ============================================================
   美高梅 · 客户端在线客服浮层
   深色卡片 + 金色顶栏；首页与游戏大厅共用
   ============================================================ */

.mgmchat {
  /* 与契约第 8 节一致的取色：优先用页面已定义的变量，缺省回落到契约色值 */
  --mgm-bg: var(--ink-1, var(--panel-2, #0b0f16));
  --mgm-bg-2: var(--ink-2, #0d1219);
  --mgm-bubble: var(--ink-4, var(--panel-3, #172030));
  --mgm-line: var(--line, rgba(255, 255, 255, 0.07));
  --mgm-line-2: var(--line-2, var(--line-strong, rgba(255, 255, 255, 0.12)));
  --mgm-text: var(--text, #e9eef6);
  --mgm-text-2: var(--text-2, var(--muted, #8a97a8));
  --mgm-text-3: var(--text-3, var(--muted-2, #5d6a7c));
  --mgm-gold: var(--gold, #f2c14e);
  --mgm-gold-deep: var(--gold-deep, var(--gold-2, #d9a227));
  --mgm-red: var(--red, #ef4b5b);
  --mgm-green: var(--green, #2fbf7a);
  --mgm-r-md: 12px;
  --mgm-r-lg: var(--r-lg, 16px);

  /* 位置：桌面右下角，移动端抬到底部导航上方 */
  --fab-bottom: 24px;
  --fab-right: 24px;
  --panel-bottom: 92px;
  --panel-right: 24px;
  --panel-h: 520px;
  --panel-w: 360px;
}

/* 游戏大厅底部有投注单，浮层整体上移 */
body.has-slipbar .mgmchat {
  --fab-bottom: 96px;
  --panel-bottom: 96px;
}

/* ---------------------------------------------------------- 悬浮按钮 */

.mgmchat-fab {
  position: fixed;
  right: var(--fab-right);
  bottom: var(--fab-bottom);
  z-index: 60;
  width: 56px;
  height: 56px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  border: 1.5px solid rgba(242, 193, 78, 0.55);
  background: radial-gradient(circle at 50% 26%, #1b2432 0%, #0b0f16 72%);
  color: var(--mgm-gold);
  box-shadow: 0 18px 36px -18px rgba(0, 0, 0, 0.95), 0 0 0 6px rgba(242, 193, 78, 0.05);
  transition: transform 0.16s ease, border-color 0.16s ease, box-shadow 0.16s ease, opacity 0.16s ease;
}

.mgmchat-fab:hover {
  transform: translateY(-2px);
  border-color: var(--mgm-gold);
  box-shadow: 0 22px 40px -18px rgba(0, 0, 0, 0.95), 0 0 0 7px rgba(242, 193, 78, 0.09);
}

.mgmchat-fab svg {
  width: 24px;
  height: 24px;
  stroke: currentColor;
  stroke-width: 1.6;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.mgmchat-dot {
  position: absolute;
  top: 5px;
  right: 5px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--mgm-red);
  border: 2px solid #0b0f16;
}

.mgmchat-dot[hidden] { display: none; }

/* ---------------------------------------------------------- 面板 */

.mgmchat-panel {
  position: fixed;
  right: var(--panel-right);
  bottom: var(--panel-bottom);
  z-index: 70;
  width: var(--panel-w);
  height: var(--panel-h);
  max-height: calc(100vh - 140px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--mgm-line-2);
  border-radius: var(--mgm-r-lg);
  background: var(--mgm-bg);
  box-shadow: 0 44px 88px -44px rgba(0, 0, 0, 0.96);
  transform: translateY(10px) scale(0.985);
  opacity: 0;
  pointer-events: none;
  transition: transform 0.2s cubic-bezier(0.32, 0.72, 0.3, 1), opacity 0.16s ease;
}

.mgmchat-panel[hidden] { display: none; }

.mgmchat.on .mgmchat-panel {
  transform: none;
  opacity: 1;
  pointer-events: auto;
}

/* 金色顶栏 */

.mgmchat-head {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  height: 48px;
  padding: 0 10px 0 14px;
  background: linear-gradient(145deg, #ffdf8e 0%, var(--mgm-gold) 55%, var(--mgm-gold-deep) 100%);
  color: #17120a;
}

.mgmchat-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13.5px;
  font-weight: 700;
  letter-spacing: 0.3px;
}

.mgmchat-live {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #1c8a58;
  box-shadow: 0 0 0 3px rgba(23, 18, 10, 0.12);
  flex-shrink: 0;
}

.mgmchat-live.off { background: #8d7a4e; }

.mgmchat-x {
  width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
  border-radius: 7px;
  font-size: 17px;
  line-height: 1;
  color: rgba(23, 18, 10, 0.68);
  transition: background-color 0.15s, color 0.15s;
}

.mgmchat-x:hover { background: rgba(23, 18, 10, 0.1); color: #17120a; }

/* 提示音开关 */

.mgmchat-sound {
  width: 26px;
  height: 26px;
  margin-left: auto;
  display: grid;
  place-items: center;
  border-radius: 7px;
  color: rgba(23, 18, 10, 0.72);
  transition: background-color 0.15s, color 0.15s;
}

.mgmchat-sound svg {
  width: 15px;
  height: 15px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.mgmchat-sound:hover { background: rgba(23, 18, 10, 0.1); }

.mgmchat-sound.off {
  color: rgba(23, 18, 10, 0.34);
  text-decoration: line-through;
}

/* 已读回执 */

.mgmchat-read {
  font-size: 10px;
  color: var(--mgm-text-2);
  opacity: 0.75;
}

.mgmchat-read.on { color: #1c8a58; opacity: 1; }

/* 访客提示 */

.mgmchat-guest {
  flex-shrink: 0;
  margin: 0;
  padding: 7px 14px;
  font-size: 11.5px;
  line-height: 1.5;
  color: var(--mgm-text-2);
  background: rgba(242, 193, 78, 0.06);
  border-bottom: 1px solid var(--mgm-line);
}

.mgmchat-guest[hidden] { display: none; }

/* 消息流 */

.mgmchat-body {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px;
  overflow-y: auto;
  overscroll-behavior: contain;
  background: var(--mgm-bg);
}

.mgmchat-empty {
  margin: auto;
  max-width: 230px;
  text-align: center;
  font-size: 12px;
  line-height: 1.7;
  color: var(--mgm-text-3);
}

.mgmchat-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-width: 84%;
}

.mgmchat-row.agent { align-self: flex-start; align-items: flex-start; }
.mgmchat-row.user { align-self: flex-end; align-items: flex-end; }
.mgmchat-row.sys { align-self: center; align-items: center; max-width: 92%; }

.mgmchat-by {
  padding-left: 2px;
  font-size: 10.5px;
  color: var(--mgm-text-3);
}

.mgmchat-bubble {
  padding: 9px 12px;
  border-radius: 12px;
  font-size: 13px;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
}

.mgmchat-row.user .mgmchat-bubble {
  background: linear-gradient(145deg, #ffdf8e 0%, var(--mgm-gold) 60%, #dda92b 100%);
  color: #17120a;
  font-weight: 500;
  border-bottom-right-radius: 4px;
}

.mgmchat-row.agent .mgmchat-bubble {
  background: var(--mgm-bubble);
  border: 1px solid var(--mgm-line);
  color: var(--mgm-text);
  border-bottom-left-radius: 4px;
}

.mgmchat-row.sys .mgmchat-bubble {
  padding: 2px 0;
  background: none;
  border: 0;
  font-size: 11px;
  line-height: 1.6;
  color: var(--mgm-text-3);
  text-align: center;
}

.mgmchat-row.sys .mgmchat-bubble.is-err { color: var(--mgm-red); }

.mgmchat-time {
  padding: 0 2px;
  font-size: 10px;
  color: var(--mgm-text-3);
  font-variant-numeric: tabular-nums;
}

/* 断线提示 */

.mgmchat-tip {
  flex-shrink: 0;
  margin: 0;
  padding: 6px 14px;
  font-size: 11px;
  line-height: 1.5;
  color: #ffb1b9;
  background: rgba(239, 75, 91, 0.1);
  border-top: 1px solid rgba(239, 75, 91, 0.22);
}

.mgmchat-tip[hidden] { display: none; }

/* 输入区 */

.mgmchat-foot {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px;
  border-top: 1px solid var(--mgm-line);
  background: var(--mgm-bg-2);
}

.mgmchat-input {
  flex: 1;
  min-width: 0;
  height: 38px;
  padding: 0 12px;
  border-radius: 10px;
  border: 1px solid var(--mgm-line-2);
  background: #080b10;
  color: var(--mgm-text);
  font-size: 13px;
  outline: none;
  transition: border-color 0.15s;
}

.mgmchat-input:focus { border-color: rgba(242, 193, 78, 0.6); }
.mgmchat-input::placeholder { color: var(--mgm-text-3); }

.mgmchat-send {
  flex-shrink: 0;
  height: 38px;
  padding: 0 16px;
  border-radius: 10px;
  background: linear-gradient(145deg, #ffdf8e 0%, var(--mgm-gold) 55%, var(--mgm-gold-deep) 100%);
  color: #17120a;
  font-size: 13px;
  font-weight: 600;
}

.mgmchat-send:disabled { opacity: 0.5; cursor: not-allowed; }

/* ---------------------------------------------------------- 图片 */

/* 输入区左侧的图片按钮 */

.mgmchat-img {
  flex-shrink: 0;
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  border: 1px solid var(--mgm-line-2);
  background: #080b10;
  color: var(--mgm-text-2);
  transition: color 0.15s, border-color 0.15s;
}

.mgmchat-img svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.mgmchat-img:hover { color: var(--mgm-gold); border-color: rgba(242, 193, 78, 0.5); }

/* 待发送预览条 */

.mgmchat-preview {
  flex-shrink: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 8px 10px;
  border-top: 1px solid var(--mgm-line);
  background: var(--mgm-bg-2);
}

.mgmchat-preview[hidden] { display: none; }

.mgmchat-up {
  position: relative;
  width: 48px;
  height: 48px;
  border-radius: 8px;
  border: 1px solid var(--mgm-line-2);
  background: #080b10;
  overflow: hidden;
}

.mgmchat-up img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.mgmchat-up.is-up { border-color: rgba(242, 193, 78, 0.55); opacity: 0.65; }
.mgmchat-up.is-err { border-color: rgba(239, 75, 91, 0.7); }

.mgmchat-up-x {
  position: absolute;
  top: 1px;
  right: 1px;
  width: 15px;
  height: 15px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: rgba(8, 11, 16, 0.8);
  color: #e9eef6;
  font-size: 11px;
  line-height: 1;
}

.mgmchat-up-x:hover { background: var(--mgm-red); }

/* 图片气泡：去掉气泡内边距，缩略图自己带圆角 */

.mgmchat-bubble.is-img {
  padding: 0;
  background: none;
  border: 0;
  line-height: 0;
}

.mgmchat-row.user .mgmchat-bubble.is-img,
.mgmchat-row.agent .mgmchat-bubble.is-img {
  background: none;
  border: 0;
}

.mgmchat-photo {
  display: block;
  max-width: 160px;
  max-height: 200px;
  border-radius: 10px;
  border: 1px solid var(--mgm-line-2);
  background: var(--mgm-bubble);
  cursor: zoom-in;
  transition: opacity 0.15s;
}

.mgmchat-photo:hover { opacity: 0.9; }

.mgmchat-cap {
  margin-top: 5px;
  padding: 0 2px;
  font-size: 12px;
  line-height: 1.5;
  color: var(--mgm-text-2);
  white-space: pre-wrap;
  word-break: break-word;
}

.mgmchat-row.user .mgmchat-cap { color: #5b4a1e; }

/* 上传中的占位气泡 */

.mgmchat-bubble.is-pending {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: var(--mgm-bubble);
  color: var(--mgm-text-2);
  border: 1px solid var(--mgm-line);
  font-weight: 400;
}

.mgmchat-spin {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 2px solid rgba(242, 193, 78, 0.25);
  border-top-color: var(--mgm-gold);
  animation: mgmSpin 0.7s linear infinite;
}

@keyframes mgmSpin {
  to { transform: rotate(360deg); }
}

/* 拖拽落点 */

.mgmchat-panel.drag-over {
  outline: 1.5px dashed rgba(242, 193, 78, 0.6);
  outline-offset: -6px;
}

/* 灯箱 */

.mgmchat-lightbox {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: grid;
  place-items: center;
  padding: 32px;
  background: rgba(4, 6, 10, 0.92);
  cursor: zoom-out;
  animation: mgmLbIn 0.14s ease-out;
}

.mgmchat-lightbox[hidden] { display: none; }

.mgmchat-lightbox img {
  max-width: 100%;
  max-height: 100%;
  border-radius: var(--mgm-r-md);
  box-shadow: 0 40px 90px -40px #000;
  cursor: default;
}

.mgmchat-lb-x {
  position: absolute;
  top: 14px;
  right: 16px;
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  border: 1px solid var(--mgm-line-2);
  background: rgba(11, 15, 22, 0.85);
  color: var(--mgm-text);
  font-size: 19px;
  line-height: 1;
}

.mgmchat-lb-x:hover { border-color: var(--mgm-gold); color: var(--mgm-gold); }

@keyframes mgmLbIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* ---------------------------------------------------------- 移动端 */

@media (max-width: 760px) {
  .mgmchat {
    --fab-bottom: 76px;
    --fab-right: 16px;
    --panel-bottom: 76px;
    --panel-right: 12px;
    --panel-w: auto;
    --panel-h: calc(100vh - 140px);
  }

  body.has-slipbar .mgmchat {
    --fab-bottom: 104px;
    --panel-bottom: 104px;
    --panel-h: calc(100vh - 168px);
  }

  .mgmchat-panel {
    left: var(--panel-right);
    right: var(--panel-right);
    width: auto;
    max-height: calc(100vh - 120px);
    border-radius: var(--mgm-r-lg);
  }

  .mgmchat-row { max-width: 88%; }

  /* 面板展开时收起悬浮按钮，避免与输入区抢位置 */
  .mgmchat.on .mgmchat-fab {
    opacity: 0;
    transform: scale(0.9);
    pointer-events: none;
  }
}
