/* Ajustes especiales para fullscreen del simulador */
.fullscreen-simulador #renderCanvas {
  height: calc(80vh + 40px) !important;
  min-height: calc(500px + 40px) !important;
  max-height: calc(900px + 40px) !important;
  width: calc(100% + 40px) !important;
  margin-left: -20px !important;
  margin-right: -20px !important;
}
/*

  Rediseño industrial y profesional para el simulador, siguiendo el mismo estilo que style.css
  (bordes negros, botones claros, paneles, contraste alto, tipografía clara, etc.)

*/
body {
  background: #f4f4f4;
  font-family: 'Segoe UI', Arial, sans-serif;
  color: #181818;
  margin: 0;
}

/* Header */
header {
  background: #181818;
  color: #fff;
  padding: 24px 0 12px 0;
  border-bottom: 3px solid #222;
  text-align: center;
}

header h1 {
  font-size: 2.1em;
  font-weight: 700;
  margin: 0;
  letter-spacing: 1px;
}

#fecha_hoy {
  color: #bbb;
  font-size: 1em;
  text-align: right;
  margin: 0 24px 0 0;
}

/* Navegación */
nav {
  background: #fff;
  border-bottom: 2px solid #222;
  display: flex;
  justify-content: center;
  gap: 0;
}

nav .tab {
  color: #181818;
  background: none;
  border: none;
  font-weight: 600;
  font-size: 1.08em;
  padding: 12px 36px 10px 36px;
  border-right: 1.5px solid #222;
  border-radius: 0;
  transition: background 0.2s, color 0.2s;
  text-transform: uppercase;
  letter-spacing: 1px;
  text-decoration: none;
}

nav .tab:last-child { border-right: none; }

nav .tab.active, nav .tab:hover {
  background: #222;
  color: #fff;
}

/* Contenedor principal */
.container {
  max-width: 1100px;
  margin: 36px auto 0 auto;
  background: #fff;
  border: 2.5px solid #222;
  border-radius: 18px;
  box-shadow: 0 4px 24px #0002;
  padding: 32px 32px 24px 32px;
}

/* barra de herramientas */
.toolbar {
  display: flex;
  gap: 0;
  margin-bottom: 8px;
  align-items: center;
  border: 2px solid #222;
  border-radius: 8px;
  background: #f9f9f9;
  padding: 2px 2px;
  min-height: 0;
}

.tool-btn, #btn_guardar_objetos, #btn_cargar_bloques, #fullscreenBtn {
  background: #222;
  color: #fff;
  border: none;
  border-radius: 0;
  padding: 4px 12px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
  border-top: 1px solid #222;
  border-bottom: 1px solid #222;
  border-left: 0;
  border-right: 0;
  letter-spacing: 0.2px;
  min-width: 0;
  line-height: 1.2;
  transform: none;
  margin: 0;
}
.toolbar .tool-btn:first-child,
.toolbar #btn_guardar_objetos:first-child,
.toolbar #btn_cargar_bloques:first-child,
.toolbar #fullscreenBtn:first-child {
  border-left: 1px solid #222;
  border-top-left-radius: 3px;
  border-bottom-left-radius: 3px;
}
.toolbar .tool-btn:last-child,
.toolbar #btn_guardar_objetos:last-child,
.toolbar #btn_cargar_bloques:last-child,
.toolbar #fullscreenBtn:last-child {
  border-right: 1px solid #222;
  border-top-right-radius: 3px;
  border-bottom-right-radius: 3px;
}

.tool-btn.secondary {
  background: #fff;
  color: #222;
  border: 2px solid #222;
}

.tool-btn:active, #btn_guardar_objetos:active, #btn_cargar_bloques:active, #fullscreenBtn:active {
  background: #444;
  color: #fff;
}

.info {
  margin-left: auto;
  color: #181818;
  font-weight: 600;
  font-size: 0.98em;
}

