/* SVG Styling */
svg {
  cursor: grab;
  width: 100%;
  height: auto;
  max-height: 80vh;
  touch-action: pan-x pan-y pinch-zoom;
}

svg:active {
  cursor: grabbing;
}

/* Family Tree Banner */
#family-tree-banner * {
  font-family: "Roboto", sans-serif !important;
}

#family-tree-banner::before {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  width: 100px;
  height: 100px;
  background: radial-gradient(circle at top right, rgba(24, 119, 242, 0.1), transparent 70%);
  z-index: 0;
}

/* Search Container */
#truongfamily-search-container {
  position: relative;
  display: flex;
  flex-wrap: wrap; /* Cho phép wrap trên màn hình nhỏ */
  align-items: center;
  justify-content: center;
  gap: 12px;
  background-color: transparent;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1;
  width: 100%;
  max-width: 1200px;
  padding: 10px;
  font-family: "Roboto", sans-serif !important;
}

/* Search Wrapper */
.search-wrapper {
  position: relative;
  flex: 1 1 auto; /* Cho phép grow và shrink linh hoạt */
  min-width: 300px; /* Đảm bảo search luôn có đủ không gian */
  max-width: 550px;
  display: flex;
  align-items: center;
}

/* Search Input */
#family-tree-view-wrapper #truongfamily-search-input {
  width: 100%;
  height: 44px;
  padding: 10px 45px 10px 20px;
  border: 2px solid #e4e6eb;
  border-radius: 12px;
  font-size: 12px;
  outline: none;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  background: linear-gradient(145deg, #ffffff, #f8f9fa);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
  font-weight: 500;
  color: #1c1e21;
}

/* Prevent background scrolling */
body.modal-open {
  overflow: hidden !important;
  position: fixed;
  width: 100%;
  height: 100vh;
  top: 0;
  left: 0;
}

/* Relationship Modal */
.relationship-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  justify-content: center;
  align-items: flex-start;
  z-index: 999;
  padding-top: 20px;
}

.relationship-modal-content * {
  font-family: "Roboto", sans-serif !important;
}

.relationship-modal-content {
  background: #fff;
  height: 400px;
  padding: 20px;
  border-radius: 8px;
  width: 90%;
  max-width: 400px;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
  text-align: center;
  max-height: 80vh;
  margin-top: 15vh;
}

.relationship-modal-content.no-scroll {
  overflow-y: hidden; /* Tắt cuộn khi autocomplete hiển thị */
}

.relationship-modal-content p {
  margin: 0 0 20px;
  font-size: 20px !important;
  font-weight: bolder !important;
  color: #333;
}

.relationship-input-wrapper {
  position: relative;
  margin-bottom: 20px;
}

.relationship-input {
  width: 100%;
  padding: 12px;
  font-size: 16px;
  border: 1px solid #ccc;
  border-radius: 4px;
  box-sizing: border-box;
}

.relationship-autocomplete-list {
  position: absolute;
  top: calc(100% + 5px);
  left: 0;
  right: 0;
  background: #fff;
  border: 1px solid #ccc;
  border-radius: 4px;
  max-height: 200px;
  overflow-y: auto;
  list-style: none;
  padding: 0;
  margin: 0;
  z-index: 99999;
  display: none;
  -webkit-overflow-scrolling: touch; /* Giữ để tối ưu trên iOS */
  touch-action: pan-y; /* Giữ để chỉ cuộn dọc trên cảm ứng */
  pointer-events: auto;
  /* Thêm để đảm bảo cuộn chuột hoạt động tốt */
  overscroll-behavior: contain; /* Ngăn cuộn lan ra phần tử cha */
  scrollbar-width: auto; /* Đảm bảo thanh cuộn hiển thị trên Firefox */
  scrollbar-color: #ccc transparent; /* Tùy chỉnh thanh cuộn */
}

/* Tùy chỉnh thanh cuộn cho Chrome, Safari */
.relationship-autocomplete-list::-webkit-scrollbar {
  width: 8px;
}
.relationship-autocomplete-list::-webkit-scrollbar-track {
  background: transparent;
}
.relationship-autocomplete-list::-webkit-scrollbar-thumb {
  background: #ccc;
  border-radius: 4px;
}
.relationship-autocomplete-list.visible {
  display: block;
}

.relationship-autocomplete-list li {
  padding: 10px;
  cursor: pointer;
  -webkit-overflow-scrolling: touch;
}

.relationship-autocomplete-list li:hover {
  background: #f0f0f0;
}

.relationship-modal-buttons {
  display: flex;
  justify-content: space-between;
}

.relationship-modal-buttons button {
  padding: 12px 24px;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 16px;
  width: 48%;
}

#relationship-confirm-button {
  background: #007bff;
  color: #fff;
}

#relationship-cancel-button {
  background: #dc3545;
  color: #fff;
}

@media (max-width: 480px) {
  .relationship-modal {
    padding: 10px;
  }

  .relationship-modal-content {
    padding: 15px;
    max-height: 70vh;
  }

  .relationship-modal-content p {
    font-size: 16px !important;
  }

  .relationship-autocomplete-list {
    max-height: 150px;
  }
}

