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

html, body {
  height: 100%;
}

body {
  font-family: system-ui, -apple-system, sans-serif;
  background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
  display: flex;
  height: 100dvh;       /* dynamic viewport height — accounts for mobile browser chrome */
  height: 100vh;        /* fallback for browsers without dvh support */
}

/* ── Layout ── */

#layout {
  display: flex;
  width: 100%;
  height: 100%;
}

/* ── Chat widget (inline mode — fills left side) ── */

chatia-widget {
  flex: 1;
  min-width: 0;
  height: 100%;
  box-shadow: 2px 0 20px rgba(0, 0, 0, 0.1);
}

/* ── Status panel (right) ── */

#status-panel {
  width: 320px;
  flex-shrink: 0;
  padding: 24px;
  overflow-y: auto;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(10px);
  border-left: 1px solid rgba(255, 255, 255, 0.2);
  font-size: 0.85rem;
  color: #4b5563;
  line-height: 1.6;
  box-shadow: -2px 0 20px rgba(0, 0, 0, 0.1);
}

#status-panel h2 {
  font-size: 1rem;
  font-weight: 700;
  color: #1f2937;
  margin-bottom: 14px;
  letter-spacing: -0.01em;
}

#status-panel ul {
  list-style: none;
  margin-bottom: 16px;
}

#status-panel ul li {
  padding: 4px 0 4px 22px;
  position: relative;
}

#status-panel ul li::before {
  position: absolute;
  left: 0;
  font-size: 0.9rem;
}

#status-panel ul li.done::before {
  content: "\2713";
  color: #10b981;
  font-weight: bold;
}

#status-panel ul li.pending::before {
  content: "\25cb";
  color: #9ca3af;
}

#status-panel p {
  margin-top: 12px;
}

#status-panel code {
  background: #f3f4f6;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.82rem;
  color: #2563eb;
  font-weight: 500;
}

/* ── Operational info ── */

#operational-info {
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid #e5e7eb;
}

#operational-info h2 {
  font-size: 1rem;
  font-weight: 700;
  color: #1f2937;
  margin-bottom: 12px;
  letter-spacing: -0.01em;
}

#status-loading {
  color: #9ca3af;
  font-style: italic;
}

.status-list {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 4px 10px;
}

.status-list dt {
  font-weight: 600;
  color: #6b7280;
  white-space: nowrap;
}

.status-list dd {
  color: #4b5563;
}

.status-list code {
  background: #f3f4f6;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.82rem;
  color: #2563eb;
  font-weight: 500;
}

.api-entry {
  padding: 1px 0;
}

/* ── Debug endpoints ── */

#debug-endpoints {
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid #e5e7eb;
}

#debug-endpoints h3 {
  font-size: 0.875rem;
  font-weight: 700;
  color: #1f2937;
  margin-bottom: 10px;
  letter-spacing: -0.01em;
}

#debug-endpoints ul {
  list-style: none;
  font-size: 0.75rem;
  line-height: 1.8;
}

#debug-endpoints code {
  background: #f3f4f6;
  padding: 2px 5px;
  border-radius: 4px;
  font-size: 0.7rem;
  font-weight: 600;
  color: #374151;
}

#debug-endpoints a {
  color: #2563eb;
  text-decoration: none;
  font-weight: 500;
  transition: color 0.2s ease;
}

#debug-endpoints a:hover {
  color: #1e40af;
  text-decoration: underline;
}

/* ── Responsive: wide screens — give panel more room —─ */

@media (min-width: 1400px) {
  #status-panel {
    width: 400px;
    padding: 28px;
  }
}

/* ── Responsive: small screens — hide status panel ── */

@media (max-width: 768px) {
  #status-panel {
    display: none;
  }

  #chat-container {
    border-left: none;
    border-right: none;
  }
}

/* ── Responsive: very small screens — tighter spacing ── */

@media (max-width: 480px) {
  header {
    padding: 10px 12px;
  }

  #messages {
    padding: 12px;
    gap: 8px;
  }

  .message {
    max-width: 92%;
    font-size: 0.9rem;
    padding: 8px 12px;
  }

  #chat-form {
    padding: 10px 12px;
    gap: 6px;
  }

  #user-input {
    padding: 8px 12px;
    font-size: 0.9rem;
  }

  #send-btn {
    padding: 8px 14px;
    font-size: 0.9rem;
  }
}

