/* ==========================================================================
   GLOBALPOD · 招商 AI 咨询窗
   ========================================================================== */

.gp-chat {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 80;
  font-family: var(--font-sans);
  color: var(--ink);
}

.gp-chat a {
  color: inherit;
}

/* Launcher ---------------------------------------------------------------- */

.gp-chat__launcher {
  display: grid;
  grid-template-columns: auto 1fr;
  grid-template-rows: auto auto;
  align-items: center;
  gap: 2px 10px;
  padding: 11px 18px 11px 15px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-left: 3px solid var(--red);
  border-radius: 0;
  background: var(--navy);
  color: #fff;
  text-align: left;
  box-shadow: 0 10px 26px rgba(18, 32, 58, 0.26);
  clip-path: polygon(0 0, 100% 0, 100% calc(100% - 11px), calc(100% - 11px) 100%, 0 100%);
  transition: transform 0.18s var(--ease), background 0.18s var(--ease);
}

.gp-chat__launcher:hover {
  background: var(--navy-700);
  transform: translateY(-2px);
}

.gp-chat__launcher:focus-visible {
  outline: 2px solid var(--teal);
  outline-offset: 3px;
}

.gp-chat__launcher-dot {
  grid-row: 1 / span 2;
  width: 8px;
  height: 8px;
  background: var(--teal);
  box-shadow: 0 0 0 3px rgba(127, 212, 200, 0.16);
  animation: gp-chat-pulse 2.8s ease-in-out infinite;
}

.gp-chat__launcher-text {
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.02em;
  line-height: 1.25;
}

.gp-chat__launcher-sub {
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 0.22em;
  line-height: 1;
  color: var(--teal);
}

.gp-chat[data-open='true'] .gp-chat__launcher {
  display: none;
}

/* Panel ------------------------------------------------------------------- */

.gp-chat__panel {
  position: absolute;
  right: 0;
  bottom: 0;
  display: flex;
  flex-direction: column;
  width: min(392px, calc(100vw - 32px));
  height: min(640px, calc(100dvh - 48px));
  overflow: hidden;
  border: 1px solid var(--navy);
  border-radius: 2px;
  background: var(--bg);
  box-shadow: 0 24px 60px rgba(18, 32, 58, 0.24);
  animation: gp-chat-rise 0.22s var(--ease);
}

.gp-chat__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 15px 14px 13px 16px;
  border-bottom: 2px solid var(--teal);
  background-color: var(--navy);
  background-image: linear-gradient(rgba(255, 255, 255, 0.045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.045) 1px, transparent 1px);
  background-size: 16px 16px;
  color: #fff;
}

.gp-chat__head-text {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}

.gp-chat__eyebrow {
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 0.2em;
  line-height: 1.4;
  color: var(--teal);
}

.gp-chat__head strong {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.02em;
  line-height: 1.3;
}

.gp-chat__head-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.gp-chat__scope {
  padding: 3px 8px;
  border: 1px solid rgba(127, 212, 200, 0.5);
  border-radius: 2px;
  background: transparent;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.06em;
  line-height: 1.5;
  color: var(--teal);
  white-space: nowrap;
  cursor: default;
}

.gp-chat__scope.is-room {
  border-color: var(--red);
  background: var(--red);
  color: #fff;
  cursor: pointer;
}

.gp-chat__scope.is-room:hover {
  background: #b02a24;
  border-color: #b02a24;
}

.gp-chat__scope:focus-visible {
  outline: 2px solid var(--teal);
  outline-offset: 2px;
}

.gp-chat__close {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 2px;
  background: transparent;
  color: #fff;
  font-size: 17px;
  line-height: 1;
  transition: border-color 0.15s var(--ease), background 0.15s var(--ease);
}

.gp-chat__close:hover {
  border-color: var(--teal);
  background: rgba(127, 212, 200, 0.12);
}

.gp-chat__close:focus-visible {
  outline: 2px solid var(--teal);
  outline-offset: 2px;
}

/* Phone gate -------------------------------------------------------------- */

.gp-chat__gate {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 12px;
  min-height: 0;
  overflow-y: auto;
  padding: 18px 18px 16px;
}

.gp-chat__intro {
  padding-bottom: 10px;
  border-bottom: 1px dashed var(--line);
  font-size: 12.5px;
  line-height: 1.7;
  color: var(--muted);
}

