/* ==========================================================================
   PIAR - Simulator CSS (Robotics Lab Test Console)
   Estética de laboratorio futurista: blanco tecnológico, halos cian sutiles
   ========================================================================== */

.simulator-box {
  background: var(--surface-card, #ffffff);
  border: 1px solid var(--border-tech, #cbd8e6);
  border-radius: var(--radius-lg, 14px);
  box-shadow: 0 4px 20px -2px rgba(15, 29, 46, 0.06), 0 0 0 1px rgba(6, 182, 212, 0.15), var(--halo-subtle, 0 0 16px rgba(6, 182, 212, 0.08));
  margin: 1.5rem 0;
  overflow: hidden;
  position: relative;
}

.simulator-box::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--cyan-light, #22d3ee), transparent);
  opacity: 0.8;
  z-index: 10;
  pointer-events: none;
}

.simulator-header {
  background: linear-gradient(180deg, #fbfcfe 0%, #f0f4f9 100%);
  border-bottom: 1px solid var(--border-subtle, #e1e8f2);
  padding: 0.65rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.scratch-toolbar {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.btn-flag {
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  color: white;
  border: 1px solid rgba(255, 255, 255, 0.3);
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm, 6px);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(16, 185, 129, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.3);
  transition: var(--transition, all 0.15s ease);
}

.btn-flag:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 10px rgba(16, 185, 129, 0.4), 0 0 10px rgba(16, 185, 129, 0.3);
}

.btn-flag svg {
  width: 15px;
  height: 15px;
  fill: white;
}

.btn-stop {
  background: linear-gradient(135deg, #f43f5e 0%, #e11d48 100%);
  color: white;
  border: 1px solid rgba(255, 255, 255, 0.3);
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm, 6px);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(225, 29, 72, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.3);
  transition: var(--transition, all 0.15s ease);
}

.btn-stop:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 10px rgba(225, 29, 72, 0.4), 0 0 10px rgba(225, 29, 72, 0.3);
}

.btn-stop svg {
  width: 13px;
  height: 13px;
  fill: white;
}

.btn-sim-action {
  background: #ffffff;
  border: 1px solid var(--border-tech, #cbd8e6);
  color: var(--text-main, #0f1d2e);
  padding: 0.35rem 0.7rem;
  border-radius: var(--radius-sm, 6px);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  transition: var(--transition, all 0.15s ease);
  box-shadow: 0 1px 2px rgba(15, 29, 46, 0.04);
}

.btn-sim-action:hover {
  background: var(--surface-hover, #f8fbff);
  border-color: var(--cyan-core, #06b6d4);
  color: var(--blue-deep, #0369a1);
  box-shadow: 0 0 8px rgba(6, 182, 212, 0.25);
  transform: translateY(-1px);
}

.simulator-toggles {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  font-size: 0.78rem;
  color: var(--text-muted, #3a4d63);
}

.sim-toggle-label {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  cursor: pointer;
  user-select: none;
  font-weight: 500;
}

.sim-toggle-label input[type="checkbox"] {
  accent-color: var(--cyan-core, #06b6d4);
  cursor: pointer;
}

.sim-toggle-label input[type="range"] {
  accent-color: var(--cyan-core, #06b6d4);
}

.simulator-main {
  display: grid;
  grid-template-columns: 1fr;
  background-color: #0c1825;
  position: relative;
}

.canvas-wrapper {
  position: relative;
  width: 100%;
  max-width: 680px;
  margin: 0 auto;
  aspect-ratio: 4 / 3;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(180deg, #d8e8f8 0%, #b8d4f0 70%, #82c896 70%, #46aa62 100%);
  overflow: hidden;
  box-shadow: inset 0 0 20px rgba(12, 24, 37, 0.3);
}

#trampolinCanvas,
#laberintoCanvas {
  width: 100%;
  height: 100%;
  display: block;
}

.telemetry-bar {
  background: #09131f;
  color: #e2e8f0;
  border-top: 1px solid rgba(6, 182, 212, 0.2);
  padding: 0.65rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  font-size: 0.8rem;
  box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.3);
}

.telemetry-item {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.telemetry-label {
  color: #7991a8;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.telemetry-value {
  background: #050b12;
  padding: 0.15rem 0.45rem;
  border-radius: 4px;
  font-weight: 700;
  color: #38bdf8;
  border: 1px solid rgba(56, 189, 248, 0.25);
  min-width: 48px;
  text-align: center;
  text-shadow: 0 0 6px rgba(56, 189, 248, 0.4);
}

.telemetry-status {
  color: #67e8f9;
  font-weight: 500;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 0.8rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.telemetry-status::before {
  content: "";
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background-color: #22d3ee;
  box-shadow: 0 0 6px #22d3ee;
  animation: pulse-telemetry 2s ease-in-out infinite;
}

@keyframes pulse-telemetry {
  0%, 100% { opacity: 0.4; }
  50% { opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
  .telemetry-status::before {
    animation: none;
    opacity: 0.9;
  }
}

/* Indicador de bloque Scratch activo */
.code-highlight {
  outline: 2px solid var(--cyan-light, #22d3ee) !important;
  box-shadow: 0 0 14px rgba(6, 182, 212, 0.7) !important;
  transition: all 0.15s ease-in-out;
}

/* ==========================================================================
   Proyecto 3: El Laberinto Mágico
   ========================================================================== */

.canvas-wrapper.laberinto-wrapper {
  background: #1e1b4b;
}

/* Cruceta de dirección para pantallas táctiles */
.dpad {
  display: grid;
  grid-template-columns: repeat(3, 34px);
  grid-template-rows: repeat(2, 30px);
  gap: 3px;
}

.dpad .btn-sim-action {
  justify-content: center;
  padding: 0;
  font-size: 0.95rem;
  touch-action: none;
  user-select: none;
}

.dpad #btnUp { grid-column: 2; grid-row: 1; }
.dpad #btnLeft { grid-column: 1; grid-row: 2; }
.dpad #btnDown { grid-column: 2; grid-row: 2; }
.dpad #btnRight { grid-column: 3; grid-row: 2; }

.sim-select {
  font: inherit;
  font-size: 0.78rem;
  padding: 0.2rem 0.35rem;
  border: 1px solid var(--border-tech, #cbd8e6);
  border-radius: var(--radius-sm, 6px);
  background: #ffffff;
  color: var(--text-main, #0f1d2e);
  cursor: pointer;
}

.sim-select:focus-visible {
  outline: 2px solid var(--cyan-core, #06b6d4);
  outline-offset: 1px;
}

/* Muestra de color del sensor en la telemetría */
.telemetry-value.sensor-value {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  min-width: 86px;
  justify-content: flex-start;
}

.sensor-swatch {
  display: inline-block;
  width: 11px;
  height: 11px;
  border-radius: 3px;
  border: 1px solid rgba(255, 255, 255, 0.55);
}

/* Consola de mensajes (difusión de mensajes en directo) */
.message-console {
  background: #0b1020;
  border-top: 1px solid rgba(167, 139, 250, 0.25);
  padding: 0.6rem 1rem 0.75rem;
  color: #e2e8f0;
}

.message-console-title {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #a78bfa;
  font-weight: 700;
  margin-bottom: 0.4rem;
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.message-console-title span:last-child {
  color: #64748b;
  text-transform: none;
  letter-spacing: 0;
  font-weight: 500;
}

.message-log {
  list-style: none;
  margin: 0;
  padding: 0;
  min-height: 7.5rem;
  max-height: 11.5rem;
  overflow-y: auto;
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  font-size: 0.76rem;
}

.message-log:empty::before {
  content: "Aquí aparecerán los mensajes que se envían los objetos (enviar / al recibir)…";
  color: #64748b;
  font-style: italic;
}

.log-entry {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.4rem;
  padding: 0.22rem 0;
  border-bottom: 1px dashed rgba(148, 163, 184, 0.12);
  animation: log-in 0.25s ease-out;
}

.log-entry:first-child {
  color: #ffffff;
}

.log-time {
  color: #64748b;
  font-size: 0.7rem;
}

.log-icon {
  width: 1.2rem;
  text-align: center;
}

.log-pill {
  display: inline-block;
  padding: 0.08rem 0.5rem;
  border-radius: 999px;
  font-weight: 700;
  color: #ffffff;
  font-size: 0.72rem;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

/* Colores oficiales de las categorías de Scratch 3 */
.pill-events { background: #ffbf00; color: #3b2a00; }
.pill-looks { background: #9966ff; }
.pill-sensing { background: #4cbfe6; color: #062a36; }
.pill-control { background: #ffab19; color: #3b2400; }
.pill-data { background: #ff8c1a; color: #3b1d00; }
.pill-motion { background: #4c97ff; }

@keyframes log-in {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: none; }
}

@media (prefers-reduced-motion: reduce) {
  .log-entry { animation: none; }
}
