:root{
  --bg: #f5f7fb;
  --card-bg: rgba(255,255,255,.92);
  --radius: 16px;
  --shadow: 0 8px 28px rgba(0,0,0,.18);
  --left-ui: 16px;
  --top-ui: 16px;
  --footer-h: 70px;
  --hvt-azzurro: #2A62A6;
  --hvt-azzurro-soft: #62A0F1;
}

/* ========================= 
  Layout base 
  ========================= */
html, body { height:100%; margin:0; padding:0; background:var(--bg); }
#map { width:100%; height: 100%; }
/* contenitore che definisce l'area di mappa sopra il footer */
#mapShell{
  position: relative;
  height: calc(100vh - var(--footer-h));
  width: 100%;
}
/* Bottoni hvt custom */
.btn-hvt {
  --bs-btn-color: var(--hvt-azzurro);
  --bs-btn-border-color: var(--hvt-azzurro);
  --bs-btn-bg: #fff;
  --bs-btn-hover-color: #fff;
  --bs-btn-hover-bg: var(--hvt-azzurro);
  --bs-btn-hover-border-color: var(--hvt-azzurro);
  --bs-btn-focus-shadow-rgb: 42, 98, 166;
  --bs-btn-active-color: #fff;
  --bs-btn-active-bg: var(--hvt-azzurro);
  --bs-btn-active-border-color: var(--hvt-azzurro);
  --bs-btn-disabled-color: var(--hvt-azzurro);
  --bs-btn-disabled-border-color: var(--hvt-azzurro);
}

/* Z-index per overlay UI */
.top-left-ui, .top-right-logo, .style-switcher, .bottom-banner { z-index: 2; }

/* (logo HVT) */
.brand-pill{
  width: 50px; height: auto;
  background:#fff;
  border-radius: 999px;
  padding: .2rem .4rem;
  box-shadow: var(--shadow);
  line-height: 1;
  user-select: none;
}

/* =========================
  Hamburger circolare 
  ========================= */
.btn-circle{
  width:40px; height:40px; border-radius:50%;
  display:flex; align-items:center; justify-content:center;
}

.hamburger {
  width: 40px;
  height: 40px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: #fff;
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  justify-content: center;
}
.hamburger-box {
  width: 16px;
  height: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
}
/* linee più sottili e corte */
.hamburger-inner,
.hamburger-inner::before,
.hamburger-inner::after {
  background-color: #000;
  height: 2px;
  width: 16px;
  border-radius: 2px;
}
/* micro-centratura verticale */
.hamburger-inner::before {
  top: -5px;
}
.hamburger-inner::after {
  bottom: -5px;
}
/* --------- Posizionamenti --------- */
.top-left-ui{ top:var(--top-ui); left:var(--left-ui); }
.top-right-logo{ top:var(--top-ui); right:var(--left-ui); background:#ffffffc9; border-radius: 12px; padding:6px; }
.top-right-logo img{ width: 50px; height:auto; display:block; }
/* --------- Dropdown icone toolbar --------- */
.tools-toolbar .tool-btn{
  width:40px; height:40px; border-radius:50%; 
  display:inline-flex; align-items:center; justify-content:center;
  background: white; border:0; box-shadow: var(--shadow);
  color: var(--hvt-azzurro);
}
.tools-toolbar .tool-btn:hover{
  background: var(--hvt-azzurro-soft);
  color: white;
}
.tools-toolbar .dropdown-menu{
  border:0; padding:0; background:transparent;
}
.dropdown-card{
  width: 350px;
  max-height: 80vh;
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow-y: auto;
}
.dropdown-card .card-header{
  background: transparent;
  border-bottom: 1px solid rgba(0,0,0,.06);
}

/* =========================
  MENU LAYERS 
  ========================= */
  
/* Bottoncino freccia accordion nei Layers */
.layer-accordion-toggle {
  padding: 0.1rem 0.2rem;
  line-height: 1;
}
.layer-accordion-toggle i {
  font-size: 0.95rem;
}

/* accordion dei 3 macro gruppi: compatto un po' */
#layers-macro-accordion .accordion-button {
  padding: .5rem .75rem;
}
#layers-macro-accordion .accordion-body {
  padding: .5rem;
}