/* ── Panel de Control: Estilos Personalizados y Premium ── */

.status-section {
  margin-bottom: 24px;
}

.status-section h3 {
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #1f2937;
  margin-bottom: 12px;
  font-weight: 700;
  border-bottom: 2px solid #f3f4f6;
  padding-bottom: 4px;
}

.suggestions-intro {
  color: #6b7280;
  font-weight: 500;
  margin-bottom: 8px;
  font-size: 0.8rem;
}

#status-panel .suggestions-list {
  list-style: none !important;
  padding-left: 0 !important;
  margin-bottom: 16px;
}

#status-panel .suggestions-list li {
  padding: 8px 12px !important;
  margin-bottom: 6px;
  background: #f3f4f6;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 500;
  color: #374151;
}

#status-panel .suggestions-list li::before {
  content: none !important; /* Override standard status-panel list checkmarks */
}

#status-panel .suggestions-list li:hover {
  background: #e0e7ff;
  border-color: #c7d2fe;
  color: #4f46e5;
  transform: translateY(-1px);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.project-desc {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 12px;
  margin: 20px 0;
  font-size: 0.8rem;
  color: #64748b;
  line-height: 1.5;
}

.project-desc code {
  background: #e2e8f0 !important;
  color: #334155 !important;
}

/* ── Estilos de Endpoints y Depuración ── */

.section-subtitle {
  font-size: 0.75rem;
  color: #64748b;
  margin-bottom: 12px;
  line-height: 1.4;
}

#status-panel .endpoints-list {
  list-style: none !important;
  padding-left: 0 !important;
  margin-bottom: 0;
}

#status-panel .endpoints-list li {
  padding: 10px 0 !important;
  border-bottom: 1px solid #f1f5f9;
  display: block;
}

#status-panel .endpoints-list li::before {
  content: none !important;
}

#status-panel .endpoints-list li:last-child {
  border-bottom: none;
}

.endpoint-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}

.endpoint-header .method {
  font-size: 0.65rem;
  font-weight: 800;
  padding: 2px 6px;
  border-radius: 4px;
  color: #fff;
  text-transform: uppercase;
}

.endpoint-header .method.get {
  background: #10b981; /* Verde */
}

.endpoint-header .method.post {
  background: #3b82f6; /* Azul */
}

.endpoint-link {
  font-family: monospace;
  font-size: 0.8rem;
  color: #2563eb;
  text-decoration: none;
  font-weight: 600;
  transition: color 0.2s;
}

.endpoint-link:hover {
  color: #1d4ed8;
  text-decoration: underline;
}

.endpoint-desc {
  font-size: 0.72rem;
  color: #64748b;
  line-height: 1.4;
  padding-left: 0;
}

.test-environment-badge {
  background: #fef3c7;
  border: 1px solid #fde68a;
  color: #d97706;
  font-size: 0.72rem;
  font-weight: 700;
  text-align: center;
  padding: 6px 12px;
  border-radius: 6px;
  margin-bottom: 16px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
  transition: all 0.3s ease;
}

/* ── Selector de Temas ── */

.theme-select {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid #d4d4d8;
  border-radius: 6px;
  background: #ffffff;
  color: #1f2937;
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  outline: none;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.theme-select:focus {
  border-color: #6366f1;
  box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.15);
}

/* ── Temas del Sandbox ── */

body {
  transition: background 0.4s ease;
}

#status-panel, #status-panel h2, #status-panel h3, #status-panel code, .project-desc, .project-desc code, .test-environment-badge {
  transition: background-color 0.3s ease, border-color 0.3s ease, color 0.3s ease, box-shadow 0.3s ease;
}

/* 1. Tema Predeterminado / Original (Default) */
body.theme-default {
  background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
}

body.theme-default #status-panel {
  background: rgba(15, 23, 42, 0.95);
  color: #94a3b8;
  border-left: 1px solid rgba(255, 255, 255, 0.05);
}

body.theme-default #status-panel h2,
body.theme-default #status-panel h3 {
  color: #f8fafc;
}

