/* ============================================
   CHATBOT FLOTANTE INTELIGENTE — MADRE CORAJE
   Design System v1.0
   ============================================ */

/* === VARIABLES DEL CHATBOT === */
:root {
  --chat-primary: #CE1126;
  --chat-primary-dark: #A50E1F;
  --chat-primary-light: #E8364A;
  --chat-gold: #D4AF37;
  --chat-gold-light: #E5C54B;
  --chat-bg: #FFFFFF;
  --chat-bg-user: #CE1126;
  --chat-bg-bot: #F5F0E8;
  --chat-text: #333333;
  --chat-text-light: #777777;
  --chat-border: #E0D8CC;
  --chat-shadow: 0 12px 48px rgba(0,0,0,0.18);
  --chat-radius: 20px;
  --chat-width: 400px;
  --chat-height: 560px;
  --chat-font: 'Inter', system-ui, sans-serif;
}

[data-theme="dark"] {
  --chat-bg: #1E1E1E;
  --chat-bg-bot: #2A2A2A;
  --chat-text: #E0E0E0;
  --chat-text-light: #999999;
  --chat-border: #3A3A3A;
  --chat-shadow: 0 12px 48px rgba(0,0,0,0.4);
}

/* === BOTÓN FLOTANTE === */
.chatbot-toggle {
  position: fixed;
  bottom: 50px;
  left: 24px;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--chat-primary), var(--chat-primary-dark));
  color: #FFF;
  border: none;
  cursor: pointer;
  z-index: 9998;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  box-shadow: 0 6px 24px rgba(206, 17, 38, 0.4), 0 0 0 0 rgba(206, 17, 38, 0.3);
  transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
  animation: chatbot-pulse 2.5s ease-in-out infinite;
}

.chatbot-toggle:hover {
  transform: scale(1.1) rotate(5deg);
  box-shadow: 0 8px 32px rgba(206, 17, 38, 0.5);
}

.chatbot-toggle.active {
  animation: none;
  transform: scale(1) rotate(0);
  background: linear-gradient(135deg, #555, #333);
}

.chatbot-toggle__icon {
  transition: transform 0.3s ease;
  line-height: 1;
}

.chatbot-toggle.active .chatbot-toggle__icon {
  transform: rotate(90deg);
}

/* Badge de notificación */
.chatbot-toggle__badge {
  position: absolute;
  top: -4px;
  left: -4px;
  width: 22px;
  height: 22px;
  background: var(--chat-gold);
  color: #111;
  border-radius: 50%;
  font-size: 12px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid #FFF;
  animation: chatbot-badge-bounce 0.6s ease;
  transition: opacity 0.3s;
}

.chatbot-toggle.active .chatbot-toggle__badge {
  opacity: 0;
  pointer-events: none;
}

@keyframes chatbot-pulse {
  0%, 100% { box-shadow: 0 6px 24px rgba(206,17,38,0.4), 0 0 0 0 rgba(206,17,38,0.25); }
  50% { box-shadow: 0 6px 24px rgba(206,17,38,0.4), 0 0 0 14px rgba(206,17,38,0); }
}

@keyframes chatbot-badge-bounce {
  0% { transform: scale(0); }
  50% { transform: scale(1.3); }
  100% { transform: scale(1); }
}

/* === TOOLTIP DEL BOTÓN === */
.chatbot-tooltip {
  position: fixed;
  bottom: 68px;
  left: 96px;
  background: var(--chat-bg);
  color: var(--chat-text);
  padding: 10px 18px;
  border-radius: 12px;
  font-family: var(--chat-font);
  font-size: 14px;
  font-weight: 500;
  box-shadow: 0 4px 16px rgba(0,0,0,0.12);
  z-index: 9997;
  white-space: nowrap;
  opacity: 0;
  transform: translateX(10px);
  transition: all 0.4s ease;
  pointer-events: none;
}

.chatbot-tooltip::after {
  content: '';
  position: absolute;
  left: -8px;
  top: 50%;
  transform: translateY(-50%);
  border: 8px solid transparent;
  border-right-color: var(--chat-bg);
  border-left: none;
}

.chatbot-tooltip.visible {
  opacity: 1;
  transform: translateX(0);
}

/* === VENTANA DEL CHAT === */
.chatbot-window {
  position: fixed;
  bottom: 124px;
  left: 24px;
  width: var(--chat-width);
  height: var(--chat-height);
  max-height: calc(100dvh - 140px);
  background: var(--chat-bg);
  border-radius: var(--chat-radius);
  box-shadow: var(--chat-shadow);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  visibility: hidden;
  transform: translateY(20px) scale(0.95);
  transform-origin: bottom left;
  transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
  border: 1px solid var(--chat-border);
}

.chatbot-window.open {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
}

/* === HEADER DEL CHAT === */
.chatbot-header {
  background: linear-gradient(135deg, var(--chat-primary), var(--chat-primary-dark));
  color: #FFF;
  padding: 18px 20px;
  display: flex;
  align-items: center;
  gap: 14px;
  flex-shrink: 0;
  position: relative;
  overflow: hidden;
}

.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%3Cpath d='M30 5L35 15L45 15L37 22L40 32L30 26L20 32L23 22L15 15L25 15Z' fill='rgba(255,255,255,0.04)'/%3E%3C/svg%3E") repeat;
  pointer-events: none;
}

