/* Layout shared with the main map app (../map/css/styles.css): a full-viewport map with floating glass panels.
   Panel, pill-button, breadcrumb, profile and overview styles follow that file so the two apps look alike. */
:root {
    --panel-bg: rgba(255, 255, 255, 0.92);
    --panel-border: rgba(0, 0, 0, 0.1);
    --accent: #0f766e;
    --text: #111318;
    --text-dim: #5b6270;
    --warn: #b45309;
    --err: #b00020;
    --overlay-weak: rgba(0, 0, 0, 0.05);
    --overlay-strong: rgba(0, 0, 0, 0.08);
    --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Noto Sans Devanagari", "Kohinoor Devanagari", Helvetica, Arial, sans-serif;
}

html, body { margin: 0; padding: 0; overflow: hidden; }
* { box-sizing: border-box; }
[hidden] { display: none !important; }

#map { height: 100vh; width: 100vw; margin: 0; padding: 0; background: #e9eef1; font-family: var(--font); }

.panel {
    background: var(--panel-bg);
    border: 1px solid var(--panel-border);
    border-radius: 10px;
    backdrop-filter: blur(6px);
    box-shadow: 0 4px 18px rgba(0, 0, 0, 0.35);
    color: var(--text);
    font-family: var(--font);
}
.panel h3 { margin: 0 0 8px; font-size: 12px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-dim); }
.panel hr { border: none; border-top: 1px solid var(--panel-border); margin: 10px 0; }

.floating { position: absolute; z-index: 1000; }
#controls { top: 20px; right: 20px; padding: 6px; display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; max-width: calc(100vw - 340px); }
.pill-btn {
    background: var(--panel-bg);
    border: 1px solid var(--panel-border);
    color: var(--text);
    border-radius: 999px;
    padding: 8px 14px;
    font-size: 12.5px;
    cursor: pointer;
    backdrop-filter: blur(6px);
    font-family: var(--font);
}
.pill-btn:hover { border-color: var(--accent); }
.pill-btn.on { border-color: var(--accent); color: var(--accent); font-weight: 600; }

/* Left column: breadcrumb / profile / overview (the Leaflet zoom control sits bottom-left, below it) */
#left-column {
    position: absolute; top: 20px; left: 20px; width: 290px; max-height: calc(100vh - 110px);
    overflow-y: auto; display: flex; flex-direction: column; gap: 12px; z-index: 1000;
}
#breadcrumb { padding: 8px 12px; font-size: 13px; flex: none; line-height: 1.7; }
#breadcrumb .crumb { cursor: pointer; color: var(--accent); }
#breadcrumb .crumb:hover { text-decoration: underline; }
#breadcrumb .sep { color: var(--text-dim); margin: 0 6px; }
#breadcrumb .crumb.current { color: var(--text); cursor: default; text-decoration: none; font-weight: 600; }

#profile { padding: 12px 14px; font-size: 12.5px; flex: none; }
#profile h2 { margin: 0 0 4px; font-size: 16px; display: flex; align-items: baseline; gap: 6px; flex-wrap: wrap; }
#profile .tag { font-size: 10px; font-weight: 400; color: var(--text-dim); border: 1px solid var(--panel-border); border-radius: 4px; padding: 1px 5px; }
#profile .sub { color: var(--text-dim); margin-bottom: 6px; }
#profile .note { font-size: 11px; color: var(--warn); margin: 4px 0 8px; }
#profile .profile-stat { display: flex; justify-content: space-between; gap: 10px; margin-bottom: 4px; }
#profile .profile-stat .val { color: var(--accent); font-weight: 600; text-align: right; word-break: break-word; }
#profile .asof { font-size: 10.5px; color: var(--text-dim); font-style: italic; margin-top: 8px; }
#profile .empty { color: var(--text-dim); font-size: 11.5px; }
#profile .profile-section { margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--panel-border); }
#profile .profile-section:first-of-type { margin-top: 8px; padding-top: 0; border-top: none; }
#profile .profile-section-title { font-size: 10.5px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--accent); margin-bottom: 6px; }
#profile .overview-line { margin: 0; color: var(--text); line-height: 1.5; }
#profile .aliases { color: var(--text-dim); line-height: 1.5; }

#analytics-details { flex: none; }
#analytics-details summary { padding: 12px 14px 0; cursor: pointer; font-size: 12px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-dim); }
#analytics { padding: 8px 14px 12px; font-size: 12.5px; }
#analytics .stat-row { display: flex; justify-content: space-between; gap: 10px; margin-bottom: 4px; }
#analytics .stat-row .val { color: var(--accent); font-weight: 600; text-align: right; }
#analytics .category-breakdown { font-size: 11px; color: var(--text-dim); margin: 4px 0 8px; line-height: 1.5; }
#analytics .bar-row { margin: 6px 0; }
#analytics .bar-label { display: flex; justify-content: space-between; font-size: 11px; color: var(--text-dim); margin-bottom: 2px; }
#analytics .bar-track { height: 6px; border-radius: 3px; background: var(--overlay-weak); overflow: hidden; }
#analytics .bar-fill { height: 100%; background: var(--accent); border-radius: 3px; }

/* Places drawer (right, under the controls bar): units on screen + search over all of Nepal */
#places-panel {
    position: absolute; top: 76px; right: 20px; width: 290px; max-height: calc(100vh - 100px);
    flex-direction: column; padding: 12px 14px; overflow: hidden; z-index: 1000;
}
#places-panel:not([hidden]) { display: flex; }
#places-search {
    width: 100%; padding: 7px 9px; border-radius: 6px; border: 1px solid var(--panel-border);
    background: var(--overlay-weak); color: var(--text); font-size: 12.5px; margin-bottom: 8px; flex: none; font-family: var(--font);
}
#places-search:focus { outline: 1px solid var(--accent); }
#places-list { overflow-y: auto; font-size: 12.5px; }
#places-list .section-title { color: var(--accent); font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em; margin: 8px 0 4px; }
#places-list .place-item { padding: 6px 8px; border-radius: 6px; cursor: pointer; color: var(--text); }
#places-list .place-item:hover { background: var(--overlay-strong); }
#places-list .place-item small { display: block; color: var(--text-dim); font-size: 11px; }
#places-list .empty { color: var(--text-dim); padding: 6px 2px; }

/* Hover / info box, bottom centre */
#hover {
    position: absolute; left: 50%; bottom: 20px; transform: translateX(-50%); width: 380px; max-width: 80vw;
    max-height: 40vh; overflow-y: auto; background: rgba(255, 255, 255, 0.95); padding: 10px 14px; border-radius: 6px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.25); z-index: 1000; font-size: 13px; font-family: var(--font); pointer-events: none;
}
#hover h3 { margin: 0 0 4px; font-size: 14px; text-transform: none; letter-spacing: 0; color: var(--text); }
#hover .dim { color: var(--text-dim); font-size: 12px; }

#toast {
    position: fixed; left: 50%; bottom: 70px; transform: translateX(-50%); z-index: 10000; display: none;
    background: #333; color: #fff; padding: 8px 16px; border-radius: 6px; font-family: var(--font); font-size: 13px;
}
#toast.error { background: var(--err); }

/* Map labels */
.leaflet-tooltip.ttarunp, .leaflet-tooltip.ttarund, .leaflet-tooltip.ttarungn {
    background: none; border: none; box-shadow: none; padding: 0; font-family: var(--font); color: #111;
    text-shadow: 0 0 3px #fff, 0 0 3px #fff, 0 0 3px #fff;
}
.leaflet-tooltip.ttarunp { font-size: 15px; font-weight: 700; }
.leaflet-tooltip.ttarund { font-size: 13px; font-weight: 600; }
.leaflet-tooltip.ttarungn { font-size: 11px; }
.leaflet-tooltip-left:before, .leaflet-tooltip-right:before, .leaflet-tooltip-top:before, .leaflet-tooltip-bottom:before { display: none; }
.leaflet-control-zoom { box-shadow: 0 4px 18px rgba(0, 0, 0, 0.35) !important; border: 1px solid var(--panel-border) !important; }

@media (max-width: 700px) {
    #left-column { width: 210px; top: 12px; left: 12px; max-height: calc(100vh - 100px); }
    #controls { top: 12px; right: 12px; max-width: calc(100vw - 24px); }
    #left-column { top: 110px; }
    #places-panel { width: 210px; top: 110px; right: 12px; }
    #hover { width: 260px; font-size: 11.5px; }
}

/* places on the map */
.swatch { width: 12px; height: 12px; border-radius: 3px; flex: none; display: inline-block; }
.layer-note { color: var(--text-dim); font-size: 11.5px; margin: 2px 0 6px; }
.place-cluster { background: var(--accent); color: #fff; border: 2px solid #fff; border-radius: 50%; display: flex; align-items: center;
    justify-content: center; font: 700 12px var(--font); box-shadow: 0 1px 6px rgba(0, 0, 0, 0.4); cursor: pointer; }
.place-popup h4 { margin: 0 0 2px; font: 700 14px var(--font); }
.place-popup .dim { color: var(--text-dim); font-size: 12px; }
.place-popup dl { margin: 6px 0 0; font-size: 12.5px; display: grid; grid-template-columns: auto 1fr; gap: 2px 8px; }
.place-popup dt { color: var(--text-dim); }
.place-popup dd { margin: 0; word-break: break-word; }
.place-popup .tag { display: inline-block; font-size: 10.5px; border: 1px solid var(--panel-border); border-radius: 4px; padding: 0 5px; margin-right: 4px; }
#profile .holder { margin-bottom: 4px; }
#profile .holder small { color: var(--text-dim); display: block; }

/* legend: what the markers mean, with switches */
#legend { position: absolute; right: 14px; bottom: 34px; z-index: 900; width: 262px; max-height: calc(100vh - 150px); overflow-y: auto; padding: 8px 10px 10px; font-size: 12.5px; }
#legend .lg-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; cursor: pointer; user-select: none; }
#legend .lg-head h3 { margin: 0; }
#legend .lg-toggle { border: 0; background: none; font-size: 15px; cursor: pointer; color: var(--text-dim); padding: 0 4px; }
#legend .lg-tools { display: flex; gap: 6px; flex-wrap: wrap; margin: 8px 0 6px; }
#legend .lg-tools button { font: inherit; font-size: 11.5px; padding: 3px 9px; border: 1px solid var(--panel-border); border-radius: 999px; background: #fff; cursor: pointer; }
#legend .lg-tools button:hover { border-color: var(--accent); }
#legend .lg-row { display: flex; align-items: center; gap: 7px; padding: 3px 0; }
#legend .lg-row label { display: flex; align-items: center; gap: 7px; flex: 1; cursor: pointer; min-width: 0; }
#legend .lg-row input { margin: 0; }
#legend .lg-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#legend .lg-count { color: var(--text-dim); font-variant-numeric: tabular-nums; }
#legend .lg-row.zero { opacity: 0.45; }
#legend .lg-caret { border: 0; background: none; cursor: pointer; width: 18px; color: var(--text-dim); padding: 0; font-size: 11px; }
#legend .lg-leaves { margin-left: 22px; border-left: 2px solid var(--panel-border); padding-left: 8px; }
#legend .lg-leaves .lg-row { padding: 2px 0; }
#legend .lg-glyph { width: 16px; text-align: center; flex: none; font-size: 12px; line-height: 1; }
#legend .lg-foot { margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--panel-border); color: var(--text-dim); font-size: 11.5px; display: grid; gap: 4px; }
#legend .lg-foot .cl { display: inline-flex; align-items: center; justify-content: center; width: 18px; height: 18px; border-radius: 50%; background: var(--accent); color: #fff; font: 700 10px var(--font); margin-right: 6px; }
#legend.collapsed .lg-body { display: none; }
@media (max-width: 700px) { #legend { width: 200px; bottom: 30px; max-height: 45vh; } }

/* link to the election results page, shown only while an election is running */
#btnElection { text-decoration: none; display: inline-flex; align-items: center; background: #b71c1c; color: #fff; border-color: #b71c1c; }
