/* ============================================================
   LABORATORIO VIRTUAL - Aprendizaje autodidacta
   Estilo de la Academia de Robótica de La Manguita
   ============================================================ */

.lab-hero {
  background: linear-gradient(135deg, var(--azul) 0%, var(--azul-claro) 100%);
  color: var(--blanco);
  text-align: center;
  padding: 2.5rem 1rem;
}

.lab-hero h1 {
  font-size: clamp(1.6rem, 4vw, 2.4rem);
}

.lab-hero p {
  max-width: 640px;
  margin: 0.8rem auto 0;
  color: #dbeafe;
  font-size: 0.95rem;
}

/* ---------- Contenedor general ---------- */
.laboratorio {
  max-width: 1200px;
  margin: 0 auto;
  padding: 1.5rem 1rem 3rem;
}

.lab-barra {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.lab-tabs {
  display: flex;
  gap: 0.4rem;
  background-color: var(--blanco);
  border: 2px solid #e5e7eb;
  border-radius: 14px;
  padding: 0.35rem;
}

.lab-tab {
  border: none;
  cursor: pointer;
  font-family: inherit;
  font-weight: 700;
  font-size: 0.82rem;
  color: var(--gris);
  background: transparent;
  padding: 0.5rem 1rem;
  border-radius: 10px;
  transition: all 0.2s ease;
}

.lab-tab:hover {
  color: var(--azul);
}

.lab-tab.activa {
  background-color: var(--azul-claro);
  color: var(--blanco);
  box-shadow: 0 4px 10px rgba(59, 130, 246, 0.35);
}

.lab-progreso {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  flex: 1;
  min-width: 220px;
  max-width: 380px;
}

.lab-barra-progreso {
  flex: 1;
  height: 12px;
  background-color: #e5e7eb;
  border-radius: 999px;
  overflow: hidden;
}

#progressBar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--verde), var(--celeste));
  border-radius: 999px;
  transition: width 0.5s ease;
}

#progressText {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--azul);
  white-space: nowrap;
}

/* ---------- Rejilla principal ---------- */
.lab-grid {
  display: grid;
  grid-template-columns: 1.15fr 0.85fr;
  gap: 1.5rem;
  align-items: start;
}

.lab-col {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

/* ---------- Tarjetas ---------- */
.tarjeta-lab {
  background-color: var(--blanco);
  border: 2px solid #e5e7eb;
  border-radius: 20px;
  padding: 1.4rem;
  box-shadow: 0 6px 18px rgba(30, 58, 138, 0.07);
}

.titulo-mini {
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--azul-claro);
}

/* Selector de clases */
.selector-clases {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.5rem;
  margin-top: 0.9rem;
}

.btn-clase {
  border: 2px solid #e5e7eb;
  background-color: var(--blanco);
  border-radius: 12px;
  padding: 0.5rem 0.6rem;
  text-align: left;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.15s ease;
  line-height: 1.25;
}

.btn-clase .num {
  display: block;
  font-size: 0.62rem;
  font-weight: 800;
  color: var(--gris);
  text-transform: uppercase;
}

.btn-clase .nom {
  display: block;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--gris-oscuro);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.btn-clase:hover {
  border-color: var(--celeste);
  transform: translateY(-2px);
}

.btn-clase.activa {
  border-color: var(--azul-claro);
  background-color: #eff6ff;
}

.btn-clase.activa .num {
  color: var(--azul-claro);
}

.btn-clase.completada .nom::after {
  content: " ✓";
  color: var(--verde);
}

/* Encabezado de lección */
.cabecera-leccion {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 0.7rem;
}

.badge-leccion {
  display: inline-block;
  background-color: #eff6ff;
  color: var(--azul-claro);
  font-size: 0.7rem;
  font-weight: 800;
  padding: 0.25rem 0.8rem;
  border-radius: 999px;
}

#lessonTitle {
  font-size: 1.35rem;
  color: var(--azul);
  margin-bottom: 0.9rem;
}

.teoria {
  font-size: 0.88rem;
  color: var(--gris-oscuro);
  line-height: 1.65;
}

.teoria ul {
  margin: 0.6rem 0 0.6rem 1.2rem;
  list-style: disc;
}

.teoria li {
  margin-bottom: 0.35rem;
}

.teoria code,
.caja-reto code,
.opcion-quiz code,
.respuesta-guia code {
  font-family: "Consolas", "Courier New", monospace;
  font-size: 0.82em;
  background-color: #eff6ff;
  color: var(--azul-claro);
  padding: 0.1em 0.4em;
  border-radius: 6px;
}

.caja-reto {
  border-left: 5px solid var(--amarillo);
  background-color: #fffbeb;
  border-radius: 0 14px 14px 0;
  padding: 0.9rem 1.1rem;
  margin-top: 1.1rem;
}

.caja-reto h4 {
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: #b45309;
  margin-bottom: 0.25rem;
}

.caja-reto p {
  font-size: 0.83rem;
  color: var(--gris-oscuro);
}

/* Quiz */
.bloque-quiz {
  border-top: 2px dashed #e5e7eb;
  margin-top: 1.4rem;
  padding-top: 1.2rem;
}