/* canvas 3D */
#viewer {
  width: 100%;
  height: 600px;
  background: linear-gradient(#cfe8ff, #eaf4ff);
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 6px 18px rgba(0,0,0,0.15);
}

/* canvas 3D más largo */
#renderCanvas {
  width: 100%;
  height: 80vh;
  min-height: 500px;
  max-height: 900px;
  display: block;
  border: 2.5px solid #222;
  border-radius: 12px;
  margin: 24px 0 32px 0;
  background: #eaeaea;
}

#plcPanel {
  width: 100%;
  background: #f9f9f9;
  color: #181818;
  padding: 18px 18px 10px 18px;
  border: 2px solid #222;
  border-radius: 10px;
  margin: 24px 0 0 0;
  box-shadow: 0 2px 8px #0001;
}

#plcPanel h3 {
  margin: 0 0 10px 0;
  font-size: 1.1em;
  font-weight: 700;
  color: #181818;
  text-transform: uppercase;
  letter-spacing: 1px;
}

#plcPanel ul {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.plc-item {
  flex: 1 1 auto;
  min-width: 80px;
  padding: 8px 14px;
  background: #fff;
  color: #181818;
  cursor: pointer;
  border-radius: 6px;
  font-size: 1em;
  border: 1.5px solid #222;
  font-weight: 600;
  text-align: center;
  transition: background 0.2s, color 0.2s;
}

.plc-item:hover {
  background: #eaeaea;
}

/* Panel compacto */
.compact-panel {
  margin: 10px 0;
  padding: 0;
  list-style: none;
  border: 1.5px solid #222;
  border-radius: 8px;
  background: #f4f4f4;
  max-width: 400px;
}

.compact-panel li {
  display: flex;
  justify-content: space-between;
  padding: 8px 14px;
  font-size: 1em;
  border-bottom: 1px solid #ddd;
  color: #181818;
}

.compact-panel li:last-child {
  border-bottom: none;
}

.pizarron {
  margin-top: 32px;
  padding: 18px 18px 10px 18px;
  background: #f9f9f9;
  border: 2px solid #222;
  border-radius: 10px;
}

.flujo-container {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 18px;
  flex-wrap: wrap;
}

.flujo-step {
  background: #eaeaea;
  border: 2px solid #222;
  border-radius: 8px;
  padding: 14px 18px;
  min-width: 110px;
  text-align: center;
  font-weight: 700;
  color: #181818;
  font-size: 1em;
}

.arrow {
  font-size: 28px;
  color: #222;
  font-weight: bold;
}

.flujo-panel {
  margin-top: 24px;
}

.pasos-flujo {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
}

.paso-plc {
  flex: 1 1 200px;
  min-width: 200px;
  max-width: 300px;
  box-shadow: 0 0 5px #0001;
  border: 1.5px solid #222;
  border-radius: 8px;
  background: #fff;
  padding: 10px 14px;
}

/* Menu contextual */
#menu-contextual, #contextMenu {
  position: fixed;
  background: #222;
  border: 1.5px solid #555;
  padding: 12px;
  border-radius: 6px;
  box-shadow: 0 4px 12px #0008;
  color: #fff;
  min-width: 240px;
  max-width: 300px;
  z-index: 1000;
}

#menu-contextual .info-item {
  margin: 8px 0;
  padding: 6px 0;
  border-bottom: 1px solid #444;
  font-size: 0.85em;
  line-height: 1.4;
}

#menu-contextual .info-label {
  color: #aaa;
  font-weight: 600;
  font-size: 0.75em;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

#menu-contextual .info-value {
  color: #fff;
  margin-top: 2px;
  word-break: break-all;
}

#menu-contextual .menu-input {
  width: 100%;
  padding: 6px;
  margin-top: 4px;
  background: #333;
  border: 1px solid #555;
  color: #fff;
  border-radius: 3px;
  font-size: 0.9em;
}

