/* Bantito — Asesor virtual de admisiones · Grupo Educativo Banting
   Sistema de diseño heredado de colegio-banting-main:
   - Púrpura magistral #4504aa
   - Background claro #f6f6f8
   - Tipografías Nunito (body) + Space Grotesk (display, fallback de Puffin Display Soft)
   - Glass panels sutiles, sombras suaves, sin neón ni starfield. */

:root {
  /* Brand */
  --color-primary: #4504aa;
  --color-primary-dark: #3a0391;
  --color-primary-light: #9b51e0;
  --color-primary-light-hover: #7b3bb5;

  /* Acentos (úsalos con moderación) */
  --color-accent-orange: #ff4800;
  --color-accent-blue: #257cff;
  --color-accent-cyan: #45ffed;

  /* Surfaces */
  --bg: #f6f6f8;
  --bg-elev: #ffffff;
  --bg-navy: #111621;
  --surface: rgba(69, 4, 170, 0.04);
  --surface-strong: rgba(69, 4, 170, 0.08);
  --surface-border: rgba(69, 4, 170, 0.15);

  /* Texto */
  --text: #0f172a;            /* slate-900 */
  --text-muted: #475569;      /* slate-600 */
  --text-dim: #94a3b8;        /* slate-400 */
  --text-on-primary: #ffffff;

  /* Estados */
  --success: #10b981;
  --danger: #ef4444;
  --warning: #f59e0b;

  /* Spacing */
  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-5: 24px;
  --sp-6: 32px;
  --sp-8: 48px;

  /* Radii */
  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 16px;
  --r-xl: 24px;
  --r-full: 9999px;

  /* Sombras */
  --shadow-soft: 0 20px 40px -10px rgba(15, 23, 42, 0.08);
  --shadow-md: 0 8px 24px rgba(15, 23, 42, 0.06);
  --shadow-glow: 0 0 24px rgba(69, 4, 170, 0.18);

  /* Fonts */
  --font-display: "Space Grotesk", "Nunito", system-ui, sans-serif;
  --font-body: "Nunito", system-ui, -apple-system, sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  height: 100%;
  overflow-x: hidden;
}

body {
  font-family: var(--font-body);
  color: var(--text);
  font-size: 1rem;
  line-height: 1.6;
  min-height: 100vh;
  background: var(--bg);
}

/* Stars wrapper queda en el HTML por compatibilidad pero NO renderiza nada. */
.stars { display: none; }

.container {
  position: relative;
  z-index: 1;
  max-width: 1200px;
  margin: 0 auto;
  padding: var(--sp-5);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Header */
header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: var(--sp-5);
  border-bottom: 1px solid rgba(15, 23, 42, 0.08);
  margin-bottom: var(--sp-6);
}

header h1 {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.5rem;
  letter-spacing: -0.01em;
  color: var(--color-primary);
}

/* Subtítulo del header — el texto lo llena main.js al cargar la página
   según el ?role= del query string (ventas → "Asesor de admisiones",
   tutor → "Tu compañero de estudios"). Sin esto, el header daba un
   texto fijo aunque el rol cargado fuera otro y generaba confusión. */
.header-subtitle {
  font-size: 0.95rem;
  color: var(--text-muted);
  font-family: var(--font-body);
  font-weight: 500;
  margin-left: var(--sp-2);
}
.header-subtitle::before {
  content: " · ";
}
.header-subtitle:empty::before {
  content: "";
}

.status {
  font-family: var(--font-body);
  font-size: 0.85rem;
  font-weight: 600;
  padding: var(--sp-1) var(--sp-3);
  border-radius: var(--r-full);
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
}

.status::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
  display: inline-block;
}

.status.disconnected { color: var(--text-dim); background: rgba(148, 163, 184, 0.15); }
.status.connected    { color: var(--success);  background: rgba(16, 185, 129, 0.12); }
.status.error        { color: var(--danger);   background: rgba(239, 68, 68, 0.12); }

main {
  flex: 1;
  display: flex;
  flex-direction: column;
}

/* Auth / Hero corporativo */
.auth-section {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

.hero {
  max-width: 640px;
  margin: 0 auto;
  text-align: center;
  background: var(--bg-elev);
  border-radius: var(--r-xl);
  border: 1px solid rgba(15, 23, 42, 0.06);
  box-shadow: var(--shadow-soft);
  padding: var(--sp-8) var(--sp-6);
}

/* Hero video oculto en role ventas (lo dejamos en el HTML por compat con tutor en main) */
.hero-video,
.hero-video-poster { display: none !important; }

.avatar { display: none; }

.hero-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(2rem, 4vw, 2.75rem);
  letter-spacing: -0.02em;
  color: var(--text);
  margin-bottom: var(--sp-3);
}