.bloque-quiz > h3 {
  font-size: 0.95rem;
  color: var(--azul);
  margin-bottom: 0.7rem;
}

.pregunta-quiz {
  background-color: var(--gris-claro);
  border-radius: 12px;
  padding: 1rem;
}

#quizQuestion {
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 0.7rem;
}

.opciones-quiz {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.opcion-quiz {
  width: 100%;
  text-align: left;
  border: 2px solid #e5e7eb;
  background-color: var(--blanco);
  border-radius: 10px;
  padding: 0.55rem 0.8rem;
  font-size: 0.8rem;
  font-family: inherit;
  color: var(--gris-oscuro);
  cursor: pointer;
  transition: all 0.15s ease;
}

.opcion-quiz:hover {
  border-color: var(--celeste);
}

.opcion-quiz.correcta {
  border-color: var(--verde);
  background-color: #f0fdf4;
  font-weight: 700;
  pointer-events: none;
}

.opcion-quiz.incorrecta {
  border-color: #ef4444;
  background-color: #fef2f2;
  font-weight: 700;
  pointer-events: none;
}

.opcion-quiz.desactivada {
  pointer-events: none;
  opacity: 0.75;
}

#quizFeedback.correcta {
  color: #15803d;
}

#quizFeedback.incorrecta {
  color: #b91c1c;
}

#quizFeedback {
  display: block;
  font-size: 0.78rem;
  font-weight: 700;
  margin-top: 0.6rem;
}

.oculto {
  display: none !important;
}

/* ---------- Placa virtual ---------- */
.placa-envoltura {
  position: relative;
  background-color: var(--gris-claro);
  border: 2px solid #e5e7eb;
  border-radius: 16px;
  padding: 1rem;
  display: flex;
  justify-content: center;
  min-height: 240px;
}

.placa-svg {
  width: 100%;
  max-width: 300px;
}

.estado-sim {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  background-color: var(--gris-claro);
  border: 1px solid #e5e7eb;
  border-radius: 999px;
  padding: 0.2rem 0.7rem;
  font-size: 0.65rem;
  font-weight: 800;
}

.estado-sim .punto {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: #ef4444;
}

.estado-sim.online .punto {
  background-color: var(--verde);
  animation: latido 1s infinite alternate;
}

.estado-sim.online {
  color: #15803d;
}

@keyframes latido {
  from { opacity: 0.4; }
  to { opacity: 1; }
}

.widget-sensor {
  position: absolute;
  bottom: 10px;
  background-color: var(--blanco);
  border: 2px solid #e5e7eb;
  border-radius: 12px;
  padding: 0.45rem 0.7rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
  box-shadow: 0 4px 10px rgba(30, 58, 138, 0.1);
}

.widget-sensor span {
  font-size: 0.6rem;
  font-weight: 800;
  color: var(--gris);
}

#potValue {
  accent-color: var(--azul-claro);
  width: 110px;
}

#potLabel {
  color: var(--azul-claro);
  font-size: 0.7rem !important;
}

.btn-fisico {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 3px solid #d1d5db;
  background-color: #ef4444;
  box-shadow: 0 4px 0 rgba(0, 0, 0, 0.2);
  cursor: pointer;
  transition: all 0.08s ease;
}

.btn-fisico:active {
  transform: translateY(3px);
  box-shadow: none;
  background-color: #b91c1c;
}

/* ---------- IDE / Editor ---------- */
.ide {
  overflow: hidden;
  padding: 0;
}

.ide-barra {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.6rem;
  padding: 0.8rem 1rem;
  background-color: var(--azul);
}

.botones-ide {
  display: flex;
  gap: 0.5rem;
}

.btn-subir {
  border: none;
  cursor: pointer;
  font-family: inherit;
  font-weight: 800;
  font-size: 0.78rem;
  background-color: var(--verde);
  color: var(--blanco);
  padding: 0.5rem 1rem;
  border-radius: 10px;
  box-shadow: 0 4px 10px rgba(34, 197, 94, 0.4);
  transition: transform 0.15s ease;
}

.btn-subir:hover {
  transform: translateY(-2px);
}

.btn-subir:active {
  transform: translateY(0);
}

.nombre-sketch {
  font-family: "Consolas", monospace;
  font-size: 0.68rem;
  color: #bfdbfe;
}

.editor-envoltura {
  display: flex;
  background-color: #1f2937;
  min-height: 230px;
}

.numeros-linea {
  user-select: none;
  text-align: right;
  padding: 0.8rem 0.5rem 0.8rem 0.8rem;
  font-family: "Consolas", monospace;
  font-size: 11px;
  line-height: 1.55;
  color: #4b5563;
  background-color: rgba(0, 0, 0, 0.25);
  border-right: 1px solid #374151;
}

#codeEditor {
  flex: 1;
  border: none;
  outline: none;
  resize: vertical;
  background: transparent;
  color: #86efac;
  caret-color: var(--amarillo);
  font-family: "Consolas", monospace;
  font-size: 11.5px;
  line-height: 1.55;
  padding: 0.8rem;
  white-space: pre;
  min-height: 230px;
}

