/* Wellness Care — Sofy Web Widget */
/* Estilos scoped bajo #wc-sofy — no chocan con el resto del sitio.
   Paleta: navy #0F1B2D · gold #C4974A · ivory #F7F4EF. */

.wc-sofy-root {
  --wc-navy: #0F1B2D;
  --wc-gold: #C4974A;
  --wc-ivory: #F7F4EF;
  --wc-ivory-2: #EDE7DE;
  --wc-text: #1E2A3B;
  --wc-muted: #6B7280;
  --wc-border: rgba(15, 27, 45, 0.08);
  --wc-shadow: 0 20px 60px rgba(15, 27, 45, 0.18);
  --wc-radius: 16px;
  --wc-font-sans: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", Roboto, sans-serif;
  --wc-font-serif: "Playfair Display", "Georgia", "Times New Roman", serif;

  position: fixed;
  bottom: 24px; /* WhatsApp vive abajo-IZQUIERDA; Sofy tiene la esquina derecha para ella sola */
  right: 24px;
  z-index: 2147483000; /* sobre todo lo demás */
  font-family: var(--wc-font-sans);
  color: var(--wc-text);
  line-height: 1.5;
  opacity: 0;
  animation: wc-sofy-appear 500ms ease 800ms forwards;
}

@keyframes wc-sofy-appear {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* === TRIGGER (botón flotante) === */
.wc-sofy-trigger {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 12px;
  padding: 8px 22px 8px 8px;
  background: var(--wc-navy);
  color: var(--wc-ivory);
  border: none;
  border-radius: 999px;
  font-family: var(--wc-font-sans);
  font-size: 14px;
  font-weight: 500;
  letter-spacing: 0.02em;
  cursor: pointer;
  box-shadow: var(--wc-shadow);
  transition: transform 200ms ease, box-shadow 200ms ease, background 200ms ease;
}
.wc-sofy-trigger:hover {
  transform: translateY(-1px);
  background: #182A44;
  box-shadow: 0 24px 70px rgba(15, 27, 45, 0.25);
}

/* Avatar circular con retrato — borde dorado sobre navy */
.wc-sofy-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  overflow: hidden;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1.5px solid var(--wc-gold);
  flex-shrink: 0;
  background: var(--wc-navy);
}
.wc-sofy-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: 50% 30%;
  display: block;
}
.wc-sofy-trigger-label { white-space: nowrap; }

/* 2 pulsos dorados sutiles al aparecer — halo se expande y se desvanece */
.wc-sofy-trigger::before {
  content: '';
  position: absolute;
  inset: -2px;
  border-radius: inherit;
  border: 2px solid var(--wc-gold);
  opacity: 0;
  pointer-events: none;
  animation: wc-sofy-pulse 1.6s ease-out 1400ms 2;
}
@keyframes wc-sofy-pulse {
  0%   { transform: scale(1);    opacity: 0.55; }
  100% { transform: scale(1.35); opacity: 0;    }
}

/* Ocultar trigger cuando panel está abierto */
.wc-sofy-root[data-open="true"] .wc-sofy-trigger {
  opacity: 0;
  pointer-events: none;
  transform: scale(0.9);
}

/* === PEEK BUBBLE (pre-mensaje diferido) === */
.wc-sofy-peek {
  position: absolute;
  bottom: 72px;
  right: 0;
  max-width: 260px;
  background: #fff;
  border: 1px solid var(--wc-border);
  border-radius: 14px;
  padding: 14px 34px 14px 16px;
  box-shadow: 0 12px 32px rgba(15, 27, 45, 0.14);
  font-size: 13px;
  line-height: 1.5;
  color: var(--wc-text);
  cursor: pointer;
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 320ms ease, transform 320ms ease;
  pointer-events: none;
  outline: none;
}
.wc-sofy-peek[data-visible="true"] {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
  animation: wc-sofy-peek-nudge 2.4s ease-in-out 400ms 1;
}
.wc-sofy-peek:hover,
.wc-sofy-peek:focus-visible { border-color: var(--wc-gold); }
/* Puntita del bubble apuntando al trigger */
.wc-sofy-peek::after {
  content: '';
  position: absolute;
  bottom: -6px;
  right: 26px;
  width: 12px;
  height: 12px;
  background: #fff;
  border-right: 1px solid var(--wc-border);
  border-bottom: 1px solid var(--wc-border);
  transform: rotate(45deg);
}
.wc-sofy-peek-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.wc-sofy-peek-text strong {
  font-family: var(--wc-font-serif);
  font-size: 15px;
  color: var(--wc-navy);
  font-weight: 600;
}
.wc-sofy-peek-close {
  position: absolute;
  top: 6px;
  right: 8px;
  background: transparent;
  border: none;
  color: var(--wc-muted);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  width: 22px;
  height: 22px;
  border-radius: 4px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.wc-sofy-peek-close:hover { background: rgba(15, 27, 45, 0.06); color: var(--wc-navy); }

@keyframes wc-sofy-peek-nudge {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-3px); }
}

