/* ═══════════════════════════════════════════════════════════════
   orientador.css — Chat Interface
   ═══════════════════════════════════════════════════════════════ */

.orientador-layout {
  display: grid;
  grid-template-columns: 300px 1fr;
  gap: 0;
  height: calc(100vh - var(--header-h));
  transition: grid-template-columns 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

.orientador-layout.sidebar-collapsed {
  grid-template-columns: 0px 1fr;
}

/* ── Sidebar toggle button ─────────────────────────────────── */
.sidebar-toggle-btn {
  width: 34px;
  height: 34px;
  background: transparent;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  color: var(--color-text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all var(--transition);
}

.sidebar-toggle-btn:hover {
  background: var(--color-primary-dim);
  color: var(--color-primary);
  border-color: var(--color-primary);
}

/* Rota el ícono cuando el panel está abierto */
.orientador-layout:not(.sidebar-collapsed) .sidebar-toggle-btn svg {
  transform: scaleX(-1);
}

/* ── Modal de acceso ────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background-color: rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 9999;
  padding: 20px;
}

.modal-content {
  background: var(--color-bg-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl);
  padding: 40px 36px 32px;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 24px 64px var(--color-shadow), 0 0 0 1px var(--color-primary-dim);
  text-align: center;
  animation: modal-appear 0.35s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

@keyframes modal-appear {
  from { opacity: 0; transform: translateY(20px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0)    scale(1); }
}

/* ícono de marca centrado */
.modal-brand-icon {
  width: 60px;
  height: 60px;
  background: linear-gradient(135deg, var(--color-primary), var(--color-accent));
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 20px;
  color: #ffffff;
}

.modal-brand-icon svg {
  width: 32px;
  height: auto;
  fill: currentColor;
}

.modal-title {
  font-family: var(--font-heading);
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--color-text);
  margin-bottom: 8px;
}

.modal-subtitle {
  font-family: var(--font-body);
  font-size: 0.85rem;
  color: var(--color-text-muted);
  line-height: 1.55;
  margin-bottom: 28px;
}

/* campos */
.modal-field {
  text-align: left;
  margin-bottom: 16px;
}

.modal-label {
  display: block;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--color-text-muted);
  margin-bottom: 6px;
}

.modal-input {
  width: 100%;
  padding: 12px 16px;
  background: var(--color-bg-subtle);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  font-family: var(--font-body);
  font-size: 0.9rem;
  color: var(--color-text);
  transition: border-color var(--transition), box-shadow var(--transition);
  box-sizing: border-box;
}

.modal-input::placeholder {
  color: var(--color-text-muted);
  opacity: 0.7;
}

.modal-input:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px var(--color-primary-dim);
  background: var(--color-bg-card);
}

/* botón principal */
.modal-btn {
  width: 100%;
  padding: 13px 20px;
  margin-top: 8px;
  background: var(--color-primary);
  color: #ffffff;
  border: none;
  border-radius: var(--radius-md);
  font-family: var(--font-heading);
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: all var(--transition);
  letter-spacing: 0.01em;
}

.modal-btn:hover {
  background: var(--color-accent);
  transform: translateY(-2px);
  box-shadow: 0 8px 24px var(--color-shadow);
}

.modal-btn:active {
  transform: translateY(0);
  box-shadow: none;
}


/* ── Sidebar ────────────────────────────────────────────────── */
.chat-sidebar {
  background: var(--color-bg-card);
  border-right: 1px solid var(--color-border);
  padding: 28px 20px;
  display: flex;
  flex-direction: column;
  gap: 24px;
  overflow: hidden;          /* clip contenido al contraer */
  min-width: 0;              /* permite que grid lo lleve a 0px */
  opacity: 1;
  transition: opacity 0.2s ease;
}

.sidebar-collapsed .chat-sidebar {
  opacity: 0;
  pointer-events: none;
  border-right: none;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--color-border);
}

.sidebar-brand-icon {
  width: 44px; height: 44px;
  background: linear-gradient(135deg, var(--color-primary), var(--color-accent));
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  /* Fondo coloreado → icono blanco para contraste óptimo */
  color: #ffffff;
}

/* Logo vectorial Trayector-IA (sustituye al ícono de robot) */
.brand-icon {
  display: block;
  fill: currentColor;
}
.sidebar-brand-icon .brand-icon { width: 26px; height: auto; }

/* Avatar del bot en mensajes: fondo degradado → icono blanco */
.msg-avatar.ai-av {
  color: #ffffff;
}
.msg-avatar.ai-av .brand-icon  { width: 18px; height: auto; }

