html,
body {
  height: 100%;
  max-height: 100%;
  overflow: hidden; /* Chặn scroll toàn trang */
  margin: 0;
  padding: 0;
}

#app {
  height: 100%;
  max-height: 100%;
  overflow: hidden;
}

#map {
  height: 100%;
  width: 100%;
}
/* ===== BASEMAP SWITCHER ===== */
#basemap-switcher {
  position: fixed;
  bottom: 20px;
  /* Căn trái bằng với sidebar (left: 0) + padding nhỏ */
  left: 10px;
  z-index: 5000;
  display: flex;
  flex-direction: row;
  gap: 10px;
}

.basemap-item {
  width: 80px;
  height: 80px;
  border-radius: 12px;
  overflow: hidden;
  cursor: pointer;
  background: #ffffff;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.35);
  border: 2px solid transparent;
  transition: all 0.2s ease;
  position: relative;
}

.basemap-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Tên bản đồ (nằm đè lên ảnh ở dưới đáy) */
.basemap-item span {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  text-align: center;
  padding: 2px 0;
  pointer-events: none; /* Giúp chuột xuyên qua chữ để click vào nút dễ hơn */
}

/* Hover: Nổi lên một chút */
.basemap-item:hover {
  transform: translateY(-4px); /* Tăng lên xíu cho cảm giác nảy hơn */
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.45);
}

/* Trạng thái active: Viền xanh */
.basemap-item.active {
  border-color: #3fa9f5;
  box-shadow: 0 0 0 2px rgba(63, 169, 245, 0.4); /* Giảm độ đậm shadow xanh cho tinh tế */
}

/* Chỉ ghi đè những gì KHÁC trên mobile */
/* Ngang điện thoại (landscape) */
/* Landscape mobile với initial-scale=0.4 */
/* 390px thực / 0.4 = 975px → cần max-height > 975px */
/* @media (max-width: 1920px) and (max-height: 1050px) and (orientation: landscape) {
  #basemap-switcher {
    bottom: 100px;
    left: 10px;
    gap: 6px;
  }
  .basemap-item {
    width: 100px;
    height: 100px;
    border-radius: 14px;
  }
  .basemap-item span {
    font-size: 14px;
  }
} */

/* Dọc điện thoại (portrait) — màn hình "rộng" 975px theo scale */
@media (max-width: 1080px) {
  #basemap-switcher {
    bottom: 100px;
    left: 16px; /* màn hình nhỏ: sidebar ẩn/fullwidth nên về sát trái */
    gap: 10px;
    transition: left 0.3s ease-in-out;
  }
  .basemap-item {
    width: 120px; /* To hơn vì scale=0.4 thu nhỏ còn 48px thực tế */
    height: 120px;
    border-radius: 16px;
  }
  .basemap-item span {
    font-size: 15px;
  }
}

/* ---- FULL CSS COPIED FROM Index.html (sidebar + layers) ---- */
:root {
  --bg: #0b1220;
  --panel: #0f1724;
  --muted: #94a3b8;
  --accent: #3fa9f5;
  --card: #071226;
  --glass: rgba(255, 255, 255, 0.02);
  --text: #e6eef6;
  --shadow: 0 8px 28px rgba(2, 6, 23, 0.9);
  --brand-grad: linear-gradient(135deg, var(--accent), #0d0d0d);
  --panel-border: rgba(255, 255, 255, 0.02);
  --checkbox-border: rgba(255, 255, 255, 0.2);
  --checkbox-border-hover: rgba(255, 255, 255, 0.35);
}
.light {
  --bg: #f7fafc;
  --panel: #ffffff;
  --muted: #475569;
  --accent: #2563eb;
  --card: #ffffff;
  --glass: rgba(232, 234, 239, 0.02);
  --text: #0f1724;
  --shadow: 0 6px 18px rgba(2, 6, 23, 0.06);
  --brand-grad: linear-gradient(135deg, var(--accent), #1e40af);
  --panel-border: rgba(15, 23, 36, 0.06);
  --checkbox-border: rgba(15, 23, 42, 0.18);
  --checkbox-border-hover: rgba(15, 23, 42, 0.4);
}

/* === NÚT ĐĂNG NHẬP ĐẸP HƠN === */
#login-btn {
  background: var(--accent);
  color: white;
  border: none;
  padding: 10px 18px;
  font-size: 15px;
  font-weight: 600;
  border-radius: 10px;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(0, 120, 255, 0.35);
  transition: all 0.25s ease;
}

/* Hover: sáng hơn và nổi lên */
#login-btn:hover {
  background: linear-gradient(135deg, var(--accent), #4cb3ff);
  box-shadow: 0 6px 16px rgba(0, 120, 255, 0.9);
  transform: translateY(-1px);
}

/* Active: nhấn xuống nhẹ */
#login-btn:active {
  transform: translateY(0px);
  box-shadow: 0 3px 10px rgba(0, 120, 255, 0.25);
}

