 /*** Khai báo biến CSS để dễ quản lý giao diện ***/
 :root {
   --primary-color: #D1ECFF;
   --secondary-color: #6CB1DA;
   --background-body: #D1ECFF;
   --text-color: #0f0f0f;
   --border-color: #ccc;
   --background-input: #f3f3f3;
   --box-shadow-1: 0 8px 20px rgba(0, 0, 0, 0.5);
   --box-shadow-2: 0 8px 20px rgba(0, 0, 0, 0.5);
   --border-radius-1: 10px;
   --border-radius-2: 6px;
 }

 /*** Font chung ***/
 body,
 input,
 button,
 label,
 textarea,
 select {
   font-family: 'Montserrat', sans-serif;
   font-size: 13px;
 }

 body {
   background: var(--background-body) !important;
   display: flex;
   position: center;
   justify-content: center;
   align-items: center;
   height: 100vh;
   /*** full chiều cao màn hình ***/
   margin: 0;
   overflow-x: hidden;
   /* Prevent horizontal scroll on the page */
 }

 /* When the app is loaded, align content from the top instead of centering (keeps login centered) */
 body.app-loaded {
   align-items: flex-start;
   padding-top: 12px;
   /* small spacing from top */
   height: auto;
   /* allow content to grow */
 }

 /*** Login ***/
 .login-box {
   width: auto;
   height: auto;
   padding: 30px;
   border-radius: var(--border-radius-1);
   background-color: white;
   box-shadow: var(--box-shadow-1);
   text-align: center;
   /*** căn giữa mọi thứ bên trong ***/
 }

 .login-logo {
   max-width: 80px;
   margin: 0 auto 30px;
   /* trên 0, trái/phải auto, dưới 25px */
 }

 .login-box h2 {
   color: var(--text-color);
   font-size: 18px;
   margin-bottom: 30px;
 }

 .login-box label {
   color: var(--text-color);
   font-size: 15px;
   display: block;
   text-align: left;
   margin-left: 0px;
 }

 .login-box input {
   background-color: var(--background-input);
   font-size: 15px;
   width: 100%;
   /* ăn theo chiều rộng login-box */
   height: 40px;
   border-radius: var(--border-radius-1);
   border: 1px solid var(--border-color);
   margin: 10px auto 15px;
   padding: 0 12px;
   box-sizing: border-box;
   /* quan trọng */
   display: block;
 }

 .login-options {
   display: flex;
   /* Đặt 2 phần tử trên cùng 1 dòng */
   justify-content: space-between;
   /* Đẩy 2 bên xa nhau */
   align-items: center;
   /* Căn giữa theo chiều dọc */
   margin: 30px 0 10px;
 }

 .login-options .remember {
   display: flex;
   align-items: center;
   gap: 6px;
   /* Khoảng cách checkbox với text */
   font-size: 13px;
 }

 .login-options input[type="checkbox"] {
   width: 16px;
   height: 16px;
   margin: 0;
 }

 .login-options .forgot-link {
   text-decoration: none;
   color: #007bff;
 }

 .login-options .forgot-link:hover {
   text-decoration: underline;
 }

 .login-box button {
   background: var(--primary-color);
   font-size: 15px;
   font-weight: bold;
   color: var(--text-color);
   width: 100%;
   height: 40px;
   border-radius: var(--border-radius-1);
   border: 1px solid var(--border-color);
   margin: 10px auto 15px;
   cursor: pointer;
   transition: 0.3s;
 }

 .login-box button:hover {
   background: var(--secondary-color);
 }

 /*** Change password popup ***/

 /*** Popup nền mờ ***/
 .popup {
   display: none;
   /* ẩn mặc định */
   position: fixed;
   z-index: 999;
   width: 100%;
   height: 100%;
   background: rgba(0, 0, 0, 0.5);
   /* canh giữa nội dung */
   display: flex;
   align-items: center;
   justify-content: center;
 }

 /*** Hộp nội dung popup ***/
 .popup-content {
   background: #fff;
   padding: 25px;
   border-radius: var(--border-radius-1);
   width: 300px;
   text-align: center;
   /* căn giữa chữ và input */
   box-shadow: var(--box-shadow-2);
   display: flex;
   flex-direction: column;
   /* sắp xếp dọc */
 }

 .popup-content h3 {
   color: var(--text-color);
   font-size: 15px;
 }

 .popup-content input {
   width: 100%;
   /* full chiều ngang của popup */
   padding: 10px;
   /* khoảng cách trong */
   margin: 5px 0;
   /* khoảng cách trên dưới */
   border: 1px solid var(--border-color);
   width: 250px;
   border-radius: var(--border-radius-1);
   font-size: 14px;
   background-color: var(--background-input);
 }

 /*** Nhóm nút action ***/
 .popup-actions {
   margin-top: 20px;
   display: flex;
   /* dùng flex để canh nút */
   justify-content: center;
   /* căn giữa ngang */
   gap: 10px;
   /* khoảng cách giữa nút */
 }

 .popup-actions button {
   padding: 10px 12px;
   font-weight: bold;
   border-radius: var(--border-radius-2);
   border: 1px solid var(--border-color);
   cursor: pointer;
   transition: 0.3s;
 }

 .popup-actions button[type="submit"] {
   background: var(--primary-color);
   color: var(--text-color);
 }

 .popup-actions button[type="submit"]:hover {
   background: var(--secondary-color);
 }

 .popup-actions button[type="button"] {
   background: #ccc;
 }

 .popup-actions button[type="button"]:hover {
   background: #474646;
 }

 .password-field {
   position: relative;
   width: 100%;
 }

 .password-field input {
   width: 100%;
   padding-right: 40px;
   /* chừa chỗ cho icon */
   /* box-sizing: border-box; */
 }

 .toggle-pass {
   position: absolute;
   right: 12px;
   top: 50%;
   transform: translateY(-50%);
   cursor: pointer;
   user-select: none;
   font-size: 14px;
   color: #666;
 }

 .toggle-pass:hover {
   color: #000;
 }

 .sidebar {
   min-height: 100vh;
   background-color: #343a40;
   width: 250px;
   transition: width 0.3s ease;
   overflow: hidden;
 }

 .sidebar-collapsed {
   width: 60px !important;
 }

 .sidebar-expanded {
   width: 250px !important;
 }

 .sidebar-collapsed .sidebar-text {
   display: none !important;
 }

 .sidebar-expanded .sidebar-text,
 .sidebar .sidebar-text {
   display: inline !important;
 }

 .sidebar .nav-link {
   color: #fff;
   white-space: nowrap;
   display: flex;
   align-items: center;
   padding: 0.75rem 1rem;
   transition: all 0.3s ease;
 }

 .sidebar .nav-link i {
   font-size: 1.2rem;
   margin-right: 0.75rem;
   min-width: 20px;
   text-align: center;
   display: inline-block;
   font-family: "bootstrap-icons" !important;
   font-style: normal;
   font-weight: normal;
   font-variant: normal;
   text-transform: none;
   line-height: 1;
   -webkit-font-smoothing: antialiased;
   -moz-osx-font-smoothing: grayscale;
 }

 .sidebar-collapsed .nav-link {
   justify-content: center;
   align-items: center;
   padding: 0.5rem 0;
   position: relative;
   overflow: visible;
   /* ensure icon glyphs aren't clipped */
 }

 .sidebar-collapsed .nav-link i {
   margin-right: 0;
   position: relative;
   z-index: 1;
   display: inline-flex;
   align-items: center;
   justify-content: center;
   width: 28px;
   /* slightly larger to avoid clipping */
   height: 28px;
   line-height: 1;
   min-width: 0;
   /* allow flex to size correctly */
   margin: 0;
 }

 .sidebar-collapsed .nav-link span {
   display: none !important;
 }

 /* Keep hover subtle and avoid expanding link widths on hover-capable devices only */
 @media (hover: hover) and (pointer: fine) {
   .sidebar .nav-link:hover {
     background-color: rgba(73, 80, 87, 0.6);
   }
 }

 .sidebar .logo,
 .sidebar .bottom {
   text-align: center;
   padding: 1rem;
 }

 .sidebar-collapsed .logo img,
 .sidebar-collapsed .bottom img {
   margin: 0 auto;
   display: block;
 }

 /* Logout button: show only icon when collapsed */
 .logout-btn {
   background: transparent;
   border: 1px solid rgba(255, 255, 255, 0.2);
   color: #fff;
 }

 .logout-btn i {
   font-size: 1rem;
 }

 .sidebar-collapsed .logout-text {
   display: none;
 }

 .sidebar-collapsed .logout-btn i {
   margin: 0;
 }

 @media (max-width: 768px) {
   #sidebarCollapse {
     display: block;
   }

   .sidebar {
     width: 250px !important;
     position: fixed;
     top: 0;
     left: 0;
     height: 100vh;
     z-index: 1000;
   }

   .sidebar.d-none {
     display: none !important;
   }
 }

 /* Main content adjustment for sidebar */
 #app {
   margin-left: 250px;
   transition: margin-left 0.3s ease;
   padding: 20px;
 }

 .sidebar-collapsed~#app {
   margin-left: 60px;
 }

 @media (max-width: 768px) {
   #app {
     margin-left: 0;
   }
 }

 /* Table wrapper: container for the table */
 .table-wrapper {
   width: 100%;
 }

 /* Make Tabulator handle horizontal scrolling internally for frozen columns */
 .table-wrapper .tabulator {
   width: 100%;
 }

 /* Active state for sidebar nav links */
 .sidebar .nav-link.active {
   background-color: var(--secondary-color);
   color: #fff;
   font-weight: bold;
 }

 .highlight-row {
   background-color: lightyellow !important;
 }

 .light-green-bg {
   background-color: lightgreen !important;
 }

 .light-green-bg {
   background-color: lightgreen !important;
 }

 .light-blue-bg {
   background-color: lightblue !important;
 }

 input:read-only {
   background-color: #f5f5f5;
   /* slightly darker light grey */
 }

 /* Tabulator header text wrapping and centering */
 .tabulator .tabulator-header .tabulator-col .tabulator-col-content .tabulator-col-title {
   white-space: normal !important;
   word-wrap: break-word !important;
   overflow-wrap: break-word !important;
   line-height: 1.2 !important;
   padding: 2px 4px !important;
   text-align: center !important;
   width: 100% !important;
   margin: 0 !important;
 }

 /* Ensure header cells expand vertically and center content */
 .tabulator .tabulator-header .tabulator-col .tabulator-col-content {
   height: 100% !important;
   min-height: 100% !important;
   display: flex !important;
   flex-direction: column !important;
   align-items: center !important;
   justify-content: space-between !important;
   text-align: center !important;
   padding: 4px 2px 0 2px !important;
   box-sizing: border-box !important;
 }

 /* Header row should expand to fit content and fill background */
 .tabulator .tabulator-header .tabulator-headers .tabulator-header-contents {
   height: 100% !important;
   min-height: 100% !important;
 }

 /* Adjust header cell to fill properly and remove excess space */
 .tabulator .tabulator-header .tabulator-col {
   height: 100% !important;
   min-height: 100% !important;
   padding: 0 !important;
   vertical-align: top !important;
 }

 /* Position header filter at the bottom edge of header */
 .tabulator .tabulator-header .tabulator-col .tabulator-header-filter {
   margin-top: auto !important;
   margin-bottom: 0 !important;
   width: 100% !important;
   text-align: center !important;
   padding: 0 2px 2px 2px !important;
   box-sizing: border-box !important;
 }

 /* Center the filter input within its container with proper spacing */
 .tabulator .tabulator-header .tabulator-col .tabulator-header-filter input {
   width: 95% !important;
   text-align: left !important;
   margin: 0 auto !important;
   padding: 2px 4px !important;
   box-sizing: border-box !important;
   font-size: 12px !important;
 }

 .tabulator-row .tabulator-cell.tabulator-frozen {
  z-index: 10 !important;
 }

