/* ── ML AfiliadoBot Widget ─────────────────────────────────────────────── */

#abot-container {
  position: fixed;
  bottom: 24px;
  z-index: 999999;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 14px;
  line-height: 1.5;
}
#abot-container.abot-pos-right { right: 24px; }
#abot-container.abot-pos-left  { left: 24px;  }

/* ── Botón flotante ──────────────────────────────────────────────────────── */
#abot-toggle {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  box-shadow: 0 4px 20px rgba(0,0,0,.25);
  transition: transform .2s, box-shadow .2s;
  position: relative;
}
#abot-toggle:hover { transform: scale(1.08); box-shadow: 0 6px 24px rgba(0,0,0,.3); }
#abot-toggle.abot-open { transform: scale(1.05); }

/* Badge de notificación */
#abot-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  width: 20px;
  height: 20px;
  background: #e74c3c;
  color: #fff;
  border-radius: 50%;
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid #fff;
}

/* ── Ventana del chat ────────────────────────────────────────────────────── */
#abot-window {
  display: flex;
  flex-direction: column;
  width: 360px;
  max-width: calc(100vw - 48px);
  height: 500px;
  max-height: calc(100vh - 100px);
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 8px 40px rgba(0,0,0,.2);
  background: #fff;
  position: absolute;
  bottom: 72px;
}
.abot-pos-right #abot-window { right: 0; }
.abot-pos-left  #abot-window { left: 0;  }

/* ── Header ──────────────────────────────────────────────────────────────── */
#abot-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  color: #1a1a1a;
  flex-shrink: 0;
}
.abot-logo {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  object-fit: cover;
}
.abot-logo-emoji {
  font-size: 28px;
  line-height: 1;
}
.abot-header-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.abot-header-info strong {
  font-size: 15px;
  font-weight: 700;
}
.abot-subtitle {
  font-size: 11px;
  opacity: .7;
}
#abot-close {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 18px;
  color: #1a1a1a;
  opacity: .7;
  padding: 4px;
  line-height: 1;
  border-radius: 50%;
  transition: opacity .15s;
}
#abot-close:hover { opacity: 1; background: rgba(0,0,0,.1); }

/* ── Mensajes ────────────────────────────────────────────────────────────── */
#abot-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: #f7f7f8;
  scroll-behavior: smooth;
}
#abot-messages::-webkit-scrollbar { width: 4px; }
#abot-messages::-webkit-scrollbar-track { background: transparent; }
#abot-messages::-webkit-scrollbar-thumb { background: #ccc; border-radius: 4px; }

.abot-msg {
  max-width: 82%;
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 14px;
  line-height: 1.5;
  word-break: break-word;
  animation: abotFadeIn .2s ease;
}
@keyframes abotFadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.abot-msg-bot {
  background: #fff;
  color: #1a1a1a;
  border-radius: 16px 16px 16px 4px;
  align-self: flex-start;
  box-shadow: 0 1px 4px rgba(0,0,0,.08);
}
.abot-msg-user {
  background: #1a1a1a;
  color: #fff;
  border-radius: 16px 16px 4px 16px;
  align-self: flex-end;
}

/* Links dentro de mensajes del bot */
.abot-msg-bot a {
  color: #3483fa;
  text-decoration: none;
  font-weight: 500;
  word-break: break-all;
}
.abot-msg-bot a:hover { text-decoration: underline; }

/* ── Typing indicator ────────────────────────────────────────────────────── */
.abot-typing {
  display: flex;
  gap: 5px;
  align-items: center;
  padding: 14px 18px;
}
.abot-typing span {
  width: 7px;
  height: 7px;
  background: #aaa;
  border-radius: 50%;
  animation: abotBounce 1.2s infinite;
}
.abot-typing span:nth-child(2) { animation-delay: .2s; }
.abot-typing span:nth-child(3) { animation-delay: .4s; }
@keyframes abotBounce {
  0%, 60%, 100% { transform: translateY(0); }
  30%           { transform: translateY(-6px); }
}

/* ── Input ───────────────────────────────────────────────────────────────── */
#abot-input-area {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 10px 12px;
  background: #fff;
  border-top: 1px solid #eee;
  flex-shrink: 0;
}
#abot-input {
  flex: 1;
  border: 1px solid #ddd;
  border-radius: 20px;
  padding: 8px 14px;
  font-size: 14px;
  font-family: inherit;
  resize: none;
  outline: none;
  line-height: 1.4;
  transition: border-color .2s;
  max-height: 100px;
  overflow-y: auto;
  background: #f9f9f9;
}
#abot-input:focus { border-color: #3483fa; background: #fff; }
#abot-send {
  width: 38px;
  height: 38px;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  color: #1a1a1a;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: transform .15s;
}
#abot-send:hover:not(:disabled) { transform: scale(1.1); }
#abot-send:disabled { opacity: .5; cursor: not-allowed; }

/* ── Footer ──────────────────────────────────────────────────────────────── */
#abot-footer {
  text-align: center;
  font-size: 10px;
  color: #999;
  padding: 4px 12px 8px;
  background: #fff;
  flex-shrink: 0;
}

/* ── Admin: stats grid ───────────────────────────────────────────────────── */
.abot-stats-grid {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  margin: 20px 0;
}
.abot-stat-card {
  background: #fff;
  border: 1px solid #e0e0e0;
  border-radius: 12px;
  padding: 20px 28px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  min-width: 140px;
}
.abot-stat-number {
  font-size: 32px;
  font-weight: 700;
  color: #1a1a1a;
}
.abot-stat-label {
  font-size: 12px;
  color: #666;
  text-align: center;
}

/* ── Admin: test chat ────────────────────────────────────────────────────── */
#abot-test-chat {
  max-width: 640px;
  border: 1px solid #ddd;
  border-radius: 12px;
  overflow: hidden;
  background: #fff;
  margin-top: 16px;
}
.abot-test-messages {
  min-height: 280px;
  max-height: 400px;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: #f7f7f8;
}
.abot-test-msg {
  max-width: 80%;
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 14px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
}
.abot-msg-user { background: #1a1a1a; color: #fff; align-self: flex-end; }
.abot-msg-bot  { background: #fff; color: #1a1a1a; align-self: flex-start; box-shadow: 0 1px 4px rgba(0,0,0,.08); }
.abot-test-input-row {
  display: flex;
  gap: 8px;
  padding: 12px;
  border-top: 1px solid #eee;
}

/* ── Wrap general admin ──────────────────────────────────────────────────── */
.abot-wrap h1 { margin-bottom: 20px; }
.abot-section-title {
  margin-top: 28px;
  padding-top: 16px;
  border-top: 1px solid #e0e0e0;
}
.abot-copy-btn { margin-left: 8px; }

/* ── Responsive ──────────────────────────────────────────────────────────── */
@media (max-width: 480px) {
  #abot-window { width: calc(100vw - 32px); bottom: 68px; }
  .abot-pos-right #abot-window { right: 0; }
  .abot-pos-left  #abot-window { left: 0; }
}