.sidebar-brand h2 {
  font-size: 1rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.sidebar-brand p {
  font-size: 0.72rem;
  color: var(--color-text-muted);
}

/* Progress section */
.progress-section h4 {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--color-text-muted);
  margin-bottom: 12px;
  font-family: var(--font-mono);
}

.progress-numbers {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 8px;
}

.progress-current {
  font-family: var(--font-heading);
  font-size: 2rem;
  font-weight: 900;
  color: var(--color-primary);
  line-height: 1;
}

.progress-total {
  font-size: 0.85rem;
  color: var(--color-text-muted);
}

/* Question dots */
.question-dots {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 6px;
  margin-top: 4px;
}

.q-dot {
  height: 4px;
  border-radius: 100px;
  background: var(--color-border);
  transition: all var(--transition);
}

.q-dot.done {
  background: var(--color-success);
}

.q-dot.active {
  background: var(--color-primary);
  animation: pulse-bar 1.5s ease-in-out infinite;
}

@keyframes pulse-bar {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* Steps list */
.steps-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.step-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  color: var(--color-text-muted);
  transition: all var(--transition);
}

.step-item.done {
  color: var(--color-success);
}

.step-item.active {
  background: var(--color-primary-dim);
  color: var(--color-primary);
  font-weight: 600;
}

.step-badge {
  width: 20px; height: 20px;
  border-radius: 50%;
  background: var(--color-border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.65rem;
  font-weight: 700;
  flex-shrink: 0;
  font-family: var(--font-mono);
}

.step-item.done .step-badge {
  background: var(--color-success);
  color: #fff;
}

.step-item.active .step-badge {
  background: var(--color-primary);
  color: #fff;
}

/* Sidebar tips */
.sidebar-tip {
  background: var(--color-bg-subtle);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 14px;
  margin-top: auto;
}

.tip-label {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--color-primary);
  font-family: var(--font-mono);
  margin-bottom: 6px;
}

.sidebar-tip p {
  font-size: 0.78rem;
  color: var(--color-text-muted);
  line-height: 1.5;
}

/* ── Chat Area ──────────────────────────────────────────────── */
.chat-area {
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
}

.chat-topbar {
  padding: 16px 24px;
  border-bottom: 1px solid var(--color-border);
  background: var(--color-bg);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.chat-topbar-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.ai-status-dot {
  width: 8px; height: 8px;
  background: var(--color-success);
  border-radius: 50%;
  animation: blink 2s ease-in-out infinite;
}

@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

.chat-topbar h3 {
  font-size: 0.9rem;
  font-weight: 700;
}

.chat-topbar p {
  font-size: 0.75rem;
  color: var(--color-text-muted);
}

/* Messages container */
.messages-container {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  scroll-behavior: smooth;
}

.message-row {
  display: flex;
  gap: 10px;
  max-width: 80%;
  animation: msg-slide-up 0.35s ease forwards;
}

@keyframes msg-slide-up {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

.message-row.user {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.message-row.bot {
  align-self: flex-start;
}

.msg-avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
  flex-shrink: 0;
}

.msg-avatar.ai-av {
  background: linear-gradient(135deg, var(--color-primary), var(--color-accent));
}

.msg-avatar.user-av {
  background: var(--color-bg-subtle);
  border: 1px solid var(--color-border);
}

.msg-bubble {
  padding: 12px 16px;
  border-radius: var(--radius-md);
  font-size: 0.88rem;
  line-height: 1.6;
}

/* Párrafos dentro de las burbujas: el reset global aplica margin:0 a todos
   los elementos, lo que comprime el texto del saludo inicial en un bloque
   ilegible. Restauramos el espaciado inter-párrafo aquí. */
.msg-bubble p {
  margin-top: 0;
  margin-bottom: 0.55em;
}
.msg-bubble p:last-child {
  margin-bottom: 0;
}

/* El saludo inicial puede ser largo; el bot message toma más ancho disponible */
.message-row.bot {
  max-width: 90%;
}

/* ── Resaltado de preguntas en negritas ──────────────────────────
   El LLM envuelve cada pregunta con **dobles asteriscos**; formatMarkdown
   los convierte en <strong>. Aplicamos color primario + peso 800 para que
   la pregunta destaque visualmente del texto de transición del orientador. */
.message-row.bot .msg-bubble strong {
  color: var(--color-primary);
  font-weight: 800;
}

.message-row.bot .msg-bubble {
  background: var(--color-bg-card);
  border: 1px solid var(--color-border);
  border-bottom-left-radius: 4px;
  color: var(--color-text);
}

.message-row.user .msg-bubble {
  background: var(--color-primary);
  color: #fff;
  border-bottom-right-radius: 4px;
}

/* Typing indicator */
.typing-indicator {
  display: flex;
  gap: 4px;
  align-items: center;
  padding: 10px 14px;
}

.typing-indicator span {
  width: 6px; height: 6px;
  background: var(--color-text-muted);
  border-radius: 50%;
  animation: typing-dot 1.4s ease-in-out infinite;
}

.typing-indicator span:nth-child(2) { animation-delay: 0.2s; }
.typing-indicator span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typing-dot {
  0%, 80%, 100% { transform: translateY(0); opacity: 0.4; }
  40%            { transform: translateY(-5px); opacity: 1; }
}

/* Warning / info messages */
.msg-warning {
  background: rgba(240, 165, 0, 0.1);
  border: 1px solid rgba(240, 165, 0, 0.3);
  color: var(--color-warning);
  padding: 10px 14px;
  border-radius: var(--radius-md);
  font-size: 0.82rem;
  display: flex;
  gap: 8px;
  align-items: flex-start;
  animation: msg-slide-up 0.35s ease forwards;
  max-width: 80%;
  align-self: flex-start;
}

/* ── Input Area ─────────────────────────────────────────────── */
.chat-input-area {
  padding: 16px 24px;
  border-top: 1px solid var(--color-border);
  background: var(--color-bg);
  flex-shrink: 0;
}

.word-count-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
  font-size: 0.72rem;
  color: var(--color-text-muted);
  font-family: var(--font-mono);
}

.wc-number {
  font-weight: 600;
  transition: color var(--transition);
}

.wc-number.ok { color: var(--color-success); }
.wc-number.warn { color: var(--color-warning); }

.input-row {
  display: flex;
  gap: 10px;
  align-items: flex-end;
}

#chat-input {
  flex: 1;
  background: var(--color-bg-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 12px 16px;
  font-family: var(--font-body);
  font-size: 0.9rem;
  color: var(--color-text);
  resize: none;
  min-height: 48px;
  max-height: 120px;
  transition: border-color var(--transition);
  line-height: 1.5;
}

#chat-input:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px var(--color-primary-dim);
}

