/* 首頁會員聊天浮窗：桌機右下面板、手機避開底欄 */
.chat-float-fab {
  position: fixed;
  z-index: 1030;
  right: 20px;
  bottom: 20px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 48px;
  padding: 0 16px 0 14px;
  border: 0;
  border-radius: 999px;
  color: #fff;
  background: linear-gradient(135deg, #0b6fc4 0%, var(--ref-primary, #003d79) 100%);
  box-shadow: 0 8px 22px rgba(0, 61, 121, 0.28);
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.04em;
  cursor: pointer;
}

.chat-float-fab i {
  font-size: 18px;
}

.chat-float-fab:focus-visible {
  outline: 2px solid var(--ref-gold, #d4a150);
  outline-offset: 3px;
}

.chat-float[hidden] {
  display: none !important;
}

.chat-float.is-open {
  display: block;
}

.chat-float__backdrop {
  display: none;
}

.chat-float__panel {
  position: fixed;
  z-index: 4200;
  right: 20px;
  bottom: 80px;
  display: flex;
  flex-direction: column;
  width: 380px;
  height: min(560px, calc(100dvh - 120px));
  overflow: hidden;
  border-radius: 16px;
  background: #fff;
  box-shadow: 0 16px 40px rgba(0, 30, 70, 0.28);
  border: 1px solid rgba(0, 61, 121, 0.12);
}

.chat-float__head {
  position: relative;
  z-index: 2;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  color: #fff;
  background: linear-gradient(135deg, #0b6fc4 0%, var(--ref-primary, #003d79) 100%);
}

.chat-float__head h2 {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
}

.chat-float__close {
  position: relative;
  z-index: 3;
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 999px;
  color: #fff;
  background: rgba(255, 255, 255, 0.14);
  cursor: pointer;
  pointer-events: auto;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.chat-float__close i {
  pointer-events: none;
}

.chat-float__welcome {
  margin: 0;
  padding: 8px 14px;
  font-size: 13px;
  color: var(--ref-primary, #003d79);
  background: rgba(0, 61, 121, 0.06);
}

.chat-float__log {
  flex: 1;
  overflow-y: auto;
  padding: 12px 14px 8px;
  background: #f6f8fb;
}

.chat-float__empty {
  margin: 24px 0 0;
  text-align: center;
  color: #7a8494;
  font-size: 14px;
}

.chat-float__msg {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  max-width: 86%;
  margin: 0 0 10px;
}

.chat-float__msg--own {
  margin-left: auto;
  flex-direction: row-reverse;
}

.chat-float__msg--follow {
  margin-top: -6px;
}

.chat-float__msg--follow .chat-float__meta {
  display: none;
}

.chat-float__msg--follow .chat-float__avatar img {
  visibility: hidden;
}

.chat-float__avatar {
  width: 36px;
  height: 36px;
  flex-shrink: 0;
  overflow: hidden;
  border-radius: 10px;
}

.chat-float__avatar img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.chat-float__body {
  min-width: 0;
  flex: 1;
}

.chat-float__meta {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 0 0 3px;
  min-width: 0;
  font-size: 12px;
  color: #6b7380;
}

.chat-float__msg--own .chat-float__meta {
  justify-content: flex-end;
}

.chat-float__vip {
  flex-shrink: 0;
  font-weight: 700;
  color: #b8862f;
  letter-spacing: 0.02em;
}

.chat-float__name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-float__bubble {
  margin: 0;
  padding: 8px 10px;
  border-radius: 12px;
  background: #fff;
  border: 1px solid rgba(0, 61, 121, 0.08);
  color: #243041;
  font-size: 14px;
  line-height: 1.45;
  word-break: break-word;
}

.chat-float__msg--own .chat-float__bubble {
  color: #fff;
  background: var(--ref-primary, #003d79);
  border-color: transparent;
}

.chat-float__time {
  display: inline-block;
  margin-left: 8px;
  font-size: 11px;
  opacity: 0.72;
}

.chat-float__status {
  min-height: 0;
  padding: 10px 14px;
  font-size: 13px;
  color: #6b4a12;
  background: #fff8e8;
}

.chat-float__status:empty {
  display: none;
}

.chat-float__status .chat-float__bar {
  height: 6px;
  margin: 8px 0 10px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(0, 61, 121, 0.1);
}

.chat-float__status .chat-float__bar > i {
  display: block;
  height: 100%;
  background: var(--ref-primary, #003d79);
}

.chat-float__status .chat-float__login {
  display: inline-flex;
  margin: 8px 0 10px;
  padding: 6px 12px;
  border: 0;
  border-radius: 999px;
  color: #fff;
  background: var(--ref-primary, #003d79);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}

.chat-float__composer {
  display: flex;
  gap: 8px;
  padding: 10px 12px 12px;
  background: #fff;
  border-top: 1px solid rgba(0, 61, 121, 0.08);
}

.chat-float__input {
  flex: 1;
  min-width: 0;
  height: 40px;
  padding: 0 12px;
  border: 1px solid rgba(0, 61, 121, 0.18);
  border-radius: 10px;
  font-size: 15px;
}

.chat-float__input:disabled {
  background: #f0f2f5;
}

.chat-float__send {
  min-width: 64px;
  height: 40px;
  border: 0;
  border-radius: 10px;
  color: #fff;
  background: var(--ref-primary, #003d79);
  font-weight: 700;
  cursor: pointer;
}

.chat-float__send:disabled {
  opacity: 0.45;
  cursor: default;
}

@media (max-width: 767px) {
  .chat-float-fab {
    right: 14px;
    bottom: calc(var(--lux-bottom-nav-offset, 80px) + env(safe-area-inset-bottom, 0px) + 12px);
  }

  body.chat-float-open .chat-float-fab {
    display: none;
  }

  .chat-float.is-open .chat-float__backdrop {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 4190;
    background: rgba(8, 20, 40, 0.42);
  }

  .chat-float__panel {
    right: 10px;
    left: 10px;
    width: auto;
    height: auto;
    bottom: calc(var(--lux-bottom-nav-offset, 80px) + env(safe-area-inset-bottom, 0px) + 10px);
    top: max(12px, env(safe-area-inset-top, 0px));
  }

  body.chat-float-open {
    overflow: hidden;
  }
}
