:root {
  --color-primary: #b81626;      /* Rojo corporativo de La 98 */
  --color-primary-dark: #8c0c19; /* Rojo oscuro */
  --color-accent: #C9A84C;       /* Dorado / Oro */
  --color-bg-chat: #f5ede4;      /* Fondo suave */
  --color-bubble-maria: #b81626; /* Burbujas de María */
  --color-bubble-user: #ffffff;  /* Burbujas del usuario */
  --color-text-dark: #222222;
  --color-text-light: #ffffff;
  --shadow-premium: 0 8px 32px rgba(136, 15, 25, 0.18);
  --border-radius-main: 16px;
}
/* Botón Flotante del Chat */
#maria-chat-btn {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  cursor: pointer;
  border: 3px solid var(--color-accent);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
  z-index: 9999;
  overflow: hidden;
  background: var(--color-primary);
  transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275), box-shadow 0.3s;
  display: flex;
  align-items: center;
  justify-content: center;
}
#maria-chat-btn:hover {
  transform: scale(1.08) rotate(5deg);
  box-shadow: 0 6px 24px rgba(184, 22, 38, 0.4);
}
#maria-chat-btn img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
/* Ventana de Chat */
#maria-chat-window {
  display: none;
  position: fixed;
  bottom: 90px;
  right: 24px;
  width: 340px;
  max-width: calc(100vw - 32px);
  height: 70vh;
  max-height: 500px;
  background: var(--color-bg-chat);
  border-radius: var(--border-radius-main);
  box-shadow: var(--shadow-premium);
  z-index: 9998;
  flex-direction: column;
  overflow: hidden;
  font-size: 13.5px;
  border: 1px solid rgba(184, 22, 38, 0.15);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  transition: all 0.3s ease;
  opacity: 0;
  transform: translateY(20px);
}
#maria-chat-window.open {
  display: flex;
  opacity: 1;
  transform: translateY(0);
}
/* Cabecera del Chat */
#chat-header {
  background: var(--color-primary);
  color: var(--color-text-light);
  padding: 10px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
  border-bottom: 2px solid var(--color-accent);
}
#chat-header-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--color-accent);
  flex-shrink: 0;
  box-shadow: 0 2px 6px rgba(0,0,0,0.15);
}
#chat-header-info {
  flex: 1;
}
#chat-header-name {
  font-weight: 700;
  font-size: 14px;
  letter-spacing: 0.2px;
}
#chat-header-status {
  font-size: 12px;
  color: #ffcdd2;
  margin-top: 2px;
  display: flex;
  align-items: center;
  gap: 4px;
}
#chat-header-status::before {
  content: '';
  width: 7px;
  height: 7px;
  background-color: #4caf50;
  border-radius: 50%;
  display: inline-block;
  box-shadow: 0 0 6px #4caf50;
}
/* Reset de botones para evitar interferencias de temas (Astra, etc.) */
#maria-chat-window button {
  padding: 0 !important;
  margin: 0 !important;
  line-height: 1 !important;
  box-sizing: border-box !important;
  min-width: 0 !important;
  min-height: 0 !important;
  text-transform: none !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
}
/* Botones de Cabecera (Voz y Cerrar) */
#maria-voice-btn {
  background: transparent;
  border: 2px solid rgba(255, 255, 255, 0.5);
  color: var(--color-text-light);
  width: 34px;
  height: 34px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  flex-shrink: 0;
}
#maria-voice-btn.active {
  border-color: var(--color-accent);
  background: rgba(201, 168, 76, 0.2);
  color: var(--color-accent);
}
#maria-voice-btn:hover {
  border-color: var(--color-accent);
  transform: scale(1.05);
}
#maria-voice-btn svg, #maria-voice-btn img {
  width: 16px;
  height: 16px;
  object-fit: contain;
}
#chat-close-btn {
  background: none;
  border: none;
  color: var(--color-text-light);
  font-size: 20px;
  cursor: pointer;
  padding: 4px;
  line-height: 1;
  opacity: 0.75;
  transition: opacity 0.2s, transform 0.2s;
}
#chat-close-btn:hover {
  opacity: 1;
  transform: scale(1.1);
}
/* Área de Mensajes */
#chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scrollbar-width: thin;
  scrollbar-color: rgba(184, 22, 38, 0.2) transparent;
}
#chat-messages::-webkit-scrollbar {
  width: 5px;
}
#chat-messages::-webkit-scrollbar-thumb {
  background-color: rgba(184, 22, 38, 0.2);
  border-radius: 4px;
}
.msg-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  max-width: 85%;
  animation: fadeInMsg 0.3s ease-out forwards;
}
@keyframes fadeInMsg {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
.msg-row.maria {
  justify-content: flex-start;
  align-self: flex-start;
}
.msg-row.user {
  justify-content: flex-end;
  align-self: flex-end;
  margin-left: auto;
}
.msg-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  object-fit: cover;
  border: 1.5px solid var(--color-accent);
  flex-shrink: 0;
  box-shadow: 0 1px 4px rgba(0,0,0,0.1);
}
/* Burbujas de Texto */
.bubble {
  padding: 10px 14px;
  border-radius: 14px;
  line-height: 1.45;
  word-break: break-word;
  font-size: 13.5px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.08);
  text-transform: none !important; /* Evitar que la plantilla capitalice todas las palabras */
}
.bubble.maria {
  background: var(--color-bubble-maria);
  color: var(--color-text-light);
  border-bottom-left-radius: 3px;
}
.bubble.maria strong {
  color: #ffe082;
}
.bubble.user {
  background: var(--color-bubble-user);
  color: var(--color-text-dark);
  border: 1px solid rgba(0,0,0,0.08);
  border-bottom-right-radius: 3px;
}
/* Burbuja de Escritura (Carga) */
.typing-bubble {
  background: var(--color-bubble-maria);
  border-radius: 14px;
  border-bottom-left-radius: 3px;
  padding: 12px 16px;
  display: inline-flex;
  gap: 5px;
  align-items: center;
  box-shadow: 0 1px 2px rgba(0,0,0,0.08);
}
.typing-bubble span {
  width: 6px;
  height: 6px;
  background: var(--color-text-light);
  border-radius: 50%;
  display: inline-block;
  animation: bounce 1.2s infinite;
}
.typing-bubble span:nth-child(2) { animation-delay: 0.2s; }
.typing-bubble span:nth-child(3) { animation-delay: 0.4s; }
@keyframes bounce {
  0%, 80%, 100% { transform: translateY(0); opacity: 0.4; }
  40% { transform: translateY(-5px); opacity: 1; }
}
/* Opciones / Botones de Decisión */
#chat-options {
  padding: 10px 16px;
  display: flex;
  flex-wrap: nowrap;
  overflow-x: auto;
  gap: 8px;
  background: rgba(0, 0, 0, 0.02);
  border-top: 1px solid rgba(184, 22, 38, 0.08);
  flex-shrink: 0;
  justify-content: flex-start;
  scrollbar-width: none; /* Firefox */
  -ms-overflow-style: none; /* IE 10+ */
}