/* TinyMCE Rich Text Editor Styles */
.tox-tinymce {
  border: 1px solid #ced4da !important;
  border-radius: 0.25rem !important;
}

.tox .tox-toolbar,
.tox .tox-toolbar__overflow,
.tox .tox-toolbar__primary {
  background-color: #f8f9fa !important;
  border-bottom: 1px solid #dee2e6 !important;
}

.tox .tox-tbtn {
  margin: 2px 1px !important;
}

.tox .tox-tbtn:hover {
  background-color: #e9ecef !important;
}

.tox .tox-edit-area {
  border: none !important;
}

/* Ensure TinyMCE fits in modal */
.modal-fullscreen .tox-tinymce {
  max-width: 100% !important;
}

/* Better spacing for the notes section */
#noteSection {
  width: 100% !important;
}

@media (max-width: 768px) {
  .tox .tox-toolbar__primary {
    flex-wrap: wrap !important;
  }
}

/* Fix jQuery UI Datepicker overflow and positioning issues */
.ui-datepicker {
  z-index: 9999 !important;
  position: fixed !important; /* Use fixed positioning to avoid modal overflow */
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3) !important;
  border: 1px solid #ddd !important;
  background: white !important;
  max-width: 250px !important;
  border-radius: 4px !important;
}

/* Ensure datepicker stays within modal bounds and above modal backdrop */
.modal .ui-datepicker,
.modal-open .ui-datepicker {
  z-index: 1060 !important; /* Bootstrap modal z-index is 1050, backdrop is 1040 */
  position: fixed !important;
}

/* Fix datepicker positioning relative to input */
.datepicker-vn {
  position: relative !important;
}

/* Ensure datepicker table is properly styled */
.ui-datepicker table {
  width: 100% !important;
  margin: 0 !important;
}

.ui-datepicker td {
  border: none !important;
  padding: 1px !important;
}

.ui-datepicker .ui-datepicker-buttonpane {
  background: #f5f5f5 !important;
  border-top: 1px solid #ddd !important;
  text-align: right !important;
  padding: 5px !important;
}

/* Fix button styling in datepicker */
.ui-datepicker .ui-datepicker-buttonpane button {
  margin: 2px !important;
  padding: 3px 8px !important;
  font-size: 11px !important;
}