body.theme-default chatia-widget {
  --chat-primary-color: #6366f1;
  --chat-bg: #ffffff;
  --chat-thinking-color: linear-gradient(135deg, #818cf8 0%, #6366f1 100%);
  --chat-font-family: system-ui, -apple-system, sans-serif;
}

/* 2. Tema DriveNYou (Naranja/Oscuro) */
body.theme-drivenyou {
  background: linear-gradient(135deg, #09090b 0%, #2e1302 100%);
}

body.theme-drivenyou #status-panel {
  background: rgba(15, 15, 16, 0.96);
  color: #94a3b8;
  border-left: 1px solid rgba(240, 100, 0, 0.2);
  box-shadow: -2px 0 20px rgba(0, 0, 0, 0.3);
}

body.theme-drivenyou #status-panel h2,
body.theme-drivenyou #status-panel h3 {
  color: #ffffff;
  border-bottom-color: rgba(240, 100, 0, 0.15);
}

body.theme-drivenyou .theme-select {
  background: #1c1c1e;
  border-color: #4a2306;
  color: #ff8f3d;
}

body.theme-drivenyou .theme-select:focus {
  border-color: #f06400;
  box-shadow: 0 0 0 2px rgba(240, 100, 0, 0.25);
}

body.theme-drivenyou #status-panel .suggestions-list li {
  background: #271408;
  border-color: #4a2306;
  color: #f28b43;
}

body.theme-drivenyou #status-panel .suggestions-list li:hover {
  background: #4a2306;
  border-color: #f06400;
  color: #ffffff;
  box-shadow: 0 2px 8px rgba(240, 100, 0, 0.2);
}

body.theme-drivenyou #status-panel .suggestions-list li svg {
  color: #f06400 !important;
}

body.theme-drivenyou #status-panel code {
  background: #271408;
  color: #ff9f43;
}

body.theme-drivenyou .project-desc {
  background: #1c140e;
  border-color: rgba(240, 100, 0, 0.1);
  color: #94a3b8;
}

body.theme-drivenyou .project-desc code {
  background: #2a1c11 !important;
  color: #e2e8f0 !important;
}

body.theme-drivenyou .status-list dt {
  color: #ff8f3d;
}

body.theme-drivenyou .status-list dd {
  color: #e2e8f0;
}

body.theme-drivenyou .endpoint-link {
  color: #ff8f3d;
}

body.theme-drivenyou .endpoint-link:hover {
  color: #ffaa6b;
}

body.theme-drivenyou .endpoint-desc {
  color: #94a3b8;
}

body.theme-drivenyou #status-panel .endpoints-list li {
  border-bottom-color: rgba(255, 255, 255, 0.05);
}

body.theme-drivenyou .test-environment-badge {
  background: #2c1a0c;
  border-color: #63320c;
  color: #ff8f3d;
}

/* DrivenYou Chat widget variables (Claro con acentos naranja) */
body.theme-drivenyou chatia-widget {
  --chat-primary-color: #f06400;
  --chat-bg: #ffffff;
  --chat-border-color: #e4e4e7;
  --chat-text-color: #18181b;
  --chat-assistant-bg: #f3f4f6;
  --chat-assistant-text: #18181b;
  --chat-user-text: #ffffff;
  --chat-input-bg: #ffffff;
  --chat-input-text: #18181b;
  --chat-input-border: #d4d4d8;
  --chat-thinking-color: linear-gradient(135deg, #ff822e 0%, #f06400 100%);
  --chat-font-family: 'Poppins', system-ui, -apple-system, sans-serif;
}

/* 3. Tema Neways (Índigo/Tecnología Oscura) */
body.theme-neways {
  background: linear-gradient(135deg, #06060e 0%, #10101a 100%);
}

body.theme-neways::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at 50% 0%, rgba(99, 102, 241, 0.12) 0%, transparent 70%);
  pointer-events: none;
  z-index: 0;
}

body.theme-neways #layout {
  position: relative;
  z-index: 1;
}

body.theme-neways #status-panel {
  background: rgba(20, 20, 31, 0.95);
  color: #94a3b8;
  border-left: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: -2px 0 20px rgba(0, 0, 0, 0.4);
}