.hero-sub {
  font-size: 1.05rem;
  color: var(--text-muted);
  max-width: 480px;
  margin: 0 auto var(--sp-6) auto;
  line-height: 1.6;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-3);
  justify-content: center;
}

/* Aviso de grabación LFPDPPP — discreto, debajo del subtítulo del hero,
   antes del botón "Iniciar conversación". Compliance requirement: el papá
   debe ver explícitamente que la sesión se graba antes de aceptar. */
.recording-notice {
  font-size: 0.85rem;
  color: var(--text-muted);
  max-width: 480px;
  margin: 0 auto var(--sp-5) auto;
  line-height: 1.5;
}
.recording-notice a {
  color: var(--color-primary);
  text-decoration: none;
  font-weight: 600;
}
.recording-notice a:hover {
  text-decoration: underline;
}

/* Botones */
.btn {
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 0.95rem;
  padding: var(--sp-3) var(--sp-5);
  border-radius: var(--r-md);
  border: 1px solid rgba(15, 23, 42, 0.08);
  background: var(--bg-elev);
  color: var(--text);
  cursor: pointer;
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
}

.btn:hover:not(:disabled) {
  background: var(--surface);
  border-color: var(--surface-border);
  transform: translateY(-1px);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.btn-primary,
#connectBtn,
#restartBtn,
#sendBtn,
#modalConnectBtn {
  background: var(--color-primary);
  color: var(--text-on-primary);
  border: 1px solid var(--color-primary);
  box-shadow: var(--shadow-glow);
}

.btn-primary:hover:not(:disabled),
#connectBtn:hover:not(:disabled),
#restartBtn:hover:not(:disabled),
#sendBtn:hover:not(:disabled),
#modalConnectBtn:hover:not(:disabled) {
  background: var(--color-primary-dark);
  border-color: var(--color-primary-dark);
  transform: translateY(-1px);
}

.icon-btn {
  background: var(--bg-elev);
  border: 1px solid rgba(15, 23, 42, 0.08);
  color: var(--text);
  font-size: 0.9rem;
  padding: var(--sp-2) var(--sp-4);
  border-radius: var(--r-md);
}

.icon-btn:hover:not(:disabled) {
  background: var(--surface);
  border-color: var(--surface-border);
}

.btn.danger,
#disconnectBtn {
  background: rgba(239, 68, 68, 0.08);
  color: var(--danger);
  border-color: rgba(239, 68, 68, 0.2);
}

/* Botón "atención necesaria": cuando el auto-start del mic falló y el usuario
   debe clickearlo manualmente para activar la conversación. Pulse + acento púrpura
   para que sea visualmente obvio cuál es el siguiente paso. */
.btn.attention-needed,
.icon-btn.attention-needed {
  background: var(--color-primary);
  color: var(--text-on-primary);
  border-color: var(--color-primary);
  animation: attention-pulse 1.4s ease-in-out infinite;
  box-shadow: var(--shadow-glow);
}

@keyframes attention-pulse {
  0%, 100% { transform: scale(1);    box-shadow: var(--shadow-glow); }
  50%      { transform: scale(1.05); box-shadow: 0 0 36px rgba(69, 4, 170, 0.55); }
}

.btn.danger:hover:not(:disabled),
#disconnectBtn:hover:not(:disabled) {
  background: rgba(239, 68, 68, 0.15);
  border-color: rgba(239, 68, 68, 0.35);
}

/* App layout (durante conversación) */
.app-section {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.app-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--sp-5);
  flex: 1;
  min-height: 0;
}

@media (max-width: 768px) {
  .app-grid {
    grid-template-columns: 1fr;
  }
}

.left-panel,
.right-panel {
  background: var(--bg-elev);
  border-radius: var(--r-lg);
  border: 1px solid rgba(15, 23, 42, 0.06);
  box-shadow: var(--shadow-md);
  padding: var(--sp-5);
  display: flex;
  flex-direction: column;
  gap: var(--sp-4);
  min-height: 0;
}

.right-panel {
  height: 100%;
}

.video-container {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: var(--bg-navy);
  border-radius: var(--r-md);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

#video-preview {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

#video-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: rgba(255, 255, 255, 0.7);
  font-size: 0.9rem;
  text-align: center;
  padding: var(--sp-4);
}

#video-placeholder.hidden {
  display: none;
}

/* Audio orb — feedback visual cuando el bot habla */
.audio-orb {
  width: 90px;
  height: 90px;
  border-radius: 50%;
  margin: 0 auto;
  position: relative;
  background: radial-gradient(circle at 30% 30%, var(--color-primary-light), var(--color-primary));
  box-shadow: var(--shadow-glow);
  flex-shrink: 0;
}

