:root {
  --sidebar-w: 260px;
}

* {
  box-sizing: border-box;
}

body {
  font-family: 'Segoe UI', Arial, sans-serif;
  background: #FFF;
  margin: 0;
  padding: 0;
  min-height: 100vh;
  overflow-x: auto; /* permitir scroll horizontal en embebidos (ENPS) */
}

.layout {
  display: flex;
  align-items: stretch;
  min-height: 100vh;
}

/* Sidebar sticky */
aside.sidebar {
  position: sticky;
  top: 0;
  align-self: flex-start;
  height: 100vh;
  width: var(--sidebar-w);
  overflow: auto;
  background: #f7f7f8;
  border-right: 1px solid #EEE;
  padding: 16px 12px;
}

.sidebar .sb-title {
  font-weight: 700;
  color: #111;
  margin: 4px 6px 12px;
  font-size: 1rem;
  letter-spacing: .2px;
}

.menu-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.menu-link {
  display: flex;
  align-items: center;
  padding: 10px 12px;
  border-radius: 8px;
  text-decoration: none;
  color: #222;
  background: #fff;
  border: 1px solid #eee;
  font-size: 0.95rem;
  line-height: 1.2;
  transition: background .15s, border-color .15s;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.menu-link:hover {
  background: #f0f0f3;
  border-color: #e5e5e9;
}

.menu-link.active {
  outline: 2px solid red;
}

.menu-loading,
.menu-error {
  padding: 10px 12px;
  color: #555;
  font-size: 0.95rem;
}

/* Main */
main.main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.chat-container {
  /* max-width: 780px; */
  width: 70%;
  margin: 24px auto;
  background: #FFF;
  border-radius: 12px;
  padding: 0;
  display: flex;
  flex-direction: column;
  min-height: 80vh;
}

.header {
  padding: 0 10px;
  color: #333;
  font-size: 2rem;
  font-weight: 600;
  border-bottom: 1px solid #EEE;
  display: flex;
  align-items: center;
  flex-direction: row;
  justify-content: center;
  gap: 10px;
  min-height: 72px;
}

/* Variante para estado sin programa: dos logos arriba, título centrado abajo */
.header.header--double {
  flex-direction: column;
  gap: 8px;
  margin-bottom: 32px; /* más espacio con el alert en default */
}
.header-logos {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
}
.header-title {
  margin: 0;
  text-align: center;
}

.header .program-pill, .program-pill {
  font-size: 0.85rem;
  font-weight: 600;
  color: #111;
  background: #f2f2f7;
  border: 0px solid #e9e9ee;
  padding: 6px 10px;
  border-radius: 10px;
}
/* Aumentar tamaño del título del programa actual */
.program-pill {
  font-size: 1.2rem;
}

.assistant-id {
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 0.75rem;
  color: #666; /* info */
  text-align: center;
  padding: 10px;
}

.messages {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 24px 32px;
  overflow-y: auto;
  overflow-x: auto; /* habilita scroll horizontal si hay contenido ancho */
  background: #FFF;
  min-height: 300px;
  max-height: 400px;
}

.message {
  display: flex;
  align-items: flex-end;
  gap: 8px;
}

.avatar {
  font-size: 1.5rem;
}

.bubble {
  border-radius: 12px;
  padding: 14px 18px;
  font-size: 1.08rem;
  line-height: 1.6;
  white-space: pre-line;
  word-break: break-word;
  max-width: 80vw;
  margin: 5px 0;
}

.user .bubble {
  background: #999;
  color: #fff;
  border-bottom-right-radius: 4px;
}

.assistant .bubble {
  background: #ececf1;
  color: #222;
  border-bottom-left-radius: 4px;
}

/* Spinner para mensajes pendientes */
.assistant .bubble.pending {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.spinner {
  width: 16px;
  height: 16px;
  border: 2px solid #cbd5e1; /* slate-300 */
  border-top-color: #111;     /* dark */
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.spinner.small {
  width: 12px;
  height: 12px;
  border-width: 2px;
}

@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.input-row {
  display: flex;
  gap: 12px;
  padding: 24px 32px 32px 32px;
  background: #FFF;
  border-radius: 0 0 12px 12px;
}

textarea {
  flex: 1;
  min-height: 48px;
  max-height: 120px;
  resize: vertical;
  padding: 12px;
  border-radius: 8px;
  border: 1px solid #ccc;
  font-size: 1rem;
  font-family: inherit;
}

button {
  padding: 0 28px;
  border-radius: 8px;
  border: none;
  background: #333;
  color: #fff;
  font-weight: bold;
  font-size: 1rem;
  cursor: pointer;
  transition: background 0.2s;
}

button:disabled {
  background: #a5b4fc;
  cursor: not-allowed;
}

.btn-secondary {
  background: #e5e7eb;
  color: #111;
}

.btn-secondary:hover {
  background: #d1d5db;
}

@media (max-width: 980px) {
  aside.sidebar {
    display: none;
  }

  .chat-container {
    margin: 0;
    border-radius: 0;
    min-height: 100vh;
  }
}

.logo {
  width: 100px;
  margin: 0 10px;
}

.copy-btn {
  position: fixed;
  right: 100px;
  bottom: 50px;
  z-index: 100;
  width: 48px;
  height: 48px;
  cursor: pointer;
  background: none;
}

.copy-toast {
  position: fixed;
  right: 48px;
  bottom: 104px;
  background: #222;
  color: #fff;
  padding: 10px 18px;
  border-radius: 8px;
  font-size: 1rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s;
  z-index: 101;
}

.copy-toast.show {
  opacity: 1;
}

/* Indicador de proceso pendiente en ítems del menú */
.dot-pending {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: #ef4444; /* rojo */
  margin-left: 8px;
  display: inline-block;
}

#details-america {
  margin-top: 1rem;
}

/* Estado inicial sin programa: centrar logo y mostrar aviso */
.chat-container.centered {
  justify-content: center;
  align-items: center;
}
.chat-container.centered .header {
  border: none;
}
.chat-container.centered .messages,
.chat-container.centered .input-row {
  display: none !important;
}
/* .chat-container.centered .header p {
  display: none;
} */

/* Alert estilo Tailwind (ligero) para estado sin programa */
.tw-alert {
  background: red; /* blue-50 */
  /* border: 2px solid red; */
  padding: 1rem 2rem;
  color: #FFF;
  max-width: 680px;
  margin: 14px auto 0 auto;
}
.tw-alert-info { /* semantic hook */ }
.tw-alert__inner {
  display: flex;
  align-items: flex-start; /* items-start */
  gap: 3rem; /* gap-3 */
}
.tw-alert__icon {
  margin-top: 2px; /* -mt-0.5 approx */
  color: red; /* blue-500 */
  flex: 0 0 auto;
}
.tw-alert__body {
  display: block;
}
.tw-alert__title {
  margin: 0 0 4px 0; /* mb-1 */
  font-size: 0.875rem; /* text-sm */
  font-weight: 600; /* font-semibold */
  color: #1f2937; /* text-gray-800 */
}
.tw-alert__text {
  margin: 0;
  font-size: 0.875rem;
  color: #FFF;
}