#chat-input::placeholder { color: var(--color-text-muted); }

#send-btn {
  width: 48px; height: 48px;
  background: var(--color-primary);
  border: none;
  border-radius: var(--radius-md);
  color: #fff;
  font-size: 1.1rem;
  cursor: pointer;
  transition: all var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

#send-btn:hover:not(:disabled) {
  background: var(--color-accent);
  transform: scale(1.05);
  box-shadow: 0 4px 16px var(--color-shadow);
}

#send-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* ── Completion overlay ─────────────────────────────────────── */
.completion-banner {
  background: linear-gradient(135deg, var(--color-primary), var(--color-accent));
  color: #fff;
  padding: 16px 24px;
  text-align: center;
  font-family: var(--font-heading);
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  flex-wrap: wrap;
  display: none;
}

.completion-banner.show { display: flex; }

/* ── Responsive ─────────────────────────────────────────────── */
@media (max-width: 768px) {
  /* En móvil el sidebar siempre ocupa su fila normal; ignoramos la clase collapsed */
  .orientador-layout,
  .orientador-layout.sidebar-collapsed {
    grid-template-columns: 1fr;
    height: auto;
    min-height: calc(100vh - var(--header-h));
  }

  .chat-sidebar,
  .sidebar-collapsed .chat-sidebar {
    opacity: 1;
    pointer-events: auto;
    border-right: none;
    border-bottom: 1px solid var(--color-border);
    padding: 16px;
    flex-direction: row;
    flex-wrap: wrap;
    gap: 12px;
  }

  .sidebar-brand { padding-bottom: 0; border-bottom: none; }
  .steps-list, .sidebar-tip { display: none; }

  /* Ocultamos el botón toggle en móvil (el sidebar siempre está visible) */
  .sidebar-toggle-btn { display: none; }

  .chat-area {
    height: calc(100vh - var(--header-h) - 140px);
  }

  .message-row { max-width: 90%; }
}

/* ── Sidebar blocks (Bloque 1 / Bloque 2) ─────────────────── */
.sidebar-block {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.block-label {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--color-text-muted);
  padding: 6px 0 4px;
  border-bottom: 1px solid var(--color-border);
  margin-bottom: 4px;
}

/* Override dots grid for 10 questions */
.question-dots {
  grid-template-columns: repeat(10, 1fr) !important;
}