body.theme-neways #status-panel h2,
body.theme-neways #status-panel h3 {
  color: #e2e8f0;
  border-bottom-color: rgba(255, 255, 255, 0.08);
}

body.theme-neways .theme-select {
  background: #1c1c2e;
  border-color: rgba(255, 255, 255, 0.08);
  color: #818cf8;
}

body.theme-neways .theme-select:focus {
  border-color: #6366f1;
  box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.25);
}

body.theme-neways #status-panel .suggestions-list li {
  background: #1c1c2e;
  border-color: rgba(255, 255, 255, 0.08);
  color: #818cf8;
}

body.theme-neways #status-panel .suggestions-list li:hover {
  background: #25253c;
  border-color: #6366f1;
  color: #ffffff;
  box-shadow: 0 2px 8px rgba(99, 102, 241, 0.2);
}

body.theme-neways #status-panel .suggestions-list li svg {
  color: #818cf8 !important;
}

body.theme-neways #status-panel code {
  background: #0d0d16;
  color: #38bdf8;
}

body.theme-neways .project-desc {
  background: #0d0d16;
  border-color: rgba(255, 255, 255, 0.05);
  color: #64748b;
}

body.theme-neways .project-desc code {
  background: #1a1a2e !important;
  color: #cbd5e1 !important;
}

body.theme-neways .status-list dt {
  color: #818cf8;
}

body.theme-neways .status-list dd {
  color: #cbd5e1;
}

body.theme-neways .endpoint-link {
  color: #38bdf8;
}

body.theme-neways .endpoint-link:hover {
  color: #7dd3fc;
}

body.theme-neways .endpoint-desc {
  color: #64748b;
}

body.theme-neways #status-panel .endpoints-list li {
  border-bottom-color: rgba(255, 255, 255, 0.05);
}

body.theme-neways .test-environment-badge {
  background: #1e1b4b;
  border-color: #312e81;
  color: #a5b4fc;
}

/* Neways Chat widget variables (Modo oscuro integrado de alta tecnología) */
body.theme-neways chatia-widget {
  --chat-primary-color: #6366f1;
  --chat-bg: #14141f;
  --chat-border-color: rgba(255, 255, 255, 0.08);
  --chat-text-color: #e2e8f0;
  --chat-assistant-bg: #1c1c2e;
  --chat-assistant-text: #e2e8f0;
  --chat-user-text: #ffffff;
  --chat-input-area-bg: #10101a;
  --chat-input-bg: #0d0d16;
  --chat-input-text: #e2e8f0;
  --chat-input-border: rgba(255, 255, 255, 0.12);
  --chat-header-bg: #10101a;
  --chat-header-border: rgba(255, 255, 255, 0.08);
  --chat-thinking-color: linear-gradient(135deg, #6366f1 0%, #0ea5e9 100%);
  --chat-font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
}

/* ── Perfil del Alumno ── */

.section-tag {
  font-size: 0.72rem;
  font-weight: 500;
  color: #6b7280;
  background: #f3f4f6;
  border: 1px solid #e5e7eb;
  border-radius: 4px;
  padding: 1px 6px;
  margin-left: 4px;
  vertical-align: middle;
}

.profile-fields {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 10px;
}

.profile-row {
  display: grid;
  grid-template-columns: 72px 1fr auto;
  align-items: center;
  gap: 6px;
}

.profile-label {
  font-size: 0.78rem;
  color: #374151;
  font-weight: 500;
  white-space: nowrap;
}

.profile-input {
  width: 100%;
  padding: 4px 7px;
  font-size: 0.8rem;
  border: 1px solid #d1d5db;
  border-radius: 5px;
  background: #fff;
  color: #1f2937;
  outline: none;
  transition: border-color 0.15s;
}

.profile-input:focus {
  border-color: #6366f1;
}

.privacy-select {
  font-size: 0.75rem;
  padding: 4px 4px;
  border: 1px solid #d1d5db;
  border-radius: 5px;
  background: #fff;
  color: #374151;
  cursor: pointer;
  outline: none;
  white-space: nowrap;
}

.privacy-select:focus {
  border-color: #6366f1;
}

.profile-active-badge {
  margin-top: 8px;
  padding: 5px 10px;
  background: #ede9fe;
  border: 1px solid #c4b5fd;
  border-radius: 6px;
  font-size: 0.78rem;
  color: #4338ca;
  font-weight: 500;
}

/* Dark theme overrides — profile */
body.theme-default .section-tag,
body.theme-neways .section-tag {
  background: #1c1c2e;
  border-color: rgba(255,255,255,0.1);
  color: #6b7280;
}

body.theme-default .profile-label,
body.theme-neways .profile-label {
  color: #94a3b8;
}

body.theme-default .profile-input,
body.theme-neways .profile-input {
  background: #1c1c2e;
  border-color: rgba(255,255,255,0.1);
  color: #e2e8f0;
}

body.theme-default .profile-input:focus,
body.theme-neways .profile-input:focus {
  border-color: #6366f1;
}

body.theme-default .privacy-select,
body.theme-neways .privacy-select {
  background: #1c1c2e;
  border-color: rgba(255,255,255,0.1);
  color: #94a3b8;
}

body.theme-default .profile-active-badge,
body.theme-neways .profile-active-badge {
  background: #1e1b4b;
  border-color: #4338ca;
  color: #a5b4fc;
}

body.theme-drivenyou .profile-label {
  color: #f28b43;
}

body.theme-drivenyou .profile-input {
  background: #271408;
  border-color: #4a2306;
  color: #fde8cc;
}

body.theme-drivenyou .profile-input:focus {
  border-color: #f06400;
}

body.theme-drivenyou .privacy-select {
  background: #271408;
  border-color: #4a2306;
  color: #f28b43;
}

body.theme-drivenyou .profile-active-badge {
  background: #2c1a0c;
  border-color: #63320c;
  color: #f28b43;
}

/* ── Filtro RAG por Categorías ── */

.rag-categories-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 4px;
}

