/*
 * KW Villas concierge chat widget — styles
 *
 * Visual tokens inherited from the site's :root vars; widget falls back
 * to its own values when injected on pages where styles.css is absent.
 * Aesthetic target: Belmond-restrained — cream, ink, gold accent, no
 * candy-coloured bubbles, no oversized rounded corners, no emojis.
 */

#kwchat-root {
  --kw-bg: #faf8f4;
  --kw-ink: #1a1a1a;
  --kw-ink-mute: #5a5a5a;
  --kw-line: #e5e0d6;
  --kw-gold: #9a7b3f;
  --kw-gold-light: #c9a864;
  --kw-wa: #25d366;
  --kw-shadow: 0 16px 48px rgba(20, 14, 4, 0.18), 0 2px 6px rgba(20, 14, 4, 0.08);
  --kw-font: 'Poppins', -apple-system, BlinkMacSystemFont, 'Helvetica Neue', sans-serif;

  position: fixed;
  z-index: 9999;
  font-family: var(--kw-font);
  color: var(--kw-ink);
  -webkit-font-smoothing: antialiased;
}

/* ── Floating bubble (closed state) ─────────────────────────────── */

.kwchat-bubble {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--kw-ink);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  border: none;
  box-shadow: var(--kw-shadow);
  transition: transform 0.18s ease, background 0.18s ease;
  padding: 0;
  z-index: 9999;
}
.kwchat-bubble:hover { transform: scale(1.05); background: var(--kw-gold); }
.kwchat-bubble:focus-visible { outline: 2px solid var(--kw-gold-light); outline-offset: 3px; }
.kwchat-bubble svg { width: 24px; height: 24px; stroke: currentColor; fill: none; stroke-width: 1.6; }

.kwchat-bubble-badge {
  position: absolute;
  top: -2px;
  right: -2px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--kw-gold-light);
  border: 2px solid var(--kw-bg);
  display: none;
}
.kwchat-bubble.has-unread .kwchat-bubble-badge { display: block; }

/* ── Panel (open state) ─────────────────────────────────────────── */

.kwchat-panel {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 380px;
  height: min(560px, calc(100vh - 48px));
  background: var(--kw-bg);
  border-radius: 4px;
  box-shadow: var(--kw-shadow);
  display: none;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--kw-line);
}
.kwchat-panel.open { display: flex; }

/* ── Header ─────────────────────────────────────────────────────── */