#menu-contextual .menu-input:focus {
  outline: none;
  border-color: #777;
  background: #3a3a3a;
}

#menu-contextual .coords-inputs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  margin-top: 4px;
}

#menu-contextual .coord-group {
  display: flex;
  flex-direction: column;
}

#menu-contextual .coord-group label {
  font-size: 0.75em;
  color: #aaa;
  margin-bottom: 2px;
  font-weight: 600;
}

#menu-contextual .coord-group input {
  padding: 4px;
  background: #333;
  border: 1px solid #555;
  color: #fff;
  border-radius: 3px;
  font-size: 0.85em;
}

#menu-contextual .coord-group input:focus {
  outline: none;
  border-color: #777;
  background: #3a3a3a;
}

#menu-contextual .color-edit {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 4px;
}

#menu-contextual .color-input {
  flex: 1;
  padding: 6px;
  height: 32px;
  border: 1px solid #555;
  border-radius: 3px;
  cursor: pointer;
}

#menu-contextual .color-preview {
  display: inline-block;
  width: 24px;
  height: 24px;
  border-radius: 3px;
  margin-right: 6px;
  border: 1px solid #666;
}

#menu-contextual button, #contextMenu .ctx-btn {
  width: 100%;
  background: #333;
  color: white;
  border: none;
  padding: 8px 10px;
  margin: 8px 0 0 0;
  cursor: pointer;
  border-radius: 4px;
  text-align: center;
  font-weight: 600;
  font-size: 0.9em;
}

#menu-contextual button:hover, #contextMenu .ctx-btn:hover {
  background: #444;
}

/* Modal */
.modal {
  display: none;
  position: fixed;
  top: 0; left: 0; width: 100%; height: 100%;
  background: rgba(0,0,0,0.5);
  justify-content: center;
  align-items: center;
  z-index: 9999;
}

.modal > div {
  background: #1e1e1e;
  padding: 24px;
  border-radius: 10px;
  width: 340px;
  color: white;
  box-shadow: 0 2px 12px #0008;
}

.modal h3 {
  margin-top: 0;
  font-size: 1.2em;
  font-weight: 700;
  color: #fff;
}

@media (max-width: 900px) {
  .container { padding: 8px 2vw; }
  .toolbar { flex-direction: column; gap: 8px; }
  #renderCanvas { height: 40vh; min-height: 220px; max-height: 60vh; }
}

/* Modal de Simulación */
.modal-simulacion {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.8);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-simulacion-content {
  background: #1a1a1a;
  border: 2px solid #333;
  border-radius: 12px;
  width: 90%;
  max-width: 1000px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.6);
}

.modal-simulacion-header {
  background: #222;
  border-bottom: 2px solid #444;
  padding: 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-radius: 12px 12px 0 0;
}

.modal-simulacion-header h2 {
  color: #fff;
  margin: 0;
  font-size: 1.5em;
  font-weight: 700;
}

.close-modal-btn {
  background: #444;
  border: none;
  color: #fff;
  font-size: 1.5em;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}

.close-modal-btn:hover {
  background: #666;
}

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

.cadena-conexion {
  background: #ffffff;
  border: 1.5px solid #ddd;
  border-radius: 8px;
  padding: 16px;
  margin-bottom: 16px;
}

.cadena-conexion h3 {
  color: #2e7d32;
  margin: 0 0 12px 0;
  font-size: 1.2em;
  font-weight: 700;
}