.rag-category-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s ease;
  background: #f9fafb;
}

.rag-category-item:hover {
  background: #ede9fe;
  border-color: #c4b5fd;
}

.rag-category-item input[type="checkbox"] {
  width: 14px;
  height: 14px;
  accent-color: #6366f1;
  cursor: pointer;
  flex-shrink: 0;
}

.rag-category-item input[type="checkbox"]:checked + .rag-category-label {
  color: #4f46e5;
  font-weight: 600;
}

.rag-category-label {
  font-size: 0.82rem;
  color: #374151;
  font-weight: 500;
  flex: 1;
  cursor: pointer;
}

.rag-active-filter {
  margin-top: 8px;
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 600;
  background: #ede9fe;
  border: 1px solid #c4b5fd;
  color: #4f46e5;
}

.rag-no-categories {
  font-size: 0.78rem;
  color: #9ca3af;
  font-style: italic;
}

/* Dark theme overrides for category filter */
body.theme-default .rag-category-item,
body.theme-neways .rag-category-item {
  background: #1c1c2e;
  border-color: rgba(255, 255, 255, 0.08);
}

body.theme-default .rag-category-item:hover,
body.theme-neways .rag-category-item:hover {
  background: #25253c;
  border-color: #6366f1;
}

body.theme-default .rag-category-label,
body.theme-neways .rag-category-label {
  color: #94a3b8;
}

body.theme-default .rag-category-item input[type="checkbox"]:checked + .rag-category-label,
body.theme-neways .rag-category-item input[type="checkbox"]:checked + .rag-category-label {
  color: #a5b4fc;
}

body.theme-default .rag-active-filter,
body.theme-neways .rag-active-filter {
  background: #1e1b4b;
  border-color: #4338ca;
  color: #a5b4fc;
}

body.theme-drivenyou .rag-category-item {
  background: #271408;
  border-color: #4a2306;
}

body.theme-drivenyou .rag-category-item:hover {
  background: #3a1f0d;
  border-color: #f06400;
}

body.theme-drivenyou .rag-category-label {
  color: #f28b43;
}

body.theme-drivenyou .rag-category-item input[type="checkbox"] {
  accent-color: #f06400;
}

body.theme-drivenyou .rag-category-item input[type="checkbox"]:checked + .rag-category-label {
  color: #ff9f43;
}

body.theme-drivenyou .rag-active-filter {
  background: #2c1a0c;
  border-color: #63320c;
  color: #ff8f3d;
}

