/* Reset */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --nav-height: 56px;
  --nav-green: #FFF8E1;
  --side-panel-width: 320px;
  --side-panel-collapsed-width: 44px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  padding-top: var(--nav-height);
  overflow: hidden;
}

/* Top Navigation Bar */
.nav-right {
  margin-left: auto;
}

.nav-center {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

.top-nav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--nav-height);
  background-color: var(--nav-green);
  color: #000;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  padding: 0 16px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.12);
  z-index: 1000;
}

.nav-left,
.nav-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: inherit;
}

.brand-logo {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid #fff;
}

.brand-text {
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.4px;
}

.nav-title {
  font-size: 20px;
  font-weight: 600;
  text-align: center;
}

.nav-menu {
  background: transparent;
  border: none;
  padding: 6px;
  cursor: pointer;
  border-radius: 6px;
}

.nav-menu:hover {
  background-color: rgba(255, 255, 255, 0.12);
}

/* Inline nav links on the left */
.nav-links {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-left: 14px;
}

.nav-link {
  color: #000;
  text-decoration: none;
  font-size: 16px;
  opacity: 0.95;
}

.nav-link:hover {
  text-decoration: underline;
}

/* Remove drawer styles (no longer used) */

/* Map area */
#map {
  height: calc(100vh - var(--nav-height));
  width: 100%;
  position: relative;
}

/* Side panel (overlay layers) */
.side-panel {
  position: fixed;
  top: calc(var(--nav-height) + 10px);
  left: 10px;
  bottom: 70px;
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid rgba(0, 0, 0, 0.10);
  border-radius: 8px;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.10);
  z-index: 1100;
  overflow: visible;
}

.side-panel-inner-container {
  height: 100%;
  display: flex;
  flex-direction: column;
}

.side-panel-header {
  height: 44px;
  background: var(--nav-green);
  color: #000;
  display: flex;
  align-items: center;
  padding: 0 12px;
  border-radius: 8px 8px 0 0;
}

.side-panel-header .label {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0.4px;
}

.side-panel-content {
  list-style: none;
  padding: 20px 20px;
  margin: 0;
  overflow: auto;
}

.layer-group-container {
  list-style: none;
}

.layer-group {
  padding-bottom: 10px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.08);
  margin-bottom: 10px;
}

.layer-container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 0;
  border-bottom: 1px solid rgba(0, 0, 0, 0.06);
}

.layer-container:last-child {
  border-bottom: none;
}

.checkbox-container {
  flex: 1 1 auto;
  min-width: 0;
  display: inline-flex;
  align-items: center;
}

.layer-label {
  position: relative;
  padding-left: 28px;
  cursor: pointer;
  font-size: 15px;
  color: #263238;
  user-select: none;
  display: inline-block;
  max-width: 100%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.layer-label input {
  position: absolute;
  opacity: 0;
  cursor: pointer;
  height: 0;
  width: 0;
}

.checkmark {
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  height: 20px;
  width: 20px;
  border-radius: 3px;
  border: 1px solid rgba(0, 0, 0, 0.25);
  background: #fff;
}

.layer-label input:checked~.checkmark {
  background: #2e7d32;
  border-color: #2e7d32;
}

.checkmark:after {
  content: "";
  position: absolute;
  display: none;
}

.layer-label input:checked~.checkmark:after {
  display: block;
}

.layer-label .checkmark:after {
  left: 6px;
  top: 2px;
  width: 4px;
  height: 9px;
  border: solid white;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

.opacity-input-container {
  flex: 0 0 100px;
  width: 100px;
}

.opacity-input {
  width: 100%;
  cursor: pointer;
}

.side-panel-control {
  position: absolute;
  top: 50%;
  right: -18px;
  transform: translateY(-50%);
  width: 36px;
  height: 36px;
  border-radius: 999px;
  border: 1px solid rgba(0, 0, 0, 0.12);
  background: #fff;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.12);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2;
}

.side-panel-control img {
  width: 20px;
  height: 20px;
  transition: transform 0.15s ease;
}

.side-panel.collapsed {
  width: 0 !important;
  background: transparent;
  border: none;
  box-shadow: none;
  left: 18px;
  pointer-events: none;
}

.side-panel.collapsed .side-panel-inner-container {
  display: none;
}

.side-panel.collapsed .side-panel-control {
  pointer-events: auto;
}

.side-panel.collapsed .side-panel-control img {
  transform: rotate(180deg);
}

/* Multi-select control styles */
.multi-select-control {
  margin-top: 6px;
}

.multi-select-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  background: #fff;
  border-radius: 4px;
  text-decoration: none;
}

.multi-select-btn img {
  display: block;
  width: 18px;
  height: 18px;
}

.multi-select-btn:hover {
  background: #f3f3f3;
}

.multi-select-btn.active {
  background: #e3f2fd;
  color: #1e88e5;
}

/* Định dạng cho các nút trên bản đồ */
.map-btns {
  position: absolute;
  top: calc(var(--nav-height) + 10px);
  right: 60px;
  z-index: 900;
  display: flex;
  gap: 15px;
}

.map-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 47px;
  height: 47px;
  background: #fff;
  border-radius: 4px;
  text-decoration: none;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
  border: 1px solid rgba(0, 0, 0, 0.1);
}

.map-btn img {
  width: 20px;
  height: 20px;
}

.map-btn svg {
  width: 20px;
  height: 20px;
  color: #263238;
}

.map-btn:hover {
  background-color: #f3f3f3;
}