html,
body {
  height: 100%;
  margin: 0;
  font-family: Inter, "Segoe UI", Roboto, Arial;
  background: var(--bg);
  color: var(--text);
}

#app {
  display: flex;
  height: 100vh;
  min-height: 100vh;
  overflow: hidden;
}

#map {
  flex: 1;
  position: relative;
  min-height: 100vh;
}
/* [THÊM] CSS cho Nút Toggle (Hamburger/X) */
#sidebar-toggle-btn {
  position: fixed; /* Cố định vị trí trên màn hình */
  top: 80px; /* Vị trí yêu cầu: 120px từ mép trên */
  left: 10px; /* Vị trí yêu cầu: 0px từ mép trái */
  z-index: 5001; /* Đảm bảo nút luôn nằm trên tất cả */
  cursor: pointer;
  background: #ef4444; /* Màu nền đỏ */
  border-radius: 8px 8px 8px 8px; /* Bo góc phải, giữ góc trái vuông */
  width: 30px;
  height: 30px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  box-shadow: 2px 2px 8px rgba(0, 0, 0, 0.2);
  transition: all 0.3s ease-in-out;
}

/* Các gạch của icon Hamburger */
#sidebar-toggle-btn .line {
  display: block;
  width: 60%;
  height: 3px;
  background: #ffffff;
  border-radius: 2px;
  margin: 3px 0;
  transition: all 0.3s ease-in-out;
}

/* Sidebar (copied from Index.html) */
.sidebar {
  width: 300px;
  max-width: 36vw;
  background: rgba(255, 255, 255, 0.7);
  padding: 18px;
  box-sizing: border-box;

  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
  border-radius: 12px;
  color: var(--text);

  position: fixed;
  left: 10px;
  top: 80px;
  z-index: 4500;

  /* Cố định chiều cao: từ top đến trên basemap-switcher
     basemap cao 72px + bottom 20px + khoảng cách 20px = 112px */
  height: calc(100vh - 80px - 190px);

  /* Nội dung bên trong cuộn dọc */
  overflow-y: auto;
  overflow-x: hidden;

  /* Thanh cuộn tinh tế */
  scrollbar-width: thin;
  scrollbar-color: rgba(0, 0, 0, 0.2) transparent;

  border: 1px solid rgba(0, 0, 0, 0.08);
  transition: transform 0.3s ease-in-out;
}

/* Thanh cuộn cho WebKit (Chrome, Safari) */
.sidebar::-webkit-scrollbar {
  width: 5px;
}
.sidebar::-webkit-scrollbar-track {
  background: transparent;
}
.sidebar::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.2);
  border-radius: 3px;
}
.sidebar::-webkit-scrollbar-thumb:hover {
  background: rgba(0, 0, 0, 0.38);
}
/* [THÊM] Trạng thái ẩn của Sidebar */
.sidebar.hidden {
  /* Ẩn hoàn toàn ra khỏi màn hình (300px) */
  transform: translateX(-100%);
}
/* Phiên bản font rất lớn cho sidebar */
.sidebar {
  font-size: 14px !important;
}

.sidebar .group-title {
  font-size: 13px !important;
  font-weight: 700;
}

.sidebar .layer-label .name {
  font-size: 12px !important;
  font-weight: 600;
}

.sidebar .layer-label .meta {
  font-size: 13px !important;
}

.sidebar .muted {
  font-size: 13px !important;
}
/* Màu chữ tối cho nền trắng */
.sidebar,
.sidebar * {
  color: #1f2937; /* gần #2b2b2b – màu chữ hiện đại */
}
/* ======================= */
/* SIDEBAR COMPACT SPACING */

.sidebar .group {
  margin-bottom: 4px !important; /* giảm 8px → 4px */
}