.hidden {
  display: none;
}
#family-tree-view-wrapper #truongfamily-search-input:focus {
  border-color: #1877f2;
  box-shadow: 0 0 0 4px rgba(24, 119, 242, 0.12), 0 4px 12px rgba(24, 119, 242, 0.15);
  background: #ffffff;
  transform: translateY(-1px);
}

#family-tree-view-wrapper #truongfamily-search-input::placeholder {
  color: #8a8d91;
  font-weight: 400;
}

/* Search Icon Button */
#family-tree-view-wrapper #truongfamily-search-button.search-icon-button {
  position: absolute;
  right: 12px;
  top: 50%;
  width: 36px;
  height: 36px;
  transform: translateY(-50%);
  background: linear-gradient(135deg, #1877f2, #42b72a);
  border: none;
  border-radius: 10px;
  cursor: pointer;
  color: #ffffff;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 2px 8px rgba(24, 119, 242, 0.25);
  z-index: 10;
}

#family-tree-view-wrapper #truongfamily-search-button.search-icon-button:hover {
  transform: translateY(-50%) scale(1.08);
  box-shadow: 0 4px 12px rgba(24, 119, 242, 0.4);
}

#family-tree-view-wrapper #truongfamily-search-button.search-icon-button:active {
  transform: translateY(-50%) scale(0.95);
}

/* Search Loading Spinner */
.search-loading {
  position: absolute;
  top: 50%;
  right: 66px;
  transform: translateY(-50%);
  width: 20px;
  height: 20px;
  border: 2px solid #1877f2;
  border-top: 2px solid transparent;
  border-radius: 50%;
  animation: spin 1s linear infinite;
  z-index: 11;
}

.search-loading.hidden {
  display: none;
}

@keyframes spin {
  0% { transform: translateY(-50%) rotate(0deg); }
  100% { transform: translateY(-50%) rotate(360deg); }
}

/* Autocomplete Styling */
.autocomplete-list {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  width: 100%;
  max-height: 320px;
  overflow-y: auto;
  background: #ffffff;
  border: 2px solid #e4e6eb;
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
  list-style: none;
  padding: 8px;
  margin: 0;
  z-index: 100;
  display: none;
}

.autocomplete-list::-webkit-scrollbar {
  width: 8px;
}

.autocomplete-list::-webkit-scrollbar-track {
  background: #f0f2f5;
  border-radius: 4px;
}

.autocomplete-list::-webkit-scrollbar-thumb {
  background: #c4c6ca;
  border-radius: 4px;
}

.autocomplete-list::-webkit-scrollbar-thumb:hover {
  background: #8a8d91;
}

.autocomplete-list li {
  padding: 12px 16px;
  cursor: pointer;
  border-radius: 8px;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  margin-bottom: 4px;
}

.autocomplete-list li:last-child {
  margin-bottom: 0;
}

.autocomplete-list li:hover {
  background: linear-gradient(135deg, #e7f3ff, #f0f8ff);
  transform: translateX(4px);
  box-shadow: 0 2px 8px rgba(24, 119, 242, 0.1);
}

.autocomplete-item {
  display: flex;
  flex-direction: column;
  font-size: 14px;
  color: #1c1e21;
}

.autocomplete-item div:first-child {
  font-weight: 600;
  margin-bottom: 4px;
  word-wrap: break-word;
  color: #1877f2;
}

.autocomplete-item div:last-child {
  color: #65676b;
  font-size: 12px;
  font-weight: 400;
}

/* Action Dropdown Select - Styled like custom dropdown */
.action-dropdown-select {
  position: relative;
  min-width: 180px;
  max-width: 250px; /* Giới hạn width để không lấn sang search */
  width: 100%;
  height: 44px;
  padding: 10px 40px 10px 18px;
  border: 2px solid #e4e6eb;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 500;
  outline: none;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  background: linear-gradient(145deg, #ffffff, #f8f9fa);
  color: #1c1e21;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%231877f2' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 16px;
  flex-shrink: 0; /* Không cho phép shrink */
}

.action-dropdown-select:hover {
  border-color: #1877f2;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.action-dropdown-select:focus {
  border-color: #1877f2;
  box-shadow: 0 0 0 4px rgba(24, 119, 242, 0.12), 0 4px 12px rgba(24, 119, 242, 0.15);
  background: #ffffff;
}

.action-dropdown-select:active {
  transform: translateY(0);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.08);
}

/* Style cho options */
.action-dropdown-select option {
  padding: 12px 16px;
  font-size: 14px;
  font-weight: 500;
  color: #1c1e21;
  background: #ffffff;
}

.action-dropdown-select option:hover {
  background: linear-gradient(135deg, #e7f3ff, #f0f8ff);
  color: #1877f2;
}

/* Giữ lại old styles để backward compatibility nếu cần */
/* Custom Dropdown Container */
.custom-dropdown {
  position: relative;
  min-width: 200px;
  flex-shrink: 0;
  cursor: pointer; /* Thêm cursor pointer cho cả wrapper */
  user-select: none; /* Ngăn select text khi click */
}

/* Tăng vùng click cho dropdown */
.custom-dropdown::before {
  content: '';
  position: absolute;
  top: -5px;
  left: -5px;
  right: -5px;
  bottom: -5px;
  z-index: -1;
}

/* Custom Dropdown Toggle Button */
.custom-dropdown-toggle {
  width: 100%;
  height: 44px;
  padding: 10px 40px 10px 18px;
  border: 2px solid #e4e6eb;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 500;
  outline: none;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  background: linear-gradient(145deg, #ffffff, #f8f9fa);
  color: #1c1e21;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
  display: flex;
  align-items: center;
  justify-content: space-between;
  text-align: left;
  pointer-events: auto; /* Đảm bảo có thể click */
}

/* Visual feedback khi hover wrapper */
.custom-dropdown:hover .custom-dropdown-toggle {
  border-color: #1877f2;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

/* Visual feedback khi active/click */
.custom-dropdown:active .custom-dropdown-toggle {
  transform: translateY(0);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.08);
}

.custom-dropdown-toggle .selected-text {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.custom-dropdown-toggle i {
  margin-left: 8px;
  font-size: 12px;
  color: #1877f2;
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  pointer-events: none; /* Không chặn click từ icon */
}

/* Loại bỏ hover riêng của button vì đã có hover ở wrapper */
/* .custom-dropdown-toggle:hover được xử lý bởi .custom-dropdown:hover */

.custom-dropdown-toggle:focus,
.custom-dropdown.open .custom-dropdown-toggle {
  border-color: #1877f2;
  box-shadow: 0 0 0 4px rgba(24, 119, 242, 0.12), 0 4px 12px rgba(24, 119, 242, 0.15);
  background: #ffffff;
}

.custom-dropdown.open .custom-dropdown-toggle i {
  transform: rotate(180deg);
}

/* Custom Dropdown Menu */
.custom-dropdown-menu {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  background: #ffffff;
  border: 2px solid #e4e6eb;
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
  list-style: none;
  padding: 8px;
  margin: 0;
  z-index: 9999 !important;
  max-height: 280px;
  overflow-y: auto;
  display: none !important; /* Mặc định ẩn */
  opacity: 0;
  transform: translateY(-10px);
  transition: opacity 0.2s, transform 0.2s;
}

/* Hiển thị menu khi dropdown open */
.custom-dropdown.open .custom-dropdown-menu {
  display: block !important;
  opacity: 1 !important;
  transform: translateY(0) !important;
}

/* Giữ lại class hidden để backward compatibility */
.custom-dropdown-menu.hidden {
  display: none !important;
}

.custom-dropdown-menu::-webkit-scrollbar {
  width: 6px;
}

.custom-dropdown-menu::-webkit-scrollbar-track {
  background: #f0f2f5;
  border-radius: 3px;
}

.custom-dropdown-menu::-webkit-scrollbar-thumb {
  background: #c4c6ca;
  border-radius: 3px;
}

.custom-dropdown-menu::-webkit-scrollbar-thumb:hover {
  background: #8a8d91;
}

/* Custom Dropdown Menu Items */
.custom-dropdown-menu li {
  padding: 12px 16px;
  cursor: pointer;
  border-radius: 8px;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  margin-bottom: 4px;
  font-size: 11px;
  font-weight: 500;
  color: #1c1e21;
  user-select: none; /* Ngăn select text */
  -webkit-tap-highlight-color: rgba(24, 119, 242, 0.3); /* Highlight khi tap trên mobile */
  touch-action: manipulation; /* Cải thiện touch response */
  min-height: 44px; /* Tăng vùng touch cho mobile */
  display: flex;
  align-items: center;
}

.custom-dropdown-menu li:last-child {
  margin-bottom: 0;
}

.custom-dropdown-menu li:hover {
  background: linear-gradient(135deg, #e7f3ff, #f0f8ff);
  color: #1877f2;
  transform: translateX(4px);
  box-shadow: 0 2px 8px rgba(24, 119, 242, 0.1);
}

.custom-dropdown-menu li:active {
  background: linear-gradient(135deg, #1877f2, #42b72a);
  color: #ffffff;
  transform: translateX(2px);
}

/* Print Button */
#family-tree-view-wrapper #print-image-button {
  height: 44px;
  padding: 10px 16px;
  background: linear-gradient(135deg, #6c63ff, #5a52d5);
  color: white;
  font-weight: 600;
  border: none;
  border-radius: 12px;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(108, 99, 255, 0.3);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
  position: relative;
  overflow: hidden;
  flex-shrink: 0;
  min-width: 44px;
}

#family-tree-view-wrapper #print-image-button::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
  transition: left 0.5s;
}

#family-tree-view-wrapper #print-image-button:hover::before {
  left: 100%;
}

#family-tree-view-wrapper #print-image-button:hover {
  background: linear-gradient(135deg, #7c73ff, #6a62e5);
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(108, 99, 255, 0.45);
}

#family-tree-view-wrapper #print-image-button:active {
  transform: translateY(0);
  box-shadow: 0 2px 8px rgba(108, 99, 255, 0.3);
}

#family-tree-view-wrapper #print-image-button i {
  font-size: 16px;
}

/* Level Range Container */
#level-range-container {
  position: absolute;
  top: calc(100% + 5px);
  right: 0;
  transform: translateX(-10%);
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 10px;
  padding: 10px;
  background-color: #fff;
  border: 1px solid #dddfe2;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  z-index: 10;
  width: auto;
}

#level-range-container.hidden {
  display: none;
}

#level-start,
#level-end {
  width: 100px;
  padding: 5px;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 14px;
  outline: none;
}

#level-start:focus,
#level-end:focus {
  border-color: #1877f2;
  box-shadow: 0 0 0 2px rgba(24, 119, 242, 0.2);
}

#confirm-level-range {
  padding: 5px 10px;
  background-color: #1877f2;
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  transition: all 0.2s ease;
}

#confirm-level-range:hover {
  background-color: #166fe5;
}

#close-level-range {
  padding: 5px 10px;
  background-color: #dc3545;
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  transition: all 0.2s ease;
}

#close-level-range:hover {
  background-color: #c82333;
}

/* Family Tree Container */
#family-tree-view-wrapper {
  width: 100%;
  height: 100vh;
  position: relative;
  overflow: hidden;
  border: 2px solid #e4e6eb;
  background-color: #ffffff;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.08);
}

#family-tree-container-tab3 {
  position: relative;
  height: 100vh !important;
  width: 100% !important;
  overflow: visible;
}

#family-tree-view-wrapper * {
  user-select: none;
}

/* Responsive Design */
@media (max-width: 768px) {
  .drag-toggle-button {
    margin-top: 8px;
  }
  #family-tree-banner {
    padding: 20px 15px;
    width: 95%;
  }
  .relationship-modal-content p {
    font-size: 18px !important;
  }

  .banner-title {
    font-size: 16px !important;
  }

  .banner-title::after {
    width: 60px;
    margin: 10px auto 0;
  }

  #truongfamily-search-container {
    flex-wrap: wrap !important;
    gap: 8px;
    padding: 8px;
    max-width: 100% !important;
  }

  .search-wrapper {
    width: 100% !important;
    max-width: 100% !important;
    order: 2;
    margin-top: 8px;
    flex: 1 1 100% !important;
  }

  #family-tree-view-wrapper #truongfamily-search-input {
    width: 100%;
    height: 40px;
    padding: 8px 45px 8px 15px;
    font-size: 14px;
  }

  #family-tree-view-wrapper #truongfamily-search-button.search-icon-button {
    right: 8px;
    width: 32px;
    height: 32px;
    font-size: 13px;
  }

  .search-loading {
    right: 48px;
    width: 18px;
    height: 18px;
  }

  /* Action Dropdown Select responsive */
  .action-dropdown-select {
    order: 1;
    flex: 1;
    min-width: auto;
    height: 40px;
    padding: 8px 35px 8px 12px;
    font-size: 13px;
    background-size: 14px;
    background-position: right 8px center;
  }

  /* Dropdown, Print, Drag buttons trên cùng 1 hàng */
  .custom-dropdown {
    order: 1;
    flex: 1;
    min-width: auto;
  }

  .custom-dropdown-toggle {
    height: 40px;
    padding: 8px 35px 8px 12px;
    font-size: 13px;
  }

  .custom-dropdown-toggle i {
    font-size: 10px;
  }

  #family-tree-view-wrapper #print-image-button {
    order: 1;
    width: 40px;
    height: 40px;
    padding: 0;
    min-width: 40px;
    font-size: 16px;
  }

  #family-tree-view-wrapper #print-image-button i {
    font-size: 14px;
  }

  .drag-toggle-button {
    order: 1;
    width: 40px;
    height: 40px;
    margin-top: 0;
  }

  .drag-toggle-button i {
    font-size: 16px;
  }

  #level-range-container {
    position: static;
    transform: none;
    width: 100%;
    margin-top: 10px;
    flex-wrap: nowrap;
    justify-content: center;
    box-shadow: none;
    border: none;
    padding: 5px;
    overflow-x: auto;
  }

  #level-start,
  #level-end {
    width: 70px;
    font-size: 12px;
    padding: 4px;
    margin: 0 2px;
  }

  #confirm-level-range,
  #close-level-range {
    padding: 4px 6px;
    font-size: 12px;
    min-width: 60px;
    margin: 0 2px;
  }

  .autocomplete-list {
    max-height: 200px;
    width: 100%;
  }

  .autocomplete-item {
    font-size: 12px;
  }

  .autocomplete-item .autocomplete-item-name {
    font-size: 10px;
  }

  .autocomplete-item div:last-child {
    font-size: 10px;
  }
}
.drag-toggle-button {
  background: linear-gradient(135deg, #65676b, #4a4c4e);
  border: none;
  padding: 0;
  cursor: pointer;
  border-radius: 12px;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  position: relative;
  overflow: hidden;
  height: 44px;
  width: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.drag-toggle-button::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
  transition: left 0.5s;
}

.drag-toggle-button:hover::before {
  left: 100%;
}

.drag-toggle-button:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.25);
}

.drag-toggle-button.active {
  background: linear-gradient(135deg, #42b72a, #36a420);
  box-shadow: 0 4px 12px rgba(66, 183, 42, 0.4);
}

.drag-toggle-button.active:hover {
  box-shadow: 0 6px 16px rgba(66, 183, 42, 0.5);
}

.drag-toggle-button i {
  color: white;
  font-size: 18px;
  z-index: 1;
  position: relative;
}

.drag-toggle-button.loading {
  cursor: not-allowed;
  opacity: 0.7;
}

.drag-toggle-button.loading i {
  animation: spin 1s linear infinite;
}

/* Keyframes cho hiệu ứng xoay */
@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* Drag Mode Selector */
.drag-mode-selector {
  display: flex;
  gap: 15px;
  padding: 8px 16px;
  background: linear-gradient(145deg, #ffffff, #f0f2f5);
  border-radius: 12px;
  border: 2px solid #e4e6eb;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  transition: all 0.3s ease;
}

.drag-mode-selector.hidden {
  display: none;
}

.drag-mode-selector label {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  color: #1c1e21;
  transition: color 0.2s ease;
  user-select: none;
}

.drag-mode-selector label:hover {
  color: #1877f2;
}

.drag-mode-selector input[type="radio"] {
  width: 18px;
  height: 18px;
  cursor: pointer;
  accent-color: #1877f2;
}

.drag-mode-selector input[type="radio"]:checked + span {
  color: #1877f2;
  font-weight: 600;
}

/* Media query cho desktop - đảm bảo không wrap */
@media (min-width: 1024px) {
  #truongfamily-search-container {
    flex-wrap: nowrap; /* Không wrap trên desktop */
  }
  
  .search-wrapper {
    flex: 1 1 auto;
    min-width: 350px; /* Tăng min-width trên desktop */
  }
  
  .action-dropdown-select {
    min-width: 200px;
    max-width: 220px; /* Giảm max-width để search có nhiều space hơn */
  }
}

/* Add your other unrelated styles (tooltip, print interface, etc.) below if needed */

/* CSS độc lập cho tooltip */
.tooltip {
  position: fixed;
  text-align: left;
  width: 300px;
  height: auto;
  padding: 10px;
  font-family: "Playfair Display", serif !important;
  transition: 0.3s ease-in-out;
  border-radius: 8px;
  pointer-events: auto;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
  z-index: 1000;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}

.tooltip-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.tooltip-container img {
  border-radius: 50%;
  margin-bottom: 5px;
}

.tooltip-info {
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: auto;
  column-gap: 10px;
  row-gap: 5px;
  align-items: center;
  text-align: left;
  width: 100%;
  background-color: rgba(245, 245, 220, 0.733); /* Nền kem nhạt, giống gốm sứ */
  border: 2px solid #8b4513; /* Viền nâu đỏ gốm sứ */
  border-radius: 6px;
  padding: 10px; /* Khoảng cách bên trong khung */
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.1); /* Hiệu ứng chạm khắc nhẹ */
}

.tooltip-data-name {
  grid-column: 1 / span 2;
  font-size: 20px;
  font-weight: bold;
  text-align: center;
  display: block;
  width: 100%;
  color: #8b4513; /* Màu nâu đỏ gốm sứ */
  margin-bottom: 5px; /* Khoảng cách dưới tên */
}

.tooltip-label {
  margin-left: 10px; /* Giảm margin để vừa khung */
  font-weight: bold;
  text-align: left;
  color: #8b4513; /* Màu nâu đỏ gốm sứ */
}

.tooltip-data {
  margin-left: 10px; /* Giảm margin để vừa khung */
  text-align: left;
  color: #8b4513; /* Màu nâu đỏ gốm sứ */
  font-size: 15px;
}

.hidden {
  display: none;
}

/* Print Interface */
.print-interface {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: linear-gradient(
    135deg,
    #e7f3ff 0%,
    #f0f8ff 100%
  ); /* Gradient nền nhẹ nhàng */
  z-index: 2000;
  display: flex;
  flex-direction: column; /* Sắp xếp dọc để thanh công cụ ở trên */
  align-items: center;
  overflow: auto; /* Cho phép cuộn nếu khung lớn hơn màn hình */
  padding: 20px;
  box-sizing: border-box;
}

.print-frame {
  width: 420mm; /* A3 landscape width */
  height: 297mm; /* A3 landscape height */
  background-color: #fff;
  border: 2px dashed #1877f2; /* Viền xanh Facebook */
  position: relative;
  overflow: hidden;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.15); /* Bóng đổ đậm hơn */
  border-radius: 8px;
  transition: transform 0.3s ease; /* Hiệu ứng phóng to khi hover */
  margin-top: 60px; /* Giảm khoảng cách vì thanh công cụ nhỏ hơn */
}

.print-frame:hover {
  transform: scale(1.01); /* Phóng to nhẹ khi hover */
}

.print-controls {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  display: flex;
  flex-direction: row; /* Sắp xếp ngang */
  justify-content: center; /* Căn giữa */
  align-items: center;
  gap: 10px; /* Giảm khoảng cách giữa các phần tử */
  background: transparent; /* Nền trong suốt */
  backdrop-filter: blur(5px); /* Hiệu ứng mờ (nếu trình duyệt hỗ trợ) */
  padding: 8px 15px; /* Giảm padding */
  z-index: 2100;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05); /* Bóng đổ nhẹ */
}

.print-controls button {
  padding: 8px 15px; /* Giảm padding */
  background-color: #1877f2; /* Màu xanh Facebook */
  color: white;
  border: none;
  border-radius: 6px; /* Giảm border-radius */
  cursor: pointer;
  font-size: 14px; /* Giảm font-size */
  font-weight: 600;
  transition: all 0.2s ease;
  font-family: "Roboto", sans-serif;
}

.print-controls button:hover {
  background-color: #166fe5; /* Đậm hơn khi hover */
  transform: translateY(-2px);
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.15);
}

.print-controls button:active {
  background-color: #145db2; /* Tối hơn khi nhấn */
  transform: translateY(0);
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

/* Định dạng cho select định dạng xuất (#export-format) */
.print-controls #export-format {
  height: 32px; /* Giảm chiều cao */
  padding: 6px 10px; /* Giảm padding */
  border: 1px solid #dddfe2;
  border-radius: 6px; /* Giảm border-radius */
  font-size: 14px; /* Giảm font-size */
  outline: none;
  transition: all 0.2s ease;
  background-color: rgba(255, 255, 255, 0.9); /* Nền trắng mờ nhẹ */
  width: 120px; /* Giảm độ rộng */
  cursor: pointer;
  color: #333;
  font-family: "Roboto", sans-serif;
}

.print-controls #export-format:focus {
  border-color: #1877f2;
  box-shadow: 0 0 0 2px rgba(24, 119, 242, 0.2);
}

.print-controls #export-format:hover {
  border-color: #1877f2;
}

/* Định dạng cho select kích thước SVG (#svg-size) */
.print-controls #svg-size {
  height: 32px; /* Giảm chiều cao */
  padding: 6px 10px; /* Giảm padding */
  border: 1px solid #dddfe2;
  border-radius: 6px; /* Giảm border-radius */
  font-size: 14px; /* Giảm font-size */
  outline: none;
  transition: all 0.2s ease;
  background-color: rgba(255, 255, 255, 0.9); /* Nền trắng mờ nhẹ */
  width: 140px; /* Giảm độ rộng */
  cursor: pointer;
  color: #333;
  font-family: "Roboto", sans-serif;
}

.print-controls #svg-size:focus {
  border-color: #1877f2;
  box-shadow: 0 0 0 2px rgba(24, 119, 242, 0.2);
}

.print-controls #svg-size:hover {
  border-color: #1877f2;
}

/* Định dạng cho select kích thước khung (#frame-size) */
.print-controls #frame-size {
  height: 32px; /* Giảm chiều cao */
  padding: 6px 10px; /* Giảm padding */
  border: 1px solid #dddfe2;
  border-radius: 6px; /* Giảm border-radius */
  font-size: 14px; /* Giảm font-size */
  outline: none;
  transition: all 0.2s ease;
  background-color: rgba(255, 255, 255, 0.9); /* Nền trắng mờ nhẹ */
  width: 120px; /* Giảm độ rộng */
  cursor: pointer;
  color: #333;
  font-family: "Roboto", sans-serif;
}

.print-controls #frame-size:focus {
  border-color: #1877f2;
  box-shadow: 0 0 0 2px rgba(24, 119, 242, 0.2);
}

.print-controls #frame-size:hover {
  border-color: #1877f2;
}

/* Đảm bảo label đồng bộ */
.print-controls label[for="frame-size"],
.print-controls label[for="export-format"],
.print-controls label[for="svg-size"] {
  font-size: 12px; /* Giảm font-size */
  color: #333;
  margin-right: 8px; /* Giảm khoảng cách giữa label và select */
  font-family: "Roboto", sans-serif;
  font-weight: 500;
}

/* Responsive cho mobile */
@media (max-width: 768px) {
  .print-interface {
    padding: 10px;
  }

  .print-frame {
    width: 100%; /* Chuyển sang % để vừa màn hình */
    height: auto; /* Tự động điều chỉnh chiều cao */
    aspect-ratio: 420 / 297; /* Giữ tỷ lệ A3 */
    max-width: 420mm;
    max-height: 297mm;
    margin-top: 100px; /* Giảm khoảng cách vì thanh công cụ nhỏ hơn */
  }

  .print-controls {
    flex-wrap: wrap; /* Cho phép xuống dòng nếu không đủ chỗ */
    justify-content: center;
    padding: 6px 10px; /* Giảm padding */
    gap: 8px; /* Giảm khoảng cách */
  }

  .print-controls #frame-size,
  .print-controls #export-format {
    width: 100px; /* Giảm độ rộng */
    font-size: 12px; /* Giảm font-size */
    padding: 4px 8px; /* Giảm padding */
    height: 28px; /* Giảm chiều cao */
  }

  .print-controls #svg-size {
    width: 120px; /* Giảm độ rộng */
    font-size: 12px; /* Giảm font-size */
    padding: 4px 8px; /* Giảm padding */
    height: 28px; /* Giảm chiều cao */
  }

  .print-controls label[for="frame-size"],
  .print-controls label[for="export-format"],
  .print-controls label[for="svg-size"] {
    font-size: 10px; /* Giảm font-size */
    margin-right: 4px; /* Giảm khoảng cách */
  }
  .print-controls button {
    padding: 6px 12px; /* Giảm padding */
    font-size: 12px; /* Giảm font-size */
  }
}

/* Mobile Landscape Enforcement */
@media (max-width: 768px) and (orientation: portrait) {
  .print-interface::before {
    content: "Vui lòng xoay ngang thiết bị để xem và in.";
    position: fixed;
    width: 90%;
    max-width: 300px;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 16px;
    color: #333;
    background: rgba(255, 255, 255, 0.9);
    padding: 15px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    text-align: center;
    z-index: 2100;
  }
  .print-frame,
  .print-controls {
    display: none;
  }
}

/* Đảm bảo khung in hiển thị tốt trên màn hình lớn */
@media (min-width: 1920px) {
  .print-frame {
    width: 594mm; /* A2 landscape width */
    height: 420mm; /* A2 landscape height */
  }
}

/* Progress Modal */
.progress-modal * {
  font-family: "Roboto", sans-serif !important;
}
.progress-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  z-index: 10000;
}
.progress-modal h3 {
  color: #eeeeef;
}
.progress-modal.success h3 {
  color: #0dea40; 
}
.progress-modal.success .download-button {
  background: #0dea40;
}

.progress-modal.success .download-button:hover {
  background: #218838; 
}
.progress-bar-container {
  width: 300px;
  height: 20px;
  background: #ddd;
  border-radius: 10px;
  overflow: hidden;
}

.progress-bar {
  width: 0;
  height: 100%;
  background: #007bff;
  transition: width 0.5s ease;
}
.progress-modal .page-counter {
  margin-top: 10px;
  font-size: 14px;
  color: #f2ecec;
  text-align: center;
  font-family: Arial, sans-serif;
}
.progress-modal.success .page-counter {
  color: #f0ffd8;
}
.download-button {
  margin-top: 20px;
  padding: 10px 20px;
  background: #28a745;
  color: white;
  border: none;
  border-radius: 5px;
  cursor: pointer;
}

.download-button {
  display: none;
  margin-top: 10px;
  padding: 8px 15px;
  background-color: #28a745;
  color: white;
  border: none;
  border-radius: 5px;
  cursor: pointer;
}

.download-button:hover {
  background-color: #218838;
}

/* Mobile Landscape Enforcement */
@media (max-width: 768px) and (orientation: portrait) {
  .print-interface::before {
    content: "Vui lòng xoay ngang thiết bị để xem và in.";
    position: absolute;
    width: 300px;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 18px;
    color: #333;
    justify-content: center;
    z-index: 2100;
  }
  .a4-frame,
  .print-controls {
    display: none;
  }
  #family-tree-view-wrapper #exportFormat {
    width: 60px !important; /* Giảm độ rộng trên mobile */
    font-size: 12px;
    padding: 6px 10px;
  }

  #family-tree-view-wrapper #print-image-button {
    padding: 6px 10px;
    font-size: 12px;
  }
}
#family-tree-view-wrapper #exportFormat {
  height: 40px;
  padding: 8px 15px;
  border: 1px solid #dddfe2;
  border-radius: 8px;
  font-size: 14px;
  outline: none;
  transition: all 0.2s ease;
  background-color: #fff;
  width: 100px; /* Độ rộng cố định để đồng bộ với các phần tử khác */
  cursor: pointer;
  color: #333;
}

#family-tree-view-wrapper #exportFormat:focus {
  border-color: #1877f2;
  box-shadow: 0 0 0 2px rgba(24, 119, 242, 0.2);
}

#family-tree-view-wrapper #exportFormat:hover {
  border-color: #1877f2;
}

/* Styling cho nút In */
/* Print button styles are defined above at line 389 */
.orientation-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 10000;
}

.orientation-modal.hidden {
  display: none;
}

.notification-modal-content {
  background: #fff;
  padding: 20px;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
  text-align: center;
  max-width: 400px;
  width: 90%;
  font-family: "Roboto", sans-serif;
}

.notification-modal-content p {
  font-size: 16px;
  color: #333;
  margin-bottom: 20px;
}

.notification-modal-content button#modal-ok-button {
  padding: 8px 20px;
  background-color: #1877f2; /* Màu Facebook blue */
  color: white;
  border: none;
  border-radius: 5px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  transition: all 0.2s ease;
}

.notification-modal-content button#modal-ok-button:hover {
  background-color: #166fe5; /* Đậm hơn khi hover */
}

.notification-modal-content button#modal-ok-button:active {
  background-color: #145db2; /* Tối hơn khi nhấn */
}

/* Loading Overlay - Animated Tree */
.loading-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(255, 255, 255, 0.95);
  display: block;
  z-index: 100;
  backdrop-filter: blur(3px);
}

.loading-overlay.hidden {
  display: none;
}

.loading-tree-container {
  text-align: center;
  animation: fadeInScale 0.5s ease-out;
}

.loading-tree-svg {
  width: 200px;
  height: 200px;
  filter: drop-shadow(0 5px 15px rgba(0, 0, 0, 0.3));
}

/* Tree trunk animation */
.tree-trunk {
  animation: growUp 1.5s ease-out infinite;
  transform-origin: center bottom;
}

/* Tree branches animation - staggered */
.tree-branch {
  animation: fadeInBounce 1.5s ease-out infinite;
  transform-origin: center bottom;
}

.tree-branch.layer-3 {
  animation-delay: 0.2s;
}

.tree-branch.layer-2 {
  animation-delay: 0.4s;
}

.tree-branch.layer-1 {
  animation-delay: 0.6s;
}

/* Star pulse animation */
.tree-star {
  animation: starPulse 2s ease-in-out infinite;
}

/* Member nodes animation */
.tree-member {
  animation: memberBlink 2s ease-in-out infinite;
}

.tree-member.m1 {
  animation-delay: 0s;
}

.tree-member.m2 {
  animation-delay: 0.3s;
}

.tree-member.m3 {
  animation-delay: 0.6s;
}

.tree-member.m4 {
  animation-delay: 0.9s;
}

/* Loading text */
.loading-text {
  color: #fff;
  font-size: 18px;
  font-weight: 600;
  margin-top: 20px;
  animation: textPulse 1.5s ease-in-out infinite;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.5);
}

/* Keyframe animations */
@keyframes fadeInScale {
  from {
    opacity: 0;
    transform: scale(0.8);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes growUp {
  0%, 100% {
    transform: scaleY(1);
    opacity: 1;
  }
  50% {
    transform: scaleY(1.1);
    opacity: 0.9;
  }
}

@keyframes fadeInBounce {
  0% {
    opacity: 0;
    transform: scale(0.5) translateY(20px);
  }
  60% {
    opacity: 1;
    transform: scale(1.05) translateY(-5px);
  }
  100% {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

@keyframes starPulse {
  0%, 100% {
    transform: scale(1);
    opacity: 1;
  }
  50% {
    transform: scale(1.3);
    opacity: 0.7;
  }
}

@keyframes memberBlink {
  0%, 100% {
    opacity: 1;
    transform: scale(1);
  }
  50% {
    opacity: 0.4;
    transform: scale(0.8);
  }
}

@keyframes textPulse {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.6;
  }
}

/* Responsive */
/* Loading Spinner Container */
.loading-spinner-container {
  position: absolute;
  top: 50px;
  left: 0;
  width: 100%;
  padding: 0 20px;
  box-sizing: border-box;
}

/* Progress Bar Container */
.spinner-rings {
  width: 100%;
  max-width: 600px;
  margin: 0 auto;
}

/* Loading Text */
.loading-progress-text {
  font-size: 15px;
  font-weight: 500;
  color: #1877f2;
  margin-bottom: 12px;
  font-family: "Roboto", sans-serif;
  text-align: center;
}

/* Progress Bar Background */
.progress-bar-bg {
  width: 100%;
  height: 6px;
  background-color: #e4e6eb;
  border-radius: 10px;
  overflow: hidden;
  position: relative;
}

/* Progress Bar Fill - Indeterminate (chạy qua lại) */
.progress-bar-fill {
  position: absolute;
  height: 100%;
  width: 40%;
  background: linear-gradient(90deg,
    transparent 0%,
    #1877f2 25%,
    #42b72a 50%,
    #00b4d8 75%,
    transparent 100%
  );
  border-radius: 10px;
  animation: indeterminateProgress 1.5s ease-in-out infinite;
}

@keyframes indeterminateProgress {
  0% {
    left: -40%;
  }
  100% {
    left: 100%;
  }
}

@media (max-width: 768px) {
  .loading-tree-svg {
    width: 150px;
    height: 150px;
  }

  .loading-text {
    font-size: 16px;
  }

  /* Responsive progress bar for mobile */
  .loading-spinner-container {
    top: 30px;
    padding: 0 15px;
  }

  .spinner-rings {
    max-width: 100%;
  }

  .loading-progress-text {
    font-size: 13px;
    margin-bottom: 10px;
  }

  .progress-bar-bg {
    height: 5px;
  }
}
