:root {
  --primary: #004080;   /* blu profondo, per brand e pulsanti principali */
  --accent: #FF7A00;    /* arancio brillante per call-to-action e hover */
  --bg: #F4F6F8;        /* grigio chiaro elegante per sfondo principale */
  --card-bg: #FFFFFF;    /* bianco per cards e sezioni */
  --text: #1A1A1A;      /* testo principale scuro */
  --text-secondary: #6B6B6B; /* testo secondario / placeholder / icone */
  --shadow: 0 4px 10px rgba(0,0,0,0.08);
  --radius: 12px;
  --transition: 0.25s ease;
}

/* Reset base */
* { box-sizing: border-box; margin:0; padding:0; }
html,body{height:100%}

body {
  font-family: 'Segoe UI', 'Roboto', sans-serif;
  color: var(--text);
  background: var(--bg);
  height: 100vh;
  display: grid;
  grid-template-columns: 170px 1fr;
  overflow: hidden;
}

/* Layout: left nav narrow, viewer center, sidebar right */
/* --- Sidebar --- */
#sidebar {
  width:600px;
  border-left:1px solid #ddd;
  padding:15px;
  overflow-y:auto;
  position:relative;
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
}

/* Barra superiore fissa nella sidebar */
#sidebarTop {
  display:flex;
  justify-content: flex-start;
  align-items:center;
  gap:25px; /* spazio tra titolo e pulsanti */
}

#sidebarTop h3 {
  color: var(--primary);
  font-size: 1.1rem;
  margin: 0;
}

#sidebarTop .actions {
  display:flex;
  align-items:center;
  gap:10px;
}

/* --- Icona carrello --- */
#cartIcon {
  position:relative;
  cursor:pointer;
}
#cartIcon img { width:28px; height:28px; filter: brightness(0) invert(0.1); }
#cartBadge {
  position:absolute;
  top:-4px;
  right:-4px;
  background: var(--accent);
  color:white;
  border-radius:50%;
  font-size:11px;
  padding:2px 6px;
  display:inline-block;
}

/* --- Titoli --- */
h3 {
  color: var(--primary);
  margin:10px 0 8px 0;
}

/* --- Pulsanti --- */
button {
  background: var(--primary);
  color:white;
  border:none;
  padding:7px 12px;
  border-radius:8px;
  cursor:pointer;
  transition:0.2s ease;
  font-weight:500;
  box-shadow: var(--shadow);
}
button:hover {
  background: var(--accent);
  transform: translateY(-1px);
}

/* --- Wrapper tabella BOM --- */
#bomWrapper {
  flex:1;
  margin-top:10px;
  overflow-x:auto;
}

#bomTable {
  border-collapse:collapse;
  font-size:14px;
  table-layout:auto;
  width:100%;
  border-radius: var(--radius);
  overflow:visible;
  box-shadow: var(--shadow);
}
#bomTable th, #bomTable td {
  border-bottom:1px solid #e2e2e2;
  padding:2px 6px;
  white-space:nowrap;
  overflow:hidden;
  text-overflow:ellipsis;
}
#bomTable th {
  background: var(--primary);
  color:#fff;
  font-weight:600;
  position:sticky;
  top:0;
  z-index:2;
}
#bomTable tr:nth-child(even) {
  background:#f9fbfd;
}
#bomTable tr:hover {
  background:#eef5fb;
}
/* Colonna sticky per + (CART) */
#bomTable th:last-child {
  position: sticky;
  right: 0;
  background: var(--primary); /* o bianco se preferisci */
  color: #fff; /* testo bianco per contrasto */
  z-index: 2;  /* più alto delle righe */
  min-width: 80px;
  text-align: center;
}

#bomTable td:last-child {
  position: sticky;
  right: 0;
  background: #fff;
  z-index: 2;
  min-width: 80px;
  text-align: center;
}
/* --- Evidenziazione --- */
.highlight {
  background-color:#b8e5ff !important;
  transition:0.3s ease;
}

/* Contenitore SVG fisso */

