/* === Casa X Chat Widget · custom · sin dependencias === */
:root {
  --cx-wine: #8b1f33;
  --cx-gold: #c9a35c;
  --cx-cream: #faf7f2;
  --cx-ink: #1a1a1a;
  --cx-ink-2: #555;
  --cx-line: #e5e5dc;
  --cx-shadow: 0 8px 32px rgba(0,0,0,0.18);
}

#cxc-bubble, #cxc-window {
  font-family: -apple-system, BlinkMacSystemFont, 'Inter', 'Helvetica Neue', sans-serif;
  box-sizing: border-box;
}
#cxc-bubble *, #cxc-window * { box-sizing: border-box; }

/* Bubble flotante */
#cxc-bubble {
  position: fixed;
  bottom: 24px; right: 24px;
  width: 60px; height: 60px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--cx-wine), #5d1422);
  color: #fff;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--cx-shadow);
  z-index: 9998;
  transition: transform .2s, box-shadow .2s;
}
#cxc-bubble:hover { transform: scale(1.05); box-shadow: 0 12px 40px rgba(139,31,51,0.4); }
#cxc-bubble svg { width: 28px; height: 28px; }
#cxc-bubble .cxc-pulse {
  position: absolute;
  inset: -4px;
  border: 2px solid var(--cx-wine);
  border-radius: 50%;
  opacity: 0.6;
  animation: cxc-pulse 2s ease-out infinite;
}
@keyframes cxc-pulse {
  0% { transform: scale(0.95); opacity: 0.7; }
  100% { transform: scale(1.4); opacity: 0; }
}
#cxc-bubble.open { background: var(--cx-ink); }
#cxc-bubble.open .cxc-pulse { display: none; }

