/* =========================================================
   Riborn Spa — "Liyza" booking chat widget
   ---------------------------------------------------------
   INTEGRATION NOTES (differences from the standalone file):
   1. The original global reset (`*{margin:0;padding:0}`) and
      `body{font-family:...}` are removed — the site has its own and the
      reset would have stripped spacing from every element on the page.
   2. The original `:root{}` palette redefined --gold, --gold-light, --white,
      --cream and --off-white, which are the SAME names the site theme uses.
      Every widget variable is now prefixed --sb-* and scoped to the widget
      roots, so it cannot recolour the site.
   3. `input::placeholder` is scoped to widget inputs only.
   4. Bubble/panel offsets derive from the site's --edge / --float-size so the
      widget stacks ABOVE the WhatsApp float button instead of on top of it.
   ========================================================= */

:root {
  /* Prefixed, so these are safe to sit on :root. */
  --sb-size: 70px;                     /* chat bubble diameter */
  /* The bubble owns the BOTTOM-RIGHT corner outright — the Call and WhatsApp
     buttons are both stacked in the bottom-LEFT corner, so there is nothing
     to clear here. Derived from the site's --edge so all fixed widgets keep
     the same margin from the viewport edge. */
  --sb-lift: var(--edge, 18px);
  --sb-panel-lift: calc(var(--sb-lift) + var(--sb-size) + 12px);
}

#spa-bubble,
#spa-chat {
  --sb-gold: #b87d2a;
  --sb-gold-light: #eda94b;
  --sb-gold-dark: #8e5d18;
  --sb-white: #ffffff;
  --sb-off-white: #faf7f3;
  --sb-cream: #f5ede0;
  --sb-warm-gray: #f0ebe3;
  --sb-text-dark: #111111;
  --sb-text-light: #a08860;
  --sb-border: rgba(200, 169, 110, 0.22);
  --sb-border-hi: rgba(200, 169, 110, 0.45);
  --sb-shadow: rgba(180, 140, 80, 0.15);

  box-sizing: border-box;
  font-family: "Plus Jakarta Sans", sans-serif;
}
#spa-bubble *,
#spa-chat *,
#spa-bubble *::before,
#spa-chat *::before,
#spa-bubble *::after,
#spa-chat *::after {
  box-sizing: border-box;
}

/* ── Bubble ── */
#spa-bubble {
  position: fixed;
  bottom: var(--sb-lift);
  right: var(--edge, 18px);
  z-index: 9999;
  width: var(--sb-size);
  height: var(--sb-size);
  border-radius: 50%;
  background: #fff;
  border: 2px solid var(--sb-gold);
  box-shadow:
    0 0 0 6px rgba(200, 169, 110, 0.1),
    0 8px 32px rgba(0, 0, 0, 0.14),
    0 2px 8px var(--sb-shadow);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  padding: 0;
  margin: 0;
  animation:
    sbBubbleIn 0.7s cubic-bezier(0.34, 1.56, 0.64, 1) both,
    sbComboShake 4s ease-in-out 1s infinite;
  transition:
    transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1),
    box-shadow 0.3s;
}
@keyframes sbBubbleIn {
  from { transform: scale(0) rotate(-20deg); opacity: 0; }
  to { transform: scale(1) rotate(0); opacity: 1; }
}
@keyframes sbComboShake {
  0%, 100% {
    transform: rotate(0);
    box-shadow: 0 0 0 5px rgba(200,169,110,.1), 0 8px 24px rgba(0,0,0,.12), 0 0 18px rgba(200,169,110,.45), 0 0 36px rgba(200,169,110,.2);
  }
  5% {
    transform: rotate(-9deg);
    box-shadow: 0 0 0 8px rgba(200,169,110,.2), 0 8px 28px rgba(0,0,0,.14), 0 0 32px rgba(200,169,110,.8), 0 0 64px rgba(200,169,110,.4);
  }
  10% { transform: rotate(9deg); }
  15% {
    transform: rotate(-7deg);
    box-shadow: 0 0 0 8px rgba(200,169,110,.2), 0 8px 28px rgba(0,0,0,.14), 0 0 32px rgba(200,169,110,.8), 0 0 64px rgba(200,169,110,.4);
  }
  20% { transform: rotate(5deg); }
  25% { transform: rotate(-3deg); }
  30% { transform: rotate(2deg); }
  35%, 60% { transform: rotate(0); }
}
@media (prefers-reduced-motion: reduce) {
  #spa-bubble { animation: sbBubbleIn 0.4s ease both; }
  .pulse-ring { animation: none; }
}

#spa-bubble:hover {
  transform: scale(1.05);
  box-shadow: 0 0 0 8px rgba(200,169,110,.15), 0 12px 40px rgba(0,0,0,.18), 0 4px 16px var(--sb-shadow);
}
#spa-bubble.open { animation: none; transform: scale(0.92) rotate(5deg); }

.bubble-img {
  width: 100%;
  height: 100% !important;
  object-fit: cover;
  object-position: top !important;
  border-radius: 50%;
  transition: opacity 0.3s, transform 0.3s;
}
.bubble-close-overlay {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background-image: linear-gradient(to right top, #b87d2a, #b47927, #b07524, #ac7220, #a86e1d);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transform: scale(0.7);
  transition: opacity 0.3s, transform 0.3s;
}
#spa-bubble.open .bubble-img { opacity: 0; transform: scale(0.7); }
#spa-bubble.open .bubble-close-overlay { opacity: 1; transform: scale(1); }

.pulse-ring {
  position: absolute;
  inset: -7px;
  border-radius: 50%;
  border: 1.5px solid rgba(200, 169, 110, 0.4);
  animation: sbPulseRing 2.5s ease-out infinite;
  pointer-events: none;
}
.pulse-ring:nth-child(2) { animation-delay: 0.9s; }
@keyframes sbPulseRing {
  0% { transform: scale(1); opacity: 0.7; }
  100% { transform: scale(1.5); opacity: 0; }
}

.notif-dot {
  position: absolute;
  top: 5px;
  right: 5px;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: #4ecb71;
  border: 2.5px solid white;
  animation: sbNotifPulse 1.8s ease-in-out infinite;
  z-index: 99;
}
@keyframes sbNotifPulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.25); }
}

/* ── Chat Window ── */
#spa-chat {
  position: fixed;
  bottom: var(--sb-panel-lift);
  right: var(--edge, 18px);
  z-index: 9998;
  width: 380px;
  height: 610px;
  max-height: calc(100dvh - var(--sb-panel-lift) - 20px);
  border-radius: 22px;
  background: var(--sb-white);
  border: 1px solid var(--sb-border);
  box-shadow:
    0 32px 80px rgba(0, 0, 0, 0.13),
    0 8px 24px rgba(180, 140, 80, 0.1),
    0 0 0 1px rgba(200, 169, 110, 0.07);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform: scale(0.88) translateY(24px);
  transform-origin: bottom right;
  opacity: 0;
  pointer-events: none;
  transition:
    transform 0.45s cubic-bezier(0.34, 1.56, 0.64, 1),
    opacity 0.3s ease;
  touch-action: pan-y;
}
#spa-chat.visible { transform: scale(1) translateY(0); opacity: 1; pointer-events: all; }

/* ── Header ── */
.spa-header {
  background: linear-gradient(135deg, #fffdf9 0%, #faf5ec 100%);
  border-bottom: 1px solid var(--sb-border);
  padding: 14px 16px 12px;
  display: flex;
  align-items: center;
  gap: 12px;
  position: relative;
  overflow: hidden;
  flex-shrink: 0;
}
.spa-header::before {
  content: "";
  position: absolute;
  top: -30px;
  right: -20px;
  width: 110px;
  height: 110px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(200, 169, 110, 0.08) 0%, transparent 70%);
  pointer-events: none;
}
.spa-header::after {
  content: "✦  ✦  ✦";
  position: absolute;
  bottom: 8px;
  right: 14px;
  font-size: 8px;
  color: rgba(200, 169, 110, 0.2);
  letter-spacing: 5px;
}

.header-avatar {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  flex-shrink: 0;
  border: 2px solid var(--sb-gold);
  overflow: hidden;
  position: relative;
  box-shadow: 0 3px 12px rgba(200, 169, 110, 0.2), 0 0 0 3px rgba(200, 169, 110, 0.08);
}
.header-avatar img {
  width: 100%;
  height: 100% !important;
  object-fit: cover;
  object-position: top !important;
  display: block;
}
.online-ring {
  position: absolute;
  bottom: 2px;
  right: 2px;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: #4ecb71;
  border: 2px solid white;
  z-index: 2;
}

.header-text { flex: 1; min-width: 0; }
.header-name {
  font-family: "Playfair Display", serif;
  font-size: 17px;
  font-weight: 500;
  color: var(--sb-text-dark);
  letter-spacing: 0.03em;
  overflow: hidden;
  text-overflow: ellipsis;
  margin: 0;
}
.header-sub {
  font-family: "Plus Jakarta Sans", sans-serif !important;
  font-size: 11px;
  font-weight: 300;
  color: var(--sb-text-light);
  margin-top: 2px;
  display: flex;
  align-items: center;
  gap: 5px;
}
.dot-live { width: 6px; height: 6px; border-radius: 100%; background: #4ecb71; flex-shrink: 0; }
.header-close {
  background: none;
  border: none;
  cursor: pointer;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--sb-text-light);
  transition: background 0.2s, color 0.2s;
  flex-shrink: 0;
}
.header-close:hover { background: var(--sb-warm-gray); color: var(--sb-gold-dark); }

/* ── Messages ── */
.spa-messages {
  flex: 1;
  overflow-y: auto;
  padding: 14px 14px 8px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: var(--sb-off-white);
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}
.spa-messages::-webkit-scrollbar { width: 3px; }
.spa-messages::-webkit-scrollbar-thumb { background: rgba(200, 169, 110, 0.25); border-radius: 4px; }

.date-divider {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: "Plus Jakarta Sans", sans-serif !important;
  font-size: 10px;
  font-weight: 500;
  color: var(--sb-text-light);
  letter-spacing: 0.1em;
  text-transform: uppercase;
}
.date-divider::before,
.date-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(200, 169, 110, 0.25), transparent);
}
.ornament { text-align: center; font-size: 12px; color: #b87d2a; letter-spacing: 10px; margin: 2px 0; }

.msg { display: flex; align-items: flex-end; gap: 8px; animation: sbMsgIn 0.38s cubic-bezier(0.34, 1.56, 0.64, 1); }
@keyframes sbMsgIn {
  from { opacity: 0; transform: translateY(14px) scale(0.94); }
  to { opacity: 1; transform: none; }
}
.msg.bot { justify-content: flex-start; }
.msg.bot > div { display: flex; flex-direction: column; align-items: flex-start; max-width: 82%; }
.msg.user { justify-content: flex-end; }
.msg.user > div { display: flex; flex-direction: column; align-items: flex-end; max-width: 82%; }

.msg-av {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  flex-shrink: 0;
  border: 1.5px solid var(--sb-gold);
  overflow: hidden;
  margin-bottom: 2px;
  box-shadow: 0 2px 8px rgba(200, 169, 110, 0.2);
}
.msg-av img {
  width: 100%;
  height: 100% !important;
  object-fit: cover;
  object-position: top !important;
  display: block;
}

.bubble {
  padding: 11px 15px;
  border-radius: 18px;
  font-family: "Plus Jakarta Sans", sans-serif !important;
  font-size: 13.5px;
  line-height: 1.6;
  word-break: break-word;
  overflow-wrap: anywhere;
}
.msg.bot .bubble {
  background: var(--sb-white);
  border: 1px solid var(--sb-border);
  color: var(--sb-text-dark);
  border-bottom-left-radius: 4px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.06);
}
.msg.user .bubble {
  background-image: linear-gradient(to right top, #b87d2a, #b47927, #b07524, #ac7220, #a86e1d);
  color: #fff;
  font-weight: 400;
  border-bottom-right-radius: 4px;
  box-shadow: 0 4px 14px rgba(200, 169, 110, 0.3);
}
.msg-time {
  font-size: 10px;
  font-family: "Plus Jakarta Sans", sans-serif !important;
  font-weight: 300;
  color: var(--sb-text-light);
  opacity: 0.6;
  margin-top: 4px;
}
.msg.bot .msg-time { text-align: left; }
.msg.user .msg-time { text-align: right; }

/* typing */
.typing-wrap { display: flex; align-items: flex-end; gap: 8px; }
.typing-bubble {
  background: var(--sb-white);
  border: 1px solid var(--sb-border);
  padding: 12px 16px;
  border-radius: 18px;
  border-bottom-left-radius: 4px;
  display: flex;
  gap: 5px;
  align-items: center;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.06);
}
.t-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--sb-gold); opacity: 0.5; animation: sbTdot 1.3s ease-in-out infinite; }
.t-dot:nth-child(2) { animation-delay: 0.2s; }
.t-dot:nth-child(3) { animation-delay: 0.4s; }
@keyframes sbTdot {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.5; }
  30% { transform: translateY(-7px); opacity: 1; }
}

/* ── Input Area ── */
.spa-input-area {
  padding: 10px 14px 12px;
  background: var(--sb-white);
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 7px;
  border-radius: 50px;
}

/* service list bubble */
.svc-list {
  background: var(--sb-off-white);
  border: 1px solid var(--sb-border-hi);
  border-radius: 16px;
  padding: 10px 14px;
  font-family: "Plus Jakarta Sans", sans-serif;
  font-size: 12.5px;
  color: var(--sb-text-dark);
  line-height: 1.8;
  max-height: 200px;
  overflow-y: auto;
}
.svc-list::-webkit-scrollbar { width: 3px; }
.svc-list::-webkit-scrollbar-thumb { background: rgba(200, 169, 110, 0.3); border-radius: 4px; }
.svc-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 10px;
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.15s;
  border-bottom: 1px solid rgba(200, 169, 110, 0.1);
}
.svc-row:last-child { border-bottom: none; }
.svc-row:hover { background: rgba(200, 169, 110, 0.1); }
.svc-row.sel { background: rgba(200, 169, 110, 0.18); font-weight: 600; }
.svc-num {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: rgba(200, 169, 110, 0.2);
  color: var(--sb-gold-dark);
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.svc-name { flex: 1; font-size: 13px; }
.svc-dur { font-size: 11px; color: var(--sb-text-light); flex-shrink: 0; }

/* yes/no */
.yn-row { display: flex; gap: 10px; }
.yn-btn {
  flex: 1;
  padding: 11px 0;
  border-radius: 22px;
  font-size: 14px;
  font-weight: 600;
  font-family: "Plus Jakarta Sans", sans-serif;
  cursor: pointer;
  transition: all 0.15s;
}
.yn-yes {
  background: linear-gradient(135deg, #c8a96e, #9a7a45);
  color: #fff;
  border: none;
  box-shadow: 0 4px 14px rgba(200, 169, 110, 0.3);
}
.yn-yes:hover { transform: scale(1.02); box-shadow: 0 6px 18px rgba(200, 169, 110, 0.4); }
.yn-no { background: var(--sb-white); color: var(--sb-gold-dark); border: 1.5px solid var(--sb-gold); }
.yn-no:hover { background: var(--sb-cream); }

/* text input + send row */
.input-send-row { display: flex; flex-direction: row; align-items: center; gap: 10px; }
.field-wrap { flex: 1; position: relative; }
.spa-field {
  width: 100%;
  padding: 11px 38px 11px 16px;
  border-radius: 22px !important;
  border: 1.5px solid var(--sb-border-hi);
  background: var(--sb-off-white);
  color: var(--sb-text-dark);
  font-family: "Plus Jakarta Sans", sans-serif !important;
  font-size: 14px;
  font-weight: 300;
  outline: none;
  transition: border-color 0.2s, background 0.2s;
  line-height: 1.4;
}
.spa-field:focus { border-color: var(--sb-gold); background: var(--sb-white); }
/* Scoped so the site's own inputs are untouched. */
#spa-chat input::placeholder { color: rgba(160, 136, 96, 0.75); opacity: 1; }
.spa-field.err { border-color: #e74c3c; background: #fff8f8; }
.spa-field.ok { border-color: #4ecb71; }
.f-icon { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); font-size: 13px; pointer-events: none; line-height: 1; }
.f-err { font-size: 11px; color: #e74c3c; padding: 0 4px; min-height: 14px; margin-top: 2px; }

.send-btn {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  flex-shrink: 0;
  background-image: linear-gradient(to right top, #b87d2a, #b47927, #b07524, #ac7220, #a86e1d);
  border: none;
  cursor: pointer;
  padding: 0;
  line-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 14px rgba(200, 169, 110, 0.3);
  transition: transform 0.2s, box-shadow 0.2s;
}
.send-btn svg { width: 18px; height: 18px; display: block; }
.send-btn:hover { transform: scale(1.08); box-shadow: 0 6px 20px rgba(200, 169, 110, 0.4); }
.send-btn:active { transform: scale(0.93); }

/* powered */
.spa-power {
  text-align: center;
  font-family: "Plus Jakarta Sans", sans-serif !important;
  font-size: 10px;
  font-weight: 300;
  color: #000;
  padding: 5px 0 9px;
  letter-spacing: 0.06em;
  background: var(--sb-white);
  flex-shrink: 0;
}
.spa-power span { color: var(--sb-gold-dark); }

/* ── Mobile ── */
@media (max-width: 480px) {
  #spa-chat {
    width: calc(100vw - 16px);
    left: 8px;
    right: 8px;
    height: calc(100dvh - var(--sb-panel-lift) - 20px);
    max-height: 590px;
    border-radius: 16px;
  }
  .spa-field { font-size: 16px; }
  .spa-input-area { position: sticky; bottom: 0; }
}
