/* Adi — Susurro Dorado · widget styles
   Brandbook: charcoal #3d3d3d + gold #d4a843 (accent-500)
   DM Serif Display (H1/H2 only) + DM Sans (UI/body) — already loaded by site */

:root {
  --adi-gold: #d4a843;
  --adi-gold-soft: rgba(212, 168, 67, 0.4);
  --adi-charcoal: #3d3d3d;
  --adi-cream: hsl(42, 30%, 96%);
  --adi-shadow: 0 8px 24px hsla(40, 10%, 10%, 0.18);
  --adi-radius: 1.25rem;
}

/* ── Susurro: la partícula gold flotante ────────────────────────────────── */
.adi-whisper {
  position: fixed;
  bottom: 1.5rem;
  left: 1.5rem;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--adi-gold) 0%, #b88a30 100%);
  box-shadow: 0 4px 12px var(--adi-gold-soft);
  z-index: 60;
  cursor: pointer;
  display: none; /* shown by adi.js after trigger */
  align-items: center;
  justify-content: center;
  border: none;
  padding: 0;
  font-family: inherit;
  transition: transform 0.3s cubic-bezier(0.22, 1, 0.36, 1), box-shadow 0.3s;
  animation: adi-whisper-pulse 3.2s ease-in-out infinite;
}
.adi-whisper.adi-whisper--ready { display: flex; }

.adi-whisper::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 2px solid var(--adi-gold);
  animation: adi-whisper-ring 4s cubic-bezier(0.22, 1, 0.36, 1) 1.5s infinite;
  pointer-events: none;
}

.adi-whisper:hover {
  transform: scale(1.08);
  box-shadow: 0 8px 24px rgba(212, 168, 67, 0.55);
}

.adi-whisper svg {
  width: 26px;
  height: 26px;
  fill: white;
  position: relative;
  z-index: 1;
}

.adi-whisper-tooltip {
  position: absolute;
  left: calc(100% + 12px);
  top: 50%;
  transform: translateY(-50%);
  background: var(--adi-charcoal);
  color: var(--adi-cream);
  padding: 0.5rem 0.875rem;
  border-radius: 0.75rem;
  font-family: 'DM Sans', system-ui, sans-serif;
  font-size: 0.875rem;
  font-weight: 400;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  box-shadow: var(--adi-shadow);
}
.adi-whisper:hover .adi-whisper-tooltip,
.adi-whisper:focus .adi-whisper-tooltip {
  opacity: 1;
  transform: translateY(-50%) translateX(4px);
}

@keyframes adi-whisper-pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.06); }
}
@keyframes adi-whisper-ring {
  0% { transform: scale(1); opacity: 0.5; }
  100% { transform: scale(1.7); opacity: 0; }
}

/* ── Panel: chat container ──────────────────────────────────────────────── */
.adi-panel {
  position: fixed;
  bottom: 1.5rem;
  left: 1.5rem;
  width: 380px;
  height: min(600px, calc(100vh - 3rem));
  background: var(--adi-cream);
  border-radius: var(--adi-radius);
  box-shadow: var(--adi-shadow);
  z-index: 61;
  display: none;
  flex-direction: column;
  overflow: hidden;
  font-family: 'DM Sans', system-ui, sans-serif;
  color: var(--adi-charcoal);
  transform-origin: bottom left;
}
.adi-panel.adi-panel--open { display: flex; }

.adi-panel-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1rem 1.25rem;
  background: var(--adi-charcoal);
  color: var(--adi-cream);
  border-bottom: 1px solid hsla(0, 0%, 0%, 0.06);
}
.adi-panel-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--adi-gold) 0%, #b88a30 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 700;
  font-size: 1rem;
  flex: none;
}
.adi-panel-title {
  flex: 1;
  display: flex;
  flex-direction: column;
}
.adi-panel-title strong { font-weight: 700; font-size: 0.95rem; }
.adi-panel-title span { font-size: 0.75rem; opacity: 0.7; }
.adi-panel-close {
  background: transparent;
  border: none;
  color: var(--adi-cream);
  cursor: pointer;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 0.5rem;
  transition: background 0.2s;
}
.adi-panel-close:hover { background: hsla(0, 0%, 100%, 0.1); }

.adi-panel-messages {
  flex: 1;
  overflow-y: auto;
  padding: 1rem 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  scrollbar-width: thin;
}

.adi-msg {
  max-width: 85%;
  padding: 0.625rem 0.875rem;
  border-radius: 1rem;
  font-size: 0.9rem;
  line-height: 1.5;
  word-wrap: break-word;
  white-space: pre-wrap;
}
.adi-msg--assistant {
  background: white;
  border: 1px solid hsla(0, 0%, 0%, 0.08);
  align-self: flex-start;
  border-bottom-left-radius: 0.25rem;
}
.adi-msg--user {
  background: var(--adi-charcoal);
  color: var(--adi-cream);
  align-self: flex-end;
  border-bottom-right-radius: 0.25rem;
}
.adi-msg a {
  color: var(--adi-gold);
  text-decoration: underline;
}
.adi-msg--user a { color: var(--adi-gold); }