.kwchat-header {
  background: var(--kw-ink);
  color: #fff;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid #000;
}
.kwchat-header-title {
  font-family: var(--kw-font);
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}
.kwchat-header-subtitle {
  font-size: 10px;
  color: rgba(255,255,255,0.55);
  letter-spacing: 0.08em;
  margin-top: 2px;
  text-transform: uppercase;
}
.kwchat-header-actions { display: flex; gap: 8px; align-items: center; }
.kwchat-iconbtn {
  background: transparent;
  color: rgba(255,255,255,0.7);
  border: none;
  cursor: pointer;
  padding: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.15s;
}
.kwchat-iconbtn:hover { color: #fff; }
.kwchat-iconbtn svg { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 1.6; }

/* ── Body / messages ───────────────────────────────────────────── */

.kwchat-body {
  flex: 1;
  overflow-y: auto;
  padding: 18px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scroll-behavior: smooth;
}
.kwchat-body::-webkit-scrollbar { width: 6px; }
.kwchat-body::-webkit-scrollbar-track { background: transparent; }
.kwchat-body::-webkit-scrollbar-thumb {
  background: var(--kw-line);
  border-radius: 3px;
}

.kwchat-msg {
  max-width: 85%;
  padding: 10px 13px;
  font-size: 14px;
  line-height: 1.55;
  border-radius: 4px;
  white-space: pre-wrap;
  word-wrap: break-word;
}
.kwchat-msg.user {
  align-self: flex-end;
  background: var(--kw-ink);
  color: #fff;
}
.kwchat-msg.bot {
  align-self: flex-start;
  background: #fff;
  border: 1px solid var(--kw-line);
  color: var(--kw-ink);
}
.kwchat-msg.bot.thinking::after {
  content: "···";
  color: var(--kw-ink-mute);
  letter-spacing: 0.2em;
  animation: kwchat-pulse 1.2s ease-in-out infinite;
}
.kwchat-msg.system {
  align-self: center;
  font-size: 11px;
  color: var(--kw-ink-mute);
  background: transparent;
  letter-spacing: 0.05em;
  padding: 4px 8px;
}
.kwchat-msg.error {
  align-self: stretch;
  background: #fef0e8;
  border: 1px solid #d97a3a;
  color: #8b3a0c;
  font-size: 12px;
}

@keyframes kwchat-pulse {
  0%, 100% { opacity: 0.3; }
  50%      { opacity: 1; }
}

/* ── WhatsApp handoff banner ───────────────────────────────────── */

.kwchat-handoff {
  padding: 10px 16px;
  background: #fffaef;
  border-top: 1px solid var(--kw-line);
  font-size: 12px;
  color: var(--kw-ink-mute);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.kwchat-handoff a {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--kw-wa);
  font-weight: 500;
  text-decoration: none;
  white-space: nowrap;
}
.kwchat-handoff a:hover { color: #1ea651; }
.kwchat-handoff svg { width: 14px; height: 14px; stroke: currentColor; fill: none; stroke-width: 1.8; }

/* ── Composer ──────────────────────────────────────────────────── */

.kwchat-composer {
  padding: 12px 16px 14px;
  border-top: 1px solid var(--kw-line);
  background: var(--kw-bg);
  display: flex;
  gap: 10px;
  align-items: flex-end;
}
.kwchat-input {
  flex: 1;
  border: 1px solid var(--kw-line);
  background: #fff;
  border-radius: 4px;
  padding: 9px 12px;
  font-family: var(--kw-font);
  font-size: 14px;
  color: var(--kw-ink);
  resize: none;
  max-height: 120px;
  outline: none;
  line-height: 1.45;
}
.kwchat-input:focus { border-color: var(--kw-gold); }
.kwchat-send {
  background: var(--kw-ink);
  color: #fff;
  border: none;
  padding: 9px 14px;
  border-radius: 4px;
  cursor: pointer;
  font-family: var(--kw-font);
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-weight: 500;
  transition: background 0.15s;
}
.kwchat-send:hover:not(:disabled) { background: var(--kw-gold); }
.kwchat-send:disabled { opacity: 0.4; cursor: not-allowed; }

.kwchat-footer {
  padding: 6px 16px 10px;
  font-size: 10px;
  color: var(--kw-ink-mute);
  text-align: center;
  letter-spacing: 0.06em;
  background: var(--kw-bg);
}

/* ── Mobile bottom sheet ───────────────────────────────────────── */

@media (max-width: 540px) {
  .kwchat-bubble { bottom: 18px; right: 18px; }
  .kwchat-panel {
    bottom: 0;
    right: 0;
    left: 0;
    width: 100%;
    height: 88vh;
    border-radius: 12px 12px 0 0;
  }
}

/* ── Hero CTA pair (replaces the giant green WA button) ────────── */
/* These classes are emitted by _build.py in the hero CTA group; */
/* keeping them here means hero styling stays adjacent to widget. */

.kwchat-hero-cta-group {
  display: inline-flex;
  flex-direction: column;
  gap: 12px;
  align-items: center;
  margin-top: 36px;
}
@media (min-width: 640px) {
  .kwchat-hero-cta-group { flex-direction: row; gap: 14px; }
}
.kwchat-hero-cta {
  /* Used outside #kwchat-root (on page hero), so all colour values are
     literal — do NOT use the --kw-* custom properties here. */
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 14px 32px;
  font-family: 'Poppins', -apple-system, BlinkMacSystemFont, 'Helvetica Neue', sans-serif;
  font-size: 13px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  font-weight: 500;
  border: 1px solid currentColor;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.18s ease, color 0.18s ease, border-color 0.18s ease, transform 0.18s ease;
  background: transparent;
  color: #ffffff;
  line-height: 1.2;
}
.kwchat-hero-cta:hover { transform: translateY(-2px); }
.kwchat-hero-cta.primary {
  background: #ffffff;
  color: #1a1a1a;
  border-color: #ffffff;
}
.kwchat-hero-cta.primary:hover { background: #c9a864; border-color: #c9a864; color: #1a1a1a; }
.kwchat-hero-cta.secondary { color: #ffffff; border-color: #ffffff; }
.kwchat-hero-cta.secondary:hover { background: rgba(255,255,255,0.12); }
.kwchat-hero-cta svg { width: 14px; height: 14px; margin-right: 8px; stroke: currentColor; fill: none; stroke-width: 2; }