.sidebar .group-header {
  padding: 4px 2px !important; /* giảm 6px → 4px */
}

.sidebar .group-body {
  padding: 4px 2px 6px 2px !important; /* giảm 8/12 → 4/6 */
}

/* mỗi layer */
.sidebar .layer-item {
  padding: 4px 6px !important; /* giảm 8px → 4px */
  margin-bottom: 4px !important; /* giảm 8px → 4px */
}

/* dòng label */
.sidebar .layer-row-top {
  gap: 4px !important; /* giảm 8px → 4px */
}

/* icon thu nhỏ */
.sidebar .layer-icon {
  width: 22px !important; /* từ 28px → 22px */
}

/* label */
.sidebar .layer-label .name {
  font-size: 11px !important; /* 12px → 11 */
}

.sidebar .layer-label .meta {
  font-size: 11px !important; /* 12px → 11 */
  margin-top: 0px !important;
}

/* checkbox */
.sidebar .chk input {
  width: 14px !important;
  height: 14px !important;
  margin-right: 4px !important;
}

/* khoảng cách opacity range */
.sidebar .opacity {
  gap: 4px !important;
}

.sidebar .opacity-range {
  width: 120px !important;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}
.brand img {
  width: 36px;
  height: 36px;
  object-fit: contain;
}

.search-row {
  display: flex;
  gap: 8px;
  margin-bottom: 8px;
}
.search-row input {
  flex: 1;
  padding: 8px;
  border-radius: 8px;
  border: 1px solid var(--panel-border);
  background: transparent;
  color: var(--text);
}
.search-row button {
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid var(--panel-border);
  background: transparent;
  color: var(--text);
  cursor: pointer;
}

.group {
  margin-bottom: 8px;
}
.group-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 2px;
  cursor: pointer;
  user-select: none;
  border-radius: 8px;
}
.group-header:hover {
  background: rgba(255, 255, 255, 0.01);
}
.group-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
}
.chev {
  font-size: 13px;
  color: var(--muted);
}

.group-body {
  padding: 8px 2px 12px 2px;
}
.layer-item {
  padding: 8px;
  border-radius: 8px;
  margin-bottom: 8px;
  display: block;
  background: transparent;
}
.layer-item:hover {
  background: rgba(255, 255, 255, 0.02);
}
.layer-row-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.left-group {
  display: flex;
  align-items: center;
  gap: 8px;
}
.layer-icon {
  width: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.layer-label .name {
  font-weight: 600;
}
.layer-label .meta {
  font-size: 12px;
  color: var(--muted);
  margin-top: 2px;
}

.right-group {
  display: flex;
  align-items: center;
  gap: 8px;
}
.chk {
  display: inline-flex;
  align-items: center;
}
.chk input {
  width: 16px;
  height: 16px;
  margin-right: 6px;
  accent-color: var(--accent);
}

.opacity {
  display: flex;
  align-items: center;
  gap: 8px;
}
.opacity-range {
  width: 140px;
}

.divider {
  height: 1px;
  background: var(--panel-border);
  margin: 8px 0;
  border-radius: 4px;
}

.muted {
  color: var(--muted);
  font-size: 12px;
}
.action-btn {
  background: transparent;
  border: 1px solid var(--panel-border);
  padding: 6px 8px;
  border-radius: 8px;
  color: var(--text);
  cursor: pointer;
}

/* map overlays */
.map-header {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  z-index: 3000;
  pointer-events: none;
}
/* Thay đổi tiêu đề web */
.map-header-inner {
  width: 100%;
  padding: 14px 22px;
  background: rgba(113, 173, 240, 0.6);
  backdrop-filter: blur(10px);
  color: rgb(19, 19, 19);
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  gap: 18px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.25);
  border-radius: 0 0 14px 14px;
  pointer-events: auto;
  position: relative;
}
/* Chữ lớn hơn */
.header-title {
  font-size: 20px !important;
  font-weight: 800;
  line-height: 1.3;
  text-align: center;
}
.header-subtitle {
  font-size: 16px !important;
  font-weight: 300;
  opacity: 0.9;
  text-align: center;
}
/* .map-footer {
        position: absolute;
        bottom: 0;
        left: 0;
        width: 100%;
        z-index: 3000;
        pointer-events: none;
      }
      .map-footer-inner {
        width: 100%;
        padding: 14px 22px;
        background: rgba(0, 120, 255, 0.15);
        backdrop-filter: blur(10px);
        display: flex;
        flex-direction: row;
        align-items: center;
        justify-content: center;
        gap: 18px;
        box-shadow: 0 -4px 14px rgba(0, 0, 0, 0.25);
        border-radius: 14px 14px 0 0;
        color: rgb(19, 16, 16);
        pointer-events: auto;
      }
      .footer-line1 {
        font-size: 16px !important;
        font-weight: 300;
        margin-bottom: 4px;
      }

      .footer-line2 {
        font-size: 14px !important;
        font-weight: 300;
        opacity: 0.9;
      } */
