/* =========================================================
   JBK INTERNATIONAL — CHATBOT.CSS
   Quiet-luxury floating customer service widget
   ========================================================= */

.chatbot {
  position: fixed;
  z-index: 1000;
  right: 22px;
  bottom: 22px;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang TC', 'Microsoft JhengHei', 'Noto Sans TC', sans-serif;
}

/* ---------- Toggle button (mascot + label pill) ---------- */
.chatbot__toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 56px;
  padding: 0 18px 0 4px;
  border: 1px solid rgba(184,153,104,0.25);
  border-radius: 999px;
  background: #1e1b19;
  color: #fff;
  cursor: pointer;
  box-shadow:
    0 8px 28px rgba(0,0,0,0.28),
    0 0 0 0 rgba(184,153,104,0);
  transition:
    background 0.35s cubic-bezier(.16,1,.3,1),
    border-color 0.35s cubic-bezier(.16,1,.3,1),
    box-shadow 0.35s cubic-bezier(.16,1,.3,1),
    transform 0.4s cubic-bezier(.34,1.56,.64,1),
    gap 0.35s cubic-bezier(.16,1,.3,1),
    padding 0.35s cubic-bezier(.16,1,.3,1);
}
.chatbot__toggle:hover {
  background: #2a2520;
  border-color: rgba(184,153,104,0.5);
  box-shadow:
    0 14px 36px rgba(0,0,0,0.32),
    0 0 0 3px rgba(184,153,104,0.12);
  transform: translateY(-2px);
}
.chatbot__toggle:active {
  transform: translateY(0) scale(0.97);
}