/* Ventana del chat */
#cxc-window {
  position: fixed;
  bottom: 100px; right: 24px;
  width: 380px;
  max-width: calc(100vw - 32px);
  height: 600px;
  max-height: calc(100vh - 130px);
  background: #fff;
  border-radius: 16px;
  box-shadow: var(--cx-shadow);
  z-index: 9999;
  display: none;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--cx-line);
  animation: cxc-pop .2s ease-out;
}
#cxc-window.open { display: flex; }
@keyframes cxc-pop {
  from { opacity: 0; transform: translateY(20px) scale(0.96); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

/* Header */
.cxc-header {
  background: linear-gradient(135deg, var(--cx-wine), #5d1422);
  color: #fff;
  padding: 16px 18px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.cxc-avatar {
  width: 38px; height: 38px;
  border-radius: 50%;
  background: rgba(255,255,255,0.15);
  display: flex; align-items: center; justify-content: center;
  font-family: 'Instrument Serif', Georgia, serif;
  font-size: 22px; font-style: italic;
  color: var(--cx-gold);
  border: 1px solid rgba(255,255,255,0.2);
}
.cxc-headerInfo { flex: 1; }
.cxc-title {
  font-family: 'Instrument Serif', Georgia, serif;
  font-size: 19px;
  font-weight: 500;
  letter-spacing: 0.3px;
}
.cxc-subtitle {
  font-size: 11px;
  opacity: 0.8;
  margin-top: 2px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.cxc-subtitle .cxc-dot {
  width: 7px; height: 7px;
  background: #4ade80;
  border-radius: 50%;
  display: inline-block;
}
.cxc-close {
  background: none; border: none;
  color: #fff; cursor: pointer;
  width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%;
  opacity: 0.7;
}
.cxc-close:hover { opacity: 1; background: rgba(255,255,255,0.1); }

/* Messages */
.cxc-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  background: var(--cx-cream);
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.cxc-msg {
  max-width: 85%;
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 14px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-wrap: break-word;
}
.cxc-msg.bot {
  background: #fff;
  color: var(--cx-ink);
  border: 1px solid var(--cx-line);
  align-self: flex-start;
  border-bottom-left-radius: 4px;
}
.cxc-msg.user {
  background: var(--cx-wine);
  color: #fff;
  align-self: flex-end;
  border-bottom-right-radius: 4px;
}
.cxc-typing {
  align-self: flex-start;
  padding: 10px 14px;
  background: #fff;
  border: 1px solid var(--cx-line);
  border-radius: 14px;
  border-bottom-left-radius: 4px;
  display: inline-flex;
  gap: 3px;
}
.cxc-typing span {
  width: 6px; height: 6px;
  background: var(--cx-ink-2);
  border-radius: 50%;
  animation: cxc-bounce 1.4s ease-in-out infinite both;
}
.cxc-typing span:nth-child(1) { animation-delay: -0.32s; }
.cxc-typing span:nth-child(2) { animation-delay: -0.16s; }
@keyframes cxc-bounce {
  0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
  40% { transform: scale(1); opacity: 1; }
}

/* Quick replies (welcome chips) */
.cxc-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 6px;
  align-self: flex-start;
  max-width: 100%;
}
.cxc-chip {
  background: #fff;
  border: 1px solid var(--cx-gold);
  color: var(--cx-wine);
  padding: 7px 12px;
  border-radius: 20px;
  font-size: 13px;
  cursor: pointer;
  transition: background .15s;
  font-weight: 500;
}
.cxc-chip:hover { background: var(--cx-gold); color: #fff; }

/* WhatsApp + Lead capture buttons */
.cxc-actionBtns {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 4px;
}
.cxc-actionBtn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 14px;
  border-radius: 100px;
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  border: none;
  cursor: pointer;
}
.cxc-actionBtn.wa {
  background: #25d366;
  color: #fff;
}
.cxc-actionBtn.lead {
  background: var(--cx-wine);
  color: #fff;
}

/* Lead form */
.cxc-leadForm {
  padding: 16px;
  background: #fff;
  border-top: 1px solid var(--cx-line);
  border-radius: 12px;
  margin: 6px 0;
  display: none;
}
.cxc-leadForm.show { display: block; }
.cxc-leadForm h4 {
  margin: 0 0 12px;
  font-family: 'Instrument Serif', Georgia, serif;
  font-size: 17px;
  font-weight: 500;
  color: var(--cx-wine);
}
.cxc-leadForm label {
  display: block;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--cx-ink-2);
  margin: 8px 0 4px;
  font-weight: 600;
}
.cxc-leadForm input, .cxc-leadForm select {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--cx-line);
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
  background: #fff;
  outline: none;
}
.cxc-leadForm input:focus, .cxc-leadForm select:focus { border-color: var(--cx-gold); }
.cxc-leadForm button {
  width: 100%;
  margin-top: 12px;
  padding: 10px;
  background: var(--cx-wine);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}
.cxc-leadForm button:disabled { opacity: 0.5; cursor: wait; }
.cxc-leadForm .cxc-formErr {
  color: #dc2626;
  font-size: 12px;
  margin-top: 8px;
}

/* Composer */
.cxc-composer {
  padding: 12px 14px;
  background: #fff;
  border-top: 1px solid var(--cx-line);
  display: flex;
  gap: 8px;
  align-items: center;
}
.cxc-composer input {
  flex: 1;
  border: 1px solid var(--cx-line);
  background: var(--cx-cream);
  padding: 10px 14px;
  border-radius: 100px;
  font-size: 14px;
  font-family: inherit;
  outline: none;
}
.cxc-composer input:focus { border-color: var(--cx-gold); }
.cxc-composer button {
  width: 38px; height: 38px;
  background: var(--cx-wine);
  border: none;
  border-radius: 50%;
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.cxc-composer button:disabled { opacity: 0.4; cursor: not-allowed; }
.cxc-composer button svg { width: 18px; height: 18px; }

/* Mobile */
@media (max-width: 640px) {
  #cxc-window {
    bottom: 0;
    right: 0;
    width: 100vw;
    max-width: 100vw;
    height: 100vh;
    max-height: 100vh;
    border-radius: 0;
  }
  #cxc-bubble {
    bottom: 16px; right: 16px;
    width: 56px; height: 56px;
  }
}
