/* Reset dan dasar font */
* {
  box-sizing: border-box;
  font-family: 'Poppins', sans-serif;
  margin: 0; padding: 0;
}
body, html {
  height: 100%;
  overflow: hidden;
  background: linear-gradient(135deg, #16251d 80%, #37d67a 100%);
  color: #e0f2da;
}

/* HEADER */
header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 25px;
  background-color: rgba(17, 73, 29, 0.9);
  box-shadow: 0 2px 15px rgba(15, 64, 26, 0.7);
  position: fixed;
  width: 100%;
  top: 0; left: 0;
  z-index: 1100;
  border-bottom: 2px solid #278234;
}
header .logo img {
  height: 42px;
  border-radius: 7px;
  box-shadow: 0 0 16px 3px #42e97366;
}
header .logo span {
  margin-left: 14px;
  font-weight: 700;
  font-size: 1.7rem;
  color: #caf2b6;
  text-shadow: 0 1.5px #248425;
}
.toolbar button {
  font-family: 'Orbitron', sans-serif;
  font-size: 0.95rem;
  color: #d9f7d9;
  background: linear-gradient(90deg, #04a300, #006400);
  padding: 8px 22px;
  border-radius: 16px;
  box-shadow: 0 0 12px #41ee3733;
  border: none;
  margin-left: 12px;
  cursor: pointer;
  transition: all 0.25s ease;
}
.toolbar button:hover {
  background: linear-gradient(90deg, #39db3b, #1a6300);
  box-shadow: 0 0 18px #6ef041cc;
  transform: scale(1.07);
}

/* SIDEBAR KANAN */
#sidebar-dashboard {
  position: fixed;
  top: 70px;
  right: 0;
  width: 320px;
  max-width: 90vw;
  height: calc(100% - 70px);
  background: rgba(18, 53, 28, 0.85);
  backdrop-filter: blur(9px);
  box-shadow: -3px 0 15px rgba(27, 136, 43, 0.9);
  border-left: 2px solid #1abb3c;
  padding: 25px 18px 35px 18px;
  overflow-y: auto;
  font-size: 1rem;
  color: #d0f0bb;
  z-index: 1050;
  transition: transform 0.3s ease;
}

#sidebar-dashboard.hidden {
  transform: translateX(100%);
}
.sidebar-header {
  display: flex;
  align-items: center;
  margin-bottom: 25px;
  gap: 10px;
}

.sidebar-hide-btn {
  background: transparent;
  border: 1px solid rgba(26, 187, 60, 0.4);
  color: #8ef67d;
  width: 32px;
  height: 32px;
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  transition: all 0.3s;
  flex-shrink: 0;
}

.sidebar-hide-btn:hover {
  background: rgba(26, 187, 60, 0.2);
  border-color: rgba(26, 187, 60, 0.6);
  color: #caf2b6;
}

