:root {
  --header-height: 48px;
}

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: 'Segoe UI', sans-serif;
  overflow-x: hidden;
  overflow-y: auto;
}

#map {
  position: absolute;
  top: var(--header-height);
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 0;
  transition: top 0.3s ease;
}

/* HEADER */
.header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--header-height);
  background-color: #7b4c00;
  color: white;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  z-index: 1000;
  box-shadow: 0 2px 5px rgba(0,0,0,0.2);
  transition: all 0.3s ease;
  flex-wrap: wrap;
}

/* BRANDING */
.branding {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.branding img {
  height: 36px;
  max-height: 100%;
  width: auto;
}

.branding h1 {
  font-size: 1.2rem;
  margin: 0;
  font-weight: 600;
  color: rgb(225, 191, 19);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* MENU TOGGLE (untuk mobile) */
.menu-toggle {
  display: none;
  font-size: 1.5rem;
  cursor: pointer;
}

/* HEADER ICONS */
.header-icons {
  display: flex;
  gap: 15px;
  align-items: center;
  flex-wrap: wrap;
}

.header-icons i {
  font-size: 1.25rem;
  cursor: pointer;
  padding: 6px;
  border-radius: 6px;
  transition: background-color 0.2s ease;
}

.header-icons i:hover {
  background-color: rgba(255,255,255,0.15);
}

#layerManager, #legend, #uploadContainer {
  background: white;
  padding: 10px;
  position: absolute;
  bottom: 10px;
  top: 57px;
  right: 7px;
  z-index: 1000;
  max-width: 100%;
  min-width: 350px; /* Menjamin panel tidak terlalu kecil */
  max-height: 100%;
  display: none;
  min-height: 200px; /* Menjamin panel memiliki tinggi minimal yang seragam */
  font-weight:500;
  overflow-y: auto;
}

#layerManager img {
  max-height: 100%;
  object-fit: contain;
  margin-left: inherit;
}


#layerManager h3, #legend h3 {
  margin-top: 0;
}

    #info {
      position: absolute;
      bottom: 10px;
      left: 10px;
      max-width: 300px;
      max-height: 120px;
      overflow-y: auto;
      background: rgba(255,255,255,0.9);
      padding: 8px;
      font-size: 0.9rem;
      border: 1px solid #ccc;
      border-radius: 4px;
      z-index: 1000;
      white-space: pre-wrap;
      font-family: monospace;
    }

.toggle-legend-btn {
  background-color: transparent;
  margin: 0 0 0 0;
  border: none;
  cursor: pointer;
}
.toggle-legend-btn:hover {
  background-color: transparent;
}

/* RESPONSIVE */
@media (max-width: 850px) {
  #map {
    top: var(--header-height);
  }

  #layerManager,
  #legend,
  #uploadContainer{
      top: 60%; /* Menghilangkan posisi 'top' */
      right: 0px;
      left: 0px;
      bottom: 0px;
      min-width: 70%;
      min-height: 40%;
    }
  }
  
  #measure-control {
  position: absolute;
  top: 179px;
  left: 10px;
  width: 10px;
  z-index: 1000;
}

#ruler-btn {
  width: 32px;
  height: 32px;
  background: white;
  border-radius: 6px;
  border: 1px solid #888;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  top: 170px;
}

#measure-menu {
  background: white;
  border: 1px solid #ccc;
  border-radius: 6px;
  margin-top: 6px;
  width: 130px;
  display: none;
  box-shadow: 0 1px 4px rgba(0,0,0,0.2);
}

#measure-menu button {
  padding: 8px;
  font-size: 14px;
  border: none;
  width: 100%;
  background: none;
  text-align: left;
  cursor: pointer;
}
#measure-menu button:hover {
  background: #eee;
}

    #uploadBox { padding: 10px; background: #f8f8f8; }
    #info {
      margin-top: 8px;
      font-family: monospace;
      white-space: pre-wrap;
      max-height: 150px;
      overflow-y: auto;
    }

@media (max-width: 650px) {
  .header-icons {
    display: flex;
    width: auto;
    justify-content: flex-end;
    padding: 0;
    gap: 2px;
    flex-shrink: 0;
  }

  .branding h1 {
    font-size: 0.57rem;
    max-width: 165px;
  }
  .branding img {
    height: 28px;
  }
  .header-icons.show {
    display: flex;
  }
  .header-icons i {
    font-size: 1.1rem;
    padding: 6px;
    transition: background-color 0.2s ease;
    border-radius: 5px;
  }
  .header-icons i:hover {
    background-color: rgba(255,255,255,0.15);
  }
}