/**
 * HUEWINE — Talk to Us chatbot widget
 * Scoped to .hw-chat-* — cannot collide with site CSS.
 */

:root {
  --hwc-blue: #0a53be;
  --hwc-blue-dark: #063c91;
  --hwc-accent: #f57813;
  --hwc-accent-dark: #d4630f;
  --hwc-grey: #6c757d;
  --hwc-bg: #f6f9ff;
  --hwc-text: #1a2238;
  --hwc-text-soft: #4a5568;
  --hwc-border: #eef1f7;
  --hwc-success: #15a04a;
  --hwc-danger: #d90769;
}

/* ===== Floating bubble (always visible site-wide) ===== */
.hw-chat-bubble {
  position: fixed; right: 22px; bottom: 22px; z-index: 10000;
  width: 60px; height: 60px; border-radius: 50%;
  background: linear-gradient(135deg, var(--hwc-blue), #3b82f6);
  box-shadow: 0 12px 28px rgba(10, 83, 190, .45);
  color: #fff; display: flex; align-items: center; justify-content: center;
  font-size: 1.6rem; cursor: pointer; border: 0;
  transition: transform .2s ease, box-shadow .2s ease;
  font-family: 'Open Sans', system-ui, -apple-system, sans-serif;
}
.hw-chat-bubble:hover { transform: scale(1.07) translateY(-2px); box-shadow: 0 16px 36px rgba(10, 83, 190, .55); }
.hw-chat-bubble::after {
  content: ''; position: absolute; inset: -8px; border-radius: 50%;
  background: rgba(10, 83, 190, .35); z-index: -1;
  animation: hwc-pulse 2.4s ease-out infinite;
}
.hw-chat-bubble.is-open::after { animation: none; }
@keyframes hwc-pulse {
  0%   { transform: scale(.9); opacity: .7; }
  70%  { transform: scale(1.5); opacity: 0; }
  100% { transform: scale(1.5); opacity: 0; }
}
.hw-chat-bubble .hw-chat-notif {
  position: absolute; top: -2px; right: -2px;
  width: 14px; height: 14px; border-radius: 50%;
  background: var(--hwc-accent); border: 2px solid #fff;
}

/* ===== Chat panel ===== */
.hw-chat-panel {
  position: fixed; right: 22px; bottom: 96px; z-index: 10001;
  width: 380px; height: 560px; max-height: calc(100vh - 130px);
  background: #fff; border-radius: 18px;
  box-shadow: 0 20px 60px rgba(10, 30, 63, .25), 0 4px 16px rgba(0, 0, 0, .08);
  display: flex; flex-direction: column; overflow: hidden;
  font-family: 'Open Sans', system-ui, -apple-system, sans-serif;
  transform: translateY(20px) scale(.96); opacity: 0; pointer-events: none;
  transition: transform .28s cubic-bezier(.2, .7, .3, 1), opacity .25s ease;
}
.hw-chat-panel.is-open { transform: translateY(0) scale(1); opacity: 1; pointer-events: auto; }

/* ===== Header ===== */
.hw-chat-head {
  background: linear-gradient(135deg, #0a1e3f, var(--hwc-blue));
  color: #fff; padding: 14px 16px;
  display: flex; align-items: center; justify-content: space-between;
  flex-shrink: 0;
}
.hw-chat-head-info { display: flex; align-items: center; gap: 12px; }
.hw-chat-head-avatar {
  width: 38px; height: 38px; border-radius: 50%;
  background: rgba(255, 255, 255, .15); display: flex; align-items: center; justify-content: center;
  font-size: 1.2rem; position: relative;
}
.hw-chat-head-avatar::after {
  content: ''; position: absolute; bottom: 2px; right: 2px;
  width: 10px; height: 10px; border-radius: 50%; background: var(--hwc-success);
  border: 2px solid #0a1e3f;
}
.hw-chat-head-title { font-weight: 700; font-size: .98rem; line-height: 1.2; }
.hw-chat-head-sub { font-size: .72rem; opacity: .8; margin-top: 2px; }
.hw-chat-head-close {
  background: rgba(255, 255, 255, .12); border: 0; color: #fff;
  width: 32px; height: 32px; border-radius: 8px; cursor: pointer;
  display: flex; align-items: center; justify-content: center; font-size: 1.1rem;
  transition: background .15s ease;
}
.hw-chat-head-close:hover { background: rgba(255, 255, 255, .22); }

/* ===== Escape hatch (phone + email always visible) ===== */
.hw-chat-escape {
  background: #fff8ec; border-bottom: 1px solid var(--hwc-border);
  padding: 8px 14px; display: flex; gap: 14px; flex-wrap: wrap;
  font-size: .76rem; flex-shrink: 0;
}
.hw-chat-escape a {
  color: var(--hwc-text); text-decoration: none; display: inline-flex; align-items: center; gap: 5px;
  font-weight: 600;
}
.hw-chat-escape a:hover { color: var(--hwc-blue); }
.hw-chat-escape i { color: var(--hwc-accent); }

/* ===== Log (message list) ===== */
.hw-chat-log {
  flex: 1; overflow-y: auto; padding: 16px 14px;
  background: linear-gradient(180deg, #fafbfd, #fff);
  scroll-behavior: smooth;
}
.hw-chat-log::-webkit-scrollbar { width: 6px; }
.hw-chat-log::-webkit-scrollbar-thumb { background: #d3d8e0; border-radius: 3px; }
.hw-chat-log::-webkit-scrollbar-track { background: transparent; }

.hw-chat-msg { display: flex; margin-bottom: 12px; max-width: 100%; animation: hwc-fadein .3s ease; }
@keyframes hwc-fadein { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }
.hw-chat-msg.bot { justify-content: flex-start; }
.hw-chat-msg.user { justify-content: flex-end; }
.hw-chat-bubble-msg {
  max-width: 82%; padding: 10px 14px; border-radius: 14px;
  font-size: .92rem; line-height: 1.5; word-wrap: break-word;
}
.hw-chat-msg.bot .hw-chat-bubble-msg {
  background: #fff; border: 1px solid var(--hwc-border); color: var(--hwc-text);
  border-bottom-left-radius: 4px;
}
.hw-chat-msg.user .hw-chat-bubble-msg {
  background: linear-gradient(135deg, var(--hwc-blue), #3b82f6); color: #fff;
  border-bottom-right-radius: 4px;
}
.hw-chat-bubble-msg a { color: var(--hwc-accent); text-decoration: underline; font-weight: 600; }
.hw-chat-msg.user .hw-chat-bubble-msg a { color: #ffdfa6; }
.hw-chat-bubble-msg strong { font-weight: 700; }
.hw-chat-bubble-msg .hw-chat-line { display: block; margin-top: 4px; }

/* Typing indicator */
.hw-chat-typing { display: flex; gap: 4px; padding: 12px 14px; }
.hw-chat-typing span {
  width: 7px; height: 7px; border-radius: 50%; background: var(--hwc-grey);
  animation: hwc-typing 1.2s ease-in-out infinite;
}
.hw-chat-typing span:nth-child(2) { animation-delay: .2s; }
.hw-chat-typing span:nth-child(3) { animation-delay: .4s; }
@keyframes hwc-typing { 0%, 60%, 100% { transform: translateY(0); opacity: .4; } 30% { transform: translateY(-6px); opacity: 1; } }

/* Quick-reply chips */
.hw-chat-chips {
  display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0 14px 0; padding-left: 4px;
}
.hw-chat-chip {
  background: #fff; border: 1px solid var(--hwc-blue); color: var(--hwc-blue);
  padding: 6px 12px; border-radius: 100px; font-size: .82rem; font-weight: 600;
  cursor: pointer; transition: all .15s ease;
  font-family: inherit;
}
.hw-chat-chip:hover { background: var(--hwc-blue); color: #fff; }
.hw-chat-chip.is-primary { background: var(--hwc-accent); color: #fff; border-color: var(--hwc-accent); }
.hw-chat-chip.is-primary:hover { background: var(--hwc-accent-dark); }

/* ===== Input row ===== */
.hw-chat-input-row {
  border-top: 1px solid var(--hwc-border); padding: 10px 12px;
  display: flex; gap: 8px; align-items: center; background: #fff; flex-shrink: 0;
}
.hw-chat-input {
  flex: 1; border: 1px solid var(--hwc-border); border-radius: 100px;
  padding: 10px 16px; font-size: .92rem; outline: none;
  transition: border-color .15s ease, box-shadow .15s ease;
  font-family: inherit;
}
.hw-chat-input:focus { border-color: var(--hwc-blue); box-shadow: 0 0 0 3px rgba(10, 83, 190, .12); }
.hw-chat-send {
  background: linear-gradient(135deg, var(--hwc-accent), #ff9530); color: #fff;
  width: 40px; height: 40px; border-radius: 50%; border: 0; cursor: pointer;
  display: flex; align-items: center; justify-content: center; font-size: 1.1rem;
  transition: transform .15s ease, box-shadow .15s ease;
  flex-shrink: 0;
}
.hw-chat-send:hover { transform: scale(1.06); box-shadow: 0 6px 16px rgba(245, 120, 19, .35); }
.hw-chat-send:disabled { background: #ccc; cursor: not-allowed; transform: none; }

.hw-chat-footer {
  padding: 6px 14px 8px; text-align: center;
  font-size: .68rem; color: var(--hwc-grey); flex-shrink: 0;
  background: #fff;
}
.hw-chat-footer a { color: var(--hwc-grey); text-decoration: none; }
.hw-chat-footer .hw-chat-reset { color: var(--hwc-blue); cursor: pointer; }
.hw-chat-footer .hw-chat-reset:hover { text-decoration: underline; }

/* Contact info block (when intent = contact_info) */
.hw-chat-contact-card {
  background: var(--hwc-bg); border: 1px solid var(--hwc-border); border-radius: 10px;
  padding: 10px 12px; margin-top: 6px; font-size: .88rem;
}
.hw-chat-contact-card .hw-line { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.hw-chat-contact-card .hw-line:last-child { margin-bottom: 0; }
.hw-chat-contact-card i { color: var(--hwc-blue); width: 16px; text-align: center; }
.hw-chat-contact-card a { color: var(--hwc-text); text-decoration: none; font-weight: 600; }
.hw-chat-contact-card a:hover { color: var(--hwc-blue); }

/* Lead success card */
.hw-chat-success {
  background: #e8f8ee; border: 1px solid #c2eccf; border-radius: 10px;
  padding: 12px; margin-top: 6px; color: #0b6e35; font-size: .9rem;
}
.hw-chat-success i { color: var(--hwc-success); margin-right: 6px; }

/* Error / failure card */
.hw-chat-error {
  background: #fdecf2; border: 1px solid #fac6d6; border-radius: 10px;
  padding: 12px; margin-top: 6px; color: #8a0a3c; font-size: .88rem;
}

/* ===== Mobile ===== */
@media (max-width: 480px) {
  .hw-chat-bubble { width: 54px; height: 54px; right: 16px; bottom: 16px; font-size: 1.4rem; }
  .hw-chat-panel {
    right: 0; left: 0; bottom: 0; top: 0; width: 100%;
    height: 100%; max-height: 100%; border-radius: 0;
  }
}

/* ===== Honeypot (anti-spam) ===== */
.hw-chat-hp {
  position: absolute !important; left: -9999px !important; top: -9999px !important;
  width: 0 !important; height: 0 !important; opacity: 0 !important;
  pointer-events: none !important;
}

/* ===== Reduced motion ===== */
@media (prefers-reduced-motion: reduce) {
  .hw-chat-bubble::after { animation: none; }
  .hw-chat-typing span { animation: none; }
  .hw-chat-panel { transition: opacity .15s ease; transform: none; }
  .hw-chat-msg { animation: none; }
}