/* =========================
  Bottom Banner (About, Project, Guide) 
  ========================= */
/* si ancora al contenitore mappa (e non alla viewport) */
.bottom-banner{
  position: absolute;
  left: 50%;
  bottom: 2%;
  transform: translateX(-50%);
}
.bottom-footer-dropdown .bottom-popover-menu {
  border: 0;
  padding: 0;
  background: transparent;
  position: fixed; /* staccato dal bottone, ancorato alla viewport */
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(var(--footer-h) + 2% + 70px); /* altezza sopra ai bottoni */
  z-index: 2;
}

/* Rimuove la freccetta dei dropdown del footer */
.bottom-footer-dropdown .dropdown-toggle::after {
  display: none !important;
}
.bottom-footer-group {
  display: flex;
  gap: 10px;
}
/* Card stile popover */
.bottom-popover-card {
  position: relative;
  width: clamp(320px, 85vw, 80vw);
  height: auto;
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow-y: auto;
}
/* Header / body interni */
.bottom-popover-header {
  padding: 0.6rem 0.9rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgba(0,0,0,0.06);
  background-color: var(--hvt-azzurro);
  color: white;
}
.bottom-popover-body {
  padding: 0.9rem;
}
.bottom-popover-header .btn {
  color: white;
  border-color: #fff;
}
.bottom-popover-header .btn:hover {
  background-color: var(--hvt-azzurro-soft);
}

/* =========================
  FOOTER 
  ========================= */
footer {
  height: var(--footer-h);
  max-height: 100px;
  background-color: #2a65af;
  display: flex;
  align-items: center;
  justify-content: center;
}
footer img {
  max-height: 100%;
  max-width: 100%;
  height: auto;
  width: auto;
  display: block;
}

/* =========================
  Ritocchi controlli MapLibre 
  ========================= */
.maplibregl-ctrl-top-left {
  top: calc(40px + var(--top-ui)) !important;
  left: var(--left-ui) !important;
  display: flex;
  flex-direction: column;
}
.maplibregl-ctrl-group {
  box-shadow: var(--shadow);
  border-radius: 10px;
  padding: 1px;
  background: #fff;
}
/* Icone base */
.maplibregl-ctrl-group button {
  color: var(--hvt-azzurro-soft);
}
/* SVG icon */
.maplibregl-ctrl-icon {
  filter: brightness(0) saturate(100%)
          invert(32%) sepia(58%) saturate(703%)
          hue-rotate(181deg) brightness(92%) contrast(91%);
}
.maplibregl-ctrl-group button:hover {
  background-color: var(--hvt-azzurro);
}
.maplibregl-ctrl-zoom-area{
  background-image: url("/imgs/zoom-area.svg");
  background-repeat: no-repeat;
  background-position: center;
  background-size: 18px 18px;
}

/* ========================= 
  RIGHT DOCK SIDEBAR 
  ========================= */
/* RIGHT DOCK: centrata verticalmente nell'area (100vh - footer) */
.right-dock{
  position: fixed;
  right: 12px;
  /* centro dell'area utile (viewport - footer) */
  top: calc((100vh - var(--footer-h)) / 2);
  transform: translateY(-50%);
  width: 500px;
  max-width: min(500px, calc(100% - 24px));
  /* non deve mai andare sotto il footer */
  max-height: calc(100vh - var(--footer-h) - 24px);
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 2;
  pointer-events: auto;
  overflow: auto;
}
.section-sidebar-wrapper {
  width: 100%;
}
.section-panels-stack {
  display: flex;
  flex-direction: column;
  gap: 5px;
}
/* Card singola della sezione */
.section-panel {
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.95);
  overflow: hidden;
}
.right-dock--visible {
  background-color: #00000000;
}
.section-sidebar {
  height: 100%;
  border-radius: 16px;
  backdrop-filter: blur(6px);
}
.section-sidebar-body {
  overflow-y: auto;
  max-height: calc(100% - 52px);
}