/* small responsive */
/* Thay đổi từ ẩn hoàn toàn sang điều chỉnh hiển thị cho màn hình nhỏ */
@media (max-width: 1080px) {
  .sidebar {
    display: block !important;
    position: fixed;
    top: 85px;
    left: 10;
    width: 30%;
    max-width: 100%;
    /* Cố định chiều cao, trừ basemap phía dưới */
    height: 650px;
    overflow-y: auto;
    overflow-x: hidden;
    border-radius: 0;
    z-index: 5000;
  }

  #basemap-switcher {
    left: 10px;
  }
  .sidebar.hidden {
    /* Ẩn hoàn toàn ra ngoài bên trái trên di động */
    transform: translateX(-100%);
  }

  /* [ĐIỀU CHỈNH] Vị trí nút trên di động */
  #sidebar-toggle-btn {
    top: 80px;left: 10; /* Điều chỉnh vị trí nút trên di động cho phù hợp */
    width: 40px;
    height: 40px;
  }

  #data-display-container {
    position: absolute;
    top: 85px;
    right: 20px;
    width: 600px;
    max-height: 400px;
    overflow-y: auto;
    z-index: 1000;

    /* Bỏ Glassmorphism và chuyển sang nền trắng/khung đơn giản */
    background: #ffffff; /* Nền trắng cho toàn bộ container */
    border-radius: 10px;
    border: 1px solid #ccc;
    box-shadow: 0 4px 12px 0 rgba(0, 0, 0, 0.2);
    color: #000000; /* Chữ đen mặc định */
    padding: 0;
  }
}

/* Lưu ý: Bạn cũng nên điều chỉnh map-header và các form khác để tránh bị sidebar che mất. */

/* form hồ chứa */
/* --- CSS MỚI CHO HIỂN THỊ DỮ LIỆU HỒ CHỨA (Đã Cập Nhật Màu Sắc) --- */
#data-display-container {
  position: absolute;
  top: 85px;
  right: 20px;
  width: 600px;
  max-height: 400px;
  overflow-y: auto;
  z-index: 1000;

  /* Bỏ Glassmorphism và chuyển sang nền trắng/khung đơn giản */
  background: #ffffff; /* Nền trắng cho toàn bộ container */
  border-radius: 10px;
  border: 1px solid #ccc;
  box-shadow: 0 4px 12px 0 rgba(0, 0, 0, 0.2);
  color: #000000; /* Chữ đen mặc định */
  padding: 0;
}

/* 1. Tiêu đề trên cùng: Nền đỏ, chữ trắng, CĂN GIỮA */
#data-display-container h3 {
  background-color: #e53935; /* Màu đỏ nổi bật */
  color: #ffffff; /* Chữ trắng */
  padding: 10px 20px;
  margin: 0;
  border-top-left-radius: 10px;
  border-top-right-radius: 10px;
  font-size: 1.2rem;
  font-weight: bold;
  text-align: center; /* THÊM THUỘC TÍNH NÀY ĐỂ CĂN GIỮA */
}

#reservoir-data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8rem; /* Cỡ chữ nhỏ */
  color: #000000; /* Chữ đen */
}

#reservoir-data-table th,
#reservoir-data-table td {
  padding: 6px 10px;
  text-align: left;
  white-space: normal;
  border-bottom: 1px solid #eee; /* Đường kẻ mờ */
}

/* 2. Tiêu đề cột (Header): Nền trắng, chữ đen, Cỡ chữ nhỏ, Bớt đậm */
#reservoir-data-table thead th {
  background-color: #ffffff; /* Nền trắng */
  color: #000000; /* Chữ đen */
  font-size: 0.8rem; /* Cỡ chữ nhỏ */
  font-weight: normal; /* ĐÃ THÊM: Giảm độ đậm của chữ */
  border-bottom: 2px solid #ccc;
  position: sticky;
  top: 0;
  z-index: 10;
  vertical-align: top;
}

