@import url('https://fonts.googleapis.com/css2?family=Montserrat:wght@400;500;600;700&display=swap');

html.arabito-chat-open,
html.arabito-chat-open body {
  overflow: hidden !important;
}

/* Ocultar botón WhatsApp del sitio (Joinchat) */
.joinchat {
  display: none !important;
  visibility: hidden !important;
  pointer-events: none !important;
}

#arabito-chatbot-root {
  --ac-brand: #d71921;
  --ac-brand-dark: #a81218;
  --ac-brand-light: #ff4a52;
  --ac-bg: #ffffff;
  --ac-surface: #f7f8fb;
  --ac-text: #1c1c1c;
  --ac-muted: #6b7280;
  --ac-border: #e5e7eb;
  --ac-bot: #ffffff;
  --ac-user: linear-gradient(135deg, #d71921 0%, #b0141b 100%);
  --ac-wa: #25d366;
  --ac-wa-dark: #1da851;
  --ac-shadow: 0 20px 50px rgba(15, 23, 42, 0.18);
  --ac-radius: 20px;
  /* Avatar flotante: escala con la resolución (móvil → escritorio) */
  --ac-avatar-w: clamp(145px, 16vmin, 250px);
  --ac-avatar-h: calc(var(--ac-avatar-w) * 1.4);
  --ac-avatar-visible-h: calc(var(--ac-avatar-h) * 0.67);
  font-family: Montserrat, system-ui, sans-serif;
  position: fixed;
  bottom: 0;
  right: clamp(4px, 1.2vmin, 16px);
  left: auto;
  z-index: 999990;
}

#arabito-chatbot-root > * {
  pointer-events: auto;
}

/* ── Teaser / burbuja de bienvenida ── */
#arabito-chatbot-teaser {
  position: absolute;
  bottom: calc(var(--ac-avatar-visible-h) - 8px);
  right: calc(var(--ac-avatar-w) + 8px);
  left: auto;
  max-width: 240px;
  display: flex;
  align-items: flex-end;
  justify-content: flex-end;
  gap: 0;
  opacity: 0;
  transform: translateY(12px) scale(0.96);
  transition: opacity 0.45s ease, transform 0.45s cubic-bezier(0.34, 1.4, 0.64, 1);
  pointer-events: none;
  filter: drop-shadow(0 12px 28px rgba(0, 0, 0, 0.12));
}

#arabito-chatbot-teaser.is-visible {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
  cursor: pointer;
}

#arabito-chatbot-teaser:hover .ac-teaser-bubble {
  border-color: rgba(215, 25, 33, 0.25);
  box-shadow: 0 16px 36px rgba(215, 25, 33, 0.12);
}

.ac-teaser-bubble {
  position: relative;
  background: linear-gradient(145deg, #ffffff 0%, #fafbfc 100%);
  border: 1px solid rgba(215, 25, 33, 0.12);
  border-radius: 18px 18px 6px 18px;
  padding: 12px 40px 12px 14px;
  max-width: 240px;
  margin-bottom: 8px;
  margin-right: 4px;
  transition: box-shadow 0.25s, border-color 0.25s;
}

.ac-teaser-bubble::after {
  content: '';
  position: absolute;
  bottom: -6px;
  right: 18px;
  left: auto;
  width: 14px;
  height: 14px;
  background: #fafbfc;
  border-right: 1px solid rgba(215, 25, 33, 0.12);
  border-bottom: 1px solid rgba(215, 25, 33, 0.12);
  transform: rotate(45deg);
  border-radius: 0 0 3px 0;
}

.ac-teaser-greeting {
  margin: 0 0 2px;
  font-size: 14px;
  font-weight: 600;
  color: var(--ac-text);
  line-height: 1.35;
}

.ac-teaser-greeting strong {
  color: var(--ac-brand);
  font-weight: 700;
}

.ac-teaser-sub {
  margin: 0;
  font-size: 13px;
  color: var(--ac-muted);
  line-height: 1.4;
}

.ac-teaser-sparkle {
  position: absolute;
  top: 12px;
  right: 14px;
  font-size: 16px;
  animation: ac-sparkle 2s ease-in-out infinite;
}

@keyframes ac-sparkle {
  0%, 100% { opacity: 0.6; transform: scale(1) rotate(0deg); }
  50% { opacity: 1; transform: scale(1.15) rotate(12deg); }
}

/* ── Botón flotante ── */
#arabito-chatbot-toggle-wrap {
  position: relative;
  width: var(--ac-avatar-w);
  height: var(--ac-avatar-visible-h);
  overflow: hidden;
}

#arabito-chatbot-toggle-ring {
  display: none;
}