/* ── Bloque 6: Botones Generales ── */

.btn-outline-sm {
  display: inline-block;
  margin-top: 8px;
  padding: 5px 12px;
  font-size: 0.78rem;
  font-weight: 500;
  color: #374151;
  background: transparent;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
  font-family: inherit;
}

.btn-outline-sm:hover:not(:disabled) {
  background: #f3f4f6;
  border-color: #9ca3af;
}

.btn-outline-sm:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.btn-primary-sm {
  padding: 6px 16px;
  font-size: 0.82rem;
  font-weight: 600;
  color: #fff;
  background: #6366f1;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.15s;
  font-family: inherit;
  white-space: nowrap;
}

.btn-primary-sm:hover:not(:disabled) {
  background: #4f46e5;
}

.btn-primary-sm:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* ── Bloque 6: Health Check ── */

.health-check-bar {
  margin-top: 4px;
}

.health-list {
  list-style: none;
  padding: 0;
  margin: 8px 0 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.health-item {
  display: flex;
  align-items: baseline;
  gap: 5px;
  font-size: 0.78rem;
  padding: 3px 0;
  flex-wrap: wrap;
}

.health-icon {
  font-size: 0.7rem;
  flex-shrink: 0;
}

.health-name {
  font-weight: 600;
  color: #374151;
  flex: 1;
  min-width: 0;
}

.health-latency {
  font-size: 0.72rem;
  color: #6b7280;
  white-space: nowrap;
}

.health-error-text {
  font-size: 0.72rem;
  color: #dc2626;
}

.health-checked-at {
  font-size: 0.7rem;
  color: #9ca3af;
  margin-top: 4px;
}

/* ── Bloque 6: Modal Buscador Semántico ── */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
}

.modal-box {
  background: #ffffff;
  border-radius: 12px;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.25);
  width: 100%;
  max-width: 680px;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid #e5e7eb;
  flex-shrink: 0;
}

.modal-header h2 {
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
  color: #111827;
  letter-spacing: -0.01em;
}

.modal-close-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1.5rem;
  color: #6b7280;
  padding: 2px 8px;
  border-radius: 4px;
  line-height: 1;
  transition: background 0.15s, color 0.15s;
}

.modal-close-btn:hover {
  background: #f3f4f6;
  color: #111827;
}

.modal-body {
  padding: 20px;
  overflow-y: auto;
  flex: 1;
}

/* ── Bloque 6: Formulario de búsqueda ── */

.rag-search-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 16px;
}

.rag-search-input {
  width: 100%;
  padding: 9px 14px;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  font-size: 0.9rem;
  font-family: inherit;
  color: #111827;
  background: #fff;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.rag-search-input:focus {
  border-color: #6366f1;
  box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.12);
}

.rag-search-controls {
  display: flex;
  align-items: center;
  gap: 10px;
}

.rag-topk-label {
  font-size: 0.82rem;
  color: #374151;
  font-weight: 500;
  white-space: nowrap;
}

.rag-topk-input {
  width: 58px;
  padding: 5px 8px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font-size: 0.85rem;
  font-family: inherit;
  color: #111827;
  outline: none;
  text-align: center;
}

.rag-topk-input:focus {
  border-color: #6366f1;
}

/* ── Bloque 6: Resultados ── */

.rag-search-results {
  min-height: 60px;
}

.rag-search-placeholder {
  font-size: 0.82rem;
  color: #9ca3af;
  font-style: italic;
}

.rag-search-summary {
  font-size: 0.78rem;
  color: #6b7280;
  margin-bottom: 12px;
}

.rag-result-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.rag-result-item {
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 12px 14px;
  background: #fafafa;
}

.rag-result-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 7px;
  flex-wrap: wrap;
}

