:root{
  /* Tema chiaro con toni del verde */
  --bg: #f6faf7;
  --panel: #ffffff;
  --panel-2: #f3f8f4;
  --text: #1f2937;
  --muted: #6b7280;
  --brand: #2e7d32;       /* verde principale */
  --brand-soft: #66bb6a;  /* verde soft */
  --accent: #a3d9a5;      /* accento tenue */
  --chip: #ffffff;
  --chip-hover: #f0f6f1;
  --border: #dfe7e1;
  --btn: #3aa76d;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial;
  color: var(--text);
  background: linear-gradient(180deg, var(--bg) 0%, #eef6f0 100%);
}

.app-header {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  background: rgba(255,255,255,0.9);
  backdrop-filter: blur(6px);
  position: sticky;
  top: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.brand-wrap { display:flex; align-items:center; gap:12px; }
.app-logo { width: 28px; height: 28px; border-radius: 8px; object-fit: cover; box-shadow: 0 2px 6px rgba(0,0,0,0.15); }
.app-header h1 { margin: 0; font-size: 20px; letter-spacing: 0.3px; color: var(--brand); }
.subtitle { color: var(--muted); font-size: 14px; }

.app-main {
  display: grid;
  grid-template-columns: 330px 1fr;
  gap: 0;
  height: calc(100vh - 58px);
}

.sidebar {
  background: var(--panel);
  border-right: 1px solid var(--border);
  overflow: auto;
}

.panel { padding: 16px; }

h2 {
  margin: 0 0 12px 0;
  font-size: 16px;
  font-weight: 700;
  color: var(--brand);
}

.filter-group { margin: 14px 0 16px; }
.group-title {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.chips { display: flex; flex-wrap: wrap; gap: 8px; }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--chip);
  border: 1px solid var(--border);
  padding: 8px 10px;
  border-radius: 999px;
  cursor: pointer;
  user-select: none;
  transition: background 120ms ease, border-color 120ms ease, transform 60ms ease, box-shadow 120ms ease;
  box-shadow: 0 1px 0 rgba(0,0,0,0.02);
}
.chip:hover { background: var(--chip-hover); }
.chip:active { transform: translateY(1px); }
.chip input[type="checkbox"] { display: none; }
.chip img { height: 18px; width: 18px; border-radius: 999px; object-fit: cover; box-shadow: 0 1px 2px rgba(0,0,0,0.06); }
.chip span { font-size: 13px; }

/* chip attivo */
.chip:has(input:checked) {
  border-color: var(--brand-soft);
  background: #f2fbf4;
  box-shadow: 0 0 0 3px rgba(46,125,50,0.10);
}
.chip input[type="checkbox"]:not(:checked) + img,
.chip input[type="checkbox"]:not(:checked) ~ span {
  filter: grayscale(0.35) opacity(0.75);
}

.filter-actions {
  display: flex; gap: 8px; flex-wrap: wrap;
  margin: 12px 0 6px;
}
.btn {
  background: var(--btn);
  border: 1px solid transparent;
  color: white;
  padding: 8px 12px;
  border-radius: 10px;
  cursor: pointer;
  font-size: 13px;
  box-shadow: 0 1px 0 rgba(0,0,0,0.03);
}
.btn-secondary {
  background: var(--panel-2);
  border-color: var(--border);
  color: var(--text);
}
.btn-outline {
  background: transparent;
  border-color: var(--border);
  color: var(--text);
}

#map { height: 100%; width: 100%; }

/* --- Tabelle popup --- */
.leaflet-container a { color: #2e7d32; }
.table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.table tr + tr { border-top: 1px dashed var(--border); }
.table td { padding: 6px 0; vertical-align: top; }
.table td.key { color: var(--muted); width: 38%; }
.table td.val { width: 62%; }
.badge {
  display:inline-block; padding:2px 6px; border-radius: 6px; font-size: 11px;
  background: #eaf7ec; border: 1px solid #cfe8d4; color: #25743f;
}

/* ===== Marker rotondi (no <img>, con badge numerico) ===== */
.pin2{
  width: 36px; height: 36px;
  border-radius: 999px;
  position: relative;
  /* was: overflow: hidden; → allow badge to overflow slightly */
  overflow: visible;
  border: 1px solid #00000014;
  box-shadow: 0 6px 12px rgba(0,0,0,0.16);
  background: #ffffff;
  -webkit-user-select: none; user-select: none;
}
.pin2::before{
  content:""; position:absolute; inset:0;
  background: radial-gradient(ellipse at 30% 30%, #f1f8f3 0%, #e6f3ea 55%, #d7e9dd 100%);
}
.pin2-vitis::before{
  background: radial-gradient(ellipse at 30% 30%, #e8f8ef 0%, #cfeedd 55%, #b6e0c6 100%);
}
.pin2-olea::before{
  background: radial-gradient(ellipse at 30% 30%, #f3f9ea 0%, #e1f0cc 55%, #cbe2a8 100%);
}
.pin2::after{
  content:""; position:absolute; inset: 5px; border-radius: 999px;
  background-image: var(--pin-bg);
  background-repeat: no-repeat; background-position: center; background-size: 80% 80%;
  background-color: #f5fbf6;  box-shadow: inset 0 0 0 1px #0000000f;
}
.cluster-badge{
  position:absolute;
  top:-8px;               /* pull slightly outside the circle */
  right:-8px;
  background:#2e7d32;
  color:#fff;
  border-radius:999px;
  font-weight:700;
  font-size:12px;
  line-height:20px;
  min-width:20px; height:20px;
  text-align:center;
  padding:0 6px;
  border:2px solid #ffffff;        /* white ring improves contrast */
  box-shadow: 0 2px 6px rgba(0,0,0,0.25);
  z-index: 2;
  text-shadow: 0 1px 0 rgba(0,0,0,0.25);
}
.pin2-olea .cluster-badge { background:#4f7d2f; }

/* --- multi-species collision marker (split icon) --- */
.pin2-multi { position: relative; }
.pin2-multi::after { display: none; } /* hide the single-image layer */

.pin2-multi .half{
  position:absolute;
  top:5px; bottom:5px;
  width: calc(50% - 1px);
  border-radius: 999px;
  background-repeat:no-repeat;
  background-position:center;
  background-size:80% 80%;
  background-color:#f5fbf6;
  box-shadow: inset 0 0 0 1px #0000000f;
}
.pin2-multi .half.left  { left:5px;  background-image: var(--pin-bg1); }
.pin2-multi .half.right { right:5px; background-image: var(--pin-bg2); }

/* keep the readable number badge (from previous fix) */
.pin2{ overflow: visible; }


/* ===================== TIMEBAR (stile “originale”) ===================== */
/* record_necropoli/css/timebar_detail.css adattata al tema verde */

#timebar-detail{
  position: fixed;
  z-index: 1000;
  background: rgba(255,255,255,0.96);
  border: 1px solid #d1d5db;
  border-radius: 12px;
  padding: 10px 12px 12px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.12);
  max-width: 1100px;
}

/* layout */
#timebar-detail .tb-controls{
  display:flex; align-items:center; justify-content:space-between;
  gap: 10px; margin-bottom: 6px;
}
#timebar-detail .tb-labels{
  display:flex; gap:8px; align-items:center; flex-wrap:wrap;
}
#timebar-detail .chip{
  display:inline-flex; gap:6px; align-items:center;
  background:#f3f4f6; border:1px solid #e5e7eb; color:#111827;
  padding:4px 8px; border-radius:999px; font-size:12px; line-height:1;
}
#timebar-detail .chip .dot{
  width:8px; height:8px; border-radius:50%; background:#22c55e;
}
#timebar-detail .tb-switch{ display:flex; gap:8px; align-items:center; }
#timebar-detail .tb-switch input{ accent-color:#22c55e; }
#timebar-detail .tb-switch-label{ font-size:12px; color:#374151; }

#timebar-detail .tb-canvas-wrap{
  width:100%; height:120px;
}

#timebar-detail .tb-sliders{
  position:relative; margin-top:6px;
}
#timebar-detail .tb-sliders input[type="range"]{
  -webkit-appearance:none; appearance:none;
  width:100%; height:18px; background:transparent; position:absolute; left:0; right:0;
}
#timebar-detail .tb-sliders input[type="range"]::-webkit-slider-thumb{
  -webkit-appearance:none; appearance:none;
  width:14px; height:14px; border-radius:50%;
  background:#2e7d32; border:2px solid white; box-shadow:0 0 0 2px rgba(46,125,50,.25);
  cursor:pointer; position:relative; z-index:2;
}
#timebar-detail .tb-sliders input[type="range"]::-moz-range-thumb{
  width:14px; height:14px; border-radius:50%;
  background:#2e7d32; border:2px solid white; box-shadow:0 0 0 2px rgba(46,125,50,.25);
  cursor:pointer; position:relative; z-index:2;
}

/* aiuto */
#timebar-detail .tb-help{
  position:absolute; top:8px; right:8px;
  border:none; background:#111827; color:white; border-radius:8px;
  width:24px; height:24px; line-height:24px; font-weight:700; cursor:pointer;
  opacity:.75;
}
#timebar-detail .tb-help:hover{ opacity:1; }

/* Ombra dell’intervallo (fallback) */
#timebar-detail{
  --tb-from: 0; --tb-to: 0; --tb-count: 14;
  background-image:
    linear-gradient( to right,
      transparent calc((var(--tb-from) / var(--tb-count)) * 100%),
      rgba(34,197,94,0.06) calc((var(--tb-from) / var(--tb-count)) * 100%),
      rgba(34,197,94,0.06) calc(((var(--tb-to)+1) / var(--tb-count)) * 100%),
      transparent calc(((var(--tb-to)+1) / var(--tb-count)) * 100%)
    );
  background-size: 100% 100%;
  background-repeat: no-repeat;
}

/* Posizionamento responsive: a bordo mappa, ma pieno schermo su mobile */
@media (max-width: 900px){
  #timebar-detail{ left: 12px !important; right: 12px !important; }
}
