/* =====================================================================
   CHATBOT WIDGET — Stylesheet
   Palette: Plum + Gold | Fonts: Fraunces (display) + Inter (body)
   ===================================================================== */

:root{
  --plum-950: #201220;
  --plum-800: #3a1f38;
  --plum-600: #6b2d5c;
  --plum-500: #8b3a62;
  --gold-500: #c9a227;
  --gold-400: #dcb94a;
  --paper: #f8f5fa;
  --paper-card: #ffffff;
  --ink: #241a2b;
  --ink-soft: #6f6478;
  --line: #e7dfea;
  --success: #3fae6f;
  --radius-lg: 22px;
  --radius-sm: 10px;
  --shadow-float: 0 18px 45px rgba(32, 18, 32, 0.28);
  --shadow-soft: 0 6px 18px rgba(32, 18, 32, 0.10);
  --font-display: "Fraunces", serif;
  --font-body: "Inter", sans-serif;
}

*{ box-sizing: border-box; }

/* ============ LAUNCHER BUTTON ============ */
.cb-launcher{
  position: fixed;
  right: 32px;
  bottom: 32px;
  width: 62px;
  height: 62px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  background: linear-gradient(150deg, var(--plum-600), var(--plum-950));
  box-shadow: var(--shadow-float);
  display:flex;
  align-items:center;
  justify-content:center;
  transition: transform .25s cubic-bezier(.34,1.56,.64,1), box-shadow .25s ease;
  z-index: 9998;
}
.cb-launcher:hover{ transform: scale(1.06) rotate(-4deg); }
.cb-launcher:active{ transform: scale(.94); }
.cb-launcher svg{ width: 26px; height: 26px; }
.cb-launcher .cb-dot{
  position:absolute;
  top: 6px;
  right: 6px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--gold-400);
  border: 2px solid var(--paper);
  animation: cb-pulse 2.2s infinite;
}
@keyframes cb-pulse{
  0%{ box-shadow: 0 0 0 0 rgba(220,185,74,.55); }
  70%{ box-shadow: 0 0 0 8px rgba(220,185,74,0); }
  100%{ box-shadow: 0 0 0 0 rgba(220,185,74,0); }
}

/* ============ CHAT WINDOW ============ */
.cb-window{
  position: fixed;
  right: 32px;
  bottom: 108px;
  width: 380px;
  max-width: calc(100vw - 40px);
  height: 560px;
  max-height: calc(100vh - 150px);
  background: var(--paper);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-float);
  display:flex;
  flex-direction:column;
  overflow:hidden;
  transform-origin: bottom right;
  transform: scale(.85) translateY(16px);
  opacity: 0;
  pointer-events: none;
  transition: transform .28s cubic-bezier(.2,.9,.3,1.2), opacity .2s ease;
  z-index: 9999;
  font-family: var(--font-body);
}
.cb-window.open{
  transform: scale(1) translateY(0);
  opacity: 1;
  pointer-events: auto;
}

/* ---- header ---- */
.cb-header{
  background: linear-gradient(135deg, var(--plum-600) 0%, var(--plum-950) 100%);
  color: #fff;
  padding: 18px 20px;
  display:flex;
  align-items:center;
  gap: 12px;
  position: relative;
  flex-shrink: 0;
}
.cb-header::after{
  content:"";
  position:absolute;
  left:0; right:0; bottom:-1px;
  height: 14px;
  background: var(--paper);
  border-radius: 14px 14px 0 0;
}
.cb-avatar{
  width: 38px; height: 38px;
  border-radius: 50%;
  background: var(--gold-400);
  display:flex; align-items:center; justify-content:center;
  color: var(--plum-950);
  font-family: var(--font-display);
  font-weight: 600;
  flex-shrink:0;
}
.cb-header-text h3{
  margin:0; font-family: var(--font-display); font-weight:600; font-size: 17px; letter-spacing: .2px;
}
.cb-header-text p{
  margin: 2px 0 0; font-size: 12px; color: rgba(255,255,255,.75); display:flex; align-items:center; gap:6px;
}
.cb-status-dot{ width:7px; height:7px; border-radius:50%; background: var(--success); display:inline-block; }
.cb-close{
  margin-left:auto; background: rgba(255,255,255,.12); border:none; color:#fff;
  width: 30px; height: 30px; border-radius: 50%; cursor:pointer;
  display:flex; align-items:center; justify-content:center;
  transition: background .2s;
}
.cb-close:hover{ background: rgba(255,255,255,.24); }

/* ---- messages ---- */
.cb-messages{
  flex: 1;
  overflow-y: auto;
  padding: 22px 16px 10px;
  display:flex;
  flex-direction:column;
  gap: 12px;
  scroll-behavior: smooth;
}
.cb-messages::-webkit-scrollbar{ width: 6px; }
.cb-messages::-webkit-scrollbar-thumb{ background: var(--line); border-radius: 4px; }

.cb-row{ display:flex; gap:8px; max-width: 88%; animation: cb-rise .25s ease; }
@keyframes cb-rise{ from{ opacity:0; transform: translateY(6px);} to{opacity:1; transform:translateY(0);} }

.cb-row.bot{ align-self:flex-start; }
.cb-row.user{ align-self:flex-end; flex-direction: row-reverse; }