/* 3. Nội dung bảng (Data): Nền trắng, chữ đen */
#reservoir-data-table tbody tr {
  transition: background-color 0.2s;
  background-color: #ffffff; /* Nền trắng */
  color: #000000; /* Chữ đen */
}

/* Tạo sọc màu nhẹ và hiệu ứng hover */
#reservoir-data-table tbody tr:nth-child(even) {
  background-color: #f7f7f7; /* Nền trắng hơi xám nhẹ */
}

#reservoir-data-table tbody tr:hover {
  background-color: #e0f2ff; /* Màu xanh nhạt khi hover */
  cursor: pointer;
}
/* ---------------------------------- */
/* ---------------------------------- */
/* Load mực nước trạm thủy văn */
/* ====================================================== */
/* 2. BẢNG MỰC NƯỚC (mucnuoc.xlsx) */
/* ====================================================== */
#water-level-display-container {
  position: absolute;
  top: 300px; /* Dính ngay phía dưới Hồ Chứa (80 + 400 + 20) */
  right: 20px;
  width: 500px;
  max-height: 400px;
  overflow-y: auto;
  z-index: 1000;

  background: #ffffff;
  border-radius: 10px;
  border: 1px solid #ccc;
  box-shadow: 0 4px 12px 0 rgba(0, 0, 0, 0.2);
  color: #000000;
  padding: 0;
}

/* Tiêu đề chính Mực Nước: Nền đỏ, căn giữa */
#water-level-display-container h3 {
  background-color: #e53935;
  color: #ffffff;
  padding: 10px 20px;
  margin: 0;
  border-top-left-radius: 10px;
  border-top-right-radius: 10px;
  font-size: 1.2rem;
  font-weight: bold;
  text-align: center;
}

/* Style chung cho bảng Mực Nước */
#water-level-data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8rem;
  color: #000000;
}

#water-level-data-table th,
#water-level-data-table td {
  padding: 6px 10px;
  text-align: left;
  white-space: normal;
  border-bottom: 1px solid #eee;
}

/* Tiêu đề cột Mực Nước: Nền trắng, chữ nhỏ, không đậm */
#water-level-data-table thead th {
  background-color: #ffffff;
  color: #000000;
  font-size: 0.8rem;
  font-weight: normal;
  border-bottom: 2px solid #ccc;
  position: sticky;
  top: 0;
  z-index: 10;
  vertical-align: top;
}

/* Nội dung bảng Mực Nước */
#water-level-data-table tbody tr {
  transition: background-color 0.2s;
  background-color: #ffffff;
  color: #000000;
}

#water-level-data-table tbody tr:nth-child(even) {
  background-color: #f7f7f7;
}

#water-level-data-table tbody tr:hover {
  background-color: #e0f2ff;
  cursor: pointer;
}
/* ---------------------------------- */

/* =====================================================
   MODAL OVERLAY & BOX
===================================================== */
.modal-overlay {
  position: fixed;
  right: 10px;
  top: 100px;
  inset: 0;
  background: none; /* ❌ bỏ nền mờ */
  display: none;
  pointer-events: none; /* ⭐ CHO CLICK XUYÊN QUA */
  z-index: 1000;
}
.modal-box {
  pointer-events: auto; /* ⭐ chỉ box nhận click */
}

.modal-box {
  width: 700px;
  max-width: 95%;
  max-height: 0vh; /* ⭐ giới hạn theo chiều cao màn hình */
  background: #ffffff;
  border-radius: 6px;
  overflow: hidden; /* ⭐ không cho modal bung */
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.3);
}