.chatbot-header__avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: rgba(255,255,255,0.15);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  flex-shrink: 0;
  border: 2px solid rgba(255,255,255,0.3);
  position: relative;
  z-index: 1;
}

.chatbot-header__info {
  flex: 1;
  position: relative;
  z-index: 1;
}

.chatbot-header__name {
  font-family: 'Playfair Display', Georgia, serif;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.3px;
}

.chatbot-header__status {
  font-size: 12px;
  opacity: 0.85;
  display: flex;
  align-items: center;
  gap: 6px;
}

.chatbot-header__status::before {
  content: '';
  width: 8px;
  height: 8px;
  background: #4ADE80;
  border-radius: 50%;
  display: inline-block;
  animation: chatbot-status-pulse 2s ease-in-out infinite;
}

@keyframes chatbot-status-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

.chatbot-header__close {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(255,255,255,0.15);
  color: #FFF;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  cursor: pointer;
  border: none;
  transition: background 0.2s;
  position: relative;
  z-index: 1;
}

.chatbot-header__close:hover {
  background: rgba(255,255,255,0.25);
}

/* === CUERPO DE MENSAJES === */
.chatbot-messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  scroll-behavior: smooth;
  background: linear-gradient(180deg, var(--chat-bg) 0%, rgba(245,240,232,0.3) 100%);
}

[data-theme="dark"] .chatbot-messages {
  background: linear-gradient(180deg, var(--chat-bg) 0%, rgba(30,30,30,1) 100%);
}

.chatbot-messages::-webkit-scrollbar {
  width: 5px;
}

.chatbot-messages::-webkit-scrollbar-track {
  background: transparent;
}

.chatbot-messages::-webkit-scrollbar-thumb {
  background: var(--chat-border);
  border-radius: 10px;
}

/* === BURBUJAS DE MENSAJE === */
.chatbot-msg {
  max-width: 85%;
  padding: 12px 16px;
  border-radius: 16px;
  font-family: var(--chat-font);
  font-size: 14px;
  line-height: 1.55;
  color: var(--chat-text);
  animation: chatbot-msg-in 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
  position: relative;
  word-wrap: break-word;
}

.chatbot-msg--bot {
  align-self: flex-start;
  background: var(--chat-bg-bot);
  border-bottom-left-radius: 4px;
}

.chatbot-msg--user {
  align-self: flex-end;
  background: var(--chat-bg-user);
  color: #FFF;
  border-bottom-right-radius: 4px;
}