/* ── Contact mini-form (appears inline after first exchange) ────────────── */
.adi-contact-card {
  background: white;
  border: 1px solid var(--adi-gold);
  border-radius: 1rem;
  padding: 0.875rem 1rem;
  margin: 0.5rem 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  align-self: stretch;
  box-shadow: 0 2px 6px rgba(212, 168, 67, 0.18);
}
.adi-contact-headline {
  margin: 0;
  font-weight: 700;
  font-size: 0.92rem;
  color: var(--adi-charcoal);
  line-height: 1.3;
}
.adi-contact-sub {
  margin: 0 0 0.25rem;
  font-size: 0.78rem;
  color: hsla(0, 0%, 0%, 0.6);
  line-height: 1.4;
}
.adi-contact-sub strong {
  color: var(--adi-charcoal);
  font-weight: 700;
}
.adi-contact-card input {
  border: 1px solid hsla(0, 0%, 0%, 0.15);
  border-radius: 0.5rem;
  padding: 0.5rem 0.7rem;
  font-family: inherit;
  font-size: 0.88rem;
  background: var(--adi-cream);
  color: var(--adi-charcoal);
  outline: none;
  transition: border-color 0.2s;
}
.adi-contact-card input:focus { border-color: var(--adi-gold); }
.adi-contact-error {
  margin: 0;
  color: #b94545;
  font-size: 0.78rem;
}
.adi-contact-actions {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  margin-top: 0.25rem;
}
.adi-contact-skip {
  background: transparent;
  border: none;
  color: hsla(0, 0%, 0%, 0.55);
  font-family: inherit;
  font-size: 0.82rem;
  cursor: pointer;
  text-decoration: underline;
  padding: 0.4rem 0.5rem;
}
.adi-contact-skip:hover { color: var(--adi-charcoal); }
.adi-contact-save {
  background: var(--adi-charcoal);
  color: white;
  border: none;
  border-radius: 0.5rem;
  padding: 0.5rem 1rem;
  font-family: inherit;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
}
.adi-contact-save:hover { background: #555; }

.adi-msg--typing {
  display: inline-flex;
  gap: 4px;
  padding: 0.875rem;
}
.adi-msg--typing span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--adi-charcoal);
  opacity: 0.4;
  animation: adi-typing 1.2s ease-in-out infinite;
}
.adi-msg--typing span:nth-child(2) { animation-delay: 0.15s; }
.adi-msg--typing span:nth-child(3) { animation-delay: 0.3s; }
@keyframes adi-typing {
  0%, 60%, 100% { opacity: 0.3; transform: translateY(0); }
  30% { opacity: 1; transform: translateY(-4px); }
}

.adi-panel-input {
  display: flex;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  border-top: 1px solid hsla(0, 0%, 0%, 0.08);
  background: white;
}
.adi-panel-input textarea {
  flex: 1;
  border: 1px solid hsla(0, 0%, 0%, 0.12);
  border-radius: 0.75rem;
  padding: 0.5rem 0.75rem;
  font-family: inherit;
  font-size: 0.9rem;
  resize: none;
  max-height: 120px;
  background: var(--adi-cream);
  color: var(--adi-charcoal);
  outline: none;
  transition: border-color 0.2s;
}
.adi-panel-input textarea:focus {
  border-color: var(--adi-gold);
}
.adi-panel-send {
  background: var(--adi-charcoal);
  color: white;
  border: none;
  border-radius: 0.75rem;
  width: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
  flex: none;
}
.adi-panel-send:hover { background: #555; }
.adi-panel-send:active { transform: scale(0.95); }
.adi-panel-send:disabled { opacity: 0.4; cursor: not-allowed; }
.adi-panel-send svg { width: 18px; height: 18px; }

.adi-panel-footer {
  font-size: 0.7rem;
  color: hsla(0, 0%, 0%, 0.5);
  padding: 0.5rem 1rem;
  text-align: center;
  background: hsla(0, 0%, 0%, 0.02);
  border-top: 1px solid hsla(0, 0%, 0%, 0.04);
  line-height: 1.3;
}
.adi-panel-footer a {
  color: var(--adi-charcoal);
  text-decoration: underline;
  font-weight: 600;
}

/* ── Mobile: full-screen panel ──────────────────────────────────────────── */
@media (max-width: 767px) {
  .adi-whisper {
    bottom: 1rem;
    left: 1rem;
    width: 52px;
    height: 52px;
  }
  .adi-whisper-tooltip { display: none; }
  .adi-panel {
    bottom: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    max-height: 100vh;
    border-radius: 0;
  }
  /* Hide WhatsApp button while Adi panel is open on mobile — it overlaps the
     chat input/send area. WhatsApp link is still available in panel footer. */
  body.adi-open .whatsapp-float {
    display: none !important;
  }
}

/* ── Reduced motion ─────────────────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  .adi-whisper {
    animation: none;
  }
  .adi-whisper::before {
    animation: none;
    display: none;
  }
  .adi-msg--typing span { animation: none; opacity: 0.5; }
  .adi-panel { transition: none !important; }
}

/* ── WhatsApp pulse — fired by adi.js when temperature=hot ─────────────── */
@keyframes whatsapp-attention {
  0%, 100% { transform: scale(1); box-shadow: 0 4px 12px rgba(37, 211, 102, 0.4); }
  50% {
    transform: scale(1.18);
    box-shadow: 0 0 0 14px rgba(212, 168, 67, 0.35), 0 4px 12px rgba(37, 211, 102, 0.5);
  }
}
.whatsapp-float--attention {
  animation: whatsapp-attention 0.7s cubic-bezier(0.22, 1, 0.36, 1) !important;
}
@media (prefers-reduced-motion: reduce) {
  .whatsapp-float--attention { animation: none !important; }
}