/* =====================================================
   HEADER
===================================================== */
.modal-header {
  background: linear-gradient(180deg, #f47c2c, #f16521);
  color: #ffffff;
  padding: 14px 20px;
  font-size: 20px;
  font-weight: 700;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-close {
  background: #ffffff;
  border: none;
  color: #333;
  font-size: 18px;
  cursor: pointer;
  border-radius: 3px;
  padding: 2px 8px;
}

.modal-close:hover {
  background: #f1f3f5;
}

/* =====================================================
   TABS (NGÀY)
===================================================== */
.modal-tabs {
  display: flex;
  gap: 8px;
  padding: 10px 12px;
  border-bottom: 2px solid #b100ff;
}

.tab {
  background: #2f9e44;
  color: #ffffff;
  border: none;
  padding: 6px 18px;
  border-radius: 18px;
  font-weight: 600;
  cursor: pointer;
  font-size: 13px;
  opacity: 0.75;
  transition: all 0.25s ease;
}

.tab:hover {
  opacity: 1;
  transform: translateY(-1px);
}

.tab.active {
  background: #1c7ed6;
  opacity: 1;
  box-shadow: 0 4px 12px rgba(28, 126, 214, 0.45);
}

/* =====================================================
   MODAL BODY
===================================================== */
.modal-body {
  padding: 12px;
  background: #ffffff;
}

/* =====================================================
   TABLE – CHUẨN DASHBOARD
===================================================== */
.flood-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 12px;
}

/* HEADER */
.flood-table th {
  background: #145a7a;
  color: #ffffff;
  padding: 10px;
  font-weight: 700;
  font-size: 14px;
  text-align: center;
  white-space: nowrap;
}

/* BODY CELL */
.flood-table td {
  background: #f1f3f5; /* sáng – rõ */
  color: #212529; /* chữ đen đậm */
  padding: 10px;
  text-align: center;
  font-size: 14px;
  font-weight: 500;
}

/* kẻ dòng nhẹ để dễ quét */
.flood-table tr + tr td {
  border-top: 1px solid #dee2e6;
}

/* =====================================================
   TẦNG 1 – DÒNG THEO GIỜ
===================================================== */
.tier1-row {
  cursor: pointer;
  transition: background 0.2s ease;
}

.tier1-row:hover {
  background: #e7f1ff !important;
}

/* =====================================================
   CỘT CẤP ĐỘ – MÀU NGHIỆP VỤ
===================================================== */
.level {
  font-weight: 700;
  font-size: 14px;
}

.level.Rấtcao {
  color: #d00000; /* đỏ đậm */
}

.level.Cao {
  color: #f08c00; /* cam đậm */
}

.level.Trungbình {
  color: #e0a800; /* vàng */
}

.level.Thấp {
  color: #2b8a3e; /* xanh */
}

/* =====================================================
   ICON ẢNH
===================================================== */
.img-icon {
  cursor: pointer;
  font-size: 18px;
  color: #1c7ed6;
}

.img-icon:hover {
  color: #0b5ed7;
}

/* =====================================================
   TEXT TRẠNG THÁI / EMPTY
===================================================== */
.empty {
  font-style: italic;
  color: #6c757d;
  font-weight: 500;
}

/* =====================================================
   TAB PANEL (NẾU DÙNG)
===================================================== */
.tab-panel {
  display: none;
  animation: fadeSlide 0.35s ease;
}

.tab-panel.active {
  display: block;
}

@keyframes fadeSlide {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* =====================================================
   UTIL
===================================================== */
.hidden {
  display: none;
}

.survey-img {
  width: 100%;
  margin-bottom: 10px;
  border-radius: 6px;
}

.empty {
  font-style: italic;
  color: #6c757d;
  font-weight: 500;
}

/* =====================================================
   TIÊU ĐỀ TẦNG 2 – CHI TIẾT THÔN
===================================================== */
#tier2Title {
  margin: 12px 0 8px 0;
  padding: 8px 12px;
  background: #e7f1ff; /* nền riêng */
  color: #0b4f6c; /* xanh đậm */
  font-weight: 700;
  font-size: 15px;
  border-left: 4px solid #1c7ed6;
  border-radius: 4px;
  position: relative;
  z-index: 1; /* QUAN TRỌNG */
}

/* =====================================================
   DRAGGABLE MODAL
===================================================== */
.modal-box {
  position: fixed;
  right: 20px; /* ⭐ CĂN PHẢI */
  top: 90px; /* ⭐ CÁCH ĐỈNH */
  left: auto; /* ❌ bỏ căn giữa */
  transform: none; /* ❌ bỏ translate */
  width: 700px;
  max-width: 95%;
  max-height: 80vh;
  background: #ffffff;
  border-radius: 6px;
  overflow: hidden;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.3);
  z-index: 6000;
}

.modal-header {
  cursor: move; /* báo cho user biết có thể kéo */
  user-select: none;
}