.audio-orb::before {
  content: "";
  position: absolute;
  inset: -8px;
  border-radius: 50%;
  border: 2px solid var(--color-primary);
  opacity: 0;
  transition: opacity 0.2s ease;
}

.audio-orb.listening::before {
  opacity: 0.4;
  animation: pulse 1.6s ease-in-out infinite;
}

.audio-orb.speaking::before {
  opacity: 0.7;
  animation: pulse 0.6s ease-in-out infinite;
}

@keyframes pulse {
  0%   { transform: scale(1);   opacity: 0.7; }
  50%  { transform: scale(1.2); opacity: 0.2; }
  100% { transform: scale(1);   opacity: 0.7; }
}

.controls {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2);
  justify-content: center;
}

/* Chat log */
.chat-log {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
  padding-right: var(--sp-2);
  min-height: 240px;
}

.chat-log::-webkit-scrollbar { width: 6px; }
.chat-log::-webkit-scrollbar-track { background: transparent; }
.chat-log::-webkit-scrollbar-thumb { background: var(--surface-border); border-radius: var(--r-full); }
.chat-log::-webkit-scrollbar-thumb:hover { background: var(--color-primary-light); }

.message {
  max-width: 85%;
  padding: var(--sp-3) var(--sp-4);
  border-radius: var(--r-md);
  font-size: 0.95rem;
  line-height: 1.5;
  word-wrap: break-word;
}

.message.user {
  align-self: flex-end;
  background: var(--color-primary);
  color: var(--text-on-primary);
  border-bottom-right-radius: var(--r-sm);
}

.message.gemini {
  align-self: flex-start;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--surface-border);
  border-bottom-left-radius: var(--r-sm);
}

/* Mensajes "system" — avisos del sistema (idle_warning, idle_timeout,
   go_away, error). Estilo neutro tipo banner, distinto al diálogo conversacional
   con Bantito para que el papá note que es un aviso operativo. */
.message.system {
  align-self: stretch;
  max-width: 100%;
  background: rgba(245, 158, 11, 0.06);
  color: var(--text-muted);
  border: 1px solid rgba(245, 158, 11, 0.25);
  border-left: 3px solid var(--warning);
  border-radius: var(--r-sm);
  font-size: 0.9rem;
  font-style: italic;
  text-align: center;
}

/* Input */
.input-area {
  display: flex;
  gap: var(--sp-2);
  padding-top: var(--sp-3);
  border-top: 1px solid rgba(15, 23, 42, 0.06);
}

#textInput {
  flex: 1;
  font-family: var(--font-body);
  font-size: 0.95rem;
  padding: var(--sp-3) var(--sp-4);
  border-radius: var(--r-md);
  border: 1px solid rgba(15, 23, 42, 0.1);
  background: var(--bg);
  color: var(--text);
  transition: border-color 0.2s ease;
}

#textInput:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(69, 4, 170, 0.1);
}

#textInput::placeholder {
  color: var(--text-dim);
}

/* Session end */
.session-end-section {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  background: var(--bg-elev);
  border-radius: var(--r-xl);
  border: 1px solid rgba(15, 23, 42, 0.06);
  box-shadow: var(--shadow-soft);
  padding: var(--sp-8) var(--sp-6);
  max-width: 640px;
  margin: 0 auto;
}

.session-end-section h2 {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.75rem;
  color: var(--text);
  margin-bottom: var(--sp-3);
}

.session-end-section p {
  color: var(--text-muted);
  margin-bottom: var(--sp-5);
  max-width: 420px;
}

.hidden {
  display: none !important;
}

/* Modal "Conoce a Bantito" — oculto en role ventas, mantengo CSS por compat tutor */
.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(15, 23, 42, 0.7);
  padding: var(--sp-4);
  backdrop-filter: blur(8px);
}

.modal-content {
  position: relative;
  background: var(--bg-elev);
  border-radius: var(--r-xl);
  width: 100%;
  max-width: 640px;
  padding: var(--sp-5);
  box-shadow: var(--shadow-soft);
}

.modal-close {
  position: absolute;
  top: var(--sp-3);
  right: var(--sp-3);
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 1.5rem;
  cursor: pointer;
  width: 32px;
  height: 32px;
  border-radius: var(--r-full);
  transition: background 0.2s ease;
}

.modal-close:hover {
  background: var(--surface);
}

.modal-content iframe {
  width: 100%;
  aspect-ratio: 16 / 9;
  border-radius: var(--r-md);
  border: none;
}

.modal-footer {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--sp-3);
  margin-top: var(--sp-4);
}

.modal-hint {
  color: var(--text-muted);
  font-size: 0.95rem;
}