/* Vị trí vùng nút trên bản đồ */
.map-btns {
  position: absolute;
  top: calc(var(--nav-height) + 10px);
  right: 60px;
  z-index: 900;
  display: flex;
  gap: 10px;
}

/* Đảm bảo menu layer nổi lên trên các nút tự tạo */
.leaflet-control-layers {
  z-index: 1100 !important;
}

/* Điều chỉnh vị trí Leaflet zoom control để tránh vướng side panel */
.leaflet-top.leaflet-left {
  left: calc(var(--side-panel-width) + 1px);
  transition: left 0.3s ease;
}

/* Khi side panel đóng, zoom control dịch về vị trí ban đầu */
body.side-panel-collapsed .leaflet-top.leaflet-left {
  left: 1px;
}

/* Legend control (Loai dat) */
.legend-control {
  background: rgba(255, 255, 255, 0.95);
  border: 1px solid rgba(0, 0, 0, 0.12);
  border-radius: 6px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.12);
  padding: 8px 10px;
  max-height: 40vh;
  overflow: auto;
  font-size: 14px;
  color: #263238;
}

.legend-title {
  font-weight: 700;
  margin-bottom: 14px;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 2px 0;
}

.legend-swatch {
  width: 20px;
  height: 20px;
  border: 1px solid rgba(0, 0, 0, 0.2);
  border-radius: 1px;
  flex: 0 0 auto;
}

.legend-label {
  white-space: nowrap;
}

.legend-empty {
  color: #607d8b;
  font-style: italic;
}

/* Responsive tweaks */
@media (max-width: 480px) {
  .brand-text {
    display: none;
  }

  .nav-title {
    font-size: 16px;
  }
}

/* Copy-right footer fixed at bottom */
.copy-right {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 12px;
  padding: 0 16px;
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: saturate(180%) blur(6px);
  box-shadow: 0 -1px 4px rgba(0, 0, 0, 0.08);
  border-top: 1px solid rgba(0, 0, 0, 0.06);
  z-index: 1000;
}

.copy-right a.left,
.copy-right a.right {
  text-decoration: none;
  font-size: 12px;
  color: #38536d;
  display: inline-flex;
  align-items: center;
  padding: 6px 10px;
  background: #ffffff;
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: 8px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
}

/* Mouse info (tọa độ & độ cao) */
#mouse-info {
  position: fixed;
  left: 10px;
  bottom: 40px;
  /* nằm trên copy-right một chút */
  padding: 6px 10px;
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid rgba(0, 0, 0, 0.1);
  border-radius: 6px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
  font-size: 12px;
  color: #263238;
  z-index: 1100;
}

/* Search Modal */
.search-modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.search-modal-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
}

.search-modal-content {
  position: relative;
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
  width: 90%;
  max-width: 500px;
  z-index: 2001;
}

.search-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.1);
  background: var(--nav-green);
  border-radius: 12px 12px 0 0;
}

.search-modal-header h3 {
  margin: 0;
  font-size: 20px;
  font-weight: 700;
  color: #263238;
}

.search-modal-close {
  background: transparent;
  border: none;
  font-size: 32px;
  line-height: 1;
  cursor: pointer;
  color: #263238;
  padding: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  transition: background 0.2s;
}

.search-modal-close:hover {
  background: rgba(0, 0, 0, 0.1);
}

.search-modal-body {
  padding: 24px;
}

/* Radio button mode selection */
.search-mode-group {
  display: flex;
  gap: 20px;
  margin-bottom: 24px;
  padding-bottom: 20px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.1);
}

.search-mode-label {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 15px;
  font-weight: 500;
  color: #37474f;
  user-select: none;
}

.search-mode-label input[type="radio"] {
  width: 18px;
  height: 18px;
  cursor: pointer;
  accent-color: #2e7d32;
}

.search-mode-label span {
  cursor: pointer;
}

/* Input groups */
.search-input-group {
  margin-bottom: 20px;
}

.search-input-group label {
  display: block;
  font-size: 14px;
  font-weight: 600;
  color: #37474f;
  margin-bottom: 8px;
}

.search-input-group input[type="text"] {
  width: 100%;
  height: 42px;
  padding: 0 12px;
  border: 1px solid rgba(0, 0, 0, 0.2);
  border-radius: 6px;
  font-size: 14px;
  transition: border-color 0.2s;
}

.search-input-group input[type="text"]:focus {
  outline: none;
  border-color: #2e7d32;
  box-shadow: 0 0 0 3px rgba(46, 125, 50, 0.1);
}

.search-input-row {
  display: flex;
  gap: 16px;
}

.search-input-field {
  flex: 1;
}

.search-input-field label {
  display: block;
  font-size: 14px;
  font-weight: 600;
  color: #37474f;
  margin-bottom: 8px;
}

.search-input-field input[type="text"] {
  width: 100%;
  height: 42px;
  padding: 0 12px;
  border: 1px solid rgba(0, 0, 0, 0.2);
  border-radius: 6px;
  font-size: 14px;
  transition: border-color 0.2s;
}

.search-input-field input[type="text"]:focus {
  outline: none;
  border-color: #2e7d32;
  box-shadow: 0 0 0 3px rgba(46, 125, 50, 0.1);
}

/* Search button */
.search-modal-btn {
  width: 100%;
  height: 44px;
  background: #2e7d32;
  color: #fff;
  border: none;
  border-radius: 6px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
  margin-top: 8px;
}

.search-modal-btn:hover {
  background: #1e88e5;
}

.search-modal-btn:active {
  transform: scale(0.98);
}

.search-results li {
  padding: 6px 8px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.08);
}

.search-results li:last-child {
  border-bottom: none;
}