/* ============================================================
   Disenis AI Chat Widget
   ============================================================ */

/* ── Toggle button ───────────────────────────────────────────── */
/* AI chat sits to the LEFT of the WhatsApp circle with a 12px gap.
   WhatsApp is 64px wide at right:24px, so AI chat offset = 24 + 64 + 12 = 100px. */
.dc-widget {
  position: fixed;
  bottom: 24px;
  right: 100px;
  z-index: 99999;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Helvetica Neue', Arial, sans-serif;
}

.dc-toggle {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(135deg, #ff2d78 0%, #e8344e 100%);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 8px 28px rgba(255, 45, 120, .5);
  transition: transform .2s, box-shadow .2s;
  position: relative;
}
.dc-toggle:hover {
  transform: scale(1.08);
  box-shadow: 0 10px 34px rgba(255, 45, 120, .6);
}
.dc-toggle.is-open .dc-icon-chat { display: none; }
.dc-toggle.is-open .dc-icon-close { display: block !important; }
.dc-toggle.is-open .dc-toggle-badge,
.dc-toggle.is-open .dc-toggle-pulse { display: none; }

/* "IA" badge on toggle button — hidden per client request */
.dc-toggle-badge { display: none !important; }

/* Pulsing ring DISABLED — the WhatsApp FAB next to this widget is the one that pulses now. */
.dc-toggle-pulse {
  display: none;
}
@keyframes dcPulse {
  0%   { transform: scale(1); opacity: .6; }
  70%  { transform: scale(1.6); opacity: 0; }
  100% { transform: scale(1.6); opacity: 0; }
}

/* Greeting bubble above toggle — shows on first load */
.dc-greet-bubble {
  position: fixed;
  bottom: 100px;
  right: 100px;
  background: #fff;
  color: #1d1d1f;
  padding: 14px 44px 14px 18px;
  border-radius: 16px;
  box-shadow: 0 8px 28px rgba(0, 0, 0, .12), 0 0 0 1px rgba(0, 0, 0, .04);
  width: 260px;
  max-width: calc(100vw - 120px);
  white-space: normal;
  font-size: 13px;
  line-height: 1.45;
  animation: dcGreetIn .5s cubic-bezier(.16,1,.3,1) .8s both;
  display: none;
  z-index: 100000;
}
.dc-greet-bubble.is-visible { display: block; }
.dc-greet-bubble::after {
  content: '';
  position: absolute;
  bottom: -8px;
  right: 22px;
  width: 16px;
  height: 16px;
  background: #fff;
  transform: rotate(45deg);
  box-shadow: 2px 2px 6px rgba(0, 0, 0, .04);
}
.dc-greet-text { display: block; }
.dc-greet-text strong { display: block; margin-bottom: 3px; color: #ff2d78; font-weight: 700; font-size: 14px; }
.dc-greet-close {
  position: absolute;
  top: 6px;
  right: 8px;
  background: transparent;
  border: none;
  color: #86868b;
  font-size: 18px;
  cursor: pointer;
  padding: 2px 6px;
  line-height: 1;
}
.dc-greet-close:hover { color: #1d1d1f; }

@keyframes dcGreetIn {
  from { opacity: 0; transform: translateY(10px) scale(.95); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* Footer note inside chat */
.dc-footer-note {
  padding: 10px 16px;
  background: #f5f5f7;
  font-size: 11px;
  color: #86868b;
  text-align: center;
  border-top: 1px solid #e5e5ea;
  line-height: 1.5;
}
.dc-footer-note a {
  color: #ff2d78;
  font-weight: 600;
  text-decoration: none;
}

/* Persistent "Hablar con persona" link — always visible above input */
.dc-handoff-link-wrap {
  text-align: center;
  padding: 6px 16px 0;
  background: #fff;
  border-top: 1px solid #e5e5ea;
}
.dc-handoff-link {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: #86868b;
  font-size: 11px;
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
  transition: color .15s;
  padding: 2px 0;
}
.dc-handoff-link:hover {
  color: #25d366;
  text-decoration: underline;
}
.dc-handoff-link svg {
  width: 12px;
  height: 12px;
  flex-shrink: 0;
}
/* When the persistent link is present, the input-wrap no longer needs its own top border */
.dc-handoff-link-wrap + .dc-input-wrap {
  border-top: none;
  padding-top: 8px;
}

/* ── Chat panel ──────────────────────────────────────────────── */
.dc-panel {
  position: absolute;
  bottom: 72px;
  right: 0;
  width: 440px;
  max-height: 680px;
  background: #fff;
  border-radius: 20px;
  box-shadow: 0 12px 48px rgba(0, 0, 0, .15), 0 0 0 1px rgba(0, 0, 0, .05);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: dcSlideUp .3s ease;
}

@keyframes dcSlideUp {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Header ──────────────────────────────────────────────────── */
.dc-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  background: #1d1d1f;
  color: #fff;
}

.dc-header-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

.dc-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: #ff2d78;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  font-weight: 700;
}

.dc-header-title {
  font-size: 15px;
  font-weight: 600;
}

.dc-header-status {
  font-size: 11px;
  color: #86868b;
  display: flex;
  align-items: center;
  gap: 4px;
}
.dc-header-status::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #34c759;
  display: inline-block;
}

.dc-header-close {
  border: none;
  background: transparent !important;
  color: #86868b;
  font-size: 24px;
  cursor: pointer;
  padding: 4px;
  line-height: 1;
  transition: color .2s;
  -webkit-appearance: none;
  border-radius: 0;
}
.dc-header-close:hover { color: #fff; }

/* WhatsApp quick-action in chat header */
.dc-header-wa {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #25d366;
  color: #fff;
  text-decoration: none;
  transition: transform .15s, box-shadow .15s;
  box-shadow: 0 2px 8px rgba(37, 211, 102, .4);
}
.dc-header-wa:hover {
  transform: scale(1.1);
  box-shadow: 0 4px 14px rgba(37, 211, 102, .55);
  color: #fff;
}

/* ── Messages area ───────────────────────────────────────────── */
.dc-messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 400px;
  max-height: 500px;
  background: #f5f5f7;
}

/* ── Message bubbles ─────────────────────────────────────────── */
.dc-msg {
  display: flex;
  max-width: 85%;
}

.dc-msg-bot {
  align-self: flex-start;
}

.dc-msg-user {
  align-self: flex-end;
}

.dc-msg-bubble {
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 14px;
  line-height: 1.5;
  word-wrap: break-word;
}

.dc-msg-bot .dc-msg-bubble {
  background: #fff;
  color: #1d1d1f;
  border-bottom-left-radius: 4px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .06);
}

.dc-msg-user .dc-msg-bubble {
  background: #ff2d78;
  color: #fff;
  border-bottom-right-radius: 4px;
}

/* Links in bot messages */
.dc-msg-bot .dc-msg-bubble a {
  color: #ff2d78;
  text-decoration: none;
  font-weight: 600;
}
.dc-msg-bot .dc-msg-bubble a:hover {
  text-decoration: underline;
}

/* Bold text */
.dc-msg-bot .dc-msg-bubble strong {
  font-weight: 700;
  color: #1d1d1f;
}

/* WhatsApp handoff button — shown when assistant transfers to a human */
.dc-msg-bot .dc-msg-bubble a.dc-handoff-btn {
  display: inline-flex !important;
  align-items: center;
  gap: 8px;
  margin: 10px 0 2px;
  padding: 10px 16px;
  background: #25d366 !important;
  color: #fff !important;
  font-weight: 700 !important;
  font-size: 13px;
  text-decoration: none !important;
  border-radius: 100px;
  box-shadow: 0 3px 12px rgba(37, 211, 102, .35);
  transition: transform .15s, box-shadow .15s;
}
.dc-msg-bot .dc-msg-bubble a.dc-handoff-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 5px 16px rgba(37, 211, 102, .5);
  text-decoration: none !important;
}
.dc-msg-bot .dc-msg-bubble a.dc-handoff-btn svg {
  width: 18px;
  height: 18px;
  color: #fff;
}

/* ── Inline lead form (rendered by [LEAD_FORM] marker) ───── */
.dc-msg-bot .dc-msg-bubble .dc-lead-form {
  display: flex !important;
  flex-direction: column;
  gap: 8px;
  margin: 10px 0 4px;
  padding: 14px;
  background: #f5f5f7;
  border-radius: 12px;
  border: 1px solid #e5e5ea;
}
.dc-lead-form .dc-lead-title {
  font-size: 13px;
  font-weight: 700;
  color: #1d1d1f;
  margin-bottom: 4px;
  line-height: 1.3;
}
.dc-lead-form input[type="text"],
.dc-lead-form input[type="email"],
.dc-lead-form input[type="tel"] {
  width: 100%;
  box-sizing: border-box;
  padding: 10px 12px;
  border: 1px solid #d2d2d7;
  border-radius: 8px;
  background: #fff;
  font-family: inherit;
  font-size: 14px; /* 14+ prevents iOS auto-zoom */
  color: #1d1d1f;
  outline: none;
  transition: border-color .15s;
}
.dc-lead-form input:focus {
  border-color: #ff2d78;
}
.dc-lead-form input::placeholder {
  color: #aeaeb2;
}
/* Honeypot — hidden from humans, visible to bots */
.dc-lead-form .dc-lead-hp {
  position: absolute !important;
  left: -9999px !important;
  opacity: 0 !important;
  pointer-events: none !important;
  height: 0 !important;
  width: 0 !important;
}
.dc-lead-form .dc-lead-submit {
  margin-top: 2px;
  padding: 11px 16px;
  border: none;
  border-radius: 8px;
  background: #ff2d78;
  color: #fff;
  font-family: inherit;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: background .15s, transform .1s;
}
.dc-lead-form .dc-lead-submit:hover:not(:disabled) {
  background: #e8205e;
}
.dc-lead-form .dc-lead-submit:disabled {
  background: #86868b;
  cursor: not-allowed;
}
.dc-lead-form .dc-lead-status {
  min-height: 0;
  font-size: 12px;
  color: #ff3b30;
  text-align: center;
  line-height: 1.4;
}
.dc-lead-form .dc-lead-status.is-error {
  min-height: 16px;
}

/* Product thumbnails injected by inject_images() — compact 56px so they don't dominate the chat.
   Exclude WordPress Twemoji (.wp-smiley / .emoji) so emoji stay inline-sized. */
.dc-msg-bot .dc-msg-bubble img.dc-prod-thumb,
.dc-msg-bot .dc-msg-bubble img:not(.wp-smiley):not(.emoji) {
  width: 56px !important;
  height: 56px !important;
  object-fit: contain !important;
  border-radius: 8px !important;
  background: #fff !important;
  border: 1px solid #e5e5ea !important;
  display: block !important;
  margin: 6px 0 2px !important;
  padding: 4px !important;
}
/* WordPress emoji images — keep them inline and small */
.dc-msg-bot .dc-msg-bubble img.wp-smiley,
.dc-msg-bot .dc-msg-bubble img.emoji {
  display: inline !important;
  width: 1em !important;
  height: 1em !important;
  margin: 0 .075em 0 .1em !important;
  padding: 0 !important;
  background: transparent !important;
  border: none !important;
  border-radius: 0 !important;
  box-shadow: none !important;
  vertical-align: -.1em !important;
}

/* ── Typing indicator ────────────────────────────────────────── */
.dc-typing {
  display: flex;
  gap: 4px;
  padding: 12px 16px;
  align-self: flex-start;
}

.dc-typing span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #c7c7cc;
  animation: dcBounce 1.4s infinite ease-in-out both;
}
.dc-typing span:nth-child(1) { animation-delay: -.32s; }
.dc-typing span:nth-child(2) { animation-delay: -.16s; }