.rag-result-category {
  font-size: 0.68rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 4px;
  background: #ede9fe;
  color: #4f46e5;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

.rag-result-score {
  font-size: 0.72rem;
  color: #6b7280;
  white-space: nowrap;
  font-weight: 600;
}

.rag-result-source {
  font-size: 0.7rem;
  color: #9ca3af;
  font-family: monospace;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
  flex: 1;
}

.rag-result-text {
  font-size: 0.8rem;
  line-height: 1.55;
  color: #374151;
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
}

/* ── Bloque 6: Overrides tema oscuro (default + neways) ── */

body.theme-default .btn-outline-sm,
body.theme-neways .btn-outline-sm {
  color: #94a3b8;
  border-color: rgba(255, 255, 255, 0.12);
}

body.theme-default .btn-outline-sm:hover:not(:disabled),
body.theme-neways .btn-outline-sm:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.2);
}

body.theme-default .health-name,
body.theme-neways .health-name {
  color: #cbd5e1;
}

body.theme-default .health-checked-at,
body.theme-neways .health-checked-at {
  color: #475569;
}

body.theme-default .modal-box,
body.theme-neways .modal-box {
  background: #14141f;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.6);
}

body.theme-default .modal-header,
body.theme-neways .modal-header {
  border-bottom-color: rgba(255, 255, 255, 0.08);
}

body.theme-default .modal-header h2,
body.theme-neways .modal-header h2 {
  color: #e2e8f0;
}

body.theme-default .modal-close-btn,
body.theme-neways .modal-close-btn {
  color: #64748b;
}

body.theme-default .modal-close-btn:hover,
body.theme-neways .modal-close-btn:hover {
  background: rgba(255, 255, 255, 0.06);
  color: #e2e8f0;
}

body.theme-default .rag-search-input,
body.theme-neways .rag-search-input {
  background: #0d0d16;
  border-color: rgba(255, 255, 255, 0.1);
  color: #e2e8f0;
}

body.theme-default .rag-search-input:focus,
body.theme-neways .rag-search-input:focus {
  border-color: #6366f1;
}

body.theme-default .rag-topk-label,
body.theme-neways .rag-topk-label {
  color: #94a3b8;
}

body.theme-default .rag-topk-input,
body.theme-neways .rag-topk-input {
  background: #0d0d16;
  border-color: rgba(255, 255, 255, 0.1);
  color: #e2e8f0;
}

body.theme-default .rag-result-item,
body.theme-neways .rag-result-item {
  background: #1c1c2e;
  border-color: rgba(255, 255, 255, 0.07);
}

body.theme-default .rag-result-category,
body.theme-neways .rag-result-category {
  background: #1e1b4b;
  color: #a5b4fc;
}

body.theme-default .rag-result-text,
body.theme-neways .rag-result-text {
  color: #cbd5e1;
}

/* ── Bloque 6: Overrides tema drivenyou ── */

body.theme-drivenyou .btn-outline-sm {
  color: #f28b43;
  border-color: #4a2306;
}

body.theme-drivenyou .btn-outline-sm:hover:not(:disabled) {
  background: #271408;
  border-color: #f06400;
}

body.theme-drivenyou .health-name {
  color: #fde8cc;
}

body.theme-drivenyou .modal-box {
  background: #12100e;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.7);
}

body.theme-drivenyou .modal-header {
  border-bottom-color: rgba(240, 100, 0, 0.15);
}

body.theme-drivenyou .modal-header h2 {
  color: #fde8cc;
}

body.theme-drivenyou .modal-close-btn {
  color: #f28b43;
}

body.theme-drivenyou .modal-close-btn:hover {
  background: #271408;
  color: #ff9f43;
}

body.theme-drivenyou .rag-search-input {
  background: #1c100a;
  border-color: #4a2306;
  color: #fde8cc;
}

body.theme-drivenyou .rag-search-input:focus {
  border-color: #f06400;
}

body.theme-drivenyou .rag-topk-label {
  color: #f28b43;
}

body.theme-drivenyou .rag-topk-input {
  background: #1c100a;
  border-color: #4a2306;
  color: #fde8cc;
}

body.theme-drivenyou .rag-result-item {
  background: #1c100a;
  border-color: rgba(240, 100, 0, 0.12);
}

body.theme-drivenyou .rag-result-category {
  background: #2c1a0c;
  color: #ff8f3d;
}

body.theme-drivenyou .rag-result-text {
  color: #fde8cc;
}

body.theme-drivenyou .btn-primary-sm {
  background: #f06400;
}

body.theme-drivenyou .btn-primary-sm:hover:not(:disabled) {
  background: #d45700;
}