#arabito-chatbot-toggle {
  position: absolute;
  left: 0;
  bottom: calc((var(--ac-avatar-h) - var(--ac-avatar-visible-h)) * -1);
  width: var(--ac-avatar-w);
  height: var(--ac-avatar-h);
  border: none;
  border-radius: 0;
  background: transparent;
  padding: 0;
  cursor: pointer;
  box-shadow: none;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  overflow: hidden;
  z-index: 1;
}

#arabito-chatbot-toggle img,
#arabito-chatbot-toggle .ac-blink-avatar {
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: bottom center;
}

.ac-blink-avatar {
  position: relative;
  display: block;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.ac-blink-avatar__img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: bottom center;
  filter: drop-shadow(0 8px 18px rgba(0, 0, 0, 0.15));
}

.ac-blink-avatar__eyes {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.ac-blink-avatar__eye {
  position: absolute;
  pointer-events: none;
}

.ac-blink-avatar__lid {
  position: absolute;
  inset: -10% -14%;
  border-radius: 46% 46% 54% 54%;
  transform: scaleY(0);
  transform-origin: top center;
  transition: transform 0.07s cubic-bezier(0.4, 0, 0.2, 1);
  will-change: transform;
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.04);
}

.ac-blink-avatar__lid.is-closed {
  transform: scaleY(1.08);
  transition: transform 0.11s cubic-bezier(0.4, 0, 0.2, 1);
}

@media (prefers-reduced-motion: reduce) {
  .ac-blink-avatar__lid {
    display: none;
  }
}

/* ── Panel principal ── */
#arabito-chatbot-panel {
  display: none;
  flex-direction: column;
  position: absolute;
  bottom: var(--ac-avatar-visible-h);
  right: 0;
  left: auto;
  width: 360px;
  max-width: calc(100vw - 24px);
  height: 520px;
  max-height: calc(100vh - var(--ac-avatar-visible-h) - 20px);
  background: var(--ac-bg);
  border-radius: var(--ac-radius);
  box-shadow: var(--ac-shadow);
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.8);
  transform-origin: bottom right;
  z-index: 5;
  pointer-events: auto;
  isolation: isolate;
}

#arabito-chatbot-root.is-open {
  pointer-events: none;
}

#arabito-chatbot-root.is-open > * {
  pointer-events: auto;
}

#arabito-chatbot-panel.is-open {
  display: flex;
  animation: ac-panel-in 0.35s cubic-bezier(0.34, 1.2, 0.64, 1);
}

@keyframes ac-panel-in {
  from { opacity: 0; transform: translateY(16px) scale(0.94); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

#arabito-chatbot-header {
  background: linear-gradient(135deg, #d71921 0%, #9e1017 100%);
  color: #fff;
  padding: 16px 18px;
  display: flex;
  align-items: center;
  gap: 12px;
  position: relative;
  flex-shrink: 0;
}

#arabito-chatbot-header::before {
  content: '';
  position: absolute;
  inset: 0;
  background: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23ffffff' fill-opacity='0.04'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
  pointer-events: none;
}

.ac-header-info {
  flex: 1;
  position: relative;
  z-index: 1;
}

.ac-header-info strong {
  display: block;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.ac-header-status {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  opacity: 0.92;
  margin-top: 2px;
  font-weight: 500;
}

.ac-status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #4ade80;
  box-shadow: 0 0 0 3px rgba(74, 222, 128, 0.3);
  animation: ac-blink 2s ease infinite;
}

@keyframes ac-blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.65; }
}

.ac-avatar {
  object-fit: contain;
  border-radius: 0;
  flex-shrink: 0;
  background: transparent;
}

.ac-avatar--header {
  width: 56px;
  height: 64px;
  border: none;
  box-shadow: none;
  object-position: bottom center;
  position: relative;
  z-index: 1;
  filter: drop-shadow(0 2px 6px rgba(0, 0, 0, 0.25));
}

.ac-avatar--msg {
  width: 40px;
  height: 46px;
  border: none;
  box-shadow: none;
  object-position: bottom center;
  filter: drop-shadow(0 1px 4px rgba(0, 0, 0, 0.12));
}

#arabito-chatbot-close {
  position: relative;
  z-index: 1;
  width: 34px;
  height: 34px;
  border: none;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
  flex-shrink: 0;
}

#arabito-chatbot-close:hover {
  background: rgba(255, 255, 255, 0.28);
}

#arabito-chatbot-close svg {
  width: 18px;
  height: 18px;
  fill: currentColor;
}

/* ── Mensajes ── */
#arabito-chatbot-messages {
  flex: 1 1 auto;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  padding: 18px 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: var(--ac-surface);
  touch-action: pan-y;
}

#arabito-chatbot-messages::-webkit-scrollbar {
  width: 5px;
}