.cb-bubble{
  padding: 10px 14px;
  font-size: 14px;
  line-height: 1.5;
  color: var(--ink);
}
.cb-row.bot .cb-bubble{
  background: var(--paper-card);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm) var(--radius-sm) var(--radius-sm) 3px;
  box-shadow: var(--shadow-soft);
}
.cb-row.user .cb-bubble{
  background: linear-gradient(135deg, var(--plum-500), var(--plum-600));
  color: #fff;
  border-radius: var(--radius-sm) var(--radius-sm) 3px var(--radius-sm);
}
.cb-mini-avatar{
  width: 26px; height: 26px; border-radius: 50%;
  flex-shrink:0;
  display:flex; align-items:center; justify-content:center;
  font-family: var(--font-display); font-weight:600; font-size: 12px;
}
.cb-row.bot .cb-mini-avatar{ background: var(--gold-400); color: var(--plum-950); }
.cb-row.user .cb-mini-avatar{ background: var(--plum-800); color: #fff; }

.cb-time{ font-size: 10px; color: var(--ink-soft); margin-top: 4px; }
.cb-row.user .cb-time{ text-align: right; }

/* ---- typing indicator (brand colored) ---- */
.cb-typing{
  display:flex; gap:5px; padding: 12px 16px;
  background: var(--paper-card); border:1px solid var(--line);
  border-radius: var(--radius-sm) var(--radius-sm) var(--radius-sm) 3px;
  box-shadow: var(--shadow-soft);
  width: fit-content;
}
.cb-typing span{
  width:6px; height:6px; border-radius:50%;
  background: var(--plum-500);
  animation: cb-bounce 1.2s infinite ease-in-out;
}
.cb-typing span:nth-child(2){ animation-delay: .15s; }
.cb-typing span:nth-child(3){ animation-delay: .3s; }
@keyframes cb-bounce{
  0%,60%,100%{ transform: translateY(0); opacity:.45; }
  30%{ transform: translateY(-5px); opacity:1; }
}

/* ---- call / whatsapp action buttons ---- */
.cb-actions{
  display:flex; gap: 8px; padding: 4px 16px 6px;
}
.cb-action-btn{
  flex: 1;
  display:flex; align-items:center; justify-content:center; gap: 7px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  color: var(--ink);
  text-decoration: none;
  cursor: pointer;
  transition: transform .15s ease, box-shadow .15s ease, border-color .15s ease;
}
.cb-action-btn:hover{
  transform: translateY(-1px);
  box-shadow: var(--shadow-soft);
  border-color: var(--plum-500);
}
.cb-action-icon{
  width: 26px; height: 26px; border-radius: 50%;
  display:flex; align-items:center; justify-content:center;
  flex-shrink: 0;
}
.cb-action-call{ background: rgba(139,58,98,.12); color: var(--plum-600); }
.cb-action-email{ background: rgba(220,185,74,.18); color: var(--gold-500); }

/* ---- quick replies ---- */
.cb-quick{
  display:flex; flex-wrap:wrap; gap: 8px; padding: 4px 16px 14px;
}
.cb-chip{
  border: 1px solid var(--plum-500);
  color: var(--plum-600);
  background: #fff;
  font-size: 12.5px;
  padding: 7px 12px;
  border-radius: 999px;
  cursor: pointer;
  transition: background .18s, color .18s;
  font-family: var(--font-body);
}
.cb-chip:hover{ background: var(--plum-600); color: #fff; }

/* ---- input bar ---- */
.cb-inputbar{
  display:flex; align-items:center; gap: 8px;
  padding: 12px 14px;
  background: var(--paper-card);
  border-top: 1px solid var(--line);
  flex-shrink:0;
}
.cb-inputbar input{
  flex:1;
  border: 1px solid var(--line);
  background: var(--paper);
  border-radius: 999px;
  padding: 11px 16px;
  font-size: 14px;
  font-family: var(--font-body);
  color: var(--ink);
  outline: none;
  transition: border-color .18s, box-shadow .18s;
}
.cb-inputbar input:focus{
  border-color: var(--plum-500);
  box-shadow: 0 0 0 3px rgba(139,58,98,.14);
}
.cb-send{
  width: 42px; height: 42px; flex-shrink:0;
  border-radius: 50%;
  border:none;
  background: linear-gradient(135deg, var(--gold-400), var(--gold-500));
  color: var(--plum-950);
  display:flex; align-items:center; justify-content:center;
  cursor:pointer;
  transition: transform .15s ease;
}
.cb-send:hover{ transform: scale(1.07); }
.cb-send:active{ transform: scale(.92); }
.cb-send svg{ width:18px; height:18px; transform: translateX(-1px); }
.cb-send:disabled{ opacity:.5; cursor:not-allowed; transform:none; }

.cb-footer-note{
  text-align:center; font-size: 10.5px; color: var(--ink-soft); padding: 6px 0 12px;
  font-family: var(--font-body);
}

@media (max-width: 480px){
  .cb-window{ width: calc(100vw - 24px); right: 12px; bottom: 92px; height: calc(100vh - 130px); }
  .cb-launcher{ right: 18px; bottom: 18px; }
}

@media (prefers-reduced-motion: reduce){
  .cb-launcher, .cb-window, .cb-row, .cb-dot, .cb-typing span{ animation: none !important; transition: none !important; }
}