/* ============================================================
   VARIABILI GLOBALI
   ============================================================ */
:root {
  --primary: #004080;
  --accent: #FF7A00;
  --bg: #F4F6F8;
  --card-bg: #FFFFFF;
  --text: #1A1A1A;
  --text-secondary: #6B6B6B;
  --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;
  background: var(--bg);
  color: var(--text);
  display: flex;
  min-height: 100vh;
}

/* ============================================================
   SIDEBAR PRINCIPALE
   ============================================================ */
.sidebar {
  width: 240px;
  background-color: var(--primary);
  color: #fff;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding-top: 20px;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  box-shadow: 3px 0 15px rgba(0,0,0,0.15);
  overflow: hidden;
  transition: width 0.25s ease;
  z-index: 100;
}

.sidebar-header {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 15px 10px;
}

/* Logo normale */
.sidebar img {
  height: 50px;
  margin-bottom: 25px;
  transition: height 0.3s ease, margin-bottom 0.3s ease, transform 0.3s ease, opacity 0.3s ease;
}

/* Logo quando sidebar collassata */
.sidebar.collapsed img {
  height: 30px;
  margin-top: 120px;  /* spazio verso il basso reale */
  margin-bottom: 0;
  transform: rotate(-90deg);
  transform-origin: left top;
  opacity: 1;
  pointer-events: auto;
}




/* NAV LINKS */
.sidebar nav {
  display: flex;
  flex-direction: column;
  width: 100%;
  margin-top: 20px; /* distanza minima dalle top del sidebar */
  transition: margin-top 0.3s ease;
}

.sidebar nav a {
  color: #fff;
  text-decoration: none;
  padding: 14px 25px;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  transition: background 0.25s ease;
  white-space: nowrap;
  position: relative;
  border-radius: 8px;
}

.sidebar nav a:hover {
  background: rgba(255,255,255,0.1);
}

.sidebar nav a.active {
  background: var(--accent);
}

.sidebar nav a span {
  font-size: 0.95rem;
  transition: transform 0.25s ease, opacity 0.25s ease;
}





/* ============================================================
   SIDEBAR COLLASSATA
   ============================================================ */
.sidebar.collapsed {
  width: 60px;
}

/* NAV COLLASSATA MIGLIORATA */
.sidebar.collapsed nav {
  display: flex;
  flex-direction: column;     /* una colonna verticale */
  flex-wrap: nowrap;          /* evita sovrapposizioni */
  justify-content: flex-start;
  align-items: center;
  
  padding: 10px 5px;
  padding-bottom: 70px;       /* evita sovrapposizione col toggle */
  gap: 20px;                  /* spazio tra i bottoni */

  overflow-y: auto;           /* scroll verticale */
  overflow-x: hidden;
  max-height: calc(100% - 100px);

  scrollbar-width: thin;      /* Firefox */
}

.sidebar.collapsed nav::-webkit-scrollbar {
  width: 6px;
}

.sidebar.collapsed nav::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,0.25);
  border-radius: 4px;
}

/* Bottoni in sidebar collassata */
.sidebar.collapsed nav a {
  width: 100%;
  max-width: 100%;
  height: auto;
  margin: 0;
  padding: 10px 0;
  display: flex;
  align-items: center;
  justify-content: center;
  writing-mode: vertical-rl;
  transform: rotate(-180deg);
  font-size: 0.9rem;
  text-align: center;
  white-space: normal;
  border-radius: 6px;
}

/* Highlight correttamente esteso */
.sidebar.collapsed nav a:hover,
.sidebar.collapsed nav a.active {
  background: var(--accent);
  color: #fff;
}


/* ============================================================
   RESIZE HANDLE
   ============================================================ */
.resize-handle {
  position: absolute;
  top: 0;
  right: 0;
  width: 15px;
  height: 100%;
  cursor: ew-resize;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255,255,255,0);
  z-index: 120;
  transition: background 0.2s;
}

.resize-handle:hover {
  background: rgba(255,255,255,0.1);
}

#toggleSidebar {
  position: absolute;
  top: 95%;
  left: 15px;
  transform: translateY(-50%);
  width: 30px;
  height: 30px;
  background: var(--primary);
  border: 2px solid #fff;
  color: #fff;
  font-size: 1.2rem;
  cursor: pointer;
  border-radius: 6px;
  z-index: 999;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s ease;
}

#toggleSidebar:hover {
  background: var(--accent);
}

/* ============================================================
   MENU A SOTTO-LIVELLO (Ricambi)
   ============================================================ */
.menu-group {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: stretch;
}

.menu-toggle {
  background: none;
  border: none;
  color: #fff;
  text-align: left;
  padding: 14px 25px;
  font-size: 0.95rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  transition: background 0.25s;
  width: 100%;
  position: relative;
}

.menu-toggle:hover {
  background: rgba(255,255,255,0.1);
}

.menu-toggle .chevron {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-right: 2px solid #fff;
  border-bottom: 2px solid #fff;
  transform: rotate(45deg);
  transition: transform 0.3s ease;
  margin-left: 8px;
}

.menu-toggle.open .chevron {
  transform: rotate(135deg);
}

/* --- SOTTOMENU CON SLIDE --- */
.submenu {
  display: flex;
  flex-direction: column;
  background: rgba(255,255,255,0.05);
  padding-left: 20px;
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.35s ease, opacity 0.3s ease;
  opacity: 0;
}

.submenu.show {
  max-height: 200px;
  opacity: 1;
}

.submenu-item {
  color: #fff;
  text-decoration: none;
  padding: 10px 20px;
  border-radius: 6px;
  font-size: 0.9rem;
  transition: background 0.2s;
}

.submenu-item:hover {
  background: rgba(255,255,255,0.15);
}

.submenu-item.active {
  background: var(--accent);
  font-weight: 600;
  color: #fff;
}

/* ============================================================
   Ricambi / menu-toggle in modalità collassata
   ============================================================ */
.sidebar.collapsed .menu-toggle {
  width: 100%;
  max-width: 100%;
  height: auto;
  padding: 10px 0;
  justify-content: center;
  align-items: center;
  writing-mode: vertical-rl;
  transform: rotate(-180deg);
  white-space: normal;
  border-radius: 6px;
}

.sidebar.collapsed .menu-toggle span {
  font-size: 0.9rem;
  text-align: center;
}

.sidebar.collapsed .menu-toggle .chevron {
  display: none;
}

.menu-toggle.active {
  background: var(--accent);
}










/* ============================================================
   MAIN + FOOTER
   ============================================================ */
.main {
  flex: 1;
  margin-left: 240px;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  transition: margin-left var(--transition);
}

.sidebar.collapsed ~ .main {
  margin-left: 60px;
}

footer {
  background: var(--card-bg);
  text-align: center;
  padding: 18px 10px;
  border-top: 1px solid rgba(0,0,0,0.1);
  font-size: 0.85rem;
  color: var(--text-secondary);
  position: fixed;
  bottom: 0;
  left: 240px;
  right: 0;
  transition: left var(--transition);
}

.sidebar.collapsed ~ .main footer {
  left: 60px;
}

footer strong {
  color: var(--primary);
}



/* ============================================================
   HEADER
   ============================================================ */
header {
  background: var(--card-bg);
  padding: 18px 25px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: 0 2px 5px rgba(0,0,0,0.08);
  position: sticky;
  top: 0;
  z-index: 10;
}

header h1 {
  color: var(--primary);
  font-size: 1.6rem;
  font-weight: 600;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 15px;
}

#searchInput {
  width: 260px;
  padding: 8px 12px;
  border: 1px solid var(--text-secondary);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--text);
  font-size: 0.95rem;
  transition: var(--transition);
}

#searchInput:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(255,122,0,0.25);
}

.header-right {
  display: flex;
  align-items: center;
  gap: 15px;
}

#userName {
  font-weight: 600;
  color: var(--primary);
  margin-right: 10px;
  font-size: 1rem;
}

/* --- CARRELLO BADGE --- */
#cartIcon {
  position: relative;
  cursor: pointer;
  display: inline-block;
}

#cartBadge {
  position: absolute;
  top: -8px;        /* distanza dall’angolo superiore */
  right: -8px;      /* distanza dall’angolo destro */
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  background: var(--accent);  /* arancio acceso */
  color: #fff;
  font-size: 0.75rem;
  font-weight: 600;
  border-radius: 50%;        /* forma circolare */
  display: none;              /* nascosto se vuoto */
  text-align: center;
  line-height: 20px;
  box-shadow: 0 2px 6px rgba(0,0,0,0.2);
  transition: transform 0.2s ease, background 0.2s ease;
}

#cartBadge.show {
  display: inline-block;
  transform: scale(1);
}

#cartBadge:hover {
  background: #FF9A33;       /* arancio leggermente più chiaro al passaggio */
  transform: scale(1.2);      /* leggero effetto “pop” */
}
#loginBtn {
  padding: 10px 18px;
  border-radius: 8px;
  background: var(--accent);
  border: none;
  color: #fff;
  font-weight: 500;
  cursor: pointer;
  transition: 0.3s;
}

#loginBtn:hover {
  background: #e56f00;
}


/* --- RISULTATI RICERCA SOTTO HEADER --- */
#searchResult {
  background: var(--card-bg);
  border-top: 1px solid rgba(0,0,0,0.05);
  box-shadow: var(--shadow);
  border-radius: 0 0 var(--radius) var(--radius);
  margin: 0 auto;
  width: 99%;
  max-width: none;
  max-height: 150px;
  overflow-y: auto;
  padding: 10px 15px;
  display: none;
  z-index: 5;
}

/* --- RISULTATI --- */
.result-item {
  padding: 6px 0;
  border-bottom: 1px solid rgba(0,0,0,0.06);
}
.result-item:last-child { border-bottom: none; }
.result-item strong { color: var(--accent); }
.result-item .group { color: var(--text-secondary); font-style: italic; }
.no-result { text-align: center; color: var(--text-secondary); font-style: italic; }




/* ============================================================
   CONTENUTO PRINCIPALE
   ============================================================ */
main.content {
  flex: 1;
  padding: 40px 30px 90px 30px;
  overflow-y: auto;
}

main h2 {
  color: var(--primary);
  text-align: center;
  margin-bottom: 40px;
  font-size: 1.6rem;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 20px;
}


/* --- CARD --- */
.card {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  text-align: center;
  border: 2px solid transparent;
  transition: transform 0.25s, border-color 0.25s;
  cursor: pointer;
}

.card:hover {
  border: 2px solid var(--accent);
  transform: translateY(-4px);
}

.card img {
  width: 100%;
  height: 120px;
  object-fit: contain;
  margin-bottom: 10px;
}

.card h2 {
  font-size: 1rem;
  font-weight: 500;
  margin-bottom: 10px;
}

/* --- BOTTONI --- */
.button-container {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin-top: 10px;
}

.view-btn {
  border: 1px solid var(-primary-);
  border-radius: 8px;
  padding: 6px 14px;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  background: var(--primary);
  color: #fff;
  box-shadow: 0 2px 6px rgba(0,0,0,0.1);
}

.view-btn:hover {
  background: #FF7A00;            /* arancio */
  border: 1px solid var(--accenty);
  color: #fff;                     /* testo sempre bianco */
  box-shadow: 0 4px 10px rgba(0,0,0,0.15);
  transform: translateY(-2px);
}

.view-btn:active {
  transform: translateY(0);
  box-shadow: 0 2px 6px rgba(0,0,0,0.1);
}

.view-btn.disabled {
  background: #ccc;
  color: #666;
  cursor: not-allowed;
}

/* contenitore centrato e con spazio tra bottoni */
.button-container {
  display: flex;
  justify-content: center;
  gap: 20px;
  margin-top: 15px;
  flex-wrap: wrap;
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 600px) {
  .sidebar { width: 200px; }
  .sidebar.collapsed { width: 50px; }
  .main { margin-left: 200px; }
  .sidebar.collapsed ~ .main { margin-left: 50px; }
  header h1 { font-size: 1.3rem; }
  #searchInput { width: 180px; }
}








/* ============================================================
   SEZIONE ORDINA PER
   ============================================================ */
.sort-container {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.sort-label {
  font-weight: 600;
  color: var(--primary);
  font-size: 0.95rem;
}

.sort-select {
  padding: 8px 12px;
  border: 1px solid rgba(0,0,0,0.2);
  border-radius: var(--radius);
  background-color: var(--card-bg);
  color: var(--text);
  font-size: 0.95rem;
  cursor: pointer;
  transition: all 0.25s ease;
  min-width: 150px;
}

.sort-select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(255,122,0,0.25);
}

.sort-select option {
  padding: 8px 10px;
  font-size: 0.95rem;
}

/* Hover e attivo */
.sort-select:hover {
  border-color: var(--primary);
}

.sort-select:disabled {
  background-color: #f0f0f0;
  color: #888;
  cursor: not-allowed;
}






/* Link sidebar base */
.sidebar-link {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 25px;
  color: #fff;                
  text-decoration: none;
  border-radius: 8px;
  position: relative;
  transition: background 0.3s ease;
}

/* Hover leggero */
.sidebar-link:hover {
  background: rgba(255,255,255,0.05);
}

/* Link attivo: sfondo arancio (Tutorial) */
.sidebar-link.active {
  background: var(--accent);
  color: #fff;
}



/*sottog-sezione*/
.sidebar-link.indent {
  padding-left: 40px; /* aumenta il padding sinistro per indentare */
}

/* Chevron FAQ sempre a sinistra */
.sidebar-link.faq-chevron::after {
  content: "";
  display: inline-block;
  position: absolute;
  right: 15px;             
  top: 50%;
  transform: translateY(-50%) rotate(135deg); /* freccia sempre verso sinistra */
  width: 8px;
  height: 8px;
  border-right: 2px solid #fff;
  border-bottom: 2px solid #fff;
  transition: border-color 0.3s ease;
}

/* Hover sulla FAQ */
.sidebar-link.faq-chevron:hover::after {
  border-color: #fff;
}


/* Chevron FAQ personalizzata */
.sidebar-link.faq-chevron::after {
  content: "";
  display: inline-block;
  position: absolute;
  right: 15px;          /* estremità destra */
  top: 50%;
  transform: translateY(-50%) rotate(45deg); /* freccia rivolta verso sinistra */
  width: 8px;
  height: 8px;
  border-right: 2px solid #fff;
  border-bottom: 2px solid #fff;
  transition: transform 0.3s ease, border-color 0.3s ease;
}

/* Se vuoi animare la chevron quando il link è attivo */
.sidebar-link.faq-chevron.active::after {
  transform: translateY(-50%) rotate(135deg); /* ruota verso basso se vuoi espandere */
  border-color: #fff; /* colore della freccia */
}


.sidebar.collapsed .sidebar-link.faq-chevron::after {
  display: none; /* nasconde il chevron quando la sidebar è collassata */
}


/*lingue*/
/* 🌐 Language Switcher */
.lang-switcher {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 9999;
  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;
}