.tabs {
  display: flex;
  justify-content: center;
  border-bottom: 2px solid #28ce3b;
  margin-bottom: 14px;
}
.tab-btn {
  flex-grow: 1;
  padding: 11px 0;
  border: none;
  background: none;
  color: #9cdeb0;
  font-weight: 600;
  cursor: pointer;
  letter-spacing: 0.8px;
  transition: color 0.3s;
}
.tab-btn.active, .tab-btn:hover {
  color: #d4ffd6;
  box-shadow: inset 0 -3px 0 0 #2aff3a;
}
.tab-content {
  display: none;
  padding: 16px 6px 12px 14px;
}
.tab-content.active {
  display: block;
}
.filter-panel label {
  display: block;
  margin: 18px 0 10px 0;
  font-weight: 700;
  color: #8ef67d;
  font-size: 0.96rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.filter-panel select {
  width: 100%;
  padding: 12px 14px;
  border-radius: 10px;
  border: 2px solid rgba(26, 187, 60, 0.4);
  font-size: 0.96rem;
  color: #0d2812;
  background: linear-gradient(135deg, #d4f3cc, #e0ffd4);
  box-shadow: 0 4px 12px rgba(26, 187, 60, 0.2), inset 0 1px 2px rgba(255, 255, 255, 0.5);
  transition: all 0.3s ease;
  font-weight: 600;
  cursor: pointer;
}

.filter-panel select:hover, .filter-panel select:focus {
  background: linear-gradient(135deg, #e0ffd4, #ecffe8);
  border-color: rgba(26, 187, 60, 0.7);
  box-shadow: 0 6px 16px rgba(26, 187, 60, 0.3), inset 0 1px 2px rgba(255, 255, 255, 0.6);
  outline: none;
  transform: translateY(-1px);
}

.layer-control {
  background: linear-gradient(135deg, rgba(26, 187, 60, 0.12), rgba(26, 187, 60, 0.08));
  padding: 14px;
  border-radius: 10px;
  border: 2px solid rgba(26, 187, 60, 0.25);
  margin: 16px 0;
  box-shadow: 0 2px 8px rgba(26, 187, 60, 0.1);
  transition: all 0.3s ease;
}

.layer-control:hover {
  border-color: rgba(26, 187, 60, 0.4);
  box-shadow: 0 4px 12px rgba(26, 187, 60, 0.15);
}

.layer-control label {
  display: flex;
  align-items: center; 
  font-weight: 600;
  margin-bottom: 12px;
  color: #c8e6be;
  cursor: pointer;
  transition: all 0.3s ease;
  font-size: 0.95rem;
}

.layer-control label:hover {
  color: #8ef67d;
  transform: translateX(2px);
}

.layer-control label:last-child {
  margin-bottom: 0;
}

.layer-control input[type="checkbox"] {
  margin-right: 10px;
  width: 20px;
  height: 20px;
  cursor: pointer;
  accent-color: #1abb3c;
  border-radius: 4px;
  transition: transform 0.2s ease;
}

.layer-control input[type="checkbox"]:checked {
  transform: scale(1.05);
}

.upload-panel {
  margin: 20px 0 14px 0;
}

.upload-panel label {
  font-weight: 700;
  color: #8ef67d;
  font-size: 0.96rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  display: block;
  margin-bottom: 10px;
}

.upload-panel input[type="file"] {
  width: 100%;
  padding: 14px;
  border-radius: 10px;
  border: 2px dashed rgba(26, 187, 60, 0.4);
  background: linear-gradient(135deg, rgba(26, 187, 60, 0.08), rgba(26, 187, 60, 0.04));
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(26, 187, 60, 0.1);
  color: #a9d49f;
  font-size: 0.9rem;
  transition: all 0.3s ease;
  font-weight: 500;
}

.upload-panel input[type="file"]:hover {
  background: linear-gradient(135deg, rgba(26, 187, 60, 0.12), rgba(26, 187, 60, 0.08));
  border-color: rgba(26, 187, 60, 0.6);
  box-shadow: 0 4px 14px rgba(26, 187, 60, 0.2);
  border-width: 2px;
}

.upload-panel input[type="file"]:focus {
  outline: none;
  border-color: rgba(26, 187, 60, 0.8);
  box-shadow: 0 6px 16px rgba(26, 187, 60, 0.25);
}
.button-panel {
  margin-top: 18px;
  display: flex;
  gap: 10px;
}
.btn-green, .btn-blue {
  flex: 1;
  border-radius: 10px;
  padding: 12px 14px;
  border: none;
  font-weight: 700;
  font-size: 0.9rem;
  color: white;
  cursor: pointer;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.btn-green {
  background: linear-gradient(135deg, #1abb3c, #0f8a4f);
  box-shadow: 0 4px 12px rgba(26, 187, 60, 0.25);
  border: 1px solid rgba(26, 187, 60, 0.3);
}

.btn-green:hover {
  background: linear-gradient(135deg, #20a759, #155835);
  box-shadow: 0 6px 16px rgba(26, 187, 60, 0.4);
  transform: translateY(-2px);
}

.btn-green:active {
  transform: translateY(0);
}

.btn-blue {
  background: linear-gradient(135deg, #3a82bd, #2563a8);
  box-shadow: 0 4px 12px rgba(58, 130, 189, 0.25);
  border: 1px solid rgba(58, 130, 189, 0.3);
}

.btn-blue:hover {
  background: linear-gradient(135deg, #4a92cd, #3573b8);
  box-shadow: 0 6px 16px rgba(58, 130, 189, 0.4);
  transform: translateY(-2px);
}

.btn-blue:active {
  transform: translateY(0);
}

/* Part Legend Tab */
#legend-tab h4 {
  margin-bottom: 13px;
  font-weight: 700;
  text-align: center;
  color: #cde6b9;
}
#legend-tab ul {
  list-style: none;
  padding-left: 16px;
}
#legend-tab ul li {
  margin:  12px 0;
  font-weight: 600;
  display: flex;
  align-items: center;
  color: #a9d49f;
}
#legend-tab ul li span {
  min-width: 20px;
  min-height: 20px;
  margin-right: 14px;
  border-radius: 4px;
}

/* Toolbar kiri */
.toolbar-left {
  position: fixed;
  top: 80px;
  left: 14px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  background: rgba(26, 56, 29, 0.72);
  border-radius: 18px;
  padding: 12px 8px 12px 8px;
  box-shadow: 0 0 20px 3px #30e13e90;
  z-index: 1200;
}
.toolbar-left button {
  width: 45px;
  height: 45px;
  background: #23d347;
  border: none;
  border-radius: 60%;
  color: #112511;
  font-size: 1.3rem;
  cursor: pointer;
  outline: none;
  box-shadow: 0 0 16px #49dd3a84;
  transition: 0.25s ease all;
}
.toolbar-left button:hover {
  background: #1c9e11;
  box-shadow: 0 0 28px #7cffa064;
  transform: scale(1.15);
}

/* Toolbar kanan */
  .toolbar-left {
    position: fixed;
    top: 50px;
    left: 10px;
    background: rgba(27, 55, 43, 0.78);
    border-radius: 16px;
    padding: 8px 2px;
    box-shadow: 0 0 24px #1de98e4d;
    display: flex;
    flex-direction: column;
    gap: 8px;
    z-index: 1150;
    width: 56px;
    min-width: 44px;
    align-items: center;
    height: auto;
    max-height: 90vh;
    overflow-y: auto;
  }

.toolbar-right-btn {
  width: 44px;
  height: 44px;
  background: linear-gradient(135deg, #1abb3c, #0f8a4f);
  border: 1px solid rgba(26, 187, 60, 0.4);
  border-radius: 8px;
  color: #e0f7e8;
  font-size: 1.2rem;
  cursor: pointer;
  outline: none;
  box-shadow: 0 4px 12px rgba(26, 187, 60, 0.25);
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.toolbar-right-btn:hover {
  background: linear-gradient(135deg, #20a759, #155835);
  border-color: rgba(26, 187, 60, 0.6);
  box-shadow: 0 6px 16px rgba(26, 187, 60, 0.4);
  transform: translateY(-2px);
}

.toolbar-right-btn:active {
  transform: translateY(0);
}

/* Basemap Dropdown */
.basemap-dropdown {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.basemap-menu {
  position: absolute;
  top: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  background: rgba(18, 53, 28, 0.97);
  border: 2px solid rgba(26, 187, 60, 0.5);
  border-radius: 14px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.5), inset 0 1px 0 rgba(26, 187, 60, 0.2);
  padding: 10px 0;
  min-width: 180px;
  max-width: 260px;
  display: none;
  flex-direction: column;
  gap: 0;
  z-index: 2000;
  backdrop-filter: blur(10px);
  max-height: 320px;
  overflow-y: auto;
  animation: slideUp 0.25s ease;
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.basemap-menu.active {
  display: flex;
  z-index: 2000;
}

.basemap-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  box-sizing: border-box;
  padding: 14px 18px;
  color: #c8e6c9;
  cursor: pointer;
  font-size: 0.95rem;
  font-weight: 500;
  transition: all 0.25s ease;
  border-left: 3px solid transparent;
  position: relative;
}

.basemap-item::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: linear-gradient(to bottom, #1abb3c, #0f8a4f);
  opacity: 0;
  transition: opacity 0.25s ease;
}

.basemap-item:hover {
  background: linear-gradient(90deg, rgba(26, 187, 60, 0.2), rgba(26, 187, 60, 0.05));
  border-left-color: #1abb3c;
  color: #8ef67d;
}

/* Ensure right toolbar dropdown opens to the left of the button (global rule) */
.toolbar-right .basemap-menu {
  top: calc(100% + 6px);
  right: 100%;
  left: auto;
  transform: none;
  width: 180px;
  box-sizing: border-box;
}

.basemap-item i {
  font-size: 1.15rem;
  color: #1abb3c;
  min-width: 24px;
  text-align: center;
  transition: all 0.25s ease;
}

.basemap-item:hover i {
  color: #8ef67d;
  transform: scale(1.1);
}

/* Peta */
#map {
  position: absolute;
  top: 70px;
  left: 0;
  right: 0;
  bottom: 80px;
  z-index: 1;
  border-radius: 12px;
  box-shadow: inset 0 0 35px #29a62a;
}

/* Summary table tampilan */
.data-table {
  position: fixed;
  bottom: 8px;
  left: 24px;
  background: rgba(25, 60, 27, 0.95);
  padding: 0;
  border-radius: 12px;
  box-shadow: 0 4px 20px rgba(26, 187, 60, 0.4);
  max-width: 700px;
  width: 90vw;
  max-height: 280px;
  z-index: 1150;
  color: #d0f0bb;
  border: 1px solid rgba(26, 187, 60, 0.3);
  display: flex;
  flex-direction: column;
  transition: max-height 0.3s ease, opacity 0.3s ease;
}

.data-table.hidden {
  max-height: 0;
  opacity: 0;
  pointer-events: none;
}

.data-table.compact {
  max-height: 200px;
}

.table-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 15px;
  background: rgba(26, 187, 60, 0.1);
  border-bottom: 1px solid rgba(26, 187, 60, 0.3);
  flex-shrink: 0;
}

.table-header h4 {
  margin: 0;
  font-size: 0.95rem;
  color: #8ef67d;
}

.table-controls {
  display: flex;
  gap: 6px;
}

.table-btn {
  background: rgba(26, 187, 60, 0.2);
  border: 1px solid rgba(26, 187, 60, 0.4);
  color: #8ef67d;
  width: 28px;
  height: 28px;
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  transition: all 0.3s;
}

.table-btn:hover {
  background: rgba(26, 187, 60, 0.4);
  border-color: rgba(26, 187, 60, 0.6);
  color: #caf2b6;
  transform: scale(1.1);
}

.data-table table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
  font-weight: 600;
  overflow-y: auto;
  flex: 1;
}

.data-table th,
.data-table td {
  border: none;
  padding: 8px 10px;
  text-align: center;
  vertical-align: middle;
}

.data-table thead {
  border-bottom: 1px solid rgba(26, 187, 60, 0.3);
  color: #8ef67d;
  background: rgba(26, 187, 60, 0.05);
  position: sticky;
  top: 0;
}

.data-table tbody tr {
  border-bottom: 1px solid rgba(26, 187, 60, 0.15);
  transition: background 0.3s;
}

.data-table tbody tr:hover {
  background: rgba(26, 187, 60, 0.12);
}

.data-table .kerapatan-name {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-weight: 700;
  font-size: 0.85rem;
}

.data-table .color-indicator {
  width: 14px;
  height: 14px;
  border-radius: 3px;
  flex-shrink: 0;
}

.data-table .luas-value {
  color: #8ef67d;
  font-weight: 700;
  font-size: 0.85rem;
  min-width: 65px;
  text-align: center;
}

.data-table .persen-value {
  color: #a9d49f;
  min-width: 45px;
  text-align: center;
  font-size: 0.85rem;
}

.data-table .bar-container {
  width: 100%;
  height: 16px;
  background: rgba(0, 0, 0, 0.2);
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid rgba(26, 187, 60, 0.3);
}

.data-table .bar {
  height: 100%;
  transition: width 0.5s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 6px;
  font-size: 10px;
  font-weight: 700;
  color: white;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}

.data-table .bar-lebat {
  background: linear-gradient(90deg, #2ecc40, #26aa36);
}

.data-table .bar-sedang {
  background: linear-gradient(90deg, #a4e69b, #7dbf73);
}

.data-table .bar-jarang {
  background: linear-gradient(90deg, #f3ffbd, #d4e895);
}


/* Comprehensive Responsive Design */

/* Large desktops and laptops */
@media screen and (max-width: 1200px) {
  #sidebar-dashboard {
    width: 300px;
  }

  .toolbar-left button {
    width: 42px;
    height: 42px;
    font-size: 1.2rem;
  }

  .toolbar-right-btn {
    width: 42px;
    height: 42px;
    font-size: 1.1rem;
  }

  .basemap-menu {
    min-width: 180px;
  }
}

/* Medium desktops and laptops */
@media screen and (max-width: 1024px) {
  #sidebar-dashboard {
    width: 280px;
  }

  header .logo span {
    font-size: 1.5rem;
  }

  .toolbar-left button {
    width: 40px;
    height: 40px;
    font-size: 1.1rem;
  }

  .toolbar-right-btn {
    width: 40px;
    height: 40px;
    font-size: 1rem;
  }

  .basemap-menu {
    min-width: 160px;
  }

  .basemap-item {
    padding: 12px 16px;
    font-size: 0.9rem;
  }
}

/* Tablets */
@media screen and (max-width: 768px) {
  header {
    padding: 8px 15px;
  }

  header .logo img {
    height: 36px;
  }

  header .logo span {
    font-size: 1.3rem;
    margin-left: 10px;
  }

  #sidebar-dashboard {
    width: 90vw;
    height: 50vh;
    position: fixed;
    bottom: 0;
    right: 0;
    top: auto;
    left: 5vw;
    border-left: none;
    border-top: 2px solid #1bdc87;
    padding: 20px 15px;
  }

  #map {
    top: 60px;
    bottom: 55vh;
    left: 0;
    right: 0;
    border-radius: 0;
  }

  .data-table {
    max-width: 90vw;
    left: 5vw;
    bottom: 8px;
    max-height: 200px;
  }

  .toolbar-left {
    top: 70px;
    left: 5px;
    gap: 12px;
  }

    .toolbar-left button {
      width: 44px;
      height: 44px;
      background: #1de98e;
      border: none;
      border-radius: 50%;
      color: #0b3d22;
      font-size: 1.4rem;
      cursor: pointer;
      outline: none;
      box-shadow: 0 0 20px #29e464af;
      transition: background-color 0.3s, transform 0.2s;
      margin: 0;
      display: flex;
      align-items: center;
      justify-content: center;
    }
    .toolbar-left .basemap-dropdown {
      width: 44px;
      margin: 0;
      position: relative;
    }
    .toolbar-left .basemap-dropdown button {
      width: 44px;
      height: 44px;
      border-radius: 50%;
      padding: 0;
    }
    .toolbar-left .basemap-menu {
      top: calc(100% + 6px);
      left: 50%;
      transform: translateX(-50%);
      min-width: 140px;
      max-width: 220px;
      border-radius: 12px;
      z-index: 1200;
    }
    /* For right-side toolbar: show dropdown to the left of the button */
    .toolbar-right .basemap-menu {
      top: calc(100% + 6px);
      right: 100%;
      left: auto;
      transform: none;
      width: 180px; /* fixed width to avoid expanding */
      min-width: 140px;
      max-width: 220px;
      border-radius: 12px;
      z-index: 1300;
      box-sizing: border-box;
    }
    /* removed stray width, height, font-size */
  }

  .sidebar-header span {
    font-size: 1.4rem;
  }

  .filter-panel select,
  .upload-panel input[type="file"] {
    font-size: 14px;
    padding: 10px 12px;
  }

  .btn-green,
  .btn-blue {
    font-size: 14px;
    padding: 10px 12px;
  }

  .data-table th,
  .data-table td {
    padding: 6px 8px;
    font-size: 0.8rem;
  }

  .data-table .kerapatan-name {
    font-size: 0.8rem;
  }

  .data-table .luas-value,
  .data-table .persen-value {
    font-size: 0.8rem;
  }

/* Mobile landscape */
@media screen and (max-width: 640px) {
  header {
    padding: 6px 12px;
  }

  header .logo img {
    height: 32px;
  }

  header .logo span {
    font-size: 1.2rem;
    margin-left: 8px;
  }

  #sidebar-dashboard {
    width: 95vw;
    height: 45vh;
    left: 2.5vw;
    right: 2.5vw;
    padding: 15px 12px;
  }

  #map {
    top: 50px;
    bottom: 50vh;
  }

  .data-table {
    max-width: 95vw;
    left: 2.5vw;
    max-height: 180px;
  }

  .toolbar-left {
    top: 60px;
    gap: 10px;
  }

  .toolbar-left button {
    width: 35px;
    height: 35px;
    font-size: 0.95rem;
  }

  .toolbar-right {
    top: 60px;
    gap: 8px;
  }

  .toolbar-right-btn {
    width: 35px;
    height: 35px;
    font-size: 0.9rem;
  }

  .sidebar-header span {
    font-size: 1.3rem;
  }

  .filter-panel select,
  .upload-panel input[type="file"] {
    font-size: 13px;
    padding: 8px 10px;
  }

  .btn-green,
  .btn-blue {
    font-size: 13px;
    padding: 8px 10px;
  }

  .data-table th,
  .data-table td {
    padding: 5px 6px;
    font-size: 0.75rem;
  }

  .data-table .kerapatan-name {
    font-size: 0.75rem;
  }

  .data-table .luas-value,
  .data-table .persen-value {
    font-size: 0.75rem;
  }
}

/* Mobile portrait */
@media screen and (max-width: 480px) {
  header {
    padding: 4px 10px;
  }

  header .logo img {
    height: 28px;
  }

  header .logo span {
    font-size: 1.1rem;
    margin-left: 6px;
  }

  #sidebar-dashboard {
    width: 98vw;
    height: 40vh;
    left: 1vw;
    right: 1vw;
    padding: 12px 10px;
  }

  #map {
    top: 45px;
    bottom: 45vh;
  }

  .data-table {
    max-width: 98vw;
    left: 1vw;
    max-height: 160px;
  }

  .toolbar-left {
    top: 50px;
    left: 3px;
    gap: 8px;
  }

  .toolbar-left button {
    width: 32px;
    height: 32px;
    font-size: 0.9rem;
  }

  .toolbar-right {
    top: 50px;
    right: 3px;
    gap: 6px;
  }

  .toolbar-right-btn {
    width: 32px;
    height: 32px;
    font-size: 0.85rem;
  }

  .sidebar-header span {
    font-size: 1.2rem;
  }

  .sidebar-hide-btn {
    width: 28px;
    height: 28px;
    font-size: 0.9rem;
  }

  .filter-panel select,
  .upload-panel input[type="file"] {
    font-size: 12px;
    padding: 6px 8px;
  }

  .btn-green,
  .btn-blue {
    font-size: 12px;
    padding: 6px 8px;
  }

  .data-table th,
  .data-table td {
    padding: 4px 5px;
    font-size: 0.7rem;
  }

  .data-table .kerapatan-name {
    font-size: 0.7rem;
  }

  .data-table .luas-value,
  .data-table .persen-value {
    font-size: 0.7rem;
  }

  .basemap-menu {
    min-width: 140px;
    max-height: 250px;
  }

  .basemap-item {
    padding: 10px 14px;
    font-size: 0.85rem;
  }

  .basemap-item i {
    font-size: 1rem;
  }
}