/* =========================
   ICON BACKGROUNDS
   ========================= */

.section-panel-icon {
  color: #fff; /* icone sempre bianche */
}
/* variante principale */
.panel-icon-primary {
  background-color: var(--hvt-azzurro);
}
/* variante soft */
.panel-icon-soft {
  background-color: var(--hvt-azzurro-soft);
}

/* ========================= 
  PANELS 
========================= */
.section-panel-inner {
  display: flex;
}
.section-panel-icon {
  flex: 0 0 80px;
  max-width: 80px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
}
.section-panel-content {
  padding: 12px 14px;
  background: rgba(255, 255, 255, 0.96);
  border-radius: 0 16px 16px 0;
  flex: 1 1 0; /* permette al contenuto di crescere e SHRINKARE correttamente */
  min-width: 0; /* per evitare overflow orizzontale */
}
.section-panel-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
/* Variante a 3 colonne per il container popolazione */
.section-panel-grid-3 {
  grid-template-columns: auto auto 1fr; /* grafico, legenda, tabella */
  column-gap: 16px;
  align-items: flex-start;
}
/* Tabelle Bootstrap più compatte */
.section-table tbody tr td {
  padding: 2px 4px;
  font-size: 0.86rem;
}
.table-subtitle{
  color: #6c6c6c !important;
  font-weight: bold;
}
/* placeholder grafico a torta */
.section-chart-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
/* canvas del pie chart */
.population-pie-canvas {
  width: 80px;
  height: 80px;
}
/* Toolbar orizzontali */
.section-bar-row {
  font-size: 0.8rem;
}
.section-bar-track {
  width: 100%;
  height: 6px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.08);
  overflow: hidden;
}
.section-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #0d6efd, #0dcaf0);
  border-radius: 999px;
}

.logo-ithaca {
  height: 40px;
  width: auto;
  padding: 2px;
}
.layer-tooltip-icon {
  cursor: help;
  font-size: 0.95rem;
}

/* =========================
   ATTRIBUTE TABLE PANEL - fisso sopra al footer
   ========================= */

.attribute-table-panel{
  position: fixed;
  left: 0;
  right: 0;
  bottom: var(--footer-h);
  padding: 12px 14px;
  z-index: 2500; /* sopra map + banner + dock */
  pointer-events: none; /* il wrapper non blocca click */
}
/* card contenuto cliccabile */
.attribute-table-card{
  pointer-events: auto;
  margin: 0 auto;
  width: min(85vw, calc(100vw - 20vw));
  max-height: min(65vh, calc(100vh - var(--footer-h) - 28px));
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  border: 1px solid grey;
}
.attribute-table-header{
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 5px;
  padding: 8px 8px;
  background: var(--hvt-azzurro);
  color: white;
}
.attribute-table-body{
  padding: 10px;
  overflow: auto;
  font-size: 0.85rem;
}
/* evita che DataTables "sbordi" orizzontalmente */
.attribute-table-body .dt-container{
  width: 100%;
}
.attribute-table-body .dt-scroll-body{
  border: 1px solid rgba(0,0,0,.08);
}
/* Bottone CSV */
.attribute-table-body .dt-buttons .btn,
.attribute-table-body .dt-buttons .btn.btn-secondary,
.attribute-table-body .dt-buttons .btn.btn-outline-secondary{
  background: var(--hvt-azzurro) !important;
  border-color: var(--hvt-azzurro) !important;
  color: #fff !important;
}
.attribute-table-body .dt-buttons .btn:hover{
  filter: brightness(1.35);
}
/* Titoli colonne: più piccoli e centrati */
#attributeTable thead th{
  text-align: center !important;
  vertical-align: middle !important;
  white-space: nowrap; /* non permette titoli colonne su più righe */
}
/* Valori celle: centrati */
#attributeTable tbody td{
  text-align: center !important;
  vertical-align: middle !important;
}
/* Colonna Zoom: stretta */
#attributeTable thead th.col-zoom,
#attributeTable tbody td.col-zoom{
  width: 44px !important;
  min-width: 44px !important;
  max-width: 44px !important;
  padding-left: 6px !important;
  padding-right: 6px !important;
}
/* Numero pagina attiva */
.attribute-table-body .dt-paging .pagination .page-item.active .page-link{
  background-color: var(--hvt-azzurro) !important;
  border-color: var(--hvt-azzurro) !important;
  color: #fff !important;
}
/* hover sulle pagine non attive */
.attribute-table-body .dt-paging .pagination .page-link:hover{
  border-color: var(--hvt-azzurro-soft) !important;
}
/* Minimize */
.attribute-table-panel.is-minimized .attribute-table-card{
  width: min(25vw, calc(100vw - 80vw));
  max-height: 10vh;         /* altezza header circa */
  border-radius: 999px;     /* effetto pill */
}
.attribute-table-panel.is-minimized .attribute-table-card .fw-semibold{
  margin-left: 5px;
  font-size: 0.8rem;
}
.attribute-table-panel.is-minimized .attribute-table-card .btn{
  scale: 0.8;
}
.attribute-table-panel.is-minimized .attribute-table-body{
  display: none;            /* nasconde DataTables */
}
/* header più compatto in modalità minimized */
.attribute-table-panel.is-minimized .attribute-table-header{
  padding: 6px 10px;
}
.attribute-table-panel.is-minimized .attribute-table-card{
  margin-left: 5vw;
  margin-right: auto;
}

/*  ========================= Bottoni header tab attributi: X / gomma / minimize ========================= */
.attribute-table-header #btnClearZoomHighlight,
.attribute-table-header #btnCloseAttributeTable,
.attribute-table-header #btnMinimizeAttributeTable,
#btn-alert-modal {
  border-color: #fff !important;
  color: #fff !important;                 /* le bi-* ereditano questo */
  background-color: var(--hvt-azzurro) !important;
}
/* hover/focus coerente */
.attribute-table-header #btnClearZoomHighlight:hover,
.attribute-table-header #btnCloseAttributeTable:hover,
.attribute-table-header #btnMinimizeAttributeTable:hover,
.attribute-table-header #btnClearZoomHighlight:focus,
.attribute-table-header #btnCloseAttributeTable:focus,
.attribute-table-header #btnMinimizeAttributeTable:focus,
#btn-alert-modal:hover, #btn-alert-modal:focus {
  border-color: #fff !important;
  background-color: var(--hvt-azzurro-soft) !important;
  color: #fff !important;
}
/* stato active */
.attribute-table-header #btnClearZoomHighlight:active,
.attribute-table-header #btnCloseAttributeTable:active,
.attribute-table-header #btnMinimizeAttributeTable:active{
  background-color: var(--hvt-azzurro-soft) !important;
  color: #fff !important;
}

/*  ====================
    Modal alert
/*  ====================  */
#appAlertModal {
  z-index: 3000; /* sopra tutto */
}

/*  ====================  Responsività ====================  */
@media (max-width: 1200px) {
  .bottom-banner{
    bottom: 1%;
  }
  .right-dock{
      max-height: 70vh;
      width: 50vw;
  }
}
@media (max-width: 912px){
  .top-right-logo img{ width:20px; }
  .bottom-banner{ min-width: unset; }
  .attribute-table-panel{
    padding: 10px;
  }
  .attribute-table-panel.is-minimized .attribute-table-card{
    width: clamp(150px, calc(100vw - 80vw));
  }
  .is-minimized .attribute-table-header{
    justify-content: center;
  }
  .attribute-table-panel.is-minimized .attribute-table-header .fw-semibold{
    display: none;
  }
  .bottom-banner{
    bottom: 1%;
  }
  .right-dock{
      max-height: 70vh;
      width: 50vw;
  }
}

/* --------- Su schermi più larghi --------- */
@media (width > 1900px) {
  :root {
    --footer-h: 100px;
  }
  .bottom-banner{
    bottom: 1%;
  }
}