.gp-chat__field {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.gp-chat__field > span {
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.08em;
  line-height: 1.4;
  color: var(--muted);
}

.gp-chat__field em {
  font-style: normal;
  color: var(--red);
}

.gp-chat__field input {
  width: 100%;
  height: 42px;
  padding: 0 12px;
  border: 1px solid var(--silver);
  border-radius: 2px;
  background: #fff;
  color: var(--ink);
  font-size: 14px;
  outline: none;
  transition: border-color 0.15s var(--ease), box-shadow 0.15s var(--ease);
}

.gp-chat__field input::placeholder {
  color: var(--gray);
}

.gp-chat__field input:focus {
  border-color: var(--navy);
  box-shadow: inset 0 -2px 0 var(--teal);
}

.gp-chat__honeypot {
  position: absolute;
  left: -9999px;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

.gp-chat__consent {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 11.5px;
  line-height: 1.65;
  color: var(--muted);
}

.gp-chat__consent input {
  flex-shrink: 0;
  width: 14px;
  height: 14px;
  margin: 3px 0 0;
  accent-color: var(--navy);
}

.gp-chat__consent a {
  color: var(--navy);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.gp-chat__error,
.gp-chat__inline-error {
  padding: 8px 10px;
  border-left: 2px solid var(--red);
  background: var(--red-soft);
  font-size: 12px;
  line-height: 1.55;
  color: var(--red);
}

.gp-chat__submit {
  height: 44px;
  margin-top: 2px;
  border: 1px solid var(--navy);
  border-radius: 2px;
  background: var(--navy);
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.08em;
  transition: background 0.15s var(--ease), border-color 0.15s var(--ease);
}

.gp-chat__submit:hover:not(:disabled) {
  border-color: var(--navy-700);
  background: var(--navy-700);
}

.gp-chat__submit:disabled {
  opacity: 0.55;
  cursor: default;
}

.gp-chat__submit:focus-visible {
  outline: 2px solid var(--teal);
  outline-offset: 2px;
}

/* Conversation ------------------------------------------------------------ */

.gp-chat__conversation {
  display: flex;
  flex: 1;
  flex-direction: column;
  min-height: 0;
}

.gp-chat__log {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 12px;
  min-height: 0;
  overflow-y: auto;
  padding: 16px 16px 10px;
  scrollbar-width: thin;
  scrollbar-color: var(--silver) transparent;
}

.gp-chat__msg {
  display: flex;
  align-items: flex-start;
  gap: 8px;
}

.gp-chat__msg--user {
  flex-direction: row-reverse;
}

.gp-chat__avatar {
  display: grid;
  flex: 0 0 26px;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 2px;
  background: var(--navy);
  color: var(--teal);
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 0.04em;
}

.gp-chat__msg--user .gp-chat__avatar {
  background: var(--sand);
  color: var(--navy);
}

/* 人工回复：头像换成品牌红，跟 AI 一眼分得开 */
.gp-chat__msg--human .gp-chat__avatar {
  background: var(--red);
  color: #fff;
}

/* 转人工状态条：一行字，说明现在是人工在接待 */
.gp-chat__status {
  margin: 0 0 8px;
  padding: 7px 10px;
  border-left: 2px solid var(--red);
  background: var(--red-soft);
  color: var(--red);
  font-size: 12px;
  font-weight: 600;
  line-height: 1.6;
}

/* 「客服」标签 —— 访客得知道现在回他的是人 */
.gp-chat__tag {
  display: inline-block;
  margin-bottom: 4px;
  padding: 1px 6px;
  border-radius: var(--radius-sm);
  background: var(--red);
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  line-height: 1.6;
}

.gp-chat__bubble {
  max-width: 82%;
  padding: 9px 12px;
  border-left: 2px solid var(--teal);
  border-radius: 2px;
  background: var(--bg-alt);
  font-size: 13px;
  line-height: 1.7;
}

/* 人工回复：左边一道红色竖线，跟 AI 分开 */
.gp-chat__msg--human .gp-chat__bubble {
  border-left: 3px solid var(--red);
  background: var(--bg);
}

.gp-chat__bubble p {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.gp-chat__msg--user .gp-chat__bubble {
  border-right: 2px solid var(--teal);
  border-left: 0;
  background: var(--navy);
  color: #fff;
}

.gp-chat__meta {
  display: block;
  margin-top: 6px;
  font-family: var(--font-mono);
  font-size: 9.5px;
  letter-spacing: 0.03em;
  line-height: 1.5;
  color: var(--gray);
}

.gp-chat__note-line {
  align-self: stretch;
  padding: 7px 10px;
  border-left: 2px solid var(--orange);
  background: var(--orange-soft);
  font-size: 11.5px;
  line-height: 1.65;
  color: var(--muted);
}

.gp-chat__typing .gp-chat__dots {
  display: flex;
  align-items: center;
  gap: 4px;
  min-height: 36px;
  padding: 0 14px;
}

.gp-chat__dots span {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--gray);
  animation: gp-chat-blink 1.1s ease-in-out infinite;
}

.gp-chat__dots span:nth-child(2) {
  animation-delay: 0.15s;
}

.gp-chat__dots span:nth-child(3) {
  animation-delay: 0.3s;
}

/* Quick prompts & composer ------------------------------------------------ */

.gp-chat__quick {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 0 16px 10px;
}

.gp-chat__chip {
  padding: 5px 9px;
  border: 1px solid var(--line);
  border-radius: 2px;
  background: #fff;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.4;
  transition: border-color 0.15s var(--ease), color 0.15s var(--ease);
}

.gp-chat__chip:hover:not(:disabled) {
  border-color: var(--navy);
  color: var(--navy);
}

.gp-chat__chip:disabled {
  opacity: 0.45;
  cursor: default;
}

.gp-chat__chip:focus-visible {
  outline: 2px solid var(--teal);
  outline-offset: 2px;
}

.gp-chat__inline-error {
  margin: 0 16px 8px;
}

.gp-chat__composer {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 10px 16px 12px;
  border-top: 1px solid var(--line);
  background: #fff;
}

.gp-chat__composer textarea {
  flex: 1;
  min-height: 40px;
  max-height: 96px;
  padding: 9px 12px;
  border: 1px solid var(--silver);
  border-radius: 2px;
  background: #fff;
  color: var(--ink);
  font-size: 13px;
  line-height: 1.55;
  outline: none;
  resize: none;
  transition: border-color 0.15s var(--ease), box-shadow 0.15s var(--ease);
}

.gp-chat__composer textarea::placeholder {
  color: var(--gray);
}

.gp-chat__composer textarea:focus {
  border-color: var(--navy);
  box-shadow: inset 0 -2px 0 var(--teal);
}

.gp-chat__composer button {
  flex: 0 0 auto;
  height: 40px;
  padding: 0 16px;
  border: 1px solid var(--navy);
  border-radius: 2px;
  background: var(--navy);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.06em;
  transition: background 0.15s var(--ease);
}

.gp-chat__composer button:hover:not(:disabled) {
  background: var(--navy-700);
}

.gp-chat__composer button:disabled,
.gp-chat__composer textarea:disabled {
  opacity: 0.45;
  cursor: default;
}

/* Footer ------------------------------------------------------------------ */

.gp-chat__foot {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 7px 16px;
  border-top: 1px solid var(--line);
  background: var(--soft);
  font-family: var(--font-mono);
  font-size: 9.5px;
  letter-spacing: 0.02em;
  line-height: 1.6;
  color: var(--gray);
}

.gp-chat__foot a {
  flex-shrink: 0;
  color: var(--red);
}

.gp-chat__foot a:hover {
  text-decoration: underline;
  text-underline-offset: 2px;
}

/* Motion & responsive ----------------------------------------------------- */

@keyframes gp-chat-rise {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes gp-chat-pulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.45;
  }
}

@keyframes gp-chat-blink {
  0%,
  80%,
  100% {
    opacity: 0.25;
  }
  40% {
    opacity: 1;
  }
}

@media (max-width: 640px) {
  .gp-chat {
    right: 12px;
    bottom: 12px;
    left: 12px;
    pointer-events: none;
  }

  .gp-chat__launcher {
    width: max-content;
    margin-left: auto;
    pointer-events: auto;
  }

  .gp-chat__panel {
    position: fixed;
    inset: 10px;
    width: auto;
    height: auto;
    max-height: none;
    pointer-events: auto;
  }
}

@media (prefers-reduced-motion: reduce) {
  .gp-chat__launcher,
  .gp-chat__launcher-dot,
  .gp-chat__panel,
  .gp-chat__dots span {
    animation: none;
    transition: none;
  }
}

@media print {
  .gp-chat {
    display: none;
  }
}

/* 转人工：访客点一下，该房间配置的顾问就在微信上接手 */
.gp-chat__handoff {
  height: 26px;
  padding: 0 12px;
  border: 1px solid var(--gp-red, #c8322b);
  border-radius: 4px;
  background: transparent;
  color: var(--gp-red, #c8322b);
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}

.gp-chat__handoff:hover:not(:disabled) {
  background: var(--gp-red, #c8322b);
  color: #fff;
}

.gp-chat__handoff:disabled {
  border-color: var(--gp-line, #e3e7eb);
  color: var(--gp-gray, #8a9099);
  cursor: default;
}
