* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: "SVN Product Sans", sans-serif;
}

@font-face {
  font-family: "SVN Product Sans";
  src: url("/assets/fonts/SVN-Product Sans Regular.otf") format("opentype");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

body {
  background: #fff;
}

.header img {
  width: 50%;
  display: block;
  margin-left: 35px; /* khoảng cách bên trái */
  margin-top: 10px; /* khoảng cách phía trên */
}

.container {
  width: 95%;
  margin: 20px auto;
}

.user-menu {
  display: inline-block;
  position: relative;
  margin-left: 20px; /* Khoảng cách so với tiêu đề */
  vertical-align: middle;
  font-weight: 600;
  cursor: pointer;
  color: #2b6edb; /* màu xanh hợp theme */
  font-family: "SVN Product Sans", sans-serif;
  user-select: none;
}

.user-name {
  display: flex;
  align-items: center;
  gap: 6px;
}

.user-icon {
  width: 20px;
  height: 20px;
}

.arrow-icon {
  width: 14px;
  height: 14px;
  transition: transform 0.3s ease;
}

.col-action {
  width: 100px;
  text-align: center; /* căn giữa ngang */
  vertical-align: middle; /* căn giữa dọc */
  align-items: center; /* căn giữa dọc */
  flex-wrap: wrap; /* nếu quá hẹp thì xuống dòng nhưng vẫn trong ô */
  min-width: 80px; /* đảm bảo không quá nhỏ */
}

.btn-action {
  display: inline-block; /* cho phép 2 icon nằm cùng hàng */
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
  vertical-align: middle; /* căn giữa theo ô */
}

.btn-action img {
  width: 20px;
  height: 20px;
  transition: transform 0.2s;
}

.btn-action:hover img {
  transform: scale(1.2);
}

.btn-action {
  flex: 0 0 auto; /* không co giãn, luôn nằm trong ô */
  padding: 4px;
}

.dropdown-menu {
  position: absolute;
  top: 100%;
  right: 0;
  background: #fff;
  border: 1px solid #ccc;
  border-radius: 6px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
  padding: 8px 0;
  margin-top: 6px;
  display: none;
  min-width: 140px;
  z-index: 10;
}

.dropdown-item {
  background: none;
  border: none;
  width: 100%;
  padding: 8px 16px;
  text-align: left;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  color: #333;
  transition: background 0.2s ease;
  white-space: nowrap;
}

.dropdown-item:hover {
  background: #f3f8ff;
}

.dropdown-icon {
  width: 18px;
  height: 18px;
  filter: invert(0);
}

/* Khi menu mở, xoay mũi tên */
.user-menu.open .arrow-icon {
  transform: rotate(180deg);
}

#toast {
  position: fixed;
  top: 20px; /* trên cùng */
  left: 50%; /* căn giữa */
  transform: translateX(-50%);
  padding: 10px 24px;
  font-size: 14px;
  color: #fff;
  z-index: 9999;
  opacity: 0;
  pointer-events: none;
  border-radius: 20px; /* tròn hai đầu */
  transition: opacity 0.3s, transform 0.3s;
  font-weight: 500;
  font-family: "SVN Product Sans", sans-serif;
  display: flex;
  justify-content: center; /* căn ngang */
  align-items: center; /* căn dọc */
}

#toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0); /* slide xuống nếu muốn */
}

#toast.success {
  background-color: #28a745; /* xanh lá */
}

#toast.error {
  background-color: #dc3545; /* đỏ */
}

/* Responsive: căn chỉnh khi màn hình nhỏ */
@media (max-width: 768px) {
  .user-menu {
    margin-left: 10px;
    font-size: 14px;
  }
  .dropdown-menu {
    min-width: 120px;
  }
}

.header-row {
  display: flex;
  justify-content: space-between; /* Tiêu đề bên trái, user menu bên phải */
  align-items: center;
  margin-bottom: 15px; /* Giữ khoảng cách dưới */
}

/* Giữ style cho h2 */
.header-row h2 {
  font-size: 22px;
  font-weight: 700;
  margin: 0;
}

/* User menu giữ nguyên như phần trước */
.user-menu {
  display: inline-block;
  position: relative;
  font-weight: 600;
  cursor: pointer;
  color: #2b6edb;
  font-family: "SVN Product Sans", sans-serif;
  user-select: none;
}

/* Các phần còn lại giữ nguyên như đã đề xuất ở trên */

h2 {
  font-size: 22px;
  margin-bottom: 15px;
}

.top-filter {
  display: flex;
  align-items: center;
  gap: 15px;
  margin-bottom: 20px;
}

.unit-box.hidden {
  display: none;
}

.unit-box label {
  font-size: 14px;
}

.unit-box select {
  padding: 6px 10px;
  border-radius: 6px;
  border: 1px solid #ccc;
}

.search-box {
  display: flex;
  align-items: center;
  gap: 5px;
}

.search-box input {
  padding: 6px 10px;
  border: 1px solid #ccc;
  border-radius: 6px;
}

button {
  border: none;
  padding: 7px 14px;
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
}

button img {
  width: 18px;
  height: 18px;
}

.btn-blue {
  background: #00aeef;
  color: #fff;
}

.btn-green {
  background: #28a745;
  color: #fff;
}
.btn-red {
  background: #dc3545;
  color: #fff;
}
.btn-yellow {
  background: #ffcc00;
  color: #fff;
}

#reload-unit {
  display: inline-block;
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
  vertical-align: middle;
  margin-right: 10px; /* khoảng cách với unit-box */
}

#reload-unit img {
  width: 20px;
  height: 20px;
  transition: transform 0.2s;
}

#reload-unit:hover img {
  transform: scale(1.2);
}

/* CSS cho icon quay */
@keyframes spin {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}

.spin {
  animation: spin 1s linear infinite;
}

.btn-gradient {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border: none;
  border-radius: 6px;
  background: linear-gradient(
    90deg,
    #2b3990 0%,
    #254c9f 28%,
    #1d5faf 37.15%,
    #139fdc 47.42%,
    #00aeef 100%
  );
  color: #fff;
  font-weight: 500;
  cursor: pointer;
  transition: opacity 0.2s;
}

.btn-gradient:hover {
  opacity: 0.85;
}

.disabled {
  opacity: 0.4;
  pointer-events: none;
}

table {
  width: 100%;
  border-collapse: collapse;
}

.table-wrapper {
  max-height: 500px; /* chiều cao cố định của bảng */
  overflow-y: auto; /* bật scroll dọc cho hàng dữ liệu */
  overflow-x: auto; /* scroll ngang nếu cần */
  border: 1px solid #ffffff;
  border-radius: 6px;
}

/* Header cố định */
.table-wrapper thead th {
  position: sticky;
  top: 0;
  background: #f3f8ff; /* nền header */
  z-index: 2;
  padding: 10px;
}

/* Hàng dữ liệu */
.table-wrapper tbody td {
  padding: 8px 10px;
}

thead tr {
  border-bottom: 2px solid #000;
}

th,
td {
  padding: 10px;
  border-bottom: 1px solid #ccc;
  vertical-align: top;
}

tr td:nth-child(1) {
  text-align: center;
}

/* Tổng thể bảng - KHÔNG justify toàn bảng */
/* Tổng thể bảng */
#table-body td {
  padding: 8px 10px;
  vertical-align: middle;
  border-bottom: 1px solid #e5e5e5;
}

/* Tên — KHÔNG justify được khi nowrap, nên chỉ để mặc định */
.col-name {
  width: 180px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Chức danh — tương tự */
.col-title {
  width: 220px;
  overflow: hidden;
  text-align: justify;
  text-align-last: left;
}

.col-unit {
  width: 150px;
  text-align: center;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Message — justify OK */
.col-message {
  width: 350px;
  white-space: normal;
  text-align: justify;
  text-align-last: left;
}

/* Cột ghim */
.col-ghim {
  width: 100px;
  text-align: center;
  font-weight: bold;
  color: red;
}

table {
  border-collapse: collapse;
}

#table-body td,
#table-body th {
  border: 1px solid #ccc;
}

#loading-overlay {
  display: none;
  position: fixed;
  top: 80px;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 9999;
  display: flex;
  justify-content: center;
  align-items: center;
  color: #fff;
  font-size: 20px;
  font-weight: bold;
}

.spinner {
  border: 4px solid rgba(255, 255, 255, 0.3);
  border-top: 4px solid #0015ff;
  border-radius: 50%;
  width: 30px;
  height: 30px;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}

.stats-box {
  margin: 15px 20px;
  padding: 12px 18px;
  font-size: 15px;
  font-family: "SVN Product Sans", sans-serif;
  background: #f3f8ff;
  border-left: 4px solid #2b6edb;
  border-radius: 6px;
  color: #1f3b63;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.05);
  display: inline-block;
  animation: fadeIn 0.3s ease;
}

.stats-count {
  color: #2b6edb; /* màu xanh */
  font-size: 18px; /* chữ to hơn */
  font-weight: bold; /* in đậm */
}

.stats-unit {
  font-style: italic; /* nghiêng */
  font-weight: bold; /* in đậm */
  color: #d9534f; /* màu đỏ */
}

/* ==== Mobile Responsive dưới 768px ==== */
@media (max-width: 768px) {
  .container {
    width: 95%;
    margin: 10px auto;
  }

  .header img {
    width: 100%;
    display: block;
    margin-left: 0px; /* khoảng cách bên trái */
    margin-top: 0px; /* khoảng cách phía trên */
  }
  h2 {
    font-size: 18px;
    margin-bottom: 10px;
  }

  .top-filter {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }

  .search-box {
    flex-direction: column;
    align-items: stretch;
    gap: 5px;
  }

  .search-box input {
    width: 100%;
  }

  button {
    justify-content: center;
    width: 100%;
  }

  /* Table wrapper scroll ngang nếu rộng */
  .table-wrapper {
    max-height: 500px; /* chiều cao cố định để scroll dọc */
    overflow-x: auto; /* scroll ngang nếu table rộng */
    overflow-y: auto; /* scroll dọc nếu nhiều hàng */
  }

  /* Header cố định vẫn giữ nguyên */
  .table-wrapper thead th {
    position: sticky;
    top: 0;
    z-index: 2;
    background: #f3f8ff;
  }

  /* Các cột table padding nhỏ hơn để vừa màn hình */
  .table-wrapper tbody td,
  .table-wrapper thead th {
    padding: 6px 8px;
  }

  /* Stats box responsive */
  .stats-box {
    margin: 10px 0;
    padding: 10px 12px;
    font-size: 14px;
  }
}

/* ===================== Popup xác nhận ===================== */
#confirm-modal {
  display: none; /* ẩn mặc định */
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.4); /* overlay mờ */
  z-index: 10000; /* trên tất cả */
  justify-content: center;
  align-items: center;
  animation: fadeInOverlay 0.3s ease;
}

@keyframes fadeInOverlay {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

#confirm-modal .modal-content {
  background-color: #fff;
  padding: 20px 30px;
  border-radius: 12px;
  max-width: 400px;
  width: 90%;
  text-align: center;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.2);
  animation: scaleIn 0.3s ease;
}

@keyframes scaleIn {
  from {
    transform: scale(0.8);
    opacity: 0;
  }
  to {
    transform: scale(1);
    opacity: 1;
  }
}

#confirm-modal p {
  font-size: 16px;
  margin-bottom: 20px;
  color: #333;
  line-height: 1.5;
}

#confirm-modal .modal-buttons {
  display: flex;
  justify-content: center;
  gap: 20px;
}

#confirm-modal .modal-buttons .btn {
  padding: 8px 20px;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 500;
  transition: all 0.2s ease;
}

#confirm-modal .modal-buttons .btn:hover {
  opacity: 0.9;
}

#confirm-modal .modal-buttons .btn-red {
  background-color: #dc3545;
  color: #fff;
}

#confirm-modal .modal-buttons .btn-gray {
  background-color: #ccc;
  color: #333;
}

/* Responsive nhỏ hơn 768px */
@media (max-width: 768px) {
  #confirm-modal .modal-content {
    padding: 16px 20px;
  }
  #confirm-modal p {
    font-size: 14px;
  }
  #confirm-modal .modal-buttons {
    flex-direction: column;
    gap: 10px;
  }
  #confirm-modal .modal-buttons .btn {
    width: 100%;
  }
}

/* ==== Modern, Minimal & Subtle Scrollbar ==== */

/* Toàn bộ scrollbar */
::-webkit-scrollbar {
  width: 5px; /* Chiều rộng scrollbar dọc */
  height: 5px; /* Chiều cao scrollbar ngang */
  background: transparent; /* Nền trong suốt */
}

/* Track (nền của scrollbar) */
::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.05); /* Mờ nhẹ, nhìn subtle */
  border-radius: 8px;
}

/* Thumb (phần kéo được) */
::-webkit-scrollbar-thumb {
  background-color: rgb(241, 241, 241); /* Màu xanh mờ, dịu mắt */
  border-radius: 8px;
  transition: background-color 0.3s ease, opacity 0.3s ease;
}

/* Thumb hover */
::-webkit-scrollbar-thumb:hover {
  background-color: #ffffff; /* Đậm hơn khi hover */
}

/* Ẩn mũi tên trên scrollbar */
::-webkit-scrollbar-button {
  display: none;
}