/* =====================================================
   GIỚI HẠN KÍCH THƯỚC MODAL
===================================================== */
.modal-box {
  max-height: 96vh; /* ⭐ không vượt màn hình */
  overflow: hidden; /* ⭐ không bung modal */
}

/* =====================================================
   MODAL BODY
===================================================== */
.modal-body {
  padding: 12px;
  overflow: hidden; /* ❌ không scroll toàn body */
}

/* =====================================================
   SCROLL RIÊNG CHO BẢNG
===================================================== */
.table-scroll {
  overflow-y: auto;
  border: 1px solid #dee2e6;
  border-radius: 4px;
  background: #ffffff;
}

/* TẦNG 1 – THEO GIỜ */
.tier1-scroll {
  max-height: 240px; /* ⭐ chỉnh tuỳ ý */
}

/* TẦNG 2 – THEO THÔN */
.tier2-scroll {
  max-height: 220px;
}

/* =====================================================
   GIỮ HEADER BẢNG KHI SCROLL
===================================================== */
.flood-table thead th {
  position: sticky;
  top: 0;
  z-index: 2;
}

.row-highlight {
  background: #fff3bf !important;
  outline: 2px solid #f59f00;
}

.marker-highlight {
  transform: scale(1.8);
  box-shadow: 0 0 12px rgba(0, 0, 0, 0.8);
}

.flood-popup {
  max-width: 220px;
  font-family: Arial, sans-serif;
}

.flood-popup h4 {
  margin: 0 0 6px;
  font-size: 13px;
  font-weight: bold;
}

.flood-popup img {
  width: 100%;
  max-height: 140px;
  object-fit: cover;
  border-radius: 4px;
  margin-bottom: 4px;
}

.flood-popup .no-image {
  font-size: 12px;
  color: #666;
  font-style: italic;
  text-align: center;
  padding: 10px 0;
}

.maplibregl-popup-content {
  background: #ffffff;
  border-radius: 8px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.35);
  padding: 10px;
  opacity: 1;
}

.flood-popup h4 {
  margin: 0 0 6px;
  font-size: 14px;
  font-weight: 700;
  color: #111;
}

.flood-popup img {
  display: block;
  width: 100%;
  border-radius: 6px;
}

/* ===== POPUP MAPLIBRE – FIX MỜ CHỮ ===== */
.maplibregl-popup {
  z-index: 9999;
}

.maplibregl-popup-content {
  background: #ffffff !important;
  opacity: 1 !important;
  border-radius: 10px;
  padding: 10px 12px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
}

/* Tiêu đề popup */
.flood-popup h4 {
  margin: 0 0 6px;
  font-size: 14px;
  font-weight: 700;
  color: #111 !important;
  line-height: 1.3;
}

/* Ghi chú (note) */
.flood-popup div {
  color: #222 !important;
  font-size: 13px;
  line-height: 1.4;
  background: #fff;
}

/* Ảnh */
.flood-popup img {
  display: block;
  width: 100%;
  margin-top: 6px;
  border-radius: 6px;
  background: #fff;
}

/* Trường hợp không có ảnh */
.flood-popup .no-image {
  color: #555;
  font-style: italic;
  margin-top: 6px;
  background: #fff;
}

/* Mũi nhọn popup */
.maplibregl-popup-tip {
  border-top-color: #fff !important;
  border-bottom-color: #fff !important;
}

/* --- TIMELINE CSS (Chuẩn từ Giamsat.html) --- */
.timeline-container {
  position: fixed;
  bottom: 20px; /* Cách đáy một chút */
  left: 50%;
  transform: translateX(-50%);
  width: calc(100% - 40px); /* Ngắn hơn 40px */
  max-width: 1200px; /* Giới hạn chiều rộng trên màn to */
  background: rgba(255, 255, 255, 0.9);
  padding: 8px 12px;
  border-radius: 8px;
  box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.15);
  z-index: 9999; /* Đảm bảo nằm trên cùng */
  display: none; /* Mặc định ẩn */
  flex-direction: column;
  gap: 6px;
  font-family: "Segoe UI", sans-serif;
  font-size: 0.85rem;
  backdrop-filter: blur(4px);
}

.timeline-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
}

.timeline-title {
  font-weight: bold;
  color: #0d9488;
  font-size: 0.9rem;
  text-transform: uppercase;
}