/* Ocultar peek cuando panel abierto */
.wc-sofy-root[data-open="true"] .wc-sofy-peek {
  opacity: 0;
  pointer-events: none;
}

/* === PANEL === */
.wc-sofy-panel {
  position: absolute;
  bottom: 0;
  right: 0;
  width: min(400px, calc(100vw - 32px));
  height: min(620px, calc(100vh - 48px));
  background: var(--wc-ivory);
  border-radius: var(--wc-radius);
  box-shadow: var(--wc-shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  transform: translateY(20px) scale(0.98);
  pointer-events: none;
  transition: opacity 250ms ease, transform 250ms ease;
  border: 1px solid var(--wc-border);
}
.wc-sofy-root[data-open="true"] .wc-sofy-panel {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

/* === HEADER === */
.wc-sofy-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  background: var(--wc-navy);
  color: var(--wc-ivory);
  border-bottom: 1px solid rgba(196, 151, 74, 0.15);
}
.wc-sofy-header-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}
.wc-sofy-header-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  overflow: hidden;
  border: 1.5px solid var(--wc-gold);
  background: var(--wc-navy);
  flex-shrink: 0;
}
.wc-sofy-header-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: 50% 30%;
  display: block;
}
.wc-sofy-header-title {
  font-family: var(--wc-font-serif);
  font-size: 20px;
  font-weight: 600;
  letter-spacing: 0.02em;
  line-height: 1;
}
.wc-sofy-header-sub {
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: rgba(247, 244, 239, 0.6);
  margin-top: 4px;
}
.wc-sofy-header-actions {
  display: flex;
  gap: 4px;
}
.wc-sofy-close,
.wc-sofy-reset {
  background: transparent;
  border: none;
  color: var(--wc-ivory);
  width: 32px;
  height: 32px;
  border-radius: 8px;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 150ms;
  font-family: var(--wc-font-sans);
}
.wc-sofy-close:hover,
.wc-sofy-reset:hover { background: rgba(247, 244, 239, 0.1); }
.wc-sofy-reset { font-size: 16px; }

/* === MENSAJES === */
.wc-sofy-messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  background: var(--wc-ivory);
  scroll-behavior: smooth;
}

/* === HERO CARD (presentación de Sofy en primera apertura) === */
.wc-sofy-hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 8px 16px 20px;
  margin-bottom: 4px;
  animation: wc-sofy-fadein 350ms ease;
}
.wc-sofy-hero-avatar {
  width: 96px;
  height: 96px;
  border-radius: 50%;
  overflow: hidden;
  border: 2px solid var(--wc-gold);
  background: var(--wc-navy);
  margin-bottom: 14px;
  box-shadow: 0 6px 20px rgba(15, 27, 45, 0.15);
}
.wc-sofy-hero-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: 50% 30%;
  display: block;
}
.wc-sofy-hero-name {
  font-family: var(--wc-font-serif);
  font-size: 26px;
  font-weight: 600;
  color: var(--wc-navy);
  line-height: 1;
  margin-bottom: 6px;
  letter-spacing: 0.01em;
}
.wc-sofy-hero-role {
  font-size: 10.5px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--wc-gold);
  font-weight: 500;
}
.wc-sofy-messages::-webkit-scrollbar { width: 6px; }
.wc-sofy-messages::-webkit-scrollbar-track { background: transparent; }
.wc-sofy-messages::-webkit-scrollbar-thumb {
  background: rgba(15, 27, 45, 0.15);
  border-radius: 3px;
}