/* Small mobile devices */
@media screen and (max-width: 360px) {
  header {
    padding: 3px 8px;
  }

  header .logo img {
    height: 24px;
  }

  header .logo span {
    font-size: 1rem;
    margin-left: 4px;
  }

  #sidebar-dashboard {
    width: 99vw;
    height: 35vh;
    left: 0.5vw;
    right: 0.5vw;
    padding: 10px 8px;
  }

  #map {
    top: 40px;
    bottom: 40vh;
  }

  .data-table {
    max-width: 99vw;
    left: 0.5vw;
    max-height: 140px;
  }

  .toolbar-left {
    top: 45px;
    gap: 6px;
  }

  .toolbar-left button {
    width: 28px;
    height: 28px;
    font-size: 0.8rem;
  }

  .toolbar-right {
    top: 45px;
    gap: 4px;
  }

  .toolbar-right-btn {
    width: 28px;
    height: 28px;
    font-size: 0.8rem;
  }

  .sidebar-header span {
    font-size: 1.1rem;
  }

  .sidebar-hide-btn {
    width: 24px;
    height: 24px;
    font-size: 0.8rem;
  }

  .filter-panel select,
  .upload-panel input[type="file"] {
    font-size: 11px;
    padding: 4px 6px;
  }

  .btn-green,
  .btn-blue {
    font-size: 11px;
    padding: 4px 6px;
  }

  .data-table th,
  .data-table td {
    padding: 3px 4px;
    font-size: 0.65rem;
  }

  .data-table .kerapatan-name {
    font-size: 0.65rem;
  }

  .data-table .luas-value,
  .data-table .persen-value {
    font-size: 0.65rem;
  }

  .basemap-menu {
    min-width: 120px;
    max-height: 200px;
  }

  .basemap-item {
    padding: 8px 12px;
    font-size: 0.8rem;
  }

  .basemap-item i {
    font-size: 0.9rem;
  }
}

