/* ===================================================================
   GLOBAL RESET & BASE
   =================================================================== */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html, body {
  height: 100%;
  margin: 0;
  padding: 0;
}

/* Mantieni il background grigio sul body per evitare strisce bianche */
body {
  background-color: #eaeaea;
}

/* ===================================================================
   HEADER 
   =================================================================== */
header {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 60px;             /* regola a piacere */
  background: #fff;         /* o il tuo colore */
  z-index: 3000;
}

/* Sposta il contenuto sotto l’header */
.main-content {
  margin-top: 60px;         /* corrisponde all’altezza di header */
  min-height: calc(100vh - 60px);
}

/* ===================================================================
   SIDEBAR – STILI COMUNI
   =================================================================== */
.sidebar,
#sidebar {
  position: relative;
  z-index: 2000;
  min-height: 100vh;
  font-size: 1rem;
  color: #000;

  /* background immagine + overlay */
  background: #e5ecf7;
}
.sidebar::before,
#sidebar::before {
  content: "";
  position: absolute;
  inset: 0;
  background: #e5ecf7;
  pointer-events: none;
  z-index: 1;
  border-radius:24px;
}
.sidebar > *,
#sidebar > * {
  position: relative;
  z-index: 2;
}

.sidebar h3 {
  font-size: 1rem;
  margin: 1rem;
  color: #000;
}

.sidebar .nav-link {
  display: block;
  padding: 0.5rem 1rem;
  font-size: 1rem;
  color: #000 !important;
  transition: all 0.2s ease;
  border: 2px solid transparent;
  border-radius: 24px;
}
.sidebar .nav-link:hover,
.sidebar .nav-link:focus {
  font-weight: bold;
  border-color:#000;
  background: #e5ecf7;
}


/* ===================================================================
   MOBILE (≤767.98px) – DRAWER + OVERLAY + BUTTONS
   =================================================================== */
@media (max-width: 1024px) {
  /* Bottone hamburger (apri) */
  #menu-toggle {
    position: fixed;
    top: 1rem; left: 1rem;
    z-index: 2100;
    background: #445ea8;
    border: none;
    color: #fff;
    padding: 0.5rem;
    font-size: 1.5rem;
    border-radius: 0.25rem;
    cursor: pointer;
  }
	
	#sidebar:not(.open) {
        display: none;
    }
  

  /* Sidebar in drawer, nascosta di default */
  #sidebar {
    position: fixed;
    top: 0; left: 0;
    width: 80vw; max-width: 300px;
    height: 100vh;
    transform: translateX(-100%);
    transition: transform 0.3s ease;
    overflow-y: auto;
    overflow-x: hidden;
  }
  #sidebar.open {
    transform: translateX(0);
  }

  /* Bottone close (X) dentro la sidebar */
  #sidebar-close {
    position: absolute;
    top: 0.5rem; right: 0.5rem;
    z-index: 2200;
    background: rgba(0,0,0,0.6);
    border: none;
    color: #fff;
    font-size: 1.25rem;
    padding: 0.25rem 0.5rem;
    border-radius: 0.25rem;
    cursor: pointer;
    display: none;
  }
  #sidebar.open #sidebar-close {
    display: block;
  }

  /* Overlay dietro sidebar */
  #sidebar-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    z-index: 1500;
    display: none;
  }
  #sidebar-overlay.open {
    display: block;
  }

  /* Blocca scroll orizzontale pagina quando aperta */
  .no-scroll-x {
    overflow-x: hidden;
  }
}

/* ===================================================================
   DESKTOP (≥768px) – SIDEBAR FISSA
   =================================================================== */
@media (min-width: 1024px) {
  /* Sidebar fissata sotto header */
  #sidebar {
    position: fixed;
    top: 60px;    /* sotto l’header */
    left: 0;
    width: 250px; 
    height: calc(100vh - 60px);
    transform: none !important;
    overflow-y: auto;
    overflow-x: hidden;
  }

  /* Nascondi hamburger, close e overlay */
  #menu-toggle,
  #sidebar-close,
  #sidebar-overlay {
    display: none !important;
  }

  /* Sposta il contenuto accanto alla sidebar */
  .main-content {
    margin-left: 250px;
    margin-right: 0;
  }
}

@media (max-width: 1024px) {
  /* 1) Forza background pieno nella sidebar */
  #sidebar {
    background-color: #445ea8; /* fallback */
    background-image: url('../img/sidebar-bg.png');
    background-repeat: repeat;
    background-size: cover;
    background-position: center;
    height: 100vh;             /* forza full-height */
  }

  /* 2) Metti il burger menu sotto overlay e sidebar */
  #menu-toggle {
    z-index: 1400;  /* sotto overlay (1500) e sidebar (2000) */
  }
}


@media (max-width: 1024px) {
  #sidebar {
    /* 1) Fallback solido + griglia che si ripete */
    background-color: #445ea8 !important;
    background-image: url('../img/sidebar-bg.png') !important;
    background-repeat: repeat !important;
    background-position: center !important;

    /* 2) Non fissare il background alla viewport:
          così la griglia “scorre” insieme al sidebar e copre
          tutta la sua altezza, non solo quella visibile all’inizio */
    background-attachment: scroll !important;

    /* 3) Assicurati che l’altezza rimanga 100% del viewport */
    height: 100vh !important;
  }
}

/* Rimuovi qualsiasi margin-top da main-content */
.main-content {
  margin: 0 !important;
  padding: 1rem;              /* il tuo padding interno */
}

/* Applica il “sollevamento” sul body, una volta sola */
body {
      /* altezza dell’header */
  background-color: #eaeaea;
}

/* Assicurati che header sia assoluto/fisso sopra tutto */
header {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 60px;
  z-index: 3000;
}

/* Desktop: sposta solo il contenuto orizzontalmente, non verticalmente */
@media (min-width: 1024px) {
  .main-content {
    margin-left: 250px;       /* width della sidebar */
  }
}


@media (min-width: 1024px) {
  /* Forza la sidebar a 250px, ignorando .col-md-3 */
  #sidebar,
  .sidebar {
    width: 250px !important;
    flex: 0 0 250px !important; /* se usi flex */
  }
}

@media (max-width: 1024px) {
  /* Azzeriamo qualsiasi padding-body impostato in precedenza */
  body {
    padding-top: 0 !important;
  }

  /* La barra nera del burger sarà alta 44px (regola se il tuo è diverso) */
  :root {
    --mobile-header-height: 44px;
  }

  /* Sposta tutto il contenuto di .main-content su di --mobile-header-height */
  .main-content {
    margin-top: calc(var(--mobile-header-height)) !important;
    padding-top: 0.5rem; /* optional: un piccolo respiro interno */
  }

  /* Se stai usando direttamente la colonna content (col-md-9), applica lo stesso */
  .col-md-9.main-content {
    margin-top: calc(var(--mobile-header-height)) !important;
  }
}

:root {
  /* valori di default, in px */
  --mobile-header-portrait: 56px;
  --mobile-header-landscape: 48px;
}

/* Portrait */
@media (max-width: 1024px) and (orientation: portrait) {
  .main-content,
  .col-md-9.main-content {
    margin-top: var(--mobile-header-portrait) !important;
  }
}

/* Landscape */
@media (max-width: 1024px) and (orientation: landscape) {
  .main-content,
  .col-md-9.main-content {
    margin-top: var(--mobile-header-landscape) !important;
  }
}


