/* AireAmigo - Chat amigable, dinámico y con colores llamativos (todo en el mismo panel) */

.aireamigo-widget {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 1040;
  font-family: var(--default-font, inherit);
}

/* Botón flotante: animado y llamativo */
.aireamigo-toggle {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.65rem 1.15rem;
  background: linear-gradient(135deg, #0284c7 0%, #0ea5e9 50%, #38bdf8 100%);
  color: #fff;
  border: 2px solid #ffffff;
  border-radius: 2rem;
  box-shadow: 0 4px 16px rgba(2, 132, 199, 0.45), 0 2px 6px rgba(0, 0, 0, 0.08);
  cursor: pointer;
  transition: transform 0.25s ease, box-shadow 0.25s ease;
  font-size: 1rem;
  font-weight: 600;
  animation: aireamigo-pulse 2.5s ease-in-out infinite;
}

.aireamigo-toggle:hover {
  transform: translateY(-3px) scale(1.02);
  box-shadow: 0 8px 24px rgba(2, 132, 199, 0.5), 0 4px 12px rgba(0, 0, 0, 0.1);
  color: #fff;
}

.aireamigo-toggle:focus {
  outline: 2px solid #0ea5e9;
  outline-offset: 3px;
}

.aireamigo-toggle-icon {
  display: inline-flex;
  align-items: center;
  line-height: 0;
}

/* Blanco manteniendo transparencia: brightness(0) → negro, invert(1) → blanco; lo transparente sigue transparente */
.aireamigo-toggle-gif {
  width: 32px;
  height: 32px;
  object-fit: contain;
  filter: brightness(0) invert(1) drop-shadow(0 1px 2px rgba(0,0,0,0.25));
  vertical-align: middle;
}

.aireamigo-header-gif {
  width: 24px;
  height: 24px;
  object-fit: contain;
  filter: brightness(0) invert(1);
  vertical-align: middle;
  margin-right: 0.35rem;
}

/* Respiración suave para texto (escala muy sutil, ritmo lento) */
.aireamigo-pulse-suave {
  display: inline-block;
  animation: aireamigo-pulse-suave 2s ease-in-out infinite;
}

@keyframes aireamigo-pulse-suave {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.015); }
}

@keyframes aireamigo-pulse {
  0%, 100% { box-shadow: 0 4px 16px rgba(2, 132, 199, 0.45), 0 2px 6px rgba(0, 0, 0, 0.08); }
  50% { box-shadow: 0 6px 20px rgba(2, 132, 199, 0.55), 0 3px 8px rgba(0, 0, 0, 0.1); }
}

/* Panel del chat */
.aireamigo-panel {
  position: absolute;
  bottom: 100%;
  right: 0;
  margin-bottom: 0.6rem;
  width: 340px;
  max-width: calc(100vw - 2rem);
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.15), 0 0 0 1px rgba(14, 165, 233, 0.15);
  overflow: hidden;
  animation: aireamigo-slideUp 0.35s ease-out;
}