/* Touch devices optimization */
@media (hover: none) and (pointer: coarse) {
  .toolbar-left button:hover,
  .toolbar-right-btn:hover,
  .btn-green:hover,
  .btn-blue:hover,
  .table-btn:hover,
  .basemap-item:hover {
    transform: none;
  }

  .toolbar-left button,
  .toolbar-right-btn {
    width: 48px;
    height: 48px;
  }

  .toolbar-left button {
    font-size: 1.4rem;
  }

  .toolbar-right-btn {
    font-size: 1.3rem;
  }

  .btn-green,
  .btn-blue {
    min-height: 44px;
  }

  .filter-panel select,
  .upload-panel input[type="file"] {
    min-height: 44px;
  }
}

/* High DPI displays */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
  header .logo img,
  .sidebar-header img,
  .data-table .color-indicator {
    image-rendering: -webkit-optimize-contrast;
    image-rendering: crisp-edges;
  }
}

/* Landscape orientation adjustments */
@media (max-height: 500px) and (orientation: landscape) {
  #sidebar-dashboard {
    height: 70vh;
  }

  #map {
    bottom: 75vh;
  }

  .data-table {
    bottom: 2px;
    max-height: 120px;
  }

  .toolbar-left,
  .toolbar-right {
    top: 50px;
  }
}

