/* Panel de Configuración por secciones, controles de opciones, administrador de cámaras, vista 3D y recorrido. */
.settings-panel {
  width: 420px;
  display: grid;
  grid-template-columns: 116px 1fr;
  border-left: 1px solid var(--border);
  background: var(--panel);
  min-height: 0;
}
.settings-panel[hidden] { display: none; }
.sections-nav { display: flex; flex-direction: column; gap: 2px; padding: 8px; border-right: 1px solid var(--border); }
.sections-nav button { border: 0; text-align: left; background: transparent; padding: 6px 8px; }
.sections-nav button[aria-current="true"] { background: var(--bg); font-weight: 600; }
.sections-body { overflow: auto; padding: 10px 14px; min-width: 0; }
.sections-body h2 { font-size: 16px; margin: 0 0 8px; }
.sections-body h3 { font-size: 14px; margin: 14px 0 6px; }
.sections-body > section > * + * { margin-top: 8px; }
.sections-body select { max-width: 100%; }
.sections-body > section > label { display: flex; flex-direction: column; gap: 4px; }

.settings-group { border: 1px solid var(--border); border-radius: 8px; padding: 6px 10px 8px; margin: 8px 0 0; }
.settings-group legend { color: var(--muted); padding: 0 4px; }
.settings-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 4px 0; }
.settings-row select, .settings-row input[type="range"] { max-width: 180px; }

.camera-list { display: flex; flex-direction: column; }
.camera-row { display: grid; grid-template-columns: 1fr; grid-auto-flow: column; grid-auto-columns: auto; gap: 8px; align-items: center; padding: 6px 0; border-bottom: 1px solid var(--border); }
.badge { font-size: 12px; padding: 1px 8px; border-radius: 999px; background: var(--bg); color: var(--muted); }
.camera-toggle { min-width: 32px; }
.camera-config { padding: 4px 0 8px 12px; border-left: 2px solid var(--border); margin: 4px 0 8px; }
.badge.on { background: var(--ok-bg); color: var(--ok-text); }

.surface-view { position: relative; height: 240px; border-radius: 8px; overflow: hidden; background: #111318; }
.surface-view canvas { display: block; width: 100%; height: 100%; }
.surface-labels { position: absolute; inset: 0; pointer-events: none; }
.surface-label { padding: 2px 6px; border-radius: 4px; background: rgb(10 132 255 / 85%); color: #fff; font-size: 11px; white-space: nowrap; }
.surface-label.distance { background: rgb(0 0 0 / 70%); }
.surface-label.corner { background: rgb(255 69 58 / 85%); }
.surface-legend { display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: center; color: var(--muted); font-size: 12px; }
.swatch { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: -6px; }
.swatch.blue { background: #0a84ff; }
.swatch.red { background: #ff453a; }
.swatch.yellow { background: #ffcc00; }
.swatch.green { background: #30d158; }
.surface-info { display: grid; grid-template-columns: auto 1fr; gap: 2px 10px; }
.surface-info dt { color: var(--muted); }
.surface-info dd { margin: 0; font-weight: 600; }
.surface-warnings { padding-left: 18px; color: var(--warn); }
.surface-fields { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 4px 10px; }
.surface-fields label { display: flex; justify-content: space-between; gap: 6px; align-items: center; }
.surface-fields input[type="number"] { width: 70px; padding: 2px 6px; }
.row-actions { display: flex; flex-wrap: wrap; gap: 8px; }

.preview { width: 100%; height: auto; border-radius: 8px; background: #000; display: block; }
.readout { white-space: pre-wrap; font-family: ui-monospace, Consolas, monospace; font-size: 12px; margin: 8px 0 0; }

.example-row { display: grid; grid-template-columns: 1fr auto; gap: 8px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--border); }
.example-row p { margin: 2px 0 0; color: var(--muted); }

.tour-highlight { position: fixed; z-index: 10000; border: 3px solid var(--accent); border-radius: 8px; pointer-events: none; box-shadow: 0 0 0 9999px rgb(0 0 0 / 35%); }
.tour-bubble { position: fixed; z-index: 10001; max-width: 320px; padding: 10px 12px; border-radius: 8px; background: var(--panel); border: 1px solid var(--border); display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.tour-bubble p { margin: 0; flex-basis: 100%; }
.tour-counter { color: var(--muted); font-size: 12px; flex: 1; }

@media (max-width: 800px) {
  .settings-panel { width: auto; grid-template-columns: 1fr; border-left: 0; border-top: 1px solid var(--border); max-height: 50vh; }
  .sections-nav { flex-direction: row; overflow-x: auto; border-right: 0; border-bottom: 1px solid var(--border); }
}
@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto; }
}

.flow-table { display: flex; flex-direction: column; font-size: 13px; margin-bottom: 8px; }
.flow-row { display: grid; grid-template-columns: 20px 90px 1fr 56px; gap: 6px; padding: 2px 0; border-bottom: 1px solid var(--border); }
.flow-row span:last-child { text-align: right; font-variant-numeric: tabular-nums; }
.flow-off { color: var(--muted); }
.flow-slow { color: var(--warn); font-weight: 600; }
.flow-total { border-bottom: none; font-weight: 600; }

/* Ventanas dentro de la página (modules/windows): se mueven por la barra y cambian de tamaño por la esquina */
.windows-layer { position: fixed; inset: 0; pointer-events: none; z-index: 900; }
.win { position: fixed; display: flex; flex-direction: column; min-width: 200px; min-height: 140px; resize: both;
  overflow: hidden; pointer-events: auto; background: #111318; border: 1px solid #2c3140; border-radius: 10px;
  box-shadow: 0 8px 24px rgb(0 0 0 / 35%); }
.win-bar { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 4px 6px 4px 10px;
  background: #1c2030; color: #e8eaf0; font-size: 13px; cursor: move; user-select: none; touch-action: none; }
.win-bar button { padding: 0 6px; background: transparent; color: inherit; border: none; font-size: 14px; }
.win-body { position: relative; flex: 1; min-height: 0; }
.win-fill { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; border-radius: 0; }
.win-contain { object-fit: contain; }
.windows-row { display: flex; align-items: center; gap: 8px; padding: 4px 0; }
.windows-row > span:first-child { flex: 1; }

/* Ajustes dentro de la vista 3D (opciones con section 'vista3d'): encima del dibujo, plegables con su propia barra */
.view-controls { position: absolute; left: 8px; top: 8px; z-index: 2; max-width: 240px; max-height: calc(100% - 16px);
  overflow: auto; padding: 6px 8px; font-size: 12px; color: #e8eaf0; background: rgb(17 19 24 / 82%); border-radius: 8px; }
.view-controls .settings-group { margin: 0; padding: 0; border: none; }
.view-controls legend { display: none; }

/* Una sección de Configuración dentro de una ventana: mismos estilos que en el panel, con su propio desplazamiento */
.win-scroll { overflow: auto; padding: 10px 14px; background: var(--panel); }
.sections-body h2 { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.pop-button { padding: 0 6px; font-size: 14px; line-height: 1.4; }

/* Tablero (modules/board): la zona principal como cuadrícula de piezas; el orden lo da CSS order (no se mueve el DOM) */
.board { display: grid; grid-template-columns: repeat(var(--board-columns, 1), minmax(0, 1fr)); grid-auto-rows: minmax(280px, 1fr);
  gap: 8px; padding: 8px; min-width: 0; min-height: 0; overflow: auto; }
.board:has(> .tile:not([hidden]):only-of-type) { padding: 0; } /* una sola pieza: ocupa todo, como antes */
.tile { display: flex; flex-direction: column; min-width: 0; min-height: 0; overflow: hidden; border: 1px solid var(--border);
  border-radius: 10px; background: var(--panel); }
.tile[hidden] { display: none; }
.tile-bar { display: flex; align-items: center; gap: 4px; padding: 3px 6px 3px 10px; background: var(--bg); cursor: grab;
  user-select: none; font-size: 13px; }
.tile-bar > span { flex: 1; }
.tile-bar button { padding: 0 6px; border: none; background: transparent; }
.tile-body { position: relative; flex: 1; min-height: 0; display: flex; flex-direction: column; }
.tile-body > .browser { flex: 1; }
.tile-body.win-scroll { overflow: auto; }
.board-empty { grid-column: 1 / -1; align-self: center; text-align: center; color: var(--muted); }

/* Ajustes de una vista fuera del navegador (app/floating-row.js) */
.floating-row { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; padding: 4px 0 8px 12px; border-left: 2px solid var(--border); }
.floating-field { display: inline-flex; align-items: center; gap: 4px; }
.floating-field input { width: 72px; }
