/* ===== CUSTOM DESIGN SYSTEM ===== */
  :root {
    --bg-color: #f2f2f7;
    --surface-color: rgba(255, 255, 255, 0.72);
    --border-color: rgba(0, 0, 0, 0.08);
    --shadow-light: 0 4px 16px rgba(0, 0, 0, 0.06);
    --shadow-medium: 0 8px 32px rgba(0, 0, 0, 0.12);
    --active-color: #007AFF; /* iOS Blue */
    --active-bg: rgba(0, 122, 255, 0.1);
    --text-primary: #1c1c1e;
    --text-secondary: #8e8e93;
  }

  html, body {
    height: 100%;
    margin: 0;
    background-color: var(--bg-color);
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    color: var(--text-primary);
  }

  #map { height: 100vh; width: 100%; }

  /* ===== GLASSMORPHISM UTILITY CLASS ===== */
  .glassmorphism {
    background: var(--surface-color);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border: 1px solid var(--border-color);
  }

  /* ===== TOOLBAR ===== */
  .toolbar {
    position: fixed;
    left: 16px;
    top: 108px; /* Adjusted for floating nav height */
    z-index: 1000;
    border-radius: 16px;
    padding: 8px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    width: 52px;
    box-shadow: var(--shadow-light);
  }

  .tool {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    display: grid;
    place-items: center;
    cursor: pointer;
    transition: transform 0.15s ease-out, background-color 0.2s ease;
    border: 1px solid transparent;
  }

  .tool:hover {
    transform: scale(1.05);
    background-color: rgba(0, 0, 0, 0.03);
  }

  .tool:active {
    transform: scale(0.95);
  }

  .tool.active {
    background-color: var(--active-bg);
    border-color: var(--active-color);
  }

  .tool img {
    width: 20px;
    height: 20px;
    pointer-events: none; /* Prevents image from capturing click events */
  }

  .divider {
    height: 1px;
    background: var(--border-color);
    margin: 4px 8px;
  }

  /* ===== LEGEND (COLLAPSIBLE) ===== */
  .legend {
    position: fixed;
    right: 16px;
    bottom: 24px;
    z-index: 900;
    border-radius: 12px;
    font-size: 0.85rem;
    box-shadow: var(--shadow-light);
    overflow: hidden;
    transition: max-height 0.3s ease-out;
    max-height: 500px; /* Default height */
  }
  .legend.collapsed {
    max-height: 50px;
  }
  .legend-header {
    padding: 12px 16px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background-color: rgba(255, 255, 255, 0.5);
  }
  .legend-header .toggle-icon {
    transition: transform 0.3s ease;
  }
  .legend.collapsed .toggle-icon {
    transform: rotate(-90deg);
  }
  .legend-content {
    padding: 12px 16px;
  }
  .legend .litem {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 6px 0;
    white-space: nowrap;
  }
  .legend img {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
  }

  /* ===== FLOATING NAVBAR ===== */
  .floating-nav {
    position: fixed;
    top: 16px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 999;
    background: #0F2A6B;
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 20px;
    box-shadow: var(--shadow-medium);
    padding: 8px 16px;
    max-width: min(1280px, 96vw);
  }

  .floating-nav .navbar-brand {
    padding-right: 14px;
    margin-right: 18px;
    border-right: 1px solid rgba(255, 255, 255, 0.15);
  }

  .floating-nav .navbar-brand img { height: 32px; width: auto; }
  .floating-nav .nav-link {
    font-weight: 600;
    letter-spacing: 0.2px;
    color: rgba(255, 255, 255, 0.9) !important;
    padding: 8px 14px;
    border-radius: 12px;
    transition: background-color 0.2s ease;
  }
  .floating-nav .nav-link:hover, .floating-nav .nav-link:focus { background: rgba(255, 255, 255, 0.15); }
  .floating-nav .dropdown-menu {
    border-radius: 16px;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-medium);
    padding: 8px;
    min-width: 240px;
    font-size: 16px;
    z-index: 13000;
  }
  .floating-nav .dropdown-item { border-radius: 10px; padding: 10px 12px; }
  .floating-nav .dropdown-item:hover { background: var(--bg-color); }
  .floating-nav .navbar-toggler { border-color: rgba(255, 255, 255, 0.45); }
  .floating-nav .navbar-toggler-icon {
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 30 30'%3e%3cpath stroke='rgba(255,255,255,0.9)' stroke-linecap='round' stroke-width='2' d='M4 7h22M4 15h22M4 23h22'/%3e%3c/svg%3e");
  }

  /* ===== LOADER & SPINNER ===== */
  #loader {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 1100;
    border-radius: 20px;
    padding: 6px 14px;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
  }

  .spinner-container {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 2000;
    display: none;
  }
  .spinner {
    width: 50px;
    height: 50px;
    border: 4px solid var(--border-color);
    border-radius: 50%;
    border-top-color: var(--active-color);
    animation: spin 1s ease-in-out infinite;
  }
  @keyframes spin { to { transform: rotate(360deg); } }

  /* ===== MODAL ===== */
  .modal-content {
    border: none;
    border-radius: 20px;
    box-shadow: var(--shadow-medium);
  }
  .modal-header { border-bottom: 1px solid var(--border-color); }
  .modal-footer { border-top: 1px solid var(--border-color); }

  /* ===== TOAST NOTIFICATION ===== */
  .toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 2000;
  }
  .toast {
    border-radius: 12px;
    padding: 12px 16px;
    box-shadow: var(--shadow-light);
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 12px;
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.3s, transform 0.3s;
    max-width: 350px;
    background: var(--surface-color);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
  }
  .toast.show { opacity: 1; transform: translateY(0); }
  .toast-icon { font-size: 1.2rem; }
  .toast.success .toast-icon { color: #34c759; }
  .toast.error .toast-icon { color: #ff3b30; }
  .toast.info .toast-icon { color: var(--active-color); }
  .toast.warning .toast-icon { color: #ff9500; }
  .toast-body { font-weight: 500; }

  /* ===== SEARCH MODAL ===== */
  .search-item { cursor:pointer; }
  .search-meta { color: var(--text-secondary); font-size: .85rem; }
  #results .list-group-item { border: none; border-radius: 10px; margin-bottom: 4px; }
  #results .list-group-item:hover { background-color: var(--bg-color); }

  /* ===== LEAFLET CONTROLS (STYLED) ===== */

  /* --- Zoom Control --- */
  .leaflet-control-zoom {
    border: none !important;
    box-shadow: var(--shadow-light) !important;
    border-radius: 12px !important;
    overflow: hidden;
  }
  .leaflet-control-zoom a {
    background: var(--surface-color) !important;
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border-bottom: 1px solid var(--border-color) !important;
    color: var(--text-primary) !important;
    font-size: 18px !important;
    line-height: 34px !important;
    width: 36px !important;
    height: 36px !important;
    transition: all 0.2s ease;
  }
  .leaflet-control-zoom a:last-child {
    border-bottom: none !important;
  }
  .leaflet-control-zoom a:hover {
    background-color: var(--active-bg) !important;
    color: var(--active-color) !important;
  }

  /* --- Popup --- */
  .leaflet-popup-content-wrapper {
    border-radius: 16px !important;
    box-shadow: var(--shadow-medium) !important;
    background: var(--surface-color) !important;
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
  }
  .leaflet-popup-content {
    margin: 16px !important;
    font-family: inherit !important;
    color: var(--text-primary) !important;
  }
  .leaflet-popup-tip {
    box-shadow: var(--shadow-light) !important;
    background: var(--surface-color) !important;
  }
  .leaflet-container a.leaflet-popup-close-button {
    padding: 8px 8px 0 0 !important;
    color: var(--text-secondary) !important;
    font-size: 20px !important;
  }
  .leaflet-container a.leaflet-popup-close-button:hover {
    color: var(--text-primary) !important;
  }

  /* ===== RAINVIEWER CONTROL BARU ===== */
  .rv-ctrl{
    position: fixed; left:50%; bottom: 84px; transform: translateX(-50%);
    z-index: 12040;
    background:#fff; border:1px solid rgba(16,24,40,.12);
    border-radius: 999px; box-shadow: 0 10px 24px rgba(16,24,40,.12);
    display:flex; align-items:center; gap:10px; padding:8px 10px;
    font-weight:600; color:#3b4559;
  }
  .rv-ctrl .rv-label{ background:#f7f8fb; border:1px solid rgba(16,24,40,.08); padding:6px 10px; border-radius:999px; font-size:13px; min-width:142px; text-align:center; }
  .rv-ctrl .rv-btn{ width:36px; height:36px; display:grid; place-items:center; border:1px solid rgba(16,24,40,.12); border-radius:999px; cursor:pointer; background:#fff; transition:transform .06s ease, background .12s ease; }
  .rv-ctrl .rv-btn:active{ transform:scale(.98); background:#f1f4ff; }
  .rv-ctrl .rv-btn[disabled]{ opacity:.45; pointer-events:none; }
  .rv-hidden{ display:none; }

  /* TAMBAHKAN: CSS untuk Slider Transparansi */
  .rv-opacity-ctrl {
    position: fixed;
    left: 50%;
    bottom: 40px; /* Posisikan di bawah kontrol utama */
    transform: translateX(-50%);
    z-index: 12040;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    background: #fff;
    border: 1px solid rgba(16, 24, 40, 0.12);
    border-radius: 999px; /* Bentuk pil */
    box-shadow: 0 4px 12px rgba(16, 24, 40, 0.08);
    font-weight: 600;
    color: #3b4559;
  }
  .rv-opacity-label {
    font-size: 13px;
    white-space: nowrap;
  }
  .rv-opacity-slider {
    -webkit-appearance: none;
    width: 100px; /* Lebar slider */
    height: 6px;
    border-radius: 3px;
    background: #e0e0e0;
    outline: none;
  }
  .rv-opacity-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #007AFF; /* Warna biru untuk thumb */
    cursor: pointer;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
  }
  .rv-opacity-slider::-moz-range-thumb {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #007AFF;
    cursor: pointer;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
    border: none;
  }
  .rv-hidden {
	  display: none !important;
  }
  .leaflet-radar-tile {
	  opacity: 0;
	  transition: opacity 520ms ease-in-out;
	  will-change: opacity;
	}


  /* ===== RESPONSIVE ===== */
  @media (max-width: 768px) {
    .floating-nav {
      left: 12px;
      right: 12px;
      transform: none;
      padding: 6px 10px;
    }
    .toolbar {
      top: 96px;
      left: 12px;
    }
    .legend {
      left: 12px;
      right: 12px;
      bottom: 12px;
    }
  }