.cadena-bloques {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.bloque-item {
  background: #f5f5f5;
  border: 1.5px solid #bbb;
  border-radius: 6px;
  padding: 10px 14px;
  color: #333;
  font-size: 0.9em;
}

.bloque-item .bloque-nombre {
  font-weight: 700;
  color: #1565c0;
}

.bloque-item .bloque-plc {
  color: #d97706;
  font-size: 0.85em;
  margin-top: 4px;
}

.bloque-item:hover {
  background: #efefef;
  border-color: #1565c0;
  transform: translateY(-2px);
  transition: all 0.2s;
}

.flecha-conexion {
  color: #999;
  font-size: 1.5em;
  font-weight: 700;
}

.tiempo-total {
  background: #f0f8f0;
  border: 1.5px solid #2e7d32;
  border-radius: 6px;
  padding: 12px;
  margin-top: 12px;
}

.tiempo-total-label {
  color: #555;
  font-size: 0.85em;
  font-weight: 600;
  text-transform: uppercase;
}

.tiempo-total-valor {
  color: #2e7d32;
  font-size: 1.8em;
  font-weight: 700;
  margin-top: 4px;
}

.no-conexiones {
  color: #666;
  text-align: center;
  padding: 40px;
  font-size: 1.1em;
}

/* Panel de información del PLC */
.info-plc-panel {
  background: #ffffff;
  border: 2px solid #ddd;
  border-radius: 8px;
  padding: 20px;
  margin-top: 24px;
}

.info-plc-placeholder,
.info-plc-error {
  color: #666;
  text-align: center;
  padding: 20px;
  font-size: 1em;
}

.info-plc-error {
  color: #d32f2f;
}

.info-plc-header {
  border-bottom: 2px solid #ddd;
  padding-bottom: 12px;
  margin-bottom: 16px;
}

.info-plc-header h3 {
  color: #1565c0;
  margin: 0 0 8px 0;
  font-size: 1.4em;
  font-weight: 700;
}

.info-plc-bloque {
  color: #666;
  font-size: 0.9em;
}

.info-plc-seccion {
  margin-bottom: 20px;
}

.info-plc-seccion h4 {
  color: #d97706;
  margin: 0 0 10px 0;
  font-size: 1.1em;
  font-weight: 700;
}

.info-plc-seccion ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

.info-plc-seccion li {
  background: #f9f9f9;
  border: 1px solid #e0e0e0;
  border-radius: 4px;
  padding: 8px 12px;
  margin-bottom: 6px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.var-name {
  color: #555;
  font-weight: 600;
  font-size: 0.9em;
}

.var-value {
  color: #333;
  font-weight: 700;
  font-size: 1em;
}

.var-velocidad {
  color: #2e7d32;
  font-size: 1.1em;
}
/* Inputs editables en panel de info */
.entrada-input {
  background: #333;
  border: 1px solid #555;
  color: #fff;
  padding: 6px 8px;
  border-radius: 4px;
  font-size: 0.95em;
  cursor: pointer;
  transition: all 0.2s ease;
}

.entrada-input:hover {
  background: #404040;
  border-color: #FFB74D;
}

.entrada-input:focus {
  outline: none;
  background: #404040;
  border-color: #64B5F6;
  box-shadow: 0 0 8px rgba(100, 181, 246, 0.4);
}

.entrada-input[type="checkbox"] {
  width: 18px;
  height: 18px;
  cursor: pointer;
  accent-color: #4CAF50;
}

.entrada-input[type="number"] {
  width: 80px;
  text-align: center;
}

/* Panel de Simulación (debajo del simulador) */
.panel-simulacion {
  background: #ffffff !important;
  border-top: 2px solid #ddd !important;
  padding: 20px !important;
  color: #333 !important;
}

.panel-simulacion h3 {
  color: #1565c0 !important;
  margin: 0 !important;
  font-size: 1.3em !important;
}

.live-indicator {
  background: #fff3cd;
  border: 1px solid #ffc107;
  color: #856404;
  padding: 12px;
  border-radius: 4px;
  margin-top: 16px;
  text-align: center;
  font-weight: 600;
}

.status-on {
  color: #2e7d32;
  font-weight: 700;
}

.status-off {
  color: #999;
  font-weight: 700;
}

.numeric-value {
  color: #1565c0;
  font-weight: 700;
}

.highlight-velocidad {
  color: #d97706;
  font-weight: 700;
}