/**
 * ai-auxiliar.css
 * Estilos para la Burbuja Flotante de Auxilio '?' y el Modal Central Inteligente.
 * Esencia: Frosted Glass / Dark Obsidian & Gold de alto contraste (The Master Music).
 */

/* ─── Control Estricto de Visibilidad (evita sobreescritura de display: flex) ─── */
.tm-ai-loading[hidden],
.tm-ai-result[hidden],
.tm-ai-result__actions[hidden],
.tm-ai-modal-overlay[hidden],
[hidden].tm-ai-loading,
[hidden].tm-ai-result,
[hidden].tm-ai-modal-overlay {
  display: none !important;
}

/* ─── Supresión Definitiva de Burbuja Flotante '?' ─── */
.tm-ai-bubble,
#tmAiBubble {
  display: none !important;
  visibility: hidden !important;
  pointer-events: none !important;
}

/* ─── Separador y Botón de Ayuda IA (Integrado en Navegación y Modal) ─── */
.tm-page-nav__item--ayuda {
  margin-top: 0.22rem;
  padding-top: 0.22rem;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

/* ─── Bloqueo de scroll cuando el modal está abierto ─── */
body.tm-ai-modal-open {
  overflow: hidden;
}

/* ─── Overlay con tintado oscuro para garantizar legibilidad ─── */
.tm-ai-modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 10000;
  background: rgba(4, 8, 18, 0.78);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  opacity: 1;
  visibility: visible;
  transition: opacity 0.25s ease, visibility 0.25s ease;
}

/* ─── Modal Central (Dark Obsidian Glass - Inmune a temas claros) ─── */
.tm-ai-modal {
  width: 100%;
  max-width: 520px;
  background: #0d1527;
  background: linear-gradient(165deg, #131d36 0%, #0a0f1d 100%);
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 22px;
  box-shadow: 0 25px 65px rgba(0, 0, 0, 0.75), 0 0 35px rgba(212, 175, 55, 0.18);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  color: #f8fafc;
  animation: tmAiModalPop 0.26s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes tmAiModalPop {
  0% {
    opacity: 0;
    transform: scale(0.92) translateY(12px);
  }
  100% {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

.tm-ai-modal__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 22px 24px 14px 24px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.tm-ai-modal__title {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 700;
  color: #ffffff;
  line-height: 1.25;
}

.tm-ai-modal__close {
  background: rgba(255, 255, 255, 0.08);
  border: none;
  color: #cbd5e1;
  cursor: pointer;
  padding: 6px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.tm-ai-modal__close:hover {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.18);
}

.tm-ai-modal__body {
  padding: 20px 24px 24px 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* ─── Chips de preguntas rápidas ─── */
.tm-ai-modal__chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.tm-ai-chip {
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 9999px;
  color: #e2e8f0;
  font-family: inherit;
  font-size: 0.775rem;
  font-weight: 500;
  padding: 6px 13px;
  cursor: pointer;
  transition: all 0.18s ease;
}

.tm-ai-chip:hover {
  background: rgba(212, 175, 55, 0.25);
  border-color: #d4af37;
  color: #ffffff;
  transform: translateY(-1px);
}

/* ─── Caja de entrada de texto ─── */
.tm-ai-modal__form {
  margin: 0;
}

.tm-ai-input-wrap {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
  box-sizing: border-box;
}

.tm-ai-modal .tm-ai-input {
  width: 100%;
  box-sizing: border-box;
  margin: 0;
  padding: 13px 92px 13px 16px;
  background: rgba(2, 6, 23, 0.75);
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 12px;
  color: #ffffff;
  font-family: inherit;
  font-size: 0.92rem;
  line-height: 1.35;
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.tm-ai-modal .tm-ai-input:focus {
  border-color: #f59e0b;
  box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.25);
}

.tm-ai-modal .tm-ai-input::placeholder {
  color: #64748b;
}

.tm-ai-modal .tm-ai-input-btns {
  position: absolute;
  top: 50%;
  right: 8px;
  transform: translateY(-50%);
  display: flex;
  align-items: center;
  gap: 6px;
}

.tm-ai-modal .tm-ai-mic-btn {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 8px;
  color: #d4af37;
  width: 36px;
  height: 36px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.18s ease;
  flex-shrink: 0;
}

.tm-ai-mic-btn:hover {
  background: rgba(212, 175, 55, 0.2);
  transform: scale(1.05);
}

.tm-ai-mic-btn.is-listening {
  background: #b42318;
  border-color: #f87171;
  color: #fff;
  animation: tm-ai-pulse-mic 1.2s infinite;
}

@keyframes tm-ai-pulse-mic {
  0% { transform: scale(1); }
  50% { transform: scale(1.08); }
  100% { transform: scale(1); }
}

.tm-ai-modal .tm-ai-submit {
  position: relative;
  right: auto;
  background: linear-gradient(135deg, #d4af37, #b45309);
  border: none;
  border-radius: 8px;
  color: #ffffff;
  width: 36px;
  height: 36px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.18s ease;
  flex-shrink: 0;
}

.tm-ai-submit:hover {
  transform: scale(1.05);
  filter: brightness(1.1);
}

/* ─── Estado de carga ─── */
.tm-ai-loading {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 10px;
}

.tm-ai-loading__spinner {
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255, 255, 255, 0.2);
  border-top-color: #f59e0b;
  border-radius: 50%;
  animation: tmAiSpin 0.75s linear infinite;
}

@keyframes tmAiSpin {
  to { transform: rotate(360deg); }
}

.tm-ai-loading__label {
  font-size: 0.8125rem;
  color: #94a3b8;
}

/* ─── Resultado de la respuesta ─── */
.tm-ai-result {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 12px;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  animation: tmAiFadeIn 0.22s ease forwards;
}

@keyframes tmAiFadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

.tm-ai-result__text {
  margin: 0;
  font-size: 0.9375rem;
  line-height: 1.55;
  color: #f8fafc;
}

.tm-ai-result__actions {
  display: flex;
  justify-content: flex-end;
}

.tm-ai-action-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  background: linear-gradient(135deg, #d4af37 0%, #6366f1 100%);
  border: none;
  border-radius: 9999px;
  color: #ffffff;
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 4px 18px rgba(99, 102, 241, 0.4);
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.tm-ai-action-btn:hover {
  transform: translateY(-1px) scale(1.02);
  box-shadow: 0 6px 24px rgba(99, 102, 241, 0.6);
}

/* ─── Animación de Puntos Suspensivos (Soporte en Vivo) ─── */
.tm-ai-typing-dots {
  display: inline-flex;
  gap: 3px;
  align-items: center;
}

.tm-ai-typing-dots span {
  display: inline-block;
  width: 5px;
  height: 5px;
  background-color: #d4af37;
  border-radius: 50%;
  animation: tmAiTypingDot 1.4s infinite ease-in-out both;
}

.tm-ai-typing-dots span:nth-child(1) {
  animation-delay: -0.32s;
}

.tm-ai-typing-dots span:nth-child(2) {
  animation-delay: -0.16s;
}

@keyframes tmAiTypingDot {
  0%, 80%, 100% {
    transform: scale(0);
    opacity: 0.3;
  }
  40% {
    transform: scale(1);
    opacity: 1;
  }
}