#arabito-chatbot-messages::-webkit-scrollbar-thumb {
  background: #d1d5db;
  border-radius: 4px;
}

.ac-msg-row {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  max-width: 92%;
  animation: ac-msg-in 0.35s ease both;
}

@keyframes ac-msg-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

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

.ac-msg {
  padding: 11px 14px;
  border-radius: 16px;
  font-size: 13.5px;
  line-height: 1.5;
  word-wrap: break-word;
  white-space: pre-wrap;
}

.ac-msg--bot {
  background: var(--ac-bot);
  color: var(--ac-text);
  border-bottom-left-radius: 5px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
  border: 1px solid rgba(0, 0, 0, 0.04);
}

.ac-msg--user {
  align-self: flex-end;
  background: var(--ac-user);
  color: #fff;
  border-bottom-right-radius: 5px;
  box-shadow: 0 4px 14px rgba(215, 25, 33, 0.3);
  animation: ac-msg-in 0.35s ease both;
  max-width: 85%;
}

.ac-typing {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  align-self: flex-start;
  animation: ac-msg-in 0.3s ease both;
}

.ac-typing-bubble {
  background: #fff;
  border-radius: 16px 16px 16px 5px;
  padding: 12px 16px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
  border: 1px solid rgba(0, 0, 0, 0.04);
  display: flex;
  gap: 5px;
  align-items: center;
}

.ac-typing-bubble span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #d71921;
  opacity: 0.4;
  animation: ac-typing 1.2s ease infinite;
}

.ac-typing-bubble span:nth-child(2) { animation-delay: 0.15s; }
.ac-typing-bubble span:nth-child(3) { animation-delay: 0.3s; }

@keyframes ac-typing {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.35; }
  30% { transform: translateY(-5px); opacity: 1; }
}

.ac-options {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-left: 42px;
  align-self: flex-start;
  animation: ac-msg-in 0.4s ease both;
}

.ac-option {
  border: 1.5px solid rgba(215, 25, 33, 0.35);
  background: #fff;
  color: var(--ac-brand);
  border-radius: 22px;
  padding: 8px 14px;
  font-size: 12.5px;
  font-family: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.ac-option:hover {
  background: var(--ac-brand);
  color: #fff;
  border-color: var(--ac-brand);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(215, 25, 33, 0.25);
}

/* ── Footer ── */
#arabito-chatbot-footer {
  border-top: 1px solid var(--ac-border);
  padding: 12px 14px 14px;
  background: #fff;
  flex-shrink: 0;
}

#arabito-chatbot-form {
  display: flex;
  gap: 8px;
  align-items: center;
}

#arabito-chatbot-input {
  flex: 1;
  border: 1.5px solid var(--ac-border);
  border-radius: 24px;
  padding: 11px 16px;
  font-size: 13.5px;
  font-family: inherit;
  outline: none;
  background: var(--ac-surface);
  transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
}

#arabito-chatbot-input:focus {
  border-color: rgba(215, 25, 33, 0.5);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(215, 25, 33, 0.1);
}

#arabito-chatbot-input::placeholder {
  color: #9ca3af;
}

#arabito-chatbot-send {
  width: 44px;
  height: 44px;
  border: none;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--ac-brand) 0%, var(--ac-brand-dark) 100%);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: transform 0.2s, box-shadow 0.2s;
  box-shadow: 0 4px 12px rgba(215, 25, 33, 0.35);
}

#arabito-chatbot-send:not(:disabled):hover {
  transform: scale(1.06);
}

#arabito-chatbot-send:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  box-shadow: none;
}

#arabito-chatbot-wa {
  display: none;
  width: 100%;
  margin-top: 10px;
  padding: 12px 16px;
  border: none;
  border-radius: 24px;
  background: linear-gradient(135deg, var(--ac-wa) 0%, var(--ac-wa-dark) 100%);
  color: #fff;
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: transform 0.2s, box-shadow 0.2s;
  box-shadow: 0 4px 14px rgba(37, 211, 102, 0.35);
}

#arabito-chatbot-wa.is-visible {
  display: flex;
  animation: ac-msg-in 0.35s ease both;
}

#arabito-chatbot-wa:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 18px rgba(37, 211, 102, 0.45);
}

#arabito-chatbot-wa svg {
  width: 20px;
  height: 20px;
  fill: currentColor;
}

@media (max-width: 480px) {
  #arabito-chatbot-teaser {
    right: 0;
    bottom: calc(var(--ac-avatar-visible-h) + 4px);
    max-width: calc(100vw - 16px);
  }

  #arabito-chatbot-panel {
    width: calc(100vw - 16px);
    height: min(480px, calc(100vh - var(--ac-avatar-visible-h) - 16px));
  }
}
