/*
 * PSB Sidebar (slim) — solo stili sidebar + variabili.
 * Versione ridotta di psb-theme.css per uso dentro app moderne (es. SPA React)
 * che hanno il proprio sistema di styling (Tailwind) e non vogliono i
 * reset/font-boost globali del tema completo.
 */

:root {
  --navy: #1a2332;
  --navy-light: #243447;
  --navy-dark: #0f1923;
  --primary: #3b82f6;
  --primary-dark: #2563eb;
  --primary-light: #dbeafe;
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --gray-50: #f9fafb;
  --gray-100: #f3f4f6;
  --gray-200: #e5e7eb;
  --gray-300: #d1d5db;
  --gray-400: #9ca3af;
  --gray-500: #6b7280;
  --gray-600: #4b5563;
  --gray-700: #374151;
  --gray-800: #1f2937;
  --gray-900: #111827;
  --white: #ffffff;
  --sidebar-w: 240px;
  --transition: 0.2s ease;
}

/* Preset body margin per evitare flash/salto:
   psb-navbar.js (defer) imposta body.marginLeft = 240px DOPO il parsing,
   causando un re-layout visibile. Settandolo via CSS con !important per
   battere il preflight Tailwind che resetta body { margin: 0 }.
   NB: questo file va linkato nell'<head> delle pagine (render-blocking),
   altrimenti il primo paint avviene prima che psb-navbar.js lo inietti. */
body { margin-left: var(--sidebar-w) !important; }

/* Colonna navy segnaposto disegnata in puro CSS al primo paint, PRIMA che
   psb-navbar.js (a fine body) inietti la sidebar vera: niente salto del
   contenuto ne' striscia bianca. La sidebar (z-index 1000) la copre. */
body::before {
  content: '';
  position: fixed;
  top: 0; left: 0; bottom: 0;
  width: var(--sidebar-w);
  background: var(--navy);
  z-index: 999;
}

/* Mobile: niente margine, sidebar off-canvas (aperta via .open) */
@media (max-width: 1024px) {
  body { margin-left: 0 !important; }
  body::before { display: none; }
  .psb-sidebar { transform: translateX(-100%); transition: transform .25s ease; }
  .psb-sidebar.open { transform: translateX(0); }
}

/* === SIDEBAR === */
.psb-sidebar {
  position: fixed !important;
  top: 0 !important;
  left: 0 !important;
  bottom: 0 !important;
  width: var(--sidebar-w) !important;
  background: var(--navy) !important;
  color: var(--white) !important;
  display: flex !important;
  flex-direction: column !important;
  z-index: 1000 !important;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: thin;
  scrollbar-color: var(--navy-light) transparent;
  font-family: -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  margin: 0;
  padding: 0;
}

.psb-sidebar * { box-sizing: border-box; }

.psb-sidebar::-webkit-scrollbar { width: 4px; }
.psb-sidebar::-webkit-scrollbar-thumb { background: var(--navy-light); border-radius: 2px; }

.psb-sidebar a { text-decoration: none; }

.psb-sidebar-header {
  padding: 20px 20px 14px;
  border-bottom: 1px solid var(--navy-light);
  flex-shrink: 0;
}

.psb-sidebar-header h2 {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0.5px;
  color: var(--white);
  margin: 0;
}

.psb-sidebar-header small {
  color: var(--gray-400);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.psb-sidebar-nav {
  list-style: none;
  padding: 8px 0;
  margin: 0;
  flex: 1;
}

.psb-sidebar-nav .nav-section {
  padding: 16px 20px 4px;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: var(--gray-500);
  font-weight: 600;
}

.psb-sidebar-nav .nav-section:first-child { padding-top: 8px; }

.psb-sidebar-nav li a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 20px;
  color: var(--gray-300);
  font-size: 13px;
  transition: all var(--transition);
  border-left: 3px solid transparent;
}

.psb-sidebar-nav li a:hover {
  background: var(--navy-light);
  color: var(--white);
}

.psb-sidebar-nav li a.active {
  background: var(--primary);
  color: var(--white);
  border-left-color: var(--white);
  font-weight: 500;
}

.psb-sidebar-nav li a .nav-icon {
  font-size: 15px;
  width: 20px;
  text-align: center;
  flex-shrink: 0;
}

.psb-sidebar-nav li a .nav-badge {
  margin-left: auto;
  background: rgba(255,255,255,0.15);
  padding: 1px 7px;
  border-radius: 10px;
  font-size: 10px;
  font-weight: 600;
}

.psb-sidebar-footer {
  padding: 12px 20px;
  border-top: 1px solid var(--navy-light);
  flex-shrink: 0;
}

.psb-sidebar-footer .user-info {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--gray-300);
  font-size: 12px;
}

.psb-sidebar-footer .user-avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--primary);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 13px; color: var(--white);
}

.psb-sidebar-footer .btn-logout {
  display: block;
  margin-top: 8px;
  padding: 6px 0;
  text-align: center;
  color: var(--gray-400);
  font-size: 12px;
  border: 1px solid var(--gray-600);
  border-radius: 4px;
  transition: all var(--transition);
  cursor: pointer;
  background: none;
  width: 100%;
  font-family: inherit;
}

.psb-sidebar-footer .btn-logout:hover {
  background: var(--danger);
  border-color: var(--danger);
  color: var(--white);
}

/* === MOBILE (audit 2026-06-12): sotto i 1024px la sidebar diventa
   off-canvas, aperta dal bottone hamburger iniettato da psb-navbar.js.
   Le regole desktop restano identiche sopra i 1025px. === */
.psb-burger {
  display: none;
  position: fixed;
  top: 10px;
  left: 10px;
  z-index: 1100;
  background: var(--navy);
  color: var(--white);
  border: 1px solid var(--navy-light);
  border-radius: 8px;
  width: 42px;
  height: 42px;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
}
.psb-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: 990;
}
.psb-overlay.show { display: block; }

@media (max-width: 1024px) {
  body { margin-left: 0 !important; }
  .psb-sidebar {
    transform: translateX(-100%);
    transition: transform 0.25s ease;
  }
  .psb-sidebar.open { transform: translateX(0); }
  .psb-burger { display: block; }
}
