/* Anfitrión Bubble — Origenes premium · inspirado patrón LBP */

#anf-root {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 999999;
  font-family: -apple-system, BlinkMacSystemFont, 'Inter', 'Helvetica Neue', sans-serif;
  font-size: 15px;
  color: #0F0F0F;
}
#anf-root *, #anf-root *::before, #anf-root *::after { box-sizing: border-box; }
.anf-hidden { display: none !important; }

/* ─── Toggle premium con avatar + texto + flecha ───────────────────── */
#anf-toggle {
  display: flex;
  align-items: center;
  gap: 12px;
  background: linear-gradient(135deg, #f04835 0%, #E63320 50%, #c22a1a 100%);
  color: #FFFBF0;
  border: none;
  border-radius: 999px;
  padding: 10px 20px 10px 10px;
  font-size: 14px;
  font-family: inherit;
  font-weight: 500;
  cursor: pointer;
  box-shadow: 0 10px 30px rgba(230, 51, 32, 0.38), 0 2px 6px rgba(0,0,0,0.08);
  transition: transform 0.2s cubic-bezier(.34,1.56,.64,1), box-shadow 0.25s ease;
  animation: anf-attract 4s ease-in-out 2s 2;
}
#anf-toggle:hover {
  transform: translateY(-3px) scale(1.02);
  box-shadow: 0 16px 40px rgba(230, 51, 32, 0.5), 0 4px 12px rgba(0,0,0,0.1);
}
#anf-toggle:active { transform: translateY(-1px) scale(0.99); }

@keyframes anf-attract {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}

.anf-toggle-avatar {
  position: relative;
  width: 38px; height: 38px;
  border-radius: 999px;
  background: rgba(255, 251, 240, 0.18);
  border: 1.5px solid rgba(255, 251, 240, 0.55);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.anf-toggle-avatar-letter {
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-size: 22px; font-weight: 600;
  color: #FFFBF0; line-height: 1;
}
.anf-toggle-pulse {
  position: absolute;
  top: -2px; right: -2px;
  width: 12px; height: 12px;
  border-radius: 999px;
  background: #4ade80;
  border: 2px solid #FFFBF0;
  animation: anf-pulse-dot 2s ease-in-out infinite;
}
@keyframes anf-pulse-dot {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.25); opacity: 0.75; }
}

.anf-toggle-text {
  display: flex; flex-direction: column;
  align-items: flex-start;
  line-height: 1.15;
  text-align: left;
}
.anf-toggle-text-line1 {
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-weight: 600;
  font-size: 15px;
  letter-spacing: 0.2px;
}
.anf-toggle-text-line2 {
  font-size: 11.5px;
  font-weight: 400;
  opacity: 0.92;
  letter-spacing: 0.1px;
}
.anf-toggle-arrow {
  font-size: 16px;
  opacity: 0.85;
  margin-left: 2px;
  transition: transform 0.2s ease;
}
#anf-toggle:hover .anf-toggle-arrow {
  transform: translateX(3px);
}

/* Mobile: compact circular button */
@media (max-width: 600px) {
  #anf-root { bottom: 18px; right: 16px; }
  #anf-toggle { padding: 8px; gap: 0; }
  .anf-toggle-avatar { width: 48px; height: 48px; }
  .anf-toggle-avatar-letter { font-size: 26px; }
  .anf-toggle-text, .anf-toggle-arrow { display: none; }
}