.wc-sofy-msg {
  max-width: 88%;
  padding: 12px 16px;
  margin-bottom: 12px;
  border-radius: 14px;
  font-size: 14px;
  line-height: 1.55;
  word-wrap: break-word;
  animation: wc-sofy-fadein 250ms ease;
}
@keyframes wc-sofy-fadein {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}
.wc-sofy-msg-user {
  background: var(--wc-navy);
  color: var(--wc-ivory);
  margin-left: auto;
  border-bottom-right-radius: 4px;
}
.wc-sofy-msg-assistant {
  background: #fff;
  color: var(--wc-text);
  margin-right: auto;
  border: 1px solid var(--wc-border);
  border-bottom-left-radius: 4px;
}
.wc-sofy-msg-assistant strong { color: var(--wc-navy); font-weight: 600; }
.wc-sofy-msg-assistant a { color: var(--wc-gold); text-decoration: underline; }
.wc-sofy-msg-assistant ul {
  margin: 8px 0 4px 0;
  padding-left: 20px;
}
.wc-sofy-msg-assistant li { margin: 2px 0; }

/* === Typing indicator === */
.wc-sofy-typing {
  display: inline-flex;
  gap: 4px;
  padding: 14px 18px;
}
.wc-sofy-typing span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--wc-navy);
  opacity: 0.35;
  animation: wc-sofy-blink 1.2s infinite ease-in-out both;
}
.wc-sofy-typing span:nth-child(2) { animation-delay: 0.15s; }
.wc-sofy-typing span:nth-child(3) { animation-delay: 0.3s; }
@keyframes wc-sofy-blink {
  0%, 60%, 100% { transform: scale(0.9); opacity: 0.35; }
  30% { transform: scale(1.15); opacity: 1; }
}

/* === INPUT === */
.wc-sofy-input {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 12px 16px 16px 16px;
  background: var(--wc-ivory);
  border-top: 1px solid var(--wc-border);
}
.wc-sofy-textarea {
  flex: 1;
  padding: 10px 12px;
  border: 1px solid var(--wc-border);
  border-radius: 12px;
  font-family: var(--wc-font-sans);
  font-size: 14px;
  line-height: 1.5;
  color: var(--wc-text);
  background: #fff;
  resize: none;
  max-height: 120px;
  outline: none;
  transition: border-color 150ms;
}
.wc-sofy-textarea:focus { border-color: var(--wc-gold); }
.wc-sofy-textarea::placeholder { color: var(--wc-muted); }

.wc-sofy-send {
  min-width: 40px;
  height: 40px;
  padding: 0 18px;
  border-radius: 12px;
  border: none;
  background: var(--wc-navy);
  color: var(--wc-ivory);
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  line-height: 1;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 150ms, transform 150ms;
  flex-shrink: 0;
}
.wc-sofy-send:hover { background: #182A44; transform: translateX(1px); }
.wc-sofy-send:active { transform: scale(0.95); }

/* === Móvil === */
@media (max-width: 480px) {
  .wc-sofy-root { bottom: 12px; right: 12px; left: 12px; }
  /* El panel sigue anclado al root (position:absolute — NO fixed: el root tiene
     transform de la animación y capturaría un fixed, colapsando el panel).
     El bug del header cortado era el 100vh, que en móvil incluye la barra del
     navegador; 100dvh usa la altura VISIBLE, así el header (con los botones
     cerrar/reiniciar) siempre cabe. Fallback a vh para navegadores viejos. */
  .wc-sofy-panel {
    width: 100%;
    height: calc(100vh - 24px);
    height: calc(100dvh - 24px);
    max-height: none;
  }
  .wc-sofy-trigger { margin-left: auto; display: flex; }
}

/* Móviles muy bajos en horizontal: reduce el hero para no comer altura */
@media (max-width: 480px) and (max-height: 640px) {
  .wc-sofy-hero { padding: 4px 16px 12px; }
  .wc-sofy-hero-avatar { width: 64px; height: 64px; margin-bottom: 8px; }
  .wc-sofy-hero-name { font-size: 22px; }
}