@keyframes aireamigo-slideUp {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.aireamigo-panel[hidden] {
  display: none !important;
}

.aireamigo-panel-inner {
  padding: 0;
}

/* Cabecera con gradiente */
.aireamigo-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.85rem 1rem;
  background: linear-gradient(135deg, #0c4a6e 0%, #0369a1 50%, #0284c7 100%);
  color: #fff;
}

.aireamigo-name {
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: 0.02em;
}

.aireamigo-close {
  background: rgba(255, 255, 255, 0.2);
  border: none;
  color: inherit;
  padding: 0.35rem;
  cursor: pointer;
  border-radius: 8px;
  line-height: 1;
  transition: background 0.2s;
}

.aireamigo-close:hover {
  background: rgba(255, 255, 255, 0.35);
}

/* Switch notificaciones emergentes en cabecera */
.aireamigo-notif-wrap {
  display: flex;
  align-items: center;
}
.aireamigo-notif-label {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  margin: 0;
  user-select: none;
}
.aireamigo-notif-text {
  font-size: 0.8rem;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.95);
  white-space: nowrap;
  transition: color 0.2s ease, opacity 0.2s ease;
}
.aireamigo-notif-label:has(.aireamigo-notif-switch:not(:checked)) .aireamigo-notif-text {
  color: rgba(255, 255, 255, 0.65);
}
.aireamigo-notif-switch {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
.aireamigo-notif-track {
  display: inline-flex;
  align-items: center;
  width: 2.5rem;
  height: 1.35rem;
  background: rgba(0, 0, 0, 0.35);
  border-radius: 999px;
  border: 2px solid rgba(255, 255, 255, 0.25);
  transition: background 0.25s ease, border-color 0.25s ease, box-shadow 0.25s ease;
  flex-shrink: 0;
  box-sizing: border-box;
}
.aireamigo-notif-track::after {
  content: '';
  display: block;
  width: 1rem;
  height: 1rem;
  margin-left: 0.15rem;
  background: #e2e8f0;
  border-radius: 50%;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.35);
  transition: transform 0.25s ease, background 0.25s ease;
}
/* Activo: track verde, círculo blanco a la derecha */
.aireamigo-notif-switch:checked + .aireamigo-notif-track {
  background: linear-gradient(135deg, #22c55e 0%, #16a34a 100%);
  border-color: rgba(255, 255, 255, 0.5);
  box-shadow: 0 0 0 1px rgba(34, 197, 94, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.2);
}
.aireamigo-notif-switch:checked + .aireamigo-notif-track::after {
  transform: translateX(1.05rem);
  background: #fff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.25);
}
/* Inactivo: track oscuro, círculo gris a la izquierda */
.aireamigo-notif-switch:focus + .aireamigo-notif-track,
.aireamigo-notif-switch:focus-visible + .aireamigo-notif-track {
  outline: 2px solid #fff;
  outline-offset: 2px;
}
.aireamigo-notif-label:hover .aireamigo-notif-track {
  border-color: rgba(255, 255, 255, 0.4);
}
.aireamigo-notif-label:hover .aireamigo-notif-switch:checked + .aireamigo-notif-track {
  background: linear-gradient(135deg, #4ade80 0%, #22c55e 100%);
  box-shadow: 0 0 0 1px rgba(34, 197, 94, 0.6), inset 0 1px 0 rgba(255, 255, 255, 0.25);
}

/* Contenido: vistas intercambiables */
.aireamigo-content {
  padding: 1rem;
  max-height: 70vh;
  overflow-y: auto;
}

.aireamigo-vista {
  animation: aireamigo-fadeIn 0.3s ease-out;
}

.aireamigo-vista[hidden] {
  display: none !important;
}

@keyframes aireamigo-fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* Burbujas de mensaje por tipo */
.aireamigo-bubble {
  padding: 1rem;
  border-radius: 14px;
  margin-bottom: 0.85rem;
  border-left: 4px solid;
}

.aireamigo-bubble-orientador {
  background: linear-gradient(135deg, #e0f2fe 0%, #bae6fd 100%);
  border-left-color: #0284c7;
}

.aireamigo-bubble-refuerzo {
  background: linear-gradient(135deg, #dcfce7 0%, #bbf7d0 100%);
  border-left-color: #16a34a;
}

.aireamigo-badge {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #0369a1;
  margin-bottom: 0.4rem;
  padding: 0.2rem 0.5rem;
  background: rgba(255,255,255,0.7);
  border-radius: 6px;
}

.aireamigo-bubble-refuerzo .aireamigo-badge {
  color: #15803d;
}

.aireamigo-message {
  font-size: 0.95rem;
  line-height: 1.5;
  margin: 0 0 0.4rem 0;
  color: #1e293b;
  font-weight: 500;
}

.aireamigo-subtitle {
  font-size: 0.875rem;
  color: #475569;
  margin: 0;
  line-height: 1.4;
}

/* Quiz de educación dentro del chat */
.aireamigo-quiz-block {
  padding: 0.85rem;
  margin-bottom: 0.85rem;
  background: linear-gradient(135deg, #f0f9ff 0%, #e0f2fe 100%);
  border-radius: 12px;
  border: 1px solid rgba(2, 132, 199, 0.2);
}

.aireamigo-quiz-title {
  font-size: 0.85rem;
  font-weight: 700;
  color: #0369a1;
  margin: 0 0 0.5rem 0;
}

.aireamigo-quiz-pregunta {
  font-size: 0.875rem;
  font-weight: 500;
  color: #1e293b;
  margin: 0 0 0.5rem 0;
  line-height: 1.35;
}

.aireamigo-quiz-opciones .form-check-label {
  font-size: 0.8rem;
  cursor: pointer;
}

.aireamigo-quiz-feedback.alert {
  font-size: 0.8rem;
  padding: 0.5rem 0.65rem;
}

/* Alertas dentro del chat */
.aireamigo-alerta {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 0.5rem;
  padding: 0.75rem;
  border-radius: 12px;
  margin-bottom: 0.85rem;
  font-size: 0.875rem;
  line-height: 1.4;
}

.aireamigo-alerta i {
  flex-shrink: 0;
  font-size: 1.1rem;
}

.aireamigo-alerta-reminder {
  background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
  color: #92400e;
  border: 1px solid #fcd34d;
}

.aireamigo-alerta-reminder i {
  color: #d97706;
}

.aireamigo-alerta-aviso {
  background: linear-gradient(135deg, #fef9c3 0%, #fef08a 100%);
  color: #854d0e;
  border: 1px solid #fde047;
  margin-bottom: 0.75rem;
}

.aireamigo-alerta-aviso i {
  color: #ca8a04;
}

.aireamigo-btn-inline {
  font-weight: 700;
  color: #b45309;
  text-decoration: none;
  white-space: nowrap;
}

.aireamigo-btn-inline:hover {
  color: #92400e;
  text-decoration: underline;
}

/* Aviso médico */
.aireamigo-disclaimer {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  padding: 0.6rem 0;
  margin-bottom: 0.75rem;
  border-top: 1px solid #e2e8f0;
}

.aireamigo-disclaimer i {
  color: #16a34a;
  font-size: 1rem;
  flex-shrink: 0;
  margin-top: 0.1rem;
}

.aireamigo-disclaimer small {
  font-size: 0.75rem;
  color: #64748b;
  line-height: 1.4;
}

/* Botones de acción */
.aireamigo-actions {
  margin-top: 0.25rem;
}

.aireamigo-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.55rem 1rem;
  border-radius: 10px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: transform 0.2s, box-shadow 0.2s;
  width: 100%;
  justify-content: center;
}

.aireamigo-btn:hover {
  transform: translateY(-1px);
}

.aireamigo-btn-sugerencias {
  background: linear-gradient(135deg, #7c3aed 0%, #a78bfa 100%);
  color: #fff;
  box-shadow: 0 2px 8px rgba(124, 58, 237, 0.35);
}

.aireamigo-btn-sugerencias:hover {
  box-shadow: 0 4px 14px rgba(124, 58, 237, 0.45);
  color: #fff;
}

/* Vista sugerencias: formulario dentro del chat */
.aireamigo-vista-header {
  margin-bottom: 0.75rem;
}

.aireamigo-back {
  background: none;
  border: none;
  color: #0369a1;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  padding: 0.25rem 0;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  transition: color 0.2s;
}

.aireamigo-back:hover {
  color: #0284c7;
}

.aireamigo-form .aireamigo-label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: #334155;
  margin-bottom: 0.3rem;
  margin-top: 0.6rem;
}

.aireamigo-form .aireamigo-label:first-of-type {
  margin-top: 0;
}

.aireamigo-input {
  width: 100%;
  padding: 0.5rem 0.65rem;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  font-size: 0.875rem;
  transition: border-color 0.2s, box-shadow 0.2s;
  font-family: inherit;
}

.aireamigo-input:focus {
  outline: none;
  border-color: #0ea5e9;
  box-shadow: 0 0 0 3px rgba(14, 165, 233, 0.2);
}

.aireamigo-input.is-invalid {
  border-color: #dc2626;
}

.aireamigo-btn-primary {
  margin-top: 0.85rem;
  background: linear-gradient(135deg, #059669 0%, #10b981 100%);
  color: #fff;
  box-shadow: 0 2px 8px rgba(5, 150, 105, 0.35);
}

.aireamigo-btn-primary:hover {
  color: #fff;
  box-shadow: 0 4px 12px rgba(5, 150, 105, 0.45);
}

.aireamigo-result {
  padding: 0.5rem 0;
}

.aireamigo-result-text {
  font-size: 0.95rem;
  font-weight: 500;
  margin-bottom: 0.75rem;
  padding: 0.75rem;
  border-radius: 10px;
}

.aireamigo-result.exito .aireamigo-result-text {
  background: linear-gradient(135deg, #dcfce7 0%, #bbf7d0 100%);
  color: #166534;
}

.aireamigo-result.error .aireamigo-result-text {
  background: linear-gradient(135deg, #fee2e2 0%, #fecaca 100%);
  color: #991b1b;
}

.aireamigo-btn-outline {
  background: #fff;
  color: #0369a1;
  border: 2px solid #0ea5e9;
}

.aireamigo-btn-outline:hover {
  background: #e0f2fe;
  color: #0369a1;
}

@media (max-width: 480px) {
  .aireamigo-widget {
    bottom: 1rem;
    right: 1rem;
  }
  .aireamigo-panel {
    width: calc(100vw - 2rem);
    max-width: 320px;
  }
}