.monitor-serie {
  background-color: #111827;
  border-top: 2px solid #374151;
}

.monitor-serie .cabecera-ms {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.45rem 1rem;
  background-color: #1f2937;
  font-size: 0.62rem;
  font-weight: 800;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: #9ca3af;
}

.btn-limpiar {
  border: none;
  background: transparent;
  color: #6b7280;
  font-size: 0.62rem;
  font-weight: 800;
  text-transform: uppercase;
  cursor: pointer;
}

.btn-limpiar:hover {
  color: #d1d5db;
}

#serialConsole {
  height: 120px;
  overflow-y: auto;
  padding: 0.7rem 1rem;
  font-family: "Consolas", monospace;
  font-size: 11px;
  color: #4ade80;
  line-height: 1.6;
}

#serialConsole div.ms-error { color: #f87171; }
#serialConsole div.ms-info { color: #93c5fd; }
#serialConsole div.ms-sistema { color: #4ade80; }
#serialConsole div.ms-texto { color: #d1d5db; }

/* ---------- Guía de estudio ---------- */
.item-pregunta {
  background-color: var(--gris-claro);
  border: 2px solid #e5e7eb;
  border-radius: 14px;
  padding: 1rem 1.1rem;
  margin-bottom: 0.8rem;
}

.item-pregunta h4 {
  font-size: 0.86rem;
  color: var(--gris-oscuro);
  display: flex;
  gap: 0.5rem;
}

.num-pregunta {
  flex-shrink: 0;
  background-color: #eff6ff;
  color: var(--azul-claro);
  font-size: 0.7rem;
  font-weight: 800;
  padding: 0.05rem 0.5rem;
  border-radius: 6px;
  height: fit-content;
}

.respuesta-guia {
  margin-top: 0.7rem;
  background-color: var(--blanco);
  border-left: 4px solid var(--verde);
  border-radius: 0 10px 10px 0;
  padding: 0.7rem 0.9rem;
  font-size: 0.8rem;
  color: var(--gris-oscuro);
  line-height: 1.6;
}

.etiqueta-respuesta {
  display: block;
  font-size: 0.62rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: #15803d;
  margin-bottom: 0.25rem;
}

.btn-revelar {
  border: none;
  background: transparent;
  cursor: pointer;
  font-family: inherit;
  font-size: 0.72rem;
  font-weight: 800;
  color: var(--azul-claro);
  margin-top: 0.5rem;
  padding: 0;
}

.btn-revelar:hover {
  text-decoration: underline;
}

.tabla-glosario {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.78rem;
}

.tabla-glosario th {
  background-color: var(--azul);
  color: var(--blanco);
  text-align: left;
  padding: 0.6rem 0.9rem;
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.tabla-glosario td {
  padding: 0.55rem 0.9rem;
  border-bottom: 1px solid #e5e7eb;
  color: var(--gris-oscuro);
}

.tabla-glosario td:first-child {
  font-weight: 700;
  color: var(--azul);
  white-space: nowrap;
}

.tabla-glosario tr:hover td {
  background-color: #f8fafc;
}

.input-busqueda {
  width: 100%;
  max-width: 260px;
  border: 2px solid #e5e7eb;
  border-radius: 10px;
  padding: 0.45rem 0.8rem;
  font-family: inherit;
  font-size: 0.78rem;
  outline: none;
}

.input-busqueda:focus {
  border-color: var(--celeste);
}

/* ---------- Recursos GitHub (vista) ---------- */
.nota-github {
  margin-top: 1.5rem;
  padding: 1.1rem 1.4rem;
  background-color: #ecfdf5;
  border: 2px dashed var(--verde);
  border-radius: 16px;
  font-size: 0.88rem;
  line-height: 1.6;
}

/* ---------- Toast ---------- */
.toast-lab {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 60;
  max-width: 320px;
  display: flex;
  gap: 0.7rem;
  align-items: flex-start;
  background-color: var(--blanco);
  border: 2px solid #e5e7eb;
  border-left: 5px solid var(--verde);
  border-radius: 14px;
  padding: 0.9rem 1.1rem;
  box-shadow: 0 14px 30px rgba(0, 0, 0, 0.18);
  opacity: 0;
  transform: translateY(80px);
  transition: all 0.35s ease;
  pointer-events: none;
}

.toast-lab.visible {
  opacity: 1;
  transform: translateY(0);
}

.toast-lab.alerta {
  border-left-color: var(--amarillo);
}

.toast-lab strong {
  font-size: 0.85rem;
  color: var(--azul);
}

.toast-lab p {
  font-size: 0.76rem;
  color: var(--gris);
  margin-top: 0.2rem;
}

.toast-icono {
  font-size: 1.3rem;
  line-height: 1;
}

/* ---------- Responsivo ---------- */
@media (max-width: 1020px) {
  .lab-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .selector-clases {
    grid-template-columns: repeat(2, 1fr);
  }

  .lab-barra {
    flex-direction: column;
    align-items: stretch;
  }

  .lab-tabs {
    justify-content: center;
  }
}