/* ─── Proactive teaser bubble ───────────────────────────────────────── */
#anf-teaser {
  position: absolute;
  bottom: 76px;
  right: 0;
  max-width: 280px;
  background: #fff;
  color: #0F0F0F;
  border: 1px solid #e8e3d5;
  border-radius: 14px;
  box-shadow: 0 14px 36px rgba(15,15,15,0.20), 0 2px 8px rgba(0,0,0,0.06);
  padding: 0;
  font-size: 14px;
  line-height: 1.4;
  animation: anf-teaser-in 0.45s cubic-bezier(.34,1.56,.64,1);
}
@keyframes anf-teaser-in {
  from { opacity: 0; transform: translateY(14px) scale(0.92); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
.anf-teaser-fading {
  opacity: 0;
  transform: translateY(14px);
  transition: opacity 0.3s ease, transform 0.3s ease;
}
.anf-teaser-arrow {
  position: absolute;
  bottom: -7px;
  right: 24px;
  width: 14px; height: 14px;
  background: #fff;
  border-right: 1px solid #e8e3d5;
  border-bottom: 1px solid #e8e3d5;
  transform: rotate(45deg);
}
.anf-teaser-msg {
  padding: 12px 36px 12px 14px;
  cursor: pointer;
  border-radius: 14px;
  user-select: none;
  outline: none;
}
.anf-teaser-msg:hover { background: #FFFBF0; }
.anf-teaser-msg:focus-visible { box-shadow: 0 0 0 2px #E63320; }
.anf-teaser-from {
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-weight: 600;
  font-size: 13px;
  color: #E63320;
  letter-spacing: 0.2px;
  margin-bottom: 2px;
}
.anf-teaser-text { color: #0F0F0F; }
.anf-teaser-dismiss {
  position: absolute;
  top: 4px; right: 4px;
  background: transparent;
  border: none;
  font-size: 16px;
  color: #6b6b6b;
  cursor: pointer;
  width: 24px; height: 24px;
  border-radius: 999px;
  display: flex; align-items: center; justify-content: center;
  padding: 0; line-height: 1;
}
.anf-teaser-dismiss:hover { background: #FFFBF0; color: #0F0F0F; }
@media (max-width: 600px) {
  #anf-teaser { max-width: calc(100vw - 32px); bottom: 80px; }
}

/* ─── Panel (chat principal) ────────────────────────────────────────── */
#anf-panel {
  width: 400px;
  max-width: calc(100vw - 32px);
  height: 600px;
  max-height: calc(100vh - 32px);
  background: #FFFBF0;
  border-radius: 16px;
  box-shadow: 0 20px 60px rgba(15,15,15,0.25);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Mobile: panel fullscreen + dvh (gestiona el teclado iOS/Android) */
@media (max-width: 600px) {
  #anf-root.anf-panel-open { bottom: 0; right: 0; left: 0; top: 0; }
  #anf-panel {
    position: fixed;
    inset: 0;
    width: 100vw; max-width: 100vw;
    height: 100vh; height: 100dvh;
    max-height: 100vh; max-height: 100dvh;
    border-radius: 0;
    box-shadow: none;
  }
}

.anf-header {
  background: linear-gradient(135deg, #E63320 0%, #c22a1a 100%);
  color: #FFFBF0;
  padding: 14px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.anf-header-info { display: flex; gap: 12px; align-items: center; }
.anf-avatar {
  width: 38px; height: 38px;
  border-radius: 999px;
  background: rgba(255, 251, 240, 0.22);
  display: flex; align-items: center; justify-content: center;
  font-weight: 600;
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-size: 20px;
}
.anf-name { font-weight: 600; font-size: 16px; }
.anf-status {
  font-size: 12px;
  opacity: 0.92;
  display: flex; align-items: center;
  gap: 6px; margin-top: 1px;
}
.anf-dot {
  width: 8px; height: 8px;
  background: #4ade80;
  border-radius: 999px;
  display: inline-block;
  animation: anf-pulse-status 2s ease-in-out infinite;
}
@keyframes anf-pulse-status {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}
.anf-header-actions { display: flex; align-items: center; gap: 4px; }
.anf-close, .anf-reset {
  background: transparent;
  border: none;
  color: #FFFBF0;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  padding: 0;
  width: 34px; height: 34px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 999px;
  transition: background 0.15s ease, transform 0.2s ease;
  font-family: inherit;
}
.anf-close { font-size: 28px; }
.anf-reset { font-size: 18px; opacity: 0.85; }
.anf-close:hover, .anf-reset:hover { background: rgba(255, 251, 240, 0.18); }
.anf-reset:hover { transform: rotate(-60deg); opacity: 1; }

/* ─── Messages ──────────────────────────────────────────────────────── */
.anf-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: linear-gradient(180deg, #FFFBF0 0%, #f7f1de 100%);
}
.anf-msg {
  max-width: 88%;
  padding: 10px 14px;
  border-radius: 16px;
  line-height: 1.5;
  word-wrap: break-word;
}
.anf-msg-user {
  align-self: flex-end;
  background: #0F0F0F;
  color: #FFFBF0;
  border-bottom-right-radius: 4px;
}
.anf-msg-assistant {
  align-self: flex-start;
  background: #ffffff;
  color: #0F0F0F;
  border: 1px solid #e8e3d5;
  border-bottom-left-radius: 4px;
}
.anf-msg-assistant a { color: #E63320; }
.anf-msg-assistant strong { color: #0F0F0F; font-weight: 600; }
.anf-msg-assistant em { font-style: italic; }
.anf-msg-assistant code {
  background: #FFFBF0; padding: 1px 5px; border-radius: 3px;
  font-family: 'JetBrains Mono', 'SF Mono', Consolas, monospace;
  font-size: 0.92em; color: #0F0F0F;
}
.anf-msg-assistant ul, .anf-msg-assistant ol { margin: 6px 0 6px 18px; padding: 0; }
.anf-msg-assistant li { margin: 3px 0; }

.anf-typing { display: flex; gap: 4px; padding: 14px 16px; align-self: flex-start; }
.anf-typing span {
  width: 7px; height: 7px;
  border-radius: 999px;
  background: #E63320;
  opacity: 0.5;
  animation: anf-typing 1.4s ease-in-out infinite;
}
.anf-typing span:nth-child(2) { animation-delay: 0.15s; }
.anf-typing span:nth-child(3) { animation-delay: 0.3s; }
@keyframes anf-typing {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30% { transform: translateY(-8px); opacity: 1; }
}

/* ─── Input ─────────────────────────────────────────────────────────── */
.anf-input-wrap {
  padding: 12px;
  display: flex;
  gap: 8px;
  align-items: flex-end;
  border-top: 1px solid #e8e3d5;
  background: #fff;
}
#anf-input {
  flex: 1;
  resize: none;
  border: 1px solid #e0d8c4;
  border-radius: 12px;
  padding: 10px 14px;
  font-size: 15px;
  font-family: inherit;
  outline: none;
  background: #FFFBF0;
  max-height: 120px;
  overflow-y: auto;
  color: #0F0F0F;
}
#anf-input:focus { border-color: #E63320; }
#anf-send {
  background: #E63320;
  color: #FFFBF0;
  border: none;
  width: 42px; height: 42px;
  border-radius: 999px;
  font-size: 20px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s ease;
}
#anf-send:hover:not(:disabled) { background: #c22a1a; }
#anf-send:disabled { opacity: 0.5; cursor: not-allowed; }

.anf-footer {
  text-align: center;
  font-size: 10px;
  color: #8a8a8a;
  padding: 8px;
  background: #fff;
  border-top: 1px solid #f0e8d0;
  line-height: 1.4;
}
.anf-footer a { color: #8a8a8a; text-decoration: underline; }
