/* =======LAYOUT UTAMA & BASE======= */
html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  width: 100%;
  font-family: Arial, Helvetica, sans-serif;
  overflow: hidden;
}

#map, 
.map-container, 
.maplibregl-map {
  width: 100%;
  height: 100%;
  position: absolute;
  top: 0;
  left: 0;
  overflow: hidden;
}

.maplibregl-canvas-container, 
.maplibregl-canvas {
  outline: none;
  -webkit-tap-highlight-color: rgba(0,0,0,0);
}

/* ====PANEL SIDEBAR (MAP OVERLAY)======= */
.map-overlay {
  position: absolute;
  top: 15px;
  left: 15px;
  width: 280px;
  max-height: calc(100% - 40px);
  background: rgba(255, 255, 255, 0.95);
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.15);
  border-radius: 8px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  overflow: visible; 
}

.panel-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 15px;
  font-weight: bold;
  font-size: 15px;
  color: #2c3e50;
  border-bottom: 2px solid #3498db;
}

.panel-logo {
  width: 24px;       
  height: auto;      
  object-fit: contain;
}

.panel-description {
  font-size: 11px;
  color: #555555;
  line-height: 1.4;
  margin: 6px 0 12px 0;
  padding: 0 12px;
  text-align: left;
  box-sizing: border-box;
}

.layer-container {
  overflow-y: auto;
  padding: 10px;
}

details {
  margin-bottom: 8px;
  border: 1px solid #e0e0e0;
  border-radius: 5px;
  background: #fff;
}

summary {
  padding: 8px 10px;
  font-weight: bold;
  font-size: 12px;
  cursor: pointer;
  color: #34495e;
  background: #f8f9fa;
  border-radius: 4px;
}

.group-content {
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.layer-item {
  font-size: 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
}

.opacity-container {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: 20px;
  margin-bottom: 4px;
  font-size: 11px;
  color: #666;
}

.opacity-container input[type="range"] {
  width: 90px;
  cursor: pointer;
}

/* Sidebar Footer */
.sidebar-footer {
  margin-top: auto;
  padding: 12px 15px;
  border-top: 1px solid #e0e0e0;
  background-color: #f8f9fa;
  text-align: center;
  border-radius: 0 0 8px 8px;
  font-size: 11px;
  color: #555555;
}

.sidebar-footer p {
  margin: 0 0 3px 0;
  font-size: 12px;
  color: #2c3e50;
}

.sidebar-footer small {
  display: block;
  color: #7f8c8d;
}

/* ========SEARCH WIDGET==== */
#search-container, 
.search-container {
  position: relative;
  z-index: 10000;
  width: 100%;
  margin: 10px 0;
}

#search-input {
  width: 100%;
  padding: 8px 12px;
  font-size: 12px;
  border: 1px solid #bdc3c7;
  border-radius: 4px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
  outline: none;
  background: #ffffff;
  box-sizing: border-box;
}

#search-input:focus {
  border-color: #3498db;
  box-shadow: 0 2px 10px rgba(52, 152, 219, 0.4);
}

#search-results, 
.search-results {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  width: 100%;
  background: #ffffff;
  border: 1px solid #bdc3c7;
  border-top: none;
  border-radius: 0 0 6px 6px;
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.25);
  max-height: 200px;
  overflow-y: auto;
  z-index: 100001;
  box-sizing: border-box;
}

#search-results:empty, 
.search-results:empty,
#search-results[style*="display: none"] {
  display: none !important;
}

.search-item {
  padding: 8px 12px;
  font-size: 11px;
  color: #333;
  cursor: pointer;
  border-bottom: 1px solid #f0f0f0;
}

.search-item:last-child {
  border-bottom: none;
}

.search-item:hover {
  background-color: #3498db;
  color: #ffffff;
}

.search-item small {
  display: block;
  font-size: 9px;
  color: #7f8c8d;
}

.search-item:hover small {
  color: #ecf0f1;
}