.chatbot-msg--bot a {
  color: var(--chat-primary);
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.chatbot-msg--user a {
  color: var(--chat-gold-light);
}

.chatbot-msg__time {
  font-size: 10px;
  opacity: 0.5;
  margin-top: 6px;
  display: block;
  text-align: right;
}

@keyframes chatbot-msg-in {
  0% { opacity: 0; transform: translateY(12px) scale(0.95); }
  100% { opacity: 1; transform: translateY(0) scale(1); }
}

/* === INDICADOR DE ESCRITURA === */
.chatbot-typing {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 14px 18px;
  background: var(--chat-bg-bot);
  border-radius: 16px;
  border-bottom-left-radius: 4px;
  align-self: flex-start;
  animation: chatbot-msg-in 0.35s ease;
}

.chatbot-typing__dot {
  width: 8px;
  height: 8px;
  background: var(--chat-text-light);
  border-radius: 50%;
  animation: chatbot-typing-bounce 1.4s ease-in-out infinite;
}

.chatbot-typing__dot:nth-child(2) { animation-delay: 0.16s; }
.chatbot-typing__dot:nth-child(3) { animation-delay: 0.32s; }

@keyframes chatbot-typing-bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30% { transform: translateY(-6px); opacity: 1; }
}

/* === CHIPS DE RESPUESTA RÁPIDA === */
.chatbot-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 4px 0;
  animation: chatbot-msg-in 0.4s ease 0.1s both;
}

.chatbot-chip {
  padding: 8px 16px;
  background: transparent;
  border: 1.5px solid var(--chat-primary);
  color: var(--chat-primary);
  border-radius: 20px;
  font-family: var(--chat-font);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.25s ease;
  white-space: nowrap;
}

.chatbot-chip:hover {
  background: var(--chat-primary);
  color: #FFF;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(206,17,38,0.25);
}

/* === INPUT DEL CHAT === */
.chatbot-input {
  display: flex;
  align-items: center;
  padding: 14px 16px;
  border-top: 1px solid var(--chat-border);
  background: var(--chat-bg);
  gap: 10px;
  flex-shrink: 0;
}

.chatbot-input__field {
  flex: 1;
  border: 1.5px solid var(--chat-border);
  background: var(--chat-bg-bot);
  color: var(--chat-text);
  padding: 12px 16px;
  border-radius: 24px;
  font-family: var(--chat-font);
  font-size: 14px;
  outline: none;
  transition: border-color 0.3s, box-shadow 0.3s;
}

.chatbot-input__field::placeholder {
  color: var(--chat-text-light);
}

.chatbot-input__field:focus {
  border-color: var(--chat-primary);
  box-shadow: 0 0 0 3px rgba(206,17,38,0.1);
}

.chatbot-input__send {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--chat-primary), var(--chat-primary-dark));
  color: #FFF;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  transition: all 0.3s ease;
  flex-shrink: 0;
}

.chatbot-input__send:hover {
  transform: scale(1.08);
  box-shadow: 0 4px 16px rgba(206,17,38,0.35);
}

.chatbot-input__send:active {
  transform: scale(0.95);
}

/* === POWERED BY === */
.chatbot-footer {
  text-align: center;
  padding: 6px;
  font-size: 10px;
  color: var(--chat-text-light);
  font-family: var(--chat-font);
  border-top: 1px solid var(--chat-border);
  background: var(--chat-bg);
}

/* === RESPONSIVE === */
@media (max-width: 480px) {
  .chatbot-window {
    width: calc(100vw - 20px);
    height: calc(100dvh - 80px);
    max-height: none;
    bottom: 10px;
    left: 10px;
    border-radius: 16px;
  }

  .chatbot-toggle {
    bottom: 46px;
    left: 16px;
    width: 52px;
    height: 52px;
    font-size: 24px;
  }

  .chatbot-tooltip {
    display: none;
  }
}

@media (max-width: 360px) {
  .chatbot-window {
    width: 100vw;
    height: 100dvh;
    bottom: 0;
    left: 0;
    border-radius: 0;
  }
}