/* ---- Icon medallion: 墨黑圓底 + 香檳金細環 + 金色線條對話 icon ---- */
.chatbot__toggle-mascot {
  position: relative;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: radial-gradient(circle at 32% 26%, #2b2621 0%, #171310 78%);
  border: 1px solid rgba(199,174,126,0.55);
  box-shadow: inset 0 0 0 3px rgba(199,174,126,0.10),
              inset 0 1px 2px rgba(255,255,255,0.06);
  color: #d9c096;          /* 香檳金 icon 描邊色 */
}
/* 對話 icon */
.chatbot__toggle-ico {
  width: 24px;
  height: 24px;
  transition: transform 0.5s cubic-bezier(.34,1.56,.64,1);
}
.chatbot__toggle:hover .chatbot__toggle-mascot { border-color: rgba(199,174,126,0.85); color: #e7d3a6; }
.chatbot__toggle:hover .chatbot__toggle-ico { transform: scale(1.08) rotate(-4deg); }

/* ✦ sparkle floating above robot's head */
.chatbot__toggle-sparkle {
  position: absolute;
  top: -6px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 14px;
  color: #e5c38c;
  line-height: 1;
  pointer-events: none;
  animation: cbSparkle 2.8s ease-in-out infinite;
  filter: drop-shadow(0 0 4px rgba(229,195,140,0.5));
}
@keyframes cbSparkle {
  0%, 100% { opacity: 1; transform: translateX(-50%) translateY(0) scale(1); }
  50%      { opacity: 0.6; transform: translateX(-50%) translateY(-4px) scale(1.2); }
}

/* Pulsing green online dot */
.chatbot__toggle-dot {
  position: relative;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #1AA86A;
  flex-shrink: 0;
}
.chatbot__toggle-dot::after {
  content: '';
  position: absolute;
  inset: -3px;
  border-radius: 50%;
  background: rgba(26,168,106,0.35);
  animation: cbDotPulse 2.4s ease-in-out infinite;
}
@keyframes cbDotPulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%      { opacity: 0; transform: scale(1.8); }
}

/* Label text */
.chatbot__toggle-label {
  font-size: 14px;
  font-weight: 500;
  letter-spacing: 0.12em;
  color: rgba(255,255,255,0.92);
  white-space: nowrap;
  line-height: 1;
  transition: color 0.3s ease;
}
.chatbot__toggle:hover .chatbot__toggle-label {
  color: #e5c38c;
}

/* ---- When panel is open → collapse to mascot circle ---- */
.chatbot__toggle[aria-expanded="true"] {
  width: 54px;
  height: 54px;
  padding: 0;
  gap: 0;
  border-radius: 50%;
  justify-content: center;
  overflow: hidden;
}
.chatbot__toggle[aria-expanded="true"] .chatbot__toggle-mascot {
  width: 50px;
  height: 50px;
}
.chatbot__toggle[aria-expanded="true"] .chatbot__toggle-img {
  width: 50px;
  height: 50px;
}
.chatbot__toggle[aria-expanded="true"] .chatbot__toggle-label,
.chatbot__toggle[aria-expanded="true"] .chatbot__toggle-dot {
  width: 0;
  opacity: 0;
  overflow: hidden;
  pointer-events: none;
  transition: opacity 0.2s ease, width 0.3s ease;
}
.chatbot__toggle[aria-expanded="true"] .chatbot__toggle-sparkle {
  top: -2px;
  font-size: 11px;
  animation-duration: 2s;
}

/* ---------- Chat panel ---------- */
.chatbot__panel {
  width: min(370px, calc(100vw - 32px));
  height: min(530px, calc(100vh - 110px));
  margin-bottom: 12px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  background: #fffdf9;
  border: 1px solid rgba(199,174,126,0.30);
  border-radius: 18px;
  box-shadow: 0 24px 60px -18px rgba(23,19,16,.45), 0 2px 8px rgba(23,19,16,.12);
  animation: cbPanelIn 0.35s cubic-bezier(.16,1,.3,1);
}
.chatbot__panel[hidden] { display: none; }
@keyframes cbPanelIn {
  from { opacity: 0; transform: translateY(12px) scale(0.96); }
  to   { opacity: 1; transform: none; }
}

/* ---------- Panel header ---------- */
.chatbot__header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 18px 18px 16px;
  color: #fff;
  background: linear-gradient(180deg, #221d18 0%, #1a1611 100%);
  border-bottom: 1px solid rgba(199,174,126,0.28);
  position: relative;
}
/* 頂部一道細金線，呼應品牌 */
.chatbot__header::before {
  content: "";
  position: absolute; left: 18px; right: 18px; top: 0; height: 2px;
  background: linear-gradient(90deg, transparent, rgba(231,211,166,0.75), transparent);
}
.chatbot__header strong,
.chatbot__header span { display: block; }
.chatbot__header strong {
  font-family: 'Spectral', Georgia, 'Noto Serif TC', serif;
  font-size: 17px;
  font-weight: 600;
  letter-spacing: .04em;
  color: #f3ece0;
}
.chatbot__header span {
  margin-top: 5px;
  color: #c7b19a;
  font-size: 11.5px;
  letter-spacing: .06em;
}
.chatbot__close {
  border: 0;
  padding: 0 2px;
  background: transparent;
  color: #fff;
  font-size: 26px;
  line-height: 1;
  cursor: pointer;
  transition: color 0.2s ease;
}
.chatbot__close:hover { color: #e5c38c; }

/* ---------- Messages ---------- */
.chatbot__messages {
  flex: 1;
  overflow-y: auto;
  padding: 18px;
  background: #f6f2eb;
}
.chatbot__message {
  max-width: 88%;
  margin: 0 0 12px;
  padding: 11px 13px;
  border-radius: 14px;
  color: #3a3530;
  background: #fff;
  font-size: 14px;
  line-height: 1.68;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  box-shadow: 0 1px 3px rgba(23,19,16,.06);
}
.chatbot__message--user {
  margin-left: auto;
  color: #fff;
  background: linear-gradient(135deg, #b08d57 0%, #9a7a46 100%);
  border-bottom-right-radius: 4px;
}
.chatbot__message--bot {
  border-bottom-left-radius: 4px;
  border-left: 2px solid rgba(199,174,126,0.55);
}
.chatbot__message--pending { color: #746b60; font-style: italic; }
/* 客服帶出的商品連結 */
.chatbot__link {
  color: #8b6d3a;
  text-decoration: underline;
  text-underline-offset: 2px;
  overflow-wrap: anywhere;
}
.chatbot__link:hover { color: #6d5429; }
.chatbot__link:focus-visible { outline: 2px solid #b89968; outline-offset: 2px; }

/* ---------- Form ---------- */
.chatbot__form {
  display: flex;
  gap: 8px;
  align-items: flex-end;
  padding: 12px;
  border-top: 1px solid #e6dfd5;
  background: #fff;
}
.chatbot__form textarea {
  flex: 1;
  min-height: 42px;
  max-height: 92px;
  resize: vertical;
  padding: 10px;
  border: 1px solid #d7cdbf;
  border-radius: 8px;
  font: inherit;
  font-size: 14px;
  line-height: 1.45;
}
.chatbot__form textarea:focus {
  outline: 2px solid rgba(184,153,104,.35);
  border-color: #b89968;
}
.chatbot__form button {
  min-height: 42px;
  padding: 0 13px;
  border: 0;
  border-radius: 8px;
  background: #1e1b19;
  color: #fff;
  cursor: pointer;
  font: inherit;
  font-size: 13px;
  transition: background 0.25s ease;
}
.chatbot__form button:hover { background: #b89968; }
.chatbot__form[data-busy="true"] button { opacity: .55; pointer-events: none; }

/* ---------- Footer note ---------- */
.chatbot__note {
  margin: 0;
  padding: 0 12px 11px;
  /* 這行是個資警語，必須清楚可讀：原本 #8a8177 對白底只有 3.83:1 */
  color: var(--stone);
  background: #fff;
  font-size: 11px;
  line-height: 1.45;
}

/* ---------- Utilities ---------- */
.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;
}

/* ---------- Mobile ---------- */
@media (max-width: 520px) {
  .chatbot { right: 14px; bottom: 14px; }
  .chatbot__panel { height: min(540px, calc(100vh - 92px)); }
  .chatbot__toggle { height: 50px; padding: 0 14px 0 3px; gap: 6px; }
  .chatbot__toggle-mascot { width: 44px; height: 44px; }
  .chatbot__toggle-img { width: 44px; height: 44px; }
  .chatbot__toggle-label { font-size: 13px; letter-spacing: 0.08em; }
  .chatbot__toggle-sparkle { font-size: 12px; top: -4px; }
}