/* =========TOOLBAR KONTROL==== */
.basemap-container {
  position: absolute;
  top: 15px;
  right: 50px;
  z-index: 10;
  display: flex;
  background: rgba(255, 255, 255, 0.95);
  padding: 3px;
  border-radius: 6px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.btn-basemap {
  border: none;
  background: transparent;
  padding: 5px 10px;
  font-size: 11px;
  font-weight: bold;
  color: #555;
  cursor: pointer;
  border-radius: 4px;
  transition: all 0.2s ease;
}

.btn-basemap.active {
  background: #3498db;
  color: #ffffff;
}

.btn-basemap:hover:not(.active) {
  background: #f0f0f0;
}

.measure-container {
  position: absolute;
  top: 15px;
  right: 215px;
  z-index: 10;
  display: flex;
  gap: 3px;
  background: rgba(255, 255, 255, 0.95);
  padding: 3px;
  border-radius: 6px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.btn-measure {
  padding: 4px 6px;
  font-size: 11px;
  white-space: nowrap;
}

.btn-measure.active {
  background: #27ae60;
  color: #ffffff;
}

.btn-measure:hover:not(.active) {
  background: #f0f0f0;
}

.btn-clear { color: #c0392b; }
.btn-clear:hover { background: #fadbd8; }

.btn-export {
  color: #2980b9;
  border-left: 1px solid #ddd;
  padding-left: 8px;
  margin-left: 4px;
}
.btn-export:hover { background: #ebf5fb; }

.btn-upload {
  color: #8e44ad;
  border-left: 1px solid #ddd;
  padding-left: 8px;
  margin-left: 4px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
}
.btn-upload:hover { background: #f4ecf7; }

/* Tooltip & Overlay Panel */
#measure-tooltip, 
.measure-tooltip {
  position: absolute;
  z-index: 9999;
  background: rgba(44, 62, 80, 0.95);
  color: #ffffff;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: bold;
  pointer-events: none;
  display: none;
  white-space: nowrap;
}

.overlay-panel {
  position: absolute;
  bottom: 30px;
  left: 320px;
  z-index: 12;
  width: 320px;
  background: rgba(255, 255, 255, 0.98);
  border-radius: 8px;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
  border-left: 5px solid #8e44ad;
  font-size: 12px;
  overflow: hidden;
}

.overlay-header {
  background: #f8f9fa;
  padding: 8px 12px;
  font-weight: bold;
  color: #2c3e50;
  border-bottom: 1px solid #eee;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.overlay-header .close-btn { cursor: pointer; font-size: 16px; color: #888; }
.overlay-header .close-btn:hover { color: #e74c3c; }

.overlay-body { padding: 10px 12px; }
.overlay-body p { margin: 4px 0; color: #444; }
.highlight-val { color: #27ae60; font-weight: bold; }

/*=====PANEL LEGENDA====== */
.legend-panel {
  position: absolute;
  bottom: 20px;
  right: 45px;
  z-index: 1000;
  background: #ffffff;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  width: 220px;
  max-height: 320px;
  overflow: hidden;
  transition: all 0.3s ease;
}

.legend-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px;
  background: #ffffff;
  border-bottom: 1px solid #eeeeee;
  font-weight: bold;
  font-size: 13px;
  color: #2c3e50;
  cursor: pointer;
  user-select: none;
}

.legend-header button {
  background: none;
  border: none;
  font-size: 12px;
  color: #7f8c8d;
  cursor: pointer;
  transition: transform 0.3s ease;
  padding: 0;
}

.legend-body {
  padding: 10px 12px;
  max-height: 250px;
  overflow-y: auto;
  overflow-x: hidden;
}

.legend-panel.collapsed .legend-body { display: none !important; }
.legend-panel.collapsed .legend-header { border-bottom: none; }
.legend-panel.collapsed #btn-toggle-legend { transform: rotate(180deg); }

.legend-item { display: flex; align-items: center; margin-bottom: 4px; }
.legend-color {
  width: 14px;
  height: 14px;
  border-radius: 3px;
  margin-right: 8px;
  border: 1px solid rgba(0,0,0,0.2);
  flex-shrink: 0;
}

/* ====OVERRIDE CONTROL ======== */
.maplibregl-ctrl-group {
  height: auto;
  max-height: fit-content;
  overflow: hidden;
  background: #ffffff;
  box-shadow: 0 0 10px rgba(0,0,0,0.1);
}

.maplibregl-ctrl-group button {
  width: 29px;
  height: 29px;
  display: block;
}

.maplibregl-ctrl-home {
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%23333'%3E%3Cpath d='M10 20v-6h4v6h5v-8h3L12 3 2 12h3v8z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: center;
  background-size: 18px 18px;
}

.maplibregl-popup:empty,
.maplibregl-popup-content:empty,
#measure-tooltip:empty {
  display: none !important;
}

/* Custom Scrollbar */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(0, 0, 0, 0.2); border-radius: 3px; }

/* =====RESPONSIVE (MOBILE)======= */
@media (max-width: 768px) {
  .map-overlay {
    width: 100%;
    max-height: 40vh;
    top: auto;
    bottom: 0;
    left: 0;
    border-radius: 12px 12px 0 0;
  }

  .measure-container { display: none; }
}