#map-container {
  position: relative;
  width: 100%;
  max-width: 1200px;
  background: #ffffff;
  padding: 20px;
  border-radius: 16px;
  box-shadow: 0 8px 24px rgba(220, 7, 7, 0.08);
  border: 1px solid rgba(232, 8, 8, 0.05);
  transition: box-shadow 0.3s ease, transform 0.25s ease;
}

/* Hiệu ứng khi hover */
#map-container:hover {
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.12);
  transform: translateY(-2px);
}

/* Thêm hiệu ứng nhẹ khi click */
#map-container:active {
  transform: translateY(0);
}

svg { width: 100%; height: auto; display: block; }

.map-tooltip {
  position: absolute;
  pointer-events: none;
  background: rgba(0,0,0,0.78);
  color: #fff;
  padding: 8px 10px;
  border-radius: 6px;
  font-size: 13px;
  white-space: normal;
  display: none;
  z-index: 50;
  max-width: 360px;
  max-height: 220px;
  overflow: auto;
}
.map-tooltip ul { margin: 6px 0 0 0; padding-left: 16px; }
.map-tooltip li { margin-bottom: 4px; }

.province-hover { fill: #d6eaff !important; cursor: pointer;}

#map-controls {
  position: absolute;
  top: 10px;
  right: 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  z-index: 999; /* đảm bảo nút nằm trên bản đồ */
}

#map-controls button {
  background-color: white;
  border: none;
  border-radius: 8px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
  padding: 8px 12px;
  font-size: 16px;
  font-weight: bold;
  color: #333;
  cursor: pointer;
  transition: all 0.2s ease;
}

#map-controls button:hover {
  background-color: #f0f0f0;
  transform: translateY(-1px);
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.2);
}

#map-controls button:active {
  transform: translateY(0);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.15);
}

#reset-zoom {
  font-size: 13px;
  font-weight: normal;
}

@media (max-width: 768px) {
  #map-container { width: 96%; }
  .map-tooltip { font-size: 12px; padding: 5px 8px; }
}

/* Popup */
.popup {
  position: absolute; /* sẽ đặt tương đối trong #map-container (nên đặt #map-container {position:relative}) */
  box-sizing: border-box;
  background: #ffffff;
  border-radius: 12px;
  padding: 16px 20px;
  max-width: min(320px, 90%); /* không quá 320px, hoặc 90% màn hình */
  min-width: 160px;
  width: max-content;
  box-shadow: 0 6px 20px rgba(0,0,0,0.15);
  z-index: 1000;
  display: none;           /* ẩn mặc định */
  font-family: 'Segoe UI', Tahoma, sans-serif;
  word-wrap: break-word;
  pointer-events: auto;
  transition: opacity .18s ease, transform .18s ease;
  opacity: 0;
  transform-origin: top center;
  transform: translateY(-6px); /* nhẹ effect khi xuất hiện */
}

/* trạng thái hiển thị */
.popup.is-visible {
  display: block; /* hiển thị */
  opacity: 1;
  transform: translateY(0);
}

/* nội dung */
.popup h3 {
  margin: 0 0 8px;
  font-size: 1.1rem;
  color: #333;
}

.popup p, .popup ul {
  font-size: 0.95rem;
  color: #555;
  margin: 0;
}

/* nút đóng */
.popup-close {
  position: absolute;
  top: 8px;
  right: 10px;
  font-size: 1.2rem;
  color: #aaa;
  cursor: pointer;
  transition: color 0.2s;
}
.popup-close:hover { color: #ff5c5c; }

/* trạng thái đặt vị trí (dùng để tuỳ chỉnh arrow hoặc thay đổi style nếu cần) */
.popup[data-placement="top"] { transform-origin: bottom center; }
.popup[data-placement="bottom"] { transform-origin: top center; }

/* Responsive: màn hình nhỏ -> chuyển popup thành fixed bottom center (không tràn) */
@media (max-width: 480px) {
  .popup {
    padding: 12px 14px;
    font-size: 0.9rem;
    border-radius: 10px;
    max-width: 320px;
    min-width: 0;
  }

  /* class popup--mobile sẽ được JS thêm vào để đảm bảo vị trí fixed */
  .popup.popup--mobile {
    position: fixed !important;
    left: 50% !important;
    transform: translateX(-50%) !important;
    bottom: 12px !important;
    top: auto !important;
    right: auto !important;
    max-width: calc(100% - 24px) !important;
    /* width: auto !important; */
    box-shadow: 0 10px 30px rgba(0,0,0,0.18);
  }

  .popup h3 { font-size: 1rem; }
  .popup p, .popup ul { font-size: 0.88rem; }
  .popup-close { font-size: 1.1rem; top: 6px; right: 8px; }
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}