/* Print styles */
@media print {
  #sidebar-dashboard,
  .toolbar-left,
  .toolbar-right,
  .data-table {
    display: none !important;
  }

  #map {
    position: static !important;
    height: 100vh !important;
  }
}

/* Styling untuk Popup Lokasi */
.lokasi-popup .leaflet-popup-content {
  margin: 0;
  padding: 0;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  max-height: 70vh;
  overflow-y: auto;
}

.lokasi-popup .leaflet-popup-content-wrapper {
  border-radius: 8px;
  background: white;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
  transition: max-width 0.3s ease;
  max-width: 520px;
}

.lokasi-popup .leaflet-popup-tip {
  background: white;
}

.lokasi-popup h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
}

.lokasi-popup p {
  margin: 5px 0;
  font-size: 13px;
  color: #333;
}

.lokasi-popup img {
  border-radius: 4px;
  border: 1px solid #e0e0e0;
  width: 100%;
  height: auto;
}

.lokasi-popup img:hover {
  border-color: #1abb3c;
  box-shadow: 0 2px 8px rgba(26, 187, 60, 0.3);
  transform: none;
}

/* Ensure popup text wraps and images scale responsively */
.lokasi-popup .leaflet-popup-content {
  white-space: normal;
}
.lokasi-popup .leaflet-popup-content img {
  max-width: 100%;
  height: auto;
  display: block;
}

/* Responsive popup untuk mobile */
@media (max-width: 600px) {
  .lokasi-popup .leaflet-popup-content-wrapper {
    max-width: 280px !important;
  }
}