.timeline-time {
  min-width: 120px;
  font-weight: 600;
  color: #1e3a8a;
  text-align: right;
  font-size: 0.9rem;
}

/* Phần chính chứa slider và nút */
.timeline-main {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: nowrap;
}

.timeline-slider-container {
  flex: 1;
  display: flex;
  flex-direction: column; /* Slider trên, ngày dưới */
  gap: 4px;
  width: 100%;
  position: relative;
}

/* Input Range Slider */
.timeline-slider {
  flex: 1;
  width: 100%;
  cursor: pointer;
  margin: 0;
}

.timeline-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #0d9488;
  cursor: pointer;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
  margin-top: -6px; /* Căn chỉnh thumb với track */
}

/* Thanh ngày tháng bên dưới */
.timeline-days {
  display: flex;
  width: 100%;
  font-size: 11px;
  color: #555;
  margin-top: 2px;
}

.timeline-day-segment {
  background: #7e838d; /* Màu xám nhạt */
  color: #374151;
  text-align: center;
  padding: 2px 0;
  border-right: 1px solid #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  border-radius: 2px;
}

/* Nút điều khiển */
.timeline-controls {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

.timeline-btn {
  background: #0d9488;
  color: white;
  border: none;
  border-radius: 4px;
  padding: 6px 10px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  transition: background 0.3s;
  font-size: 0.8rem;
  width: 32px;
  height: 32px;
}

.timeline-btn:hover {
  background: #0b8377;
}

.timeline-btn:disabled {
  background: #94a3b8;
  cursor: not-allowed;
}

/* Responsive */
@media (max-width: 768px) {
  .timeline-container {
    width: 95%;
    bottom: 60px; /* Tránh bottom nav mobile */
  }
  .timeline-time {
    font-size: 0.8rem;
  }
}
/* --- ĐÂY LÀ PHẦN BẠN CẦN: NHÃN MÀU CAM --- */
#timeline-time {
  position: absolute; /* Để chạy theo slider */
  top: -45px; /* Đẩy lên phía trên thanh trượt */
  left: 5; /* JS sẽ tính toán vị trí này */
  transform: translateX(-50%); /* Căn giữa so với điểm neo */

  background-color: #f59e0b; /* ✅ MÀU CAM VÀNG */
  color: white;

  padding: 4px 10px;
  border-radius: 4px;
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
  pointer-events: none; /* Không chặn chuột */
  z-index: 20;
  transition: left 0.05s linear; /* Chuyển động mượt */
}

/* Tạo mũi tên nhỏ màu cam trỏ xuống */
/* Mũi tên nhỏ dưới tooltip */
#timeline-time::after {
  content: "";
  position: absolute;
  bottom: -6px; /* Nằm ngay dưới nhãn */
  left: 57%; /* Căn giữa so với hộp nhãn */
  transform: translateX(-50%);
  border-width: 6px 6px 0;
  border-style: solid;
  border-color: #f59e0b transparent transparent transparent; /* Màu cam khớp với nền */
}

/* CSS cho Legend Mưa GFS */
#MuaGFS-legend {
  display: none;
  position: fixed;
  bottom: 130px; /* Nằm trên timeline */
  right: 10px;
  background: white;
  padding: 5px;
  border-radius: 4px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
  z-index: 2000;
}
.modal-dialog {
  max-width: 90vw;
  height: 90vh;
  margin: auto;
}

.modal-content {
  height: 100%;
  display: flex;
  flex-direction: column;
}
.modal-body {
  flex: 1;
  overflow: hidden; /* ❌ bỏ scroll */
  display: flex;
  flex-direction: column;
}
#chart-container {
  flex: 1;
  min-height: 0;
}
@media (max-width: 1080px) {
    #song-legend,
    #dongchay-legend,
    #gio-legend,
	#MuaGFS-legend,
	#Temp2m-legend,
	#Temp2mObs-legend,
    #Radar-legend {
        position: fixed !important;
        bottom: 290px !important;
        right: 10px !important;
        z-index: 10002 !important;
    }

    .bottom-panel {
        position: fixed !important;
        bottom: 0 !important;  /* ✅ ép bám sát đáy */
        left: 0 !important;
        right: 0 !important;
        z-index: 1000 !important;
        display: flex !important; /* ✅ ép hiện */
    }
}