/* =========================================================
   Shree Ram Enclave — "Priya" site-visit booking chat widget
   Reuses the site's own --gold / --dark / --cream tokens from
   css/style.css (loaded before this file), so no palette is
   redefined here.
   ---------------------------------------------------------
   Sits alone at bottom-right (WhatsApp + call now stack at
   bottom-left instead), so no extra clearance is needed.
   ========================================================= */

:root {
  --cb-size: 62px;                 /* bubble diameter */
  --cb-edge: 26px;                 /* offset from the corner */
  --cb-lift: var(--cb-edge);
  --cb-panel-lift: calc(var(--cb-lift) + var(--cb-size) + 12px);
}

#cb-bubble, #cb-chat { box-sizing: border-box; font-family: var(--sans); }
#cb-bubble *, #cb-chat *,
#cb-bubble *::before, #cb-chat *::before,
#cb-bubble *::after, #cb-chat *::after { box-sizing: border-box; }

/* ── Bubble ── */
#cb-bubble {
  position: fixed;
  bottom: var(--cb-lift);
  right: var(--cb-edge);
  z-index: 1500;
  width: var(--cb-size);
  height: var(--cb-size);
  border-radius: 50%;
  background: linear-gradient(135deg, var(--gold-light), var(--gold-dark));
  border: 2px solid #fff;
  box-shadow: 0 0 0 6px rgba(182, 137, 47, 0.12), 0 8px 26px rgba(0, 0, 0, 0.22);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  padding: 0;
  margin: 0;
  color: #fff;
  animation: cbBubbleIn 0.6s cubic-bezier(.34,1.56,.64,1) both;
  transition: transform 0.35s cubic-bezier(.34,1.56,.64,1), box-shadow 0.3s;
}
@keyframes cbBubbleIn {
  from { transform: scale(0) rotate(-16deg); opacity: 0; }
  to { transform: scale(1) rotate(0); opacity: 1; }
}
#cb-bubble:hover { transform: scale(1.06); box-shadow: 0 0 0 8px rgba(182,137,47,.18), 0 12px 34px rgba(0,0,0,.28); }
#cb-bubble.open { transform: scale(0.92) rotate(4deg); }

#cb-bubble .cb-bubble-icon,
#cb-bubble .cb-bubble-close {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity .25s, transform .25s;
}
#cb-bubble .cb-bubble-icon svg,
#cb-bubble .cb-bubble-close svg { width: 26px; height: 26px; }
#cb-bubble .cb-bubble-icon img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
}
#cb-bubble .cb-bubble-close { opacity: 0; transform: scale(.7); }
#cb-bubble.open .cb-bubble-icon { opacity: 0; transform: scale(.7); }
#cb-bubble.open .cb-bubble-close { opacity: 1; transform: scale(1); }

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

/* ── Chat window ── */
#cb-chat {
  position: fixed;
  bottom: var(--cb-panel-lift);
  right: var(--cb-edge);
  z-index: 1499;
  width: 370px;
  height: 580px;
  max-height: calc(100dvh - var(--cb-panel-lift) - 20px);
  border-radius: 18px;
  background: #fff;
  border: 1px solid #eee5d0;
  box-shadow: 0 30px 70px rgba(0,0,0,.18), 0 8px 22px rgba(35,31,24,.12);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform: scale(.9) translateY(20px);
  transform-origin: bottom right;
  opacity: 0;
  pointer-events: none;
  transition: transform .4s cubic-bezier(.34,1.56,.64,1), opacity .3s ease;
  touch-action: pan-y;
}
#cb-chat.visible { transform: scale(1) translateY(0); opacity: 1; pointer-events: all; }

/* ── Header ── */
.cb-header {
  background: linear-gradient(135deg, var(--dark), #33291a);
  padding: 16px 16px 14px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}
.cb-header-avatar {
  width: 44px; height: 44px;
  border-radius: 50%;
  flex-shrink: 0;
  border: 2px solid var(--gold-light);
  overflow: hidden;
  display: flex; align-items: center; justify-content: center;
  background: #fff;
  position: relative;
}
.cb-header-avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.cb-online-ring {
  position: absolute; bottom: -1px; right: -1px;
  width: 11px; height: 11px; border-radius: 50%;
  background: #4ecb71; border: 2px solid var(--dark);
}
.cb-header-text { flex: 1; min-width: 0; }
.cb-header-name {
  font-family: var(--heading);
  font-size: 15.5px; font-weight: 700; color: #fff;
  letter-spacing: .2px;
}
.cb-header-sub {
  font-size: 11px; color: #cfc8b6; margin-top: 2px;
  display: flex; align-items: center; gap: 5px;
}
.cb-dot-live { width: 6px; height: 6px; border-radius: 50%; background: #4ecb71; flex-shrink: 0; }
.cb-header-close {
  background: none; border: 0; cursor: pointer;
  width: 30px; height: 30px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: #cfc8b6; flex-shrink: 0; transition: background .2s, color .2s;
}
.cb-header-close svg { width: 18px; height: 18px; }
.cb-header-close:hover { background: rgba(255,255,255,.1); color: #fff; }

/* ── Messages ── */
.cb-messages {
  flex: 1; overflow-y: auto;
  padding: 14px 14px 8px;
  display: flex; flex-direction: column; gap: 10px;
  background: var(--cream);
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}
.cb-messages::-webkit-scrollbar { width: 3px; }
.cb-messages::-webkit-scrollbar-thumb { background: rgba(182,137,47,.3); border-radius: 4px; }

.cb-msg { display: flex; align-items: flex-end; gap: 8px; animation: cbMsgIn .35s cubic-bezier(.34,1.56,.64,1); }
@keyframes cbMsgIn { from{opacity:0;transform:translateY(12px) scale(.95);} to{opacity:1;transform:none;} }
.cb-msg.bot { justify-content: flex-start; }
.cb-msg.bot > div { display: flex; flex-direction: column; align-items: flex-start; max-width: 84%; }
.cb-msg.user { justify-content: flex-end; }
.cb-msg.user > div { display: flex; flex-direction: column; align-items: flex-end; max-width: 84%; }

.cb-av {
  width: 26px; height: 26px; border-radius: 50%; flex-shrink: 0;
  border: 1.5px solid var(--gold-light); overflow: hidden; margin-bottom: 2px;
  display: flex; align-items: center; justify-content: center; background: var(--dark);
}
.cb-av img { width: 100%; height: 100%; object-fit: cover; display: block; }

.cb-bubble-msg {
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 13.5px;
  line-height: 1.6;
  word-break: break-word;
  overflow-wrap: anywhere;
}
.cb-msg.bot .cb-bubble-msg {
  background: #fff; border: 1px solid #eee5d0; color: var(--dark);
  border-bottom-left-radius: 4px; box-shadow: var(--shadow);
}
.cb-msg.user .cb-bubble-msg {
  background: linear-gradient(135deg, var(--gold-light), var(--gold-dark));
  color: #fff; font-weight: 500;
  border-bottom-right-radius: 4px; box-shadow: 0 4px 14px rgba(182,137,47,.3);
}
.cb-msg-time { font-size: 10px; color: var(--text-light); opacity: .7; margin-top: 3px; }

.cb-typing-wrap { display: flex; align-items: flex-end; gap: 8px; }
.cb-typing-bubble {
  background: #fff; border: 1px solid #eee5d0; padding: 11px 15px;
  border-radius: 16px; border-bottom-left-radius: 4px;
  display: flex; gap: 5px; align-items: center; box-shadow: var(--shadow);
}
.cb-tdot { width: 6px; height: 6px; border-radius: 50%; background: var(--gold-dark); opacity: .5; animation: cbTdot 1.3s ease-in-out infinite; }
.cb-tdot:nth-child(2) { animation-delay: .2s; }
.cb-tdot:nth-child(3) { animation-delay: .4s; }
@keyframes cbTdot { 0%,60%,100%{transform:translateY(0);opacity:.5;} 30%{transform:translateY(-6px);opacity:1;} }

/* ── Input area ── */
.cb-input-area { padding: 10px 14px 12px; background: #fff; flex-shrink: 0; display: flex; flex-direction: column; gap: 7px; }

.cb-opt-list {
  background: var(--cream); border: 1px solid #e6dcc0; border-radius: 14px;
  padding: 8px; max-height: 220px; overflow-y: auto;
}
.cb-opt-row {
  display: flex; align-items: center; gap: 10px;
  padding: 10px; border-radius: 10px; cursor: pointer;
  transition: background .15s; border-bottom: 1px solid rgba(182,137,47,.1);
}
.cb-opt-row:last-child { border-bottom: none; }
.cb-opt-row:hover { background: rgba(182,137,47,.1); }
.cb-opt-row.sel { background: rgba(182,137,47,.18); font-weight: 700; }
.cb-opt-num {
  width: 22px; height: 22px; border-radius: 50%;
  background: rgba(182,137,47,.2); color: var(--gold-dark);
  font-size: 11px; font-weight: 700;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.cb-opt-text { flex: 1; font-size: 13px; color: var(--dark); }
.cb-opt-sub { display: block; font-size: 11px; color: var(--text-light); font-weight: 400; }

/* ── Calendar date picker ── */
.cb-cal {
  background: #fff;
  border: 1px solid #eee5d0;
  border-radius: 14px;
  padding: 12px;
  box-shadow: var(--shadow);
  animation: cbMsgIn .3s cubic-bezier(.34,1.56,.64,1);
}
.cb-cal-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 10px;
}
.cb-cal-nav {
  width: 28px; height: 28px; border-radius: 50%;
  border: 1px solid #eee5d0; background: var(--cream);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; color: var(--gold-dark);
  transition: background .2s, color .2s;
}
.cb-cal-nav:hover { background: var(--gold-light); color: #fff; border-color: var(--gold-light); }
.cb-cal-nav.disabled { opacity: .3; pointer-events: none; }
.cb-cal-nav svg { width: 16px; height: 16px; }
.cb-cal-title { font-family: var(--heading); font-size: 13.5px; font-weight: 700; color: var(--dark); letter-spacing: .2px; }
.cb-cal-dow {
  display: grid; grid-template-columns: repeat(7, 1fr);
  margin-bottom: 4px;
}
.cb-cal-dow span {
  text-align: center; font-size: 9.5px; font-weight: 700;
  color: var(--text-light); text-transform: uppercase; letter-spacing: .04em;
}
.cb-cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 3px; }
.cb-cal-day {
  aspect-ratio: 1 / 1;
  display: flex; align-items: center; justify-content: center;
  border-radius: 8px; font-size: 12.5px; font-weight: 500; color: var(--dark);
  cursor: pointer; border: 1px solid transparent; background: none;
  transition: background .15s, color .15s, transform .15s;
}
.cb-cal-day.empty { visibility: hidden; pointer-events: none; }
.cb-cal-day:hover:not(.disabled):not(.empty):not(.selected) {
  background: rgba(182, 137, 47, .12); border-color: var(--gold-light);
}
.cb-cal-day.today:not(.selected) { font-weight: 700; color: var(--gold-dark); border-color: var(--gold-light); }
.cb-cal-day.selected {
  background: linear-gradient(135deg, var(--gold-light), var(--gold-dark));
  color: #fff; font-weight: 700;
  box-shadow: 0 4px 12px rgba(182, 137, 47, .4);
  transform: scale(1.04);
}
.cb-cal-day.disabled { color: #ddd2b3; cursor: not-allowed; }
.cb-cal-quick { display: flex; gap: 6px; margin-top: 12px; flex-wrap: wrap; }
.cb-cal-chip {
  padding: 6px 13px; border-radius: 20px;
  background: var(--cream); border: 1px solid #e6dcc0;
  font-size: 11.5px; font-weight: 600; color: var(--gold-dark);
  cursor: pointer; transition: background .15s, color .15s;
}
.cb-cal-chip:hover { background: var(--gold-light); color: #fff; border-color: var(--gold-light); }

.cb-input-send-row { display: flex; align-items: center; gap: 10px; }
.cb-field-wrap { flex: 1; position: relative; }
.cb-field {
  width: 100%;
  padding: 11px 36px 11px 14px;
  border-radius: 20px !important;
  border: 1.5px solid #ddd2b3;
  background: var(--cream);
  color: var(--dark);
  font-family: var(--sans);
  font-size: 14px;
  outline: none;
  transition: border-color .2s, background .2s;
}
.cb-field:focus { border-color: var(--gold); background: #fff; }
#cb-chat input::placeholder { color: var(--text-light); opacity: .8; }
.cb-field.err { border-color: #e74c3c; background: #fff8f8; }
.cb-field.ok { border-color: #4ecb71; }
.cb-f-icon { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); font-size: 13px; pointer-events: none; }
.cb-f-err { font-size: 11px; color: #e74c3c; padding: 0 4px; min-height: 14px; margin-top: 2px; }

.cb-send-btn {
  width: 40px; height: 40px; border-radius: 50%; flex-shrink: 0;
  background: linear-gradient(135deg, var(--gold-light), var(--gold-dark));
  border: none; cursor: pointer; padding: 0;
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
  box-shadow: 0 4px 14px rgba(182,137,47,.35);
  transition: transform .2s, box-shadow .2s;
}
.cb-send-btn svg { width: 17px; height: 17px; flex-shrink: 0; color: #fff; stroke: #fff; }
.cb-send-btn:hover { transform: scale(1.08); }
.cb-send-btn:active { transform: scale(.93); }

.cb-wa-cta {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  padding: 12px; border-radius: 20px;
  background: linear-gradient(135deg, #25D366, #128C4A);
  color: #fff; font-weight: 700; font-size: 13.5px;
  text-decoration: none; box-shadow: 0 4px 14px rgba(37,211,102,.3);
}
.cb-wa-cta svg { width: 17px; height: 17px; }

.cb-power {
  text-align: center; font-size: 10px; color: var(--text-light);
  padding: 6px 0 9px; letter-spacing: .05em; background: #fff; flex-shrink: 0;
}
.cb-power span { color: var(--gold-dark); font-weight: 600; }

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