#svgContainer {
  flex-shrink: 0;
  height: 100vh;
  position: relative;
  background: white; /* Sfondo bianco */
  border-radius: var(--radius);
  margin: 0;
  box-shadow: var(--shadow);
  overflow: hidden; /* 🔹 Ritaglia tutto ciò che esce */
  display: flex;
  justify-content: flex-start;
  align-items: flex-start;
}

#svgWrapper {
  width: auto;     /* prima era 100% */
  height: 98%;    /* lascia altezza automatica */
  overflow: hidden;
  cursor: grab;
  transform-origin: 0 0; /* 🟢 centro dell'elemento */
  transition: transform 0.05s linear; /* smoothing */
}

#svgWrapper svg {
  width: 100%;
  height: 100%; /* 🔹 da 98% → 100% per riempire tutto */
  display: block;
}

#svgWrapper.grabbing {
  cursor: grabbing;
  transition: none; /* rimuove smoothing durante il drag */
}




#qtyModal {
  position: absolute;
  display: none;
  background: #f4f6f8; /* uguale 3D */
  border: 1px solid #ddd;
  border-radius: 10px;
  padding: 12px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  font-family: Arial, sans-serif;
  font-size: 13px;
  color: #000;
  z-index: 1000;
  width: 300px;
  pointer-events: auto;
  cursor: grab;
}
#qtyModal:active { cursor: grabbing; }



/* Tooltip generale */
/* Tooltip leggero e vicino al cursore */
#tooltip {
    position: absolute;
    display: none;
    min-width: auto;           /* si adatta al contenuto */
    max-width: 220px;          /* evita righe troppo lunghe */
    background: rgba(34,34,34,0.95);
    color: #fff;
    padding: 2px 4px;          /* molto piccolo per avvicinarlo al mouse */
    border-radius: 3px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.4);
    z-index: 1000;
    font-family: sans-serif;
    font-size: 0.85rem;
    pointer-events: none;      /* non blocca il mouse */
    white-space: nowrap;
}

/* Pulsante "Esplora" dentro tooltip */
#tooltip button#exploreBtn {
    padding: 6px 12px;
    margin-top: 6px;
    border: none;
    border-radius: 6px;
    background: var(--accent);
    color: #fff;
    font-weight: bold;
    cursor: pointer;
    width: 100%;
    text-align: center;
    transition: background 0.2s ease;
}

#tooltip button#exploreBtn:hover {
    background:var(--accent);
}

/* Titolo del tooltip */
#tooltip strong {
    display: block;
    margin-bottom: 4px;
}

/* Descrizione del tooltip */
#tooltip span {
    color: #eee;
    font-size: 0.85rem;
    display: block;
}







/* Croce chiudi in cerchio */
#closeTooltipBtn {
  position: absolute;
  top: 6px;
  right: 6px;
  background: #6c757d;
  color: #fff;
  border: none;
  border-radius: 50%;
  padding: 2px 6px;
  cursor: pointer;
  font-weight: bold;
  font-size: 16px;
}
#closeTooltipBtn:hover { background: #5a6268; }

/* Riga Quantità per CODICE */
.qty-code-row {
  display: flex;
  align-items: center;
  gap: 6px;
}
.qty-label { font-weight: 500; color: #000; }
.code { font-weight: bold; color: #004080; } /* codice blu */

/* Riga Input + Bottone */
.modal-footer {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
}
.modal-footer input {
  width: 60px;
  padding: 5px;
  border: 1px solid #ccc;
  border-radius: 6px;
  font-size: 13px;
}
#addToCartBtn {
  background: #ff7a00;
  color: #fff;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  padding: 6px 12px;
  font-weight: bold;
}
#addToCartBtn:hover { background: #ff8f26; }





/* Sidebar overlay sopra il viewer */
#sidebar {
  position: absolute;
  top: 0;
  right: 0;
  height: 100vh;
  z-index: 100;
  background: rgba(255, 255, 255, 0.98);
  box-shadow: -4px 0 10px rgba(0,0,0,0.1);
}

/* Handle per resize */
#sidebarHandle {
  position: absolute;
  top: 0;
  left: -5px;
  height: 100%;
  width: 20px;
  cursor: ew-resize;
  background: transparent;
  z-index: 101;
}

/* Colonne ridimensionabili */
#bomTable th {
  position: relative;
  user-select: none;
}
#bomTable th .resize-handle {
  position: absolute;
  right: 0;
  top: 0;
  width: 6px;
  height: 100%;
  cursor: col-resize;
  z-index: 10;
}

/* Pannello di visibilità colonne */
#columnTogglePanel {
  position: sticky;
  top: 45px;
  background: var(--card-bg);
  border-bottom: 1px solid #ddd;
  padding: 6px 0;
  z-index: 4;
}
#columnTogglePanel label {
  margin-right: 8px;
  font-size: 13px;
  cursor: pointer;
  color: var(--text);
}

#leftSidebar {
  width: 170px;
  background: var(--primary);
  color: #fff;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  padding: 20px;
  box-shadow: var(--shadow);
  position: flex;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 120;
}

#leftSidebar .logo-section {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

#leftSidebar img {
  height: 35px;
}

#leftSidebar h1 {
  font-size: 1.2rem;
  margin: 0;
}

#leftSidebar .breadcrumb {
  font-size: 0.9rem;
  color: #cce0ff;
}

#leftSidebar .breadcrumb a {
  color: #fff;
  text-decoration: none;
}

#leftSidebar .breadcrumb a:hover {
  text-decoration: underline;
}

/* Sidebar */
#sidebar {
  position: absolute;
  top: 0;
  right: 0;
  height: 100vh;
  width: 500px;
  background: var(--card-bg);
  box-shadow: -4px 0 10px rgba(0,0,0,0.1);
  border-radius: 12px 0 0 12px;
  display: flex;
  flex-direction: column;
  transition: width 0.3s ease, transform 0.3s ease;
  overflow: hidden;
  z-index: 100;
}

/* Sidebar chiusa (scorre via a destra) */
#sidebar.closed {
  transform: translateX(100%);
  box-shadow: none;
}

/* Pulsante toggle visibile come linguetta */
#toggleSidebar {
  position: fixed;           /* 🟢 fissa al bordo destro */
  top: 3%;             /* 👈 spostato in alto */
  right: 0px;           /* allineato al bordo destro */
  transform: translateY(-50%);
  z-index: 200;
  width: 36px;
  height: 40px;
  font-size: 20px;
  border-radius: 8px 0 0 8px;
  background: var(--primary);
  color: #fff;
  border: none;
  cursor: pointer;
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s ease, right 0.2s ease;
}

#toggleSidebar:hover {
  background: var(--accent);
}

#leftSidebar {
  display: flex;
  flex-direction: column;
  height: 100vh;
  padding: 20px;
}

#leftSidebarFooter {
  font-size: 11px;
  color: #cce0ff;
  line-height: 1.2;
  margin-top: auto; /* spinge automaticamente il footer in basso */
}



/*lingue*/
/* 🌐 Language Switcher */
.lang-switcher {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 99999;
  font-family: inherit;
}

.lang-btn {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: none;
  background: var(--primary);
  color: #fff;
  font-size: 22px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 6px 18px rgba(0,0,0,0.25);
  transition: transform .25s, background .25s;
}

.lang-btn:hover {
  transform: scale(1.08);
  background: #005bb5;
}

.lang-menu {
  position: absolute;
  bottom: 58px;
  right: 0;
  background: #fff;
  border-radius: 14px;
  box-shadow: 0 10px 28px rgba(0,0,0,0.18);
  padding: 10px 0;
  width: 170px;
  opacity: 0;
  pointer-events: none;
  transform: translateY(12px);
  transition: all .25s ease;
}

.lang-switcher.active .lang-menu {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

.lang-item {
  padding: 10px 16px;
  font-size: 15px;
  cursor: pointer;
  display: flex;
  gap: 10px;
  align-items: center;
  transition: background .2s;
}

.lang-item:hover {
  background: #f1f1f1;
}


* { box-sizing: border-box; margin:0; padding:0; }
html, body { height:100%; font-family: 'Segoe UI', 'Roboto', sans-serif; }

body { display: grid; grid-template-columns: 170px 1fr; background: var(--bg); overflow: hidden; }

#leftSidebar {
  width: 170px;
  background: var(--primary);
  color: #fff;
  display: flex;
  flex-direction: column;
  padding: 20px;
  box-shadow: var(--shadow);
}

#leftSidebar .logo-section {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}
#leftSidebar img { height: 35px; }
#leftSidebar h1 { font-size: 1.2rem; margin: 0; }

#leftSidebar .breadcrumb {
  font-size: 0.9rem;
  color: #cce0ff;
}
#leftSidebar .breadcrumb a { color: #fff; text-decoration: none; }
#leftSidebar .breadcrumb a:hover { text-decoration: underline; }
#leftSidebarFooter { font-size:11px; color:#cce0ff; line-height:1.2; margin-top:auto; }

#viewerArea { 
  position: relative; 
  width:100%; 
  height:100%; 
  background:white; 
  display:flex; 
  align-items:flex-start; 
  justify-content:flex-start;
 }

#renderCanvas { 
  
  width: 100%; 
  height: 100%; 
  display: block; 
  background: white; 
  border: none; 
  outline: none; }


/*ZOOM*/

#zoomControls {
  position: absolute;
  top: 16px;
  left: 16px;
  display: flex;
  flex-direction: row;
  gap: 6px;
  z-index: 10;
}
#zoomControls button {
  background: var(--primary);
  color: white;
  border: none;
  padding: 10px 15px;
  border-radius: 8px;
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: var(--transition);
}
#zoomControls button:hover { background: var(--accent); }


#sidebar { 
   position: absolute;
  top: 0;
  right: 0;
  height: 100vh;
  width: 500px;
  background: var(--card-bg);
  box-shadow: -4px 0 10px rgba(0,0,0,0.1);
  border-radius: 12px 0 0 12px;
  display: flex;
  flex-direction: column;
  transition: width 0.3s ease, transform 0.3s ease;
  overflow: hidden;
  z-index: 100;
}

#sidebar.closed { 
  transform: translateX(100%);
  box-shadow: none;
}


/* Pulsante toggle visibile come linguetta */
#toggleSidebar {
  position: fixed;           /* 🟢 fissa al bordo destro */
  top: 3%;             /* 👈 spostato in alto */
  right: 0px;           /* allineato al bordo destro */
  transform: translateY(-50%);
  z-index: 200;
  width: 36px;
  height: 40px;
  font-size: 20px;
  border-radius: 8px 0 0 8px;
  background: var(--primary);
  color: #fff;
  border: none;
  cursor: pointer;
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s ease, right 0.2s ease;
}

#toggleSidebar:hover {
  background: var(--accent);
}

#sidebarTop { display:flex; gap:10px; align-items:center; margin-bottom:10px; }
#sidebarTop .actions { display:flex; gap:10px; align-items:center; }

#cartIcon { position:relative; cursor:pointer; }
#cartIcon img { width:28px; height:28px; filter: brightness(0) invert(0.1); }

.stockDot {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  margin-left: 8px;
  vertical-align: middle;
}
.stockDot.green { background-color: #2ecc71; }   /* verde = ok */
.stockDot.orange { background-color: #f39c12; }  /* arancio = bassa */
.stockDot.red { background-color: #e74c3c; }     /* rosso = esaurita */
 

/* Mesh table */
#meshTable td:first-child { width:130px; text-align:left; white-space:nowrap; }
#meshTable td { vertical-align:top; padding:6px 8px; }
#meshInfoContainer tr:hover { background-color:#f2f2f2; }
#meshTable tr:last-child { 
    display: none; 
}

/* Search dropdown */
#searchResults {
  display: none;
  position: relative;       /* non assoluto → spinge in basso */
 max-height: 600px;        /* scorre se troppi risultati */
  overflow-y: auto;
  background: #ffffff;
  border: 1px solid #444;
  border-radius: 6px;
  margin-top: 6px;
  padding: 4px;
  z-index: 1; /* serve solo per sicurezza */
}
#searchResults li {
  list-style: none;
  padding: 4px 8px;
  border-bottom: 1px solid #333;
}
#searchResults li:hover {
  background-color: #b8e5ff;
}

#switch2D {
    display: none !important;
    pointer-events: none !important; /* zero interazione */
}