@keyframes dcBounce {
  0%, 80%, 100% { transform: scale(0); }
  40% { transform: scale(1); }
}

/* ── Input area ──────────────────────────────────────────────── */
.dc-input-wrap {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid #e5e5ea;
  background: #fff;
}

.dc-input {
  flex: 1;
  border: none;
  outline: none;
  font-family: inherit;
  font-size: 14px;
  color: #1d1d1f;
  resize: none;
  max-height: 80px;
  line-height: 1.4;
  padding: 8px 0;
}
.dc-input::placeholder { color: #aeaeb2; }

.dc-send {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: #ff2d78;
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: opacity .2s, transform .15s;
}
.dc-send:disabled {
  opacity: .3;
  cursor: not-allowed;
}
.dc-send:not(:disabled):hover {
  transform: scale(1.08);
}

/* ── Responsive ──────────────────────────────────────────────── */
@media (max-width: 768px) {
  .dh-wa {
    display: none !important;
  }
  /* Mobile: AI circle sits 12px to the left of the 48px WhatsApp circle (16 + 48 + 12 = 76px). */
  .dc-widget {
    bottom: 16px !important;
    right: 76px !important;
    left: auto !important;
  }
  .dc-toggle {
    width: 48px;
    height: 48px;
  }
  .dc-greet-bubble {
    bottom: 76px;
    right: 76px;
    width: 220px;
  }
  .dc-panel {
    position: fixed !important;
    top: auto !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    width: 100% !important;
    max-height: 60vh !important;
    border-radius: 16px 16px 0 0 !important;
    z-index: 100001 !important;
    box-shadow: 0 -8px 40px rgba(0,0,0,.2) !important;
  }
  .dc-messages {
    min-height: 0 !important;
    max-height: none !important;
    flex: 1 !important;
    padding: 14px 12px !important;
  }
  .dc-msg-bubble {
    font-size: 13px !important;
  }
  .dc-msg-bot .dc-msg-bubble img.dc-prod-thumb,
  .dc-msg-bot .dc-msg-bubble img:not(.wp-smiley):not(.emoji) {
    width: 48px !important;
    height: 48px !important;
  }
  .dc-header {
    padding: 12px 16px;
    border-radius: 16px 16px 0 0;
  }
  .dc-input-wrap {
    padding: 10px 12px;
    padding-bottom: max(10px, env(safe-area-inset-bottom));
  }
  .dc-input {
    font-size: 14px !important;
    padding: 6px 0 !important;
  }
}

/* ── Scrollbar ───────────────────────────────────────────────── */
.dc-messages::-webkit-scrollbar { width: 4px; }
.dc-messages::-webkit-scrollbar-track { background: transparent; }
.dc-messages::-webkit-scrollbar-thumb { background: #d2d2d7; border-radius: 2px; }
#hubspot-messages-iframe-container, .widget-visible, #hs-chat-open, #hubspot-conversations-inline-parent, #hubspot-conversations-inline-iframe, [data-hubspot-rendered], iframe[src*="hubspot"], .hs-messages-widget-open, .shadow-container { display: none !important; visibility: hidden !important; }

/* ── Suggestion buttons ──────────────────────────────────────── */
.dc-suggestions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.dc-suggest-btn { background: #fff; border: 1.5px solid #e5e5ea; border-radius: 20px; padding: 6px 14px; font-size: 13px; font-weight: 500; color: #1d1d1f; cursor: pointer; transition: all .2s; white-space: nowrap; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; }
.dc-suggest-btn:hover { border-color: #ff2d78; color: #ff2d78; background: #fff5f8; }
