/* ── Reset & base ────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  font-family: 'Segoe UI', Arial, sans-serif;
  font-size: 14px;
  color: #222;
  overflow: hidden;
}

/* ── Layout ──────────────────────────────────────────────────── */
#sidebar {
  position: fixed;
  top: 0; left: 0; bottom: 0;
  width: 320px;
  background: #fff;
  display: flex;
  flex-direction: column;
  z-index: 1000;
  box-shadow: 2px 0 10px rgba(0,0,0,.18);
  transition: transform .25s ease;
}

#sidebar.collapsed {
  transform: translateX(-320px);
}

#map {
  position: fixed;
  top: 0; right: 0; bottom: 0;
  left: 320px;
  z-index: 1;
  transition: left .25s ease;
}

body.sidebar-collapsed #map { left: 0; }

/* ── Sidebar header ──────────────────────────────────────────── */
#sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px 10px;
  background: #1a3a5c;
  color: #fff;
  flex-shrink: 0;
}

#logo-area {
  display: flex;
  align-items: center;
  gap: 10px;
}

#logo-icon { font-size: 26px; }

#logo-area h1 {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: .5px;
  line-height: 1.2;
}

#logo-area p {
  font-size: 11px;
  opacity: .8;
  line-height: 1.2;
}

#sidebar-toggle {
  background: rgba(255,255,255,.15);
  border: none;
  color: #fff;
  font-size: 18px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 4px;
  line-height: 1;
  transition: background .15s;
  flex-shrink: 0;
}
#sidebar-toggle:hover { background: rgba(255,255,255,.3); }

#sidebar-open {
  position: fixed;
  top: 10px;
  left: 6px;
  z-index: 1001;
  background: #1a3a5c;
  border: none;
  color: #fff;
  font-size: 18px;
  cursor: pointer;
  padding: 5px 9px;
  border-radius: 4px;
  line-height: 1;
  box-shadow: 1px 1px 5px rgba(0,0,0,.35);
  display: none;
  transition: background .15s;
}
body.sidebar-collapsed #sidebar-open { display: block; }
#sidebar-open:hover { background: #255080; }

/* ── Tabs ────────────────────────────────────────────────────── */
#tabs {
  display: flex;
  border-bottom: 2px solid #e0e6ef;
  flex-shrink: 0;
  background: #f5f8fc;
}

.tab {
  flex: 1;
  padding: 9px 0;
  border: none;
  background: transparent;
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  color: #666;
  border-bottom: 3px solid transparent;
  margin-bottom: -2px;
  transition: color .15s, border-color .15s;
}
.tab:hover { color: #1a3a5c; }
.tab.active { color: #1a3a5c; border-bottom-color: #1a3a5c; }

/* ── Tab content ─────────────────────────────────────────────── */
#tab-content {
  flex: 1;
  overflow-y: auto;
  padding: 0;
}

.tab-panel {
  display: none;
  padding: 14px;
}
.tab-panel.active { display: block; }

.tab-panel h3 {
  font-size: 14px;
  font-weight: 700;
  color: #1a3a5c;
  margin-bottom: 12px;
  padding-bottom: 6px;
  border-bottom: 1px solid #e0e6ef;
}

#legend-pdf-footer {
  padding: 10px 0 4px;
  border-top: 1px solid #e0e6ef;
  margin-top: 8px;
  text-align: center;
}
#legend-pdf-link {
  font-size: 12px;
  font-weight: 600;
  color: #1a3a5c;
  text-decoration: none;
  background: #e8f0fb;
  border: 1px solid #b0c4de;
  border-radius: 4px;
  padding: 5px 14px;
  display: inline-block;
}
#legend-pdf-link:hover {
  background: #c8d8f0;
}

/* ── Layer controls ──────────────────────────────────────────── */
.layer-group {
  margin-bottom: 14px;
}

.layer-group h4 {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: #888;
  margin-bottom: 6px;
}

.layer-group label {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 2px;
  cursor: pointer;
  border-radius: 3px;
  transition: background .1s;
  font-size: 13px;
}
.layer-group label:hover { background: #f0f4fa; }

.layer-swatch {
  display: inline-block;
  width: 14px; height: 14px;
  border-radius: 2px;
  border: 1px solid rgba(0,0,0,.15);
  flex-shrink: 0;
}

#opacity-slider {
  margin-top: 4px;
}

#opacity-value {
  font-size: 12px;
  color: #555;
}

/* ── Legend ──────────────────────────────────────────────────── */
#legend-content {
  overflow-y: auto;
  margin-top: 4px;
}

#legend-items {
  display: flex;
  flex-direction: column;
  gap: 0;
}

/* ─ Section headers (Limite / Zone / Observații) ─ */
.leg-section-hdr {
  margin-top: 10px;
  margin-bottom: 2px;
  padding: 4px 4px 3px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .8px;
  color: #1a2a6c;
  background: #e8edf8;
  border-radius: 3px;
  border-left: 3px solid #3355aa;
}

.leg-section-hdr:first-child {
  margin-top: 0;
}

/* ─ Row items (fill, line, hatch) ─ */
.leg-item {
  display: flex;
  align-items: flex-start;
  gap: 7px;
  padding: 3px 4px;
  border-radius: 3px;
  font-size: 11.5px;
  line-height: 1.35;
  color: #222;
}

.leg-item:hover {
  background: #f0f4ff;
}

.leg-item.leg-hdr {
  margin-top: 6px;
  font-weight: 700;
  font-size: 12px;
  color: #1a1a2e;
  border-top: 1px solid #d0d8e8;
  padding-top: 5px;
}

.leg-item.leg-hdr:first-child {
  border-top: none;
  margin-top: 0;
}

/* Items with approximate/unknown colors */
.leg-item.leg-unknown .leg-text {
  color: #666;
}

/* ─ PDF symbol image ─ */
.leg-item-img {
  flex-direction: column;
  align-items: flex-start;
  gap: 3px;
  padding: 5px 0 3px;
  border-bottom: 1px solid #edf0f7;
}

.leg-item-img:last-child {
  border-bottom: none;
}

.leg-sym-img {
  display: block;
  max-height: 26px;
  width: auto;
  max-width: 210px;
  image-rendering: -webkit-optimize-contrast;
  image-rendering: crisp-edges;
}

/* ─ Fill swatch ─ */
.leg-swatch {
  flex-shrink: 0;
  width: 18px;
  height: 16px;
  border-radius: 2px;
  margin-top: 1px;
  display: inline-block;
}

/* ─ Hatch swatch ─ */
.leg-swatch-hatch {
  flex-shrink: 0;
  width: 18px;
  height: 16px;
  border-radius: 2px;
  margin-top: 1px;
  display: inline-block;
}

/* ─ Line symbol (SVG) ─ */
.leg-swatch-box {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  height: 16px;
  margin-top: 1px;
}

.leg-line-sym {
  width: 44px;
  height: 12px;
  display: block;
  overflow: visible;
}

/* ─ Zone code badge ─ */
.leg-code {
  display: inline-block;
  font-weight: 700;
  background: #e8edf8;
  border-radius: 3px;
  padding: 0 4px;
  margin-right: 4px;
  font-size: 11px;
  color: #1a2a6c;
  white-space: nowrap;
}

/* ─ Label text ─ */
.leg-text {
  flex: 1;
}

/* ─ Observation note ─ */
.leg-note {
  font-size: 10.5px;
  color: #555;
  font-style: italic;
  line-height: 1.45;
  padding: 3px 4px 3px 8px;
  border-left: 2px solid #ccd3e8;
  margin: 2px 0;
}

.leg-empty {
  font-size: 12px;
  color: #888;
  padding: 8px 4px;
}

.legend-section {
  margin-bottom: 14px;
}

.legend-section strong {
  display: block;
  font-size: 12px;
  font-weight: 700;
  color: #1a3a5c;
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: .3px;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 3px 0;
  font-size: 12px;
}

.legend-color {
  display: inline-block;
  width: 18px; height: 14px;
  border: 1px solid rgba(0,0,0,.2);
  flex-shrink: 0;
  border-radius: 2px;
}

.legend-line {
  display: inline-block;
  width: 28px;
  height: 0;
  border-top: 2px solid #000;
  flex-shrink: 0;
}

/* ── UTR list ────────────────────────────────────────────────── */
#utr-search-box {
  margin-bottom: 10px;
}

#utr-search {
  width: 100%;
  padding: 7px 10px;
  border: 1px solid #cdd5e0;
  border-radius: 5px;
  font-size: 13px;
  outline: none;
}
#utr-search:focus { border-color: #1a3a5c; box-shadow: 0 0 0 2px rgba(26,58,92,.12); }

#utr-list { /* populated by JS */ }

.utr-zone-group {
  margin-bottom: 10px;
}

.utr-zone-group-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  background: #f0f4fa;
  border-radius: 4px;
  cursor: pointer;
  font-weight: 700;
  font-size: 12px;
  color: #1a3a5c;
  border-left: 4px solid #1a3a5c;
  user-select: none;
}
.utr-zone-group-header:hover { background: #e3eaf5; }
.utr-zone-group-header .arrow { margin-left: auto; transition: transform .2s; }
.utr-zone-group-header.open .arrow { transform: rotate(90deg); }

.utr-zone-group-body {
  display: none;
  padding: 4px 0 4px 4px;
}
.utr-zone-group-body.open { display: block; }

.utr-item {
  display: flex;
  align-items: flex-start;
  padding: 4px 6px;
  gap: 8px;
  border-radius: 3px;
  cursor: pointer;
  transition: background .1s;
  font-size: 12px;
}
.utr-item:hover { background: #f5f8fc; }

.utr-code {
  font-weight: 700;
  color: #1a3a5c;
  min-width: 32px;
  font-size: 12px;
}

.utr-desc { color: #444; flex: 1; line-height: 1.4; }

.utr-link {
  font-size: 11px;
  color: #2a6ab5;
  text-decoration: none;
  white-space: nowrap;
  flex-shrink: 0;
}
.utr-link:hover { text-decoration: underline; }

/* ── Zone info panel ─────────────────────────────────────────── */
#zone-info-placeholder {
  text-align: center;
  color: #888;
  padding: 24px 12px;
  font-size: 13px;
  line-height: 1.6;
}

.zone-info-card {
  border: 1px solid #dde4ef;
  border-radius: 6px;
  overflow: hidden;
  margin-bottom: 10px;
}

.zone-info-card-header {
  background: #1a3a5c;
  color: #fff;
  padding: 10px 12px;
  font-weight: 700;
  font-size: 13px;
}

.zone-info-card-body {
  padding: 10px 12px;
  font-size: 12px;
  line-height: 1.6;
}

.zone-info-row {
  display: flex;
  gap: 8px;
  margin-bottom: 5px;
  align-items: flex-start;
}

.zone-info-label {
  font-weight: 600;
  color: #555;
  min-width: 90px;
  flex-shrink: 0;
}

.zone-info-value { color: #222; }

.zone-info-card-body a {
  color: #1a3a5c;
  font-weight: 600;
}

/* ── Sidebar footer ──────────────────────────────────────────── */
#sidebar-footer {
  padding: 10px 14px;
  border-top: 1px solid #e0e6ef;
  font-size: 11px;
  color: #888;
  line-height: 1.8;
  flex-shrink: 0;
}
#sidebar-footer a { color: #1a3a5c; text-decoration: none; }
#sidebar-footer a:hover { text-decoration: underline; }

/* ── Info tab – source & coffee ──────────────────────────────── */
#info-source {
  margin-top: 18px;
  padding: 12px;
  background: #f5f8fc;
  border-radius: 6px;
  border: 1px solid #dce6f0;
  font-size: 12px;
  line-height: 1.6;
  color: #444;
}
#info-source h4 {
  font-size: 12px;
  font-weight: 700;
  color: #1a3a5c;
  margin-bottom: 6px;
}
#info-source a {
  display: inline-block;
  margin-top: 6px;
  color: #1a3a5c;
  font-weight: 600;
  text-decoration: none;
}
#info-source a:hover { text-decoration: underline; }

#info-coffee {
  margin-top: 16px;
  text-align: center;
  font-size: 12px;
  color: #888;
}
#info-coffee p { margin-top: 6px; line-height: 1.5; }
#bmc-link {
  display: inline-block;
  background: #FFDD00;
  color: #000;
  font-weight: 700;
  font-size: 13px;
  padding: 8px 20px;
  border-radius: 20px;
  text-decoration: none;
  box-shadow: 0 2px 6px rgba(0,0,0,.15);
  transition: background .15s, transform .1s;
}
#bmc-link:hover { background: #f0d000; transform: translateY(-1px); }

/* ── Map tooltip ─────────────────────────────────────────────── */
#map-tooltip {
  position: fixed;
  background: rgba(0,0,0,.75);
  color: #fff;
  padding: 5px 9px;
  border-radius: 4px;
  font-size: 12px;
  pointer-events: none;
  display: none;
  z-index: 3000;
  max-width: 240px;
  line-height: 1.4;
}

/* ── Leaflet overrides ───────────────────────────────────────── */
.leaflet-control-zoom { border: none !important; box-shadow: 0 2px 6px rgba(0,0,0,.2) !important; }
.leaflet-control-zoom a {
  color: #1a3a5c !important;
  font-weight: 700 !important;
}

/* ── Responsive (mobile) ─────────────────────────────────────── */
@media (max-width: 640px) {
  #sidebar {
    width: 100%;
    height: 50%;
    top: auto;
    bottom: 0;
    left: 0;
    right: 0;
    flex-direction: column;
    transform: none;
    border-radius: 12px 12px 0 0;
    box-shadow: 0 -3px 12px rgba(0,0,0,.2);
  }
  #sidebar.collapsed { transform: translateY(calc(100% - 50px)); }
  #map { left: 0; bottom: 50%; }
  body.sidebar-collapsed #map { bottom: 50px; left: 0; }
}

/* ── Loading overlay ─────────────────────────────────────────── */
#loading-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(255,255,255,.85);
  z-index: 5000;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 12px;
  transition: opacity .3s;
}
#loading-overlay.hidden { opacity: 0; pointer-events: none; }

.spinner {
  width: 40px; height: 40px;
  border: 4px solid #e0e6ef;
  border-top-color: #1a3a5c;
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Layer data notice ───────────────────────────────────────── */
.data-notice {
  background: #fff8e1;
  border: 1px solid #f0c040;
  border-radius: 4px;
  padding: 8px 10px;
  font-size: 11px;
  color: #7a5c00;
  margin-top: 8px;
  line-height: 1.5;
}

/* push layer controls below the open button when sidebar is hidden */
body.sidebar-collapsed .leaflet-top.leaflet-left {
  margin-top: 46px;
  transition: margin-top .25s ease;
}

/* ── PUG layer selector (on map, top-left) ──────────────────── */
.pug-layer-ctrl {
  background: rgba(255,255,255,.96);
  border-radius: 8px;
  box-shadow: 0 2px 10px rgba(0,0,0,.22);
  padding: 10px 14px;
  min-width: 210px;
}

.pug-layer-title {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: #888;
  margin-bottom: 8px;
  font-family: 'Segoe UI', Arial, sans-serif;
}

.pug-layer-opt {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 4px;
  cursor: pointer;
  border-radius: 4px;
  font-size: 13px;
  font-family: 'Segoe UI', Arial, sans-serif;
  color: #2c3e50;
  transition: background .1s;
  white-space: nowrap;
}

.pug-layer-opt:hover { background: #f0f4fa; }

.pug-layer-opt input[type=radio] {
  accent-color: #1a3a5c;
  cursor: pointer;
  flex-shrink: 0;
}

.pug-layer-swatch {
  display: inline-block;
  width: 13px;
  height: 13px;
  border-radius: 2px;
  border: 1px solid rgba(0,0,0,.18);
  flex-shrink: 0;
  opacity: .85;
}

/* ── Basemap toggle (on map, top-right) ─────────────────────── */
.basemap-toggle-ctrl {
  display: flex;
  border-radius: 6px;
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(0,0,0,.25);
}

.bm-btn {
  padding: 7px 14px;
  border: none;
  background: #fff;
  font-size: 13px;
  font-weight: 600;
  color: #555;
  cursor: pointer;
  transition: background .15s, color .15s;
  font-family: 'Segoe UI', Arial, sans-serif;
}
.bm-btn + .bm-btn { border-left: 1px solid #ddd; }
.bm-btn:hover { background: #f0f4fa; color: #1a3a5c; }
.bm-btn.active { background: #1a3a5c; color: #fff; }

/* ── Opacity slider (bottom-center, wide) ───────────────────── */
.opacity-map-ctrl {
  position: absolute;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1000;
  background: rgba(255,255,255,.96);
  border-radius: 10px;
  box-shadow: 0 2px 12px rgba(0,0,0,.22);
  padding: 9px 22px;
  display: -webkit-box;
  display: -ms-flexbox;
  display: flex;
  -webkit-box-align: center;
  -ms-flex-align: center;
  align-items: center;
  gap: 14px;
  pointer-events: auto;
  white-space: nowrap;
}

.opc-label {
  font-size: 12px;
  font-weight: 700;
  color: #1a3a5c;
  white-space: nowrap;
  font-family: 'Segoe UI', Arial, sans-serif;
  text-transform: uppercase;
  letter-spacing: .4px;
}

.opacity-map-ctrl input[type=range] {
  -webkit-appearance: none;
  appearance: none;
  width: 800px;
  height: 4px;
  background: #c8d6e8;
  border-radius: 2px;
  outline: none;
  cursor: pointer;
  accent-color: #1a3a5c;
  padding: 0;
  margin: 0;
}
.opacity-map-ctrl input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  background: #1a3a5c;
  border-radius: 50%;
  cursor: pointer;
  box-shadow: 0 1px 4px rgba(0,0,0,.3);
}
.opacity-map-ctrl input[type=range]::-moz-range-thumb {
  width: 18px;
  height: 18px;
  background: #1a3a5c;
  border: none;
  border-radius: 50%;
  cursor: pointer;
}
.opacity-map-ctrl input[type=range]::-ms-thumb {
  width: 18px;
  height: 18px;
  background: #1a3a5c;
  border: none;
  border-radius: 50%;
  cursor: pointer;
}

.opacity-map-ctrl #opacity-value {
  font-size: 12px;
  font-weight: 700;
  color: #1a3a5c;
  min-width: 36px;
  text-align: right;
  font-family: 'Segoe UI', Arial, sans-serif;
}
