/* =========
   Variabili / tema
   ========= */
:root {
  --bg-page: #f5f5f7;
  --bg-card: #ffffff;
  --bg-header: #0a1535;
  --bg-sidebar: #ffffff;

  --text-main: #1a1a1a;
  --text-header-main: #fff;

  --border-soft: #ddd;
  --border-sidebar: #e0e0e0;

  --shadow-card: 0 16px 40px rgba(0,0,0,0.06);

  --font-body: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;

  /* LARGHEZZA SIDEBAR: cambiala qui */
  --sidebar-width: 500px;

  --line-height: 1.6;
  --font-size-base: 1rem;
}

/* su tablet / piccolo */
@media (max-width: 1000px) {
  :root {
    --sidebar-width: 500px; /* tienila uguale */
  }
}
@media (max-width: 600px) {
  :root {
    --sidebar-width: 0px; /* la nascondiamo su mobile */
  }
}

/* =========
   Reset base
   ========= */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

img,
svg,
canvas {
  max-width: 100%;
  height: auto;
  display: block;
}

html, body {
  height: 100%;
  width: 100%;
  margin: 0;
  padding: 0;
}

/* =========
   Body
   ========= */
body {
  height: 100vh;
  overflow: hidden; /* BLOCCO TOTALE dello scroll della pagina intera */
  display: flex;
  flex-direction: column; /* Impila Header e Main verticalmente */
  background: var(--bg-page);
  color: var(--text-main);
  font-family: var(--font-body);
  line-height: var(--line-height);
  font-size: var(--font-size-base);
}

/* =========
   Header
   ========= */
.site-header {
  height: 80px; /* Altezza esplicita */
  background: var(--bg-header);
  color: var(--text-header-main);
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.25rem 1.5rem;
  border-bottom: 1px solid rgba(255,255,255,0.1);
  box-shadow: 0 4px 15px rgba(0,0,0,0.4);
  position: relative;
  top: 0;
  z-index: 1000;
  margin: 0px;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.header-right {
  display: flex;
  align-items: flex-end;   /* allineato in basso */
}

.ai-note {
  font-size: 0.8rem;
  opacity: 0.7;            /* un po' discreto */
}

.site-logo {
  height: 64px;
  width: auto;
  display: block;
  filter: drop-shadow(0 0 3px rgba(255,255,255,0.2));
  object-fit: contain;
}

.site-title {
  font-size: 1.8rem;
  font-weight: 600;
  color: #ffffff;
  letter-spacing: 0.5px;
  font-family: "Segoe UI", Roboto, Helvetica, sans-serif;
}

/* =========
   Footer
   ========= */
.site-footer {
  left: 0;
  right: 0;
  bottom: 0;
  height: 60px;
  background: #fff;
  border-top: 1px solid var(--border-soft);
  box-shadow: 0 -8px 20px rgba(0,0,0,0.06);
  text-align: center;
  font-size: 0.8rem;
  color: #777;
  padding: 0.75rem 1rem;
  z-index: 1001;
}

/* =========
   Layout principale
   ========= */

.layout {
  display: grid; 
  flex: 1;
  grid-template-columns: var(--sidebar-width) 1fr;
  /*flex-grow: 1; /* Occupa tutto lo spazio rimanente sotto l'header */
  /* Utilizziamo dvh (dynamic viewport height) per precisione */
  /*height: calc(100vh - 80px);*/ 
  overflow-y: hidden; /* Impedisce al 'main' intero di scrollare */
  padding-bottom: 0; /* Rimuoviamo il padding se lo scroll è interno */
}


/* =========
   Sidebar generica (non articolo!)
   ========= */
.sidebar {
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border-sidebar);
  padding: 1rem;
  /* Fondamentale: lo scroll deve essere gestito qui */
  overflow-y: auto;
  height: 100%; 
  position: relative; /* Non serve più sticky se il padre è bloccato */
  top: 0;
}

@media (max-width: 600px) {
  .sidebar {
    display: none;
  }
}

/* se usi il menu ad albero che abbiamo messo in index.php */
.sidebar nav ul {
  list-style: none;
  padding-left: 0;
}
.sidebar a {
  text-decoration: none;
  color: #333;
}
.sidebar a:hover {
  color: #0a1535;
}

/* controlli menu (cerca, espandi, chiudi) */
.menu-search {
  width: 100%;
  margin-bottom: .5rem;
}
.menu-search input {
  width: 100%;
  padding: .4rem .55rem;
  border: 1px solid #ccc;
  border-radius: 4px;
  font-size: .8rem;
}
.menu-controls {
  display: flex;
  gap: .25rem;
  margin-bottom: .5rem;
}
.menu-controls button {
  background: #1a88c9;
  color: white;
  border: none;
  padding: .3rem .7rem;
  border-radius: 4px;
  cursor: pointer;
  font-size: .75rem;
  white-space: nowrap;
}
.menu-controls button:hover {
  background: #136a9f;
}

/* toggles cartelle */
.toggle {
  display: inline-block;
  width: 16px;
  text-align: center;
  cursor: pointer;
  font-weight: bold;
  color: #1a88c9;
  user-select: none;
}
.submenu {
  display: none;
  margin-left: 1rem;
  border-left: 1px dashed #ccc;
  padding-left: .5rem;
}
.submenu.open {
  display: block;
}
.folder.active-folder > .folder-name {
  color: #1a88c9;
  text-shadow: 0 0 4px rgba(26,136,201,0.3);
}
.hidden-by-search {
  display: none !important;
}
