:root {
  /* stati UI */
  --ui-added:      #d8ffd8;
  --ui-available:  #f5f5f5;
  --ui-selected:   #c7e6ff;
  --ui-hover:      #e6e6e6;

  /* window scena */
  --window-normal: #E9ECEF;/*#d5dadd;*/
  --window-hover:  #e6e6e6;
}
/* =========================================================
   LAYOUT GENERALE
   ========================================================= */
body {
    margin: 0;
    display: flex;
    height: 100vh;
    font-family: Arial, sans-serif;
    overflow: hidden;
}

/* Area 3D */
#left {
    flex: 1;
    background: #1a1a1a;
    position: relative;
}

/* Pannello destro */
#right {
    width: 250px;
    background: #f4f4f7;
    padding: 6px;
    border-left: 1px solid #aaa;
    overflow-y: auto;
    box-sizing: border-box;
    position: relative;
    z-index: 1;
}

/* Resizer laterale */
#side-resizer {
    width: 6px;
    height: 100vh;
    cursor: col-resize;
    background: transparent;
    user-select: none;
    z-index: 10000;
}

#side-resizer:hover {
    background: var(--ui-hover);/*#4d90fe;*/
}

/* =========================================================
   CANVAS
   ========================================================= */
canvas {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    display: block;
}

/* =========================================================
   TIPOGRAFIA / INPUT BASE
   ========================================================= */
h3 {
    margin: 8px 0 4px 0;
    font-size: 13px;
}

input,
select,
button {
    width: 100%;
    margin: 1px 0;
    padding: 2px 3px;
    font-size: 12px;
    box-sizing: border-box;
    line-height: 1.2;
}

/* =========================================================
   PANNELLO PROPRIETÀ (legacy, mantenuto)
   ========================================================= */
.prop-row {
    display: flex;
    align-items: center;
    margin: 0;
    padding: 0;
}

.prop-label {
    width: 90px;
    font-size: 12px;
    font-weight: bold;
    margin: 0;
}

.prop-value {
    flex: 1;
}

.prop-value select {
    padding: 1px 3px;
    font-size: 12px;
}

/* =========================================================
   TABELLE DATI (Window / Button / Layout)
   ========================================================= */
.window-data-container {
    width: 100%;
    height: 150px;
    overflow-y: auto;
    overflow-x: auto;
    border: 1px solid #999;
    background: white;
    margin-top: 6px;
    box-sizing: border-box;
    scroll-padding-top: 24px;
}

/* Tabella */
.windowDataTable {
    width: max-content;
    border-collapse: collapse;
    background: #fff;
    font-size: 11px;
}

/* Righe */
.windowDataTable tr {
    height: 24px;
}

/*
.windowDataTable tr:hover {
    background: #ffeaa7;
}
*/

/* Celle */
.windowDataTable th,
.windowDataTable td {
    border: 1px solid #000;
    padding: 3px 5px;
    white-space: nowrap;
    text-align: left;
}

/* Header sticky */
.windowDataTable thead th {
    position: sticky;
    top: 0;
    z-index: 3;
    background: #f0f0f0;
    font-weight: bold;
}

/* Stati riga */
.data_added {
    background: var(--ui-added); /*#d8ffd8;*/
    cursor: pointer;
}

.data_available {
    background: var(--ui-available);/*#f5f5f5;*/
    cursor: pointer;
}

.selectedRow {
    background-color: var(--ui-selected) !important; /*#c7e6ff !important;*/
}
.rowPreview {
    background: var(--ui-hover);/*#e6e6e6;*/ /* grigio leggero */
}
/* =========================================================
   COLONNE COLLASSATE
   ========================================================= */
.col-hidden {
    display: none;
}

.collapsed-col {
    width: 20px !important;
    min-width: 20px !important;
    max-width: 20px !important;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: clip;
    text-align: center !important;
    padding: 0 !important;
}

.collapse-icon {
    font-size: 12px;
    font-weight: bold;
    pointer-events: none;
}

.plusMark {
    color: #008000;
}

/* =========================================================
   SELEZIONE CELLA (Excel-like)
   ========================================================= */
.cellSelected {
    outline: 2px solid #4d90fe;
    outline-offset: -2px;
}

/* =========================================================
   CONTEXT MENU
   ========================================================= */
.contextMenu {
    position: fixed;
    background: #fff;
    border: 1px solid #b4b4b4;
    border-radius: 4px;
    padding: 4px 0;
    min-width: 160px;
    font-size: 13px;
    font-family: system-ui, sans-serif;
    box-shadow: 0 2px 10px rgba(0,0,0,0.25);
    user-select: none;
    white-space: nowrap;
    z-index: 99999999;
}

.contextMenuItem {
    padding: 6px 14px;
    cursor: pointer;
}

.contextMenuItem:hover {
    background: var(--ui-hover);/*#e5e5e5;*/
}

/* =========================================================
   POPUP SELEZIONE CAMPO
   ========================================================= */
.fieldSelectorPopup {
    position: fixed;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    background: white;
    border: 1px solid #888;
    padding: 10px;
    z-index: 999999999;
    max-height: 300px;
    overflow-y: auto;
    min-width: 240px;
    font-family: system-ui, sans-serif;
}

.fieldSelectorItem {
    padding: 5px;
    cursor: pointer;
}

.fieldSelectorItem:hover {
    background: var(--ui-hover);/*#dde7ff;*/
}
editor: {
  selectionGlow: 0xA5BFD4,
  hover: var(--ui-hover);/*0xE6E6E6*/   // 🔥 stesso grigio della UI
}

/* =========================================================
   BARRA SALVATAGGIO LAYOUT
   ========================================================= */
/*.layout-bar {
    display: grid;
    grid-template-columns: 1fr auto auto;
    gap: 6px;
}*/

.layout-bar{
  display:flex;
  align-items:center;
  gap:8px;
}

.layout-title{
  margin:0;
  white-space:nowrap;
  flex: 0 0 auto;   /* NON deve crescere */
}

.layout-bar input{
  flex: 1 1 auto;   /* PRENDE tutto lo spazio disponibile */
  min-width:0;
}

.layout-bar button {
  flex: 0 0 auto;     /* non cresce, non si restringe */
  width: auto;        /* larghezza naturale */
  min-width: unset;   /* annulla eventuali stili globali */
  padding: 2px 8px;   /* il più stretti possibile */
  white-space: nowrap;
}

.contextRow {
  background: #2a6cff33;
}

/* =========================================================
   COLLAPSIBLE GROUPS (Right panel)
   - 1 wrapper div per gruppo
   - click sul titolo per collassare
   ========================================================= */
.ui-section {
  border-bottom: 1px solid #cfcfcf;
  padding-bottom: 6px;
  margin-bottom: 6px;
}

/* Quando collassato: nasconde tutto tranne il primo figlio (header) */
.ui-section.is-collapsed > :not(:first-child) {
  display: none;
}

/* Header "semplice" (Finestre / Pulsanti): il primo figlio è h3 */
.ui-section > h3:first-child {
  margin: 8px 0 6px 0;
  font-size: 13px;
  cursor: pointer;
  user-select: none;
  position: relative;
  padding-left: 16px; /* spazio per la freccia */
}
.ui-section > h3:first-child::before {
  content: "▾";
  position: absolute;
  left: 0;
  top: 0;
}
.ui-section.is-collapsed > h3:first-child::before {
  content: "▸";
}

/* Header Layout/GLB/ROI: il primo figlio è .layout-bar (la freccia la mettiamo sul titolo) */
.ui-section[data-key="layout"] .layout-title,
.ui-section[data-key="glb"] .layout-title,
.ui-section[data-key="roi"] .layout-title {
  cursor: pointer;
  user-select: none;
  position: relative;
  padding-left: 16px; /* spazio per la freccia */
}
.ui-section[data-key="layout"] .layout-title::before,
.ui-section[data-key="glb"] .layout-title::before,
.ui-section[data-key="roi"] .layout-title::before {
  content: "▾";
  position: absolute;
  left: 0;
  top: 0;
}
.ui-section.is-collapsed[data-key="layout"] .layout-title::before,
.ui-section.is-collapsed[data-key="glb"] .layout-title::before,
.ui-section.is-collapsed[data-key="roi"] .layout-title::before {
  content: "▸";
}


/* --- GLB / ROI (integrati in HMI) --- */
.glb-toolbar, .roi-toolbar {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-wrap: wrap;
  margin: 6px 0;
}
.glb-toolbar input {
  flex: 1 1 auto;
  min-width: 160px;
}
.small-info {
  font-size: 12px;
  opacity: 0.85;
  margin: 4px 0;
}
.roi-sizes{
  display:grid;
  grid-template-columns: auto 1fr;
  gap: 4px 8px;
  align-items:center;
  margin: 6px 0;
}
.roi-sizes label{
  font-size:12px;
  opacity:0.8;
}
