/* ================================================================
   Mappa LoRa Meshtastic — tema allineato a ilbarone.net
   Layout in container fisso (max 1320px) come il resto del sito.
   ================================================================ */

:root {
    --bg:     #0d1117;
    --bg2:    #161b22;
    --bg3:    #1e2430;
    --accent: #10ffb4;
    --blue:   #3b82f6;
    --red:    #ef4444;
    --orange: #f59e0b;
    --green:  #22c55e;
    --purple: #a855f7;
    --pin:    #ec4899;     /* magenta per i marker — contrasta col verde della mappa */
    --text:   #e6edf3;
    --muted:  #8b949e;
    --border: rgba(255,255,255,.08);
    --r:      12px;
    --max-w:  1320px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
    font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background-color: var(--bg);
    color: var(--text);
    font-size: 14px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    /* Spazio per la nav fissa */
    padding-top: 56px;
}

/* ================================================================
   ILBARONE.NET TOP NAV — replica del sito principale
   ================================================================ */
.ilb-nav {
    position: fixed; top: 0; left: 0; right: 0;
    height: 56px;
    background: rgba(13, 17, 23, .92);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
    z-index: 2000;
}
.ilb-nav-inner {
    height: 100%;
    max-width: var(--max-w); margin: 0 auto;
    padding: 0 18px;
    display: flex; align-items: center; gap: 24px;
}
.ilb-brand {
    display: flex; align-items: center; gap: 10px;
    color: var(--text);
    text-decoration: none;
    font-size: 16px;
    font-weight: 700;
    letter-spacing: -0.02em;
}
.ilb-brand:hover { color: #fff; }
.ilb-logo-wrap {
    width: 36px; height: 36px;
    border-radius: 50%;
    overflow: hidden;
    background: #0d1117;
    box-shadow: 0 2px 8px rgba(0,0,0,.4), 0 0 0 2px rgba(16,255,180,.25);
    display: inline-flex; align-items: center; justify-content: center;
}
.ilb-logo-wrap img { width: 100%; height: 100%; object-fit: cover; display: block; }
.ilb-brand-text {
    background: linear-gradient(135deg, var(--accent) 0%, var(--blue) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}
.ilb-breadcrumb {
    display: flex; align-items: center; gap: 8px;
    flex: 1;
    font-size: 13px;
    color: var(--muted);
}
.ilb-breadcrumb a { color: var(--muted); text-decoration: none; transition: color .2s; }
.ilb-breadcrumb a:hover { color: var(--accent); }
.ilb-breadcrumb .sep { font-size: 10px; opacity: .5; }
.ilb-breadcrumb .current {
    color: var(--text);
    font-weight: 600;
}
.ilb-back-btn {
    display: inline-flex; align-items: center; gap: 8px;
    padding: 7px 14px;
    background: rgba(16, 255, 180, .08);
    border: 1px solid rgba(16, 255, 180, .25);
    color: var(--accent);
    border-radius: 8px;
    text-decoration: none;
    font-size: 13px;
    font-weight: 500;
    transition: all .2s;
}
.ilb-back-btn:hover { background: rgba(16,255,180,.15); transform: translateX(-2px); }
@media (max-width: 700px) {
    .ilb-breadcrumb { display: none; }
    .ilb-back-btn span { display: none; }
}

/* ================================================================
   PAGE WRAP — container centrato come Bootstrap .container
   ================================================================ */
.page-wrap {
    max-width: var(--max-w);
    margin: 0 auto;
    padding: 18px 18px 24px;
}

/* ================================================================
   TOPBAR DELLA MAPPA (nel container)
   ================================================================ */
.topbar {
    background: linear-gradient(180deg, var(--bg2) 0%, var(--bg3) 100%);
    border: 1px solid var(--border);
    border-radius: var(--r) var(--r) 0 0;
    display: flex;
    align-items: center;
    padding: 14px 20px;
    gap: 24px;
    flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 14px; }
.brand .logo {
    width: 42px; height: 42px;
    border-radius: 10px;
    background: linear-gradient(135deg, rgba(16,255,180,.15), rgba(59,130,246,.12));
    border: 1px solid rgba(16,255,180,.25);
    display: inline-flex; align-items: center; justify-content: center;
    color: var(--accent);
    font-size: 18px;
    flex-shrink: 0;
}
.brand .title { font-size: 16px; font-weight: 700; letter-spacing: -.01em; }
.brand .sub   { font-size: 11px; color: var(--muted); letter-spacing: .4px; text-transform: uppercase; }

.controls { margin-left: auto; display: flex; gap: 14px; align-items: center; flex-wrap: wrap; }
.controls label {
    font-size: 12px; color: var(--muted);
    display: flex; align-items: center; gap: 6px;
    text-transform: uppercase; letter-spacing: .4px;
    font-weight: 600;
}
.controls select {
    background: var(--bg); color: var(--text);
    border: 1px solid var(--border);
    padding: 6px 10px; border-radius: 6px;
    font-size: 13px;
    font-family: inherit;
    cursor: pointer;
}
.controls select:hover, .controls select:focus {
    border-color: rgba(16,255,180,.4);
    outline: none;
}
.controls button {
    background: linear-gradient(135deg, var(--accent), #0bd896);
    color: #06291e;
    border: 0;
    padding: 8px 16px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 700;
    font-family: inherit;
    transition: transform .15s, box-shadow .2s;
}
.controls button:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(16,255,180,.3);
}
.controls button i { margin-right: 4px; }

/* ================================================================
   STATS BAR
   ================================================================ */
.stats {
    background: var(--bg);
    border-left: 1px solid var(--border);
    border-right: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
    display: flex; align-items: center;
    padding: 8px 20px; gap: 24px;
    font-size: 12px; color: var(--muted);
    flex-wrap: wrap;
}
.stats b { color: var(--text); font-size: 13px; font-weight: 700; }
.muted { color: var(--muted); }

/* ================================================================
   MAP AREA — relativa, dentro al container, con altezza fissa
   ================================================================ */
.map-area {
    position: relative;
    width: 100%;
    height: calc(100vh - 250px);
    min-height: 480px;
    border-left: 1px solid var(--border);
    border-right: 1px solid var(--border);
    overflow: hidden;
}
#map {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: var(--bg);
}
.leaflet-container { background: var(--bg); }

/* ================================================================
   SIDEBAR — overlay sopra la mappa, dentro la map-area
   ================================================================ */
aside#sidebar {
    position: absolute;
    top: 0; right: 0; bottom: 0;
    width: 360px;
    background: var(--bg2);
    border-left: 1px solid var(--border);
    color: var(--text);
    padding: 20px 22px;
    overflow-y: auto;
    z-index: 1000;
    box-shadow: -4px 0 20px rgba(0,0,0,.4);
}
aside.hidden { display: none; }
aside #closeside {
    position: absolute; top: 10px; right: 12px;
    background: transparent; color: var(--muted);
    border: 0; font-size: 24px; cursor: pointer; line-height: 1;
}
aside #closeside:hover { color: var(--text); }
aside h2 {
    margin: 0 0 6px 0; font-size: 17px; color: var(--text);
    font-weight: 700;
}
aside .subtitle { color: var(--muted); font-size: 12px; margin-bottom: 16px; }
aside dl { display: grid; grid-template-columns: max-content 1fr; gap: 7px 16px; font-size: 13px; margin: 0; }
aside dt { color: var(--muted); font-weight: 500; }
aside dd { margin: 0; color: var(--text); }
aside .badge {
    display: inline-block; padding: 2px 9px; border-radius: 10px;
    background: rgba(59,130,246,.2); color: var(--blue);
    font-size: 11px; font-weight: 600;
}
aside .pill-ok    { background: rgba(34,197,94,.2);  color: var(--green);  }
aside .pill-stale { background: rgba(245,158,11,.2); color: var(--orange); }

/* ================================================================
   FOOTER
   ================================================================ */
.bottom-strip {
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: 0 0 var(--r) var(--r);
    padding: 10px 20px;
    display: flex; justify-content: space-between; align-items: center;
    font-size: 11px; color: var(--muted);
    flex-wrap: wrap;
    gap: 8px;
}
.bottom-strip i { margin-right: 4px; opacity: .6; }
.ilb-link {
    color: var(--accent);
    text-decoration: none;
    font-weight: 600;
}
.ilb-link:hover { color: #fff; text-decoration: underline; }

/* ================================================================
   MARKER CUSTOM
   ================================================================ */
.node-icon {
    width: 14px; height: 14px; border-radius: 50%;
    border: 2px solid #1a1a1a;
    box-shadow: 0 0 0 1px rgba(255,255,255,0.5), 0 1px 4px rgba(0,0,0,0.6);
}
.node-icon.recent { background: #fff; }                                          /* bianco con bordo nero: neutro, leggibile su qualsiasi sfondo */
.node-icon.stale  { background: var(--orange); border-color: #4a2e00; }
.node-icon.old    { background: var(--muted);  border-color: #2a2f3a; }
.node-icon.local  { background: #1e3a8a; border-color: #fff; box-shadow: 0 0 0 1px rgba(0,0,0,0.6), 0 0 12px rgba(30, 58, 138, 1); } /* blu scuro */

.leaflet-popup-content-wrapper { background: var(--bg2); color: var(--text); border-radius: 8px; }
.leaflet-popup-tip { background: var(--bg2); }
.leaflet-popup-content { font-size: 13px; min-width: 180px; }
.leaflet-popup-content b { color: var(--accent); }
.leaflet-popup-close-button { color: var(--muted) !important; }

/* MarkerCluster look adattato al tema scuro — magenta/blu/viola, niente verde */
.marker-cluster-small  { background-color: rgba(236, 72, 153, .25); }
.marker-cluster-small div  { background-color: rgba(236, 72, 153, .65); color: #fff; font-weight: 700; }
.marker-cluster-medium { background-color: rgba(59, 130, 246, .25); }
.marker-cluster-medium div { background-color: rgba(59, 130, 246, .65); color: #fff; font-weight: 700; }
.marker-cluster-large  { background-color: rgba(168, 85, 247, .25); }
.marker-cluster-large div  { background-color: rgba(168, 85, 247, .65); color: #fff; font-weight: 700; }

/* ================================================================
   RESPONSIVE
   ================================================================ */
@media (max-width: 800px) {
    .topbar { flex-direction: column; align-items: stretch; gap: 12px; }
    .controls { margin-left: 0; }
    aside#sidebar { width: 100%; }
    .map-area { height: 65vh; }
}