#chat-options::-webkit-scrollbar {
  display: none; /* Chrome, Safari, Edge */
}

.option-btn {
  background: var(--color-text-light);
  border: 1.5px solid var(--color-primary);
  color: var(--color-primary);
  padding: 8px 14px;
  border-radius: 20px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  box-shadow: 0 2px 4px rgba(0,0,0,0.05);
  transition: all 0.2s ease;
  flex-shrink: 0;
  white-space: nowrap;
}
.option-btn:hover {
  background: var(--color-primary);
  color: var(--color-text-light);
  transform: translateY(-1px);
  box-shadow: 0 4px 8px rgba(184, 22, 38, 0.2);
}
/* Área de Input de Texto */
#chat-input-area {
  display: flex;
  padding: 12px;
  background: #f0f0f0;
  gap: 8px;
  align-items: center;
  flex-shrink: 0;
  border-top: 1px solid #ddd;
}
#chat-input {
  flex: 1;
  padding: 10px 16px;
  border-radius: 24px;
  border: 1px solid #ccc;
  font-size: 13.5px;
  outline: none;
  box-shadow: inset 0 1px 3px rgba(0,0,0,0.05);
  transition: border-color 0.2s;
}
#chat-input:focus {
  border-color: var(--color-primary);
}
#maria-mic-btn {
  background: var(--color-accent);
  border: none;
  color: var(--color-primary); /* Icono rojo sobre fondo dorado */
  width: 36px;
  height: 36px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  box-shadow: 0 2px 5px rgba(0,0,0,0.15);
}
#maria-mic-btn:hover {
  background: #b8933e;
  transform: scale(1.05);
}
#maria-mic-btn.recording {
  background: #d32f2f;
  color: #ffffff;
  animation: pulseMic 1.2s infinite;
}
@keyframes pulseMic {
  0% { transform: scale(1); box-shadow: 0 0 0 0 rgba(211, 47, 47, 0.7); }
  70% { transform: scale(1.08); box-shadow: 0 0 0 8px rgba(211, 47, 47, 0); }
  100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(211, 47, 47, 0); }
}
#maria-mic-btn img, #maria-mic-btn svg {
  width: 18px;
  height: 18px;
}
#chat-send-btn {
  background: var(--color-primary);
  border: none;
  color: var(--color-accent); /* Icono dorado sobre fondo rojo */
  width: 36px;
  height: 36px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  box-shadow: 0 2px 5px rgba(184, 22, 38, 0.2);
}
#chat-send-btn:hover {
  background: var(--color-primary-dark);
  transform: scale(1.05);
}
#chat-send-btn svg {
  width: 16px;
  height: 16px;
  fill: currentColor;
}
/* Globo de Llamada a la Acción (CTA) */
#maria-chat-cta {
  position: fixed;
  bottom: 90px;
  right: 24px;
  background: #ffffff;
  color: var(--color-text-dark);
  padding: 12px 32px 12px 16px;
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
  z-index: 9999;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  font-size: 13.5px;
  font-weight: 600;
  border: 2px solid var(--color-accent);
  max-width: 250px;
  line-height: 1.4;
  animation: floatCta 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
}
#maria-chat-cta:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 28px rgba(184, 22, 38, 0.12);
}
@keyframes floatCta {
  from { opacity: 0; transform: translateY(15px) scale(0.9); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
#maria-chat-cta-close {
  position: absolute;
  top: 4px;
  right: 8px;
  background: none;
  border: none;
  font-size: 18px;
  color: #9e9e9e;
  cursor: pointer;
  line-height: 1;
  padding: 2px;
}
#maria-chat-cta-close:hover {
  color: var(--color-primary);
}
.maria-chat-cta-arrow {
  position: absolute;
  bottom: -8px;
  right: 20px;
  width: 0;
  height: 0;
  border-left: 8px solid transparent;
  border-right: 8px solid transparent;
  border-top: 8px solid var(--color-accent);
}
.maria-chat-cta-arrow::after {
  content: '';
  position: absolute;
  bottom: 2px;
  left: -7px;
  width: 0;
  height: 0;
  border-left: 7px solid transparent;
  border-right: 7px solid transparent;
  border-top: 7px solid #ffffff;
}
/* Responsividad */
@media (max-width: 420px) {
  #maria-chat-window {
    right: 8px;
    bottom: 84px;
    width: calc(100vw - 16px);
    height: calc(90vh - 80px);
  }
  #maria-chat-btn {
    bottom: 16px;
    right: 16px;
  }
  #maria-chat-cta {
    bottom: 82px;
    right: 16px;
    max-width: 220px;
    font-size: 12.5px;
  }
}