/* ───────── CSS Reset & Base Layout ───────── */
*,*:before,*:after{box-sizing:border-box}
html,body{margin:0;height:100%;font:14px/1.4 system-ui,sans-serif}

/* ───────── Layout System ───────── */
#layout{
  display:grid;
  grid-template-columns:280px 1fr;  /* sidebar | map */
  grid-template-rows:1fr;           /* single row    */
  height:100%;
}
#sidebar{grid-column:1;overflow:auto;background:#fafafa;
         border-right:1px solid #ccc}
#map    {grid-column:2;position:relative}

/* ========================================
   MOBILE HAMBURGER MENU
   ======================================== */

/* Hamburger button - hidden on desktop */
#hamburger-btn {
  display: none;
  position: fixed;
  top: 12px;
  right: 12px;  /* Changed from left to right to avoid OL zoom controls */
  z-index: 10002;
  width: 44px;
  height: 44px;
  background: linear-gradient(135deg, #1e3a8a 0%, #3b82f6 100%);
  border: none;
  border-radius: 6px;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  padding: 0;
  align-items: center;
  justify-content: center;
}

#hamburger-btn .hamburger-icon {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

#hamburger-btn .hamburger-line {
  width: 20px;
  height: 2px;
  background: white;
  border-radius: 1px;
  transition: all 0.3s ease;
}

/* Hamburger animation when open */
#hamburger-btn.active .hamburger-line:nth-child(1) {
  transform: translateY(6px) rotate(45deg);
}

#hamburger-btn.active .hamburger-line:nth-child(2) {
  opacity: 0;
}

#hamburger-btn.active .hamburger-line:nth-child(3) {
  transform: translateY(-6px) rotate(-45deg);
}

/* Overlay backdrop */
#sidebar-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  z-index: 10000;
  opacity: 0;
  transition: opacity 0.3s ease;
}

#sidebar-overlay.active {
  display: block;
  opacity: 1;
}

/* Mobile Layout */
@media(max-width:900px){
  /* Map takes full screen */
  #layout {
    position: relative;
    width: 100%;
    height: 100vh;
  }

  #map {
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 100% !important;
  }

  /* Sidebar slides in from left as overlay */
  #sidebar {
    position: fixed !important;
    top: 0 !important;
    left: -100% !important;
    width: 100% !important;
    max-width: 400px !important;
    height: 100vh !important;
    z-index: 10001 !important;
    transition: left 0.3s ease !important;
    box-shadow: 4px 0 12px rgba(0, 0, 0, 0.3) !important;
  }

  #sidebar.active {
    left: 0 !important;
  }

  /* Show hamburger button */
  #hamburger-btn {
    display: flex;
  }

  /* Hide DEM legend on mobile (takes up too much space) */
  .dem-legend {
    display: none !important;
  }
}

/* ───────── UI Widgets ───────── */
section{padding:8px 14px}
details{border:1px solid #ddd;border-radius:4px;margin-bottom:8px;background:#fff}
summary{padding:6px 10px;font-weight:600;background:#eee;cursor:pointer}
details[open]>summary{background:#e0e0e0}
label{display:block;margin:.35em 0}
input,select{width:100%;padding:4px}
button.btn{width:100%;margin:.35em 0;padding:6px;border:none;
           background:#f57c00;color:#fff;border-radius:4px;font-size:14px}
button.btn:hover{background:#c15f00}
button.btn:disabled{opacity:.55}
.row{display:flex;align-items:center;gap:.5em}
.row input[type=range]{flex:1}

/* ───────── Range Input (Slider) Styling ───────── */
/* Explicit styling with !important to override WordPress theme styles */
input[type="range"],
.layers-popover input[type="range"],
#sidebar input[type="range"] {
  -webkit-appearance: none !important;
  appearance: none !important;
  background: transparent !important;
  cursor: pointer !important;
  height: 18px !important;
  width: 100%;
}

/* Track styling - WebKit (Chrome, Safari, Edge) */
input[type="range"]::-webkit-slider-runnable-track,
.layers-popover input[type="range"]::-webkit-slider-runnable-track,
#sidebar input[type="range"]::-webkit-slider-runnable-track {
  background: linear-gradient(to right, #d1d5db 0%, #9ca3af 100%) !important;
  border-radius: 4px !important;
  height: 6px !important;
  border: 1px solid #9ca3af !important;
}

/* Track styling - Firefox */
input[type="range"]::-moz-range-track,
.layers-popover input[type="range"]::-moz-range-track,
#sidebar input[type="range"]::-moz-range-track {
  background: linear-gradient(to right, #d1d5db 0%, #9ca3af 100%) !important;
  border-radius: 4px !important;
  height: 6px !important;
  border: 1px solid #9ca3af !important;
}

/* Thumb styling - WebKit (Chrome, Safari, Edge) */
input[type="range"]::-webkit-slider-thumb,
.layers-popover input[type="range"]::-webkit-slider-thumb,
#sidebar input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none !important;
  appearance: none !important;
  width: 16px !important;
  height: 16px !important;
  background: #ef4444 !important;
  border-radius: 50% !important;
  border: 2px solid #fff !important;
  box-shadow: 0 1px 3px rgba(0,0,0,0.3) !important;
  margin-top: -6px !important; /* Center thumb on track */
  cursor: pointer !important;
}

/* Thumb styling - Firefox */
input[type="range"]::-moz-range-thumb,
.layers-popover input[type="range"]::-moz-range-thumb,
#sidebar input[type="range"]::-moz-range-thumb {
  width: 16px !important;
  height: 16px !important;
  background: #ef4444 !important;
  border-radius: 50% !important;
  border: 2px solid #fff !important;
  box-shadow: 0 1px 3px rgba(0,0,0,0.3) !important;
  cursor: pointer !important;
}

/* Hover states */
input[type="range"]:hover::-webkit-slider-thumb {
  background: #dc2626 !important;
  transform: scale(1.1);
}

input[type="range"]:hover::-moz-range-thumb {
  background: #dc2626 !important;
  transform: scale(1.1);
}

/* Focus states for accessibility */
input[type="range"]:focus {
  outline: none !important;
}

input[type="range"]:focus::-webkit-slider-thumb {
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.3), 0 1px 3px rgba(0,0,0,0.3) !important;
}

input[type="range"]:focus::-moz-range-thumb {
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.3), 0 1px 3px rgba(0,0,0,0.3) !important;
}
label.toggle{display:grid;grid-template-columns:auto 1fr;align-items:center;gap:6px;margin:.3em 0}
label.toggle input{margin:0}
.header{font-size:20px;padding:10px 14px;background:#333;color:#fff;
        display:flex;align-items:center;justify-content:space-between;gap:8px}
.header .header-title{flex:1;font-size:16px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.header .fullscreen-btn{
  background:rgba(255,255,255,0.15);border:none;color:#fff;
  padding:6px 10px;border-radius:4px;cursor:pointer;font-size:14px;
  transition:background 0.2s ease;flex-shrink:0;
}
.header .fullscreen-btn:hover{background:rgba(255,255,255,0.25)}
.header .fullscreen-btn:active{background:rgba(255,255,255,0.35)}

/* ───────── OpenLayers Popup ───────── */
.ol-popup{position:absolute;background:#fff;padding:3px;border-radius:1px;
          border:3px solid #ccc;min-width:140px;z-index:1000;font-size:12px}
.ol-popup *{margin:0;padding:0;line-height:1}
.ol-popup:before,
.ol-popup:after{
  display:none;
}

/* ───────── Measurement Result Popups ───────── */
.measurement-popup{
  position:absolute;background:rgba(255, 255, 255, 0.95);
  backdrop-filter:blur(10px);border:1px solid #e5e7eb;
  border-radius:8px;padding:0;font-size:14px;
  box-shadow:0 4px 20px rgba(0,0,0,0.15);
  z-index:9999;max-width:280px;overflow:hidden;
}

.measurement-popup-header{
  background:linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
  color:white;padding:8px 12px;font-weight:600;
  display:flex;align-items:center;gap:6px;
}

.measurement-popup-header i{
  font-size:14px;opacity:0.9;
}

.measurement-popup-content{
  padding:12px;
}

.measurement-value{
  font-size:18px;font-weight:700;color:#1f2937;
  margin-bottom:4px;
}

.measurement-unit{
  color:#6b7280;font-size:13px;margin-bottom:8px;
}

.measurement-actions{
  border-top:1px solid #f1f5f9;padding-top:8px;
  display:flex;align-items:center;justify-content:center;
}

.measurement-clear-btn{
  background:none;border:none;color:#6b7280;
  font-size:12px;cursor:pointer;padding:4px 8px;
  border-radius:4px;transition:all 0.2s ease;
  display:flex;align-items:center;gap:4px;
}

.measurement-clear-btn:hover{
  background:#f8fafc;color:#374151;
}

.measurement-clear-btn i{
  font-size:11px;
}

.measurement-units{
  margin-bottom:8px;
}

.measurement-unit-select{
  width:100%;padding:4px 8px;border:1px solid #e5e7eb;
  border-radius:4px;font-size:12px;background:#fff;
  color:#374151;cursor:pointer;
}

.measurement-unit-select:focus{
  outline:none;border-color:#6366f1;
  box-shadow:0 0 0 2px rgba(99, 102, 241, 0.1);
}

/* ───────── DEM Legend ───────── */
.dem-legend{position:absolute;top:10px;right:10px;background:#fff;border:1px solid #333;
            border-radius:4px;padding:8px;z-index:9999;font-size:13px;max-width:80px;
            box-shadow:2px 2px 5px rgba(0,0,0,.3)}
.dem-legend-title{font-weight:bold;margin-bottom:5px;text-align:center}
.dem-legend-gradient{height:12px;margin-bottom:6px;background:linear-gradient(to right,
  #0000ff 0%, #00ffff 20%, #00ff00 40%, #ffff00 60%, #ffa500 80%, #ff0000 100%);
  border:1px solid #999}

/* ───────── Utility Classes ───────── */
.hidden{display:none !important}
.viewer-hide{display:none !important}
.legacy-base{display:none}