/* ====================================
   Skote Custom CSS Overrides
   (DO NOT modify app.css or app.min.css!)
   ==================================== */

/* ===== PRELOAD TRANSITIONS FIX ===== */
/* ปิด transition ชั่วคราวตอน page load เพื่อป้องกันกระตุก */
body.preload-transitions,
body.preload-transitions *,
body.preload-transitions *::before,
body.preload-transitions *::after {
  transition: none !important;
  animation: none !important;
}

/* ===== TABLE COLUMN HIGHLIGHT (Striped Column Style) ===== */
/* ใช้สีเดียวกับ .table-striped-columns ของ Bootstrap */
.table-column-highlight {
  --bs-table-column-bg: rgba(var(--bs-emphasis-color-rgb), 0.05);
  background-color: var(--bs-table-column-bg) !important;
}

:root {
  --custom-modal-radius: 8px;
  --custom-card-radius: 8px;
  --custom-btn-radius: 4px;
  
  --bs-modal-border-radius: var(--custom-modal-radius);
  --bs-card-border-radius: var(--custom-card-radius);
  --bs-btn-border-radius: var(--custom-btn-radius);
  
  /* Button Sizes Variables */
  --bs-btn-sm-height: 30px;
  --bs-btn-sm-font-size: 12px;
  
  --bs-btn-md-height: 36px;
  --bs-btn-md-font-size: 14px;
  
  --bs-btn-lg-height: 42px;
  --bs-btn-lg-font-size: 16px;
  
  /* Custom Gray Variables (Tuned to Primary #556ee6) */
  --bs-gray-50: #f9f9fb;
  --bs-gray-100: #f3f4f6;
  --bs-gray-200: #e5e6eb;
  --bs-gray-300: #cdcfda;
  --bs-gray-400: #959ab1;
  --bs-gray-500: #666c8a;
  --bs-gray-600: #4c5067;
  --bs-gray-700: #3b3e4f;
  --bs-gray-800: #252732;
  --bs-gray-900: #181920;
  
  --bs-gray: #4c5067;
  --bs-gray-dark: #252732;

  /* Note: Default btn is 36px, btn-sm is 30px, btn-lg is 42px */
}

/* ===== ANIMATIONS ===== */
@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

@keyframes float {
  0% { transform: translateY(0px); }
  50% { transform: translateY(-10px); }
  100% { transform: translateY(0px); }
}

@keyframes pulse-soft {
  0% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.05); opacity: 0.8; }
  100% { transform: scale(1); opacity: 1; }
}

/* Gradient Flow Animation - เหมือนหน้า Login */
@keyframes gradientFlow {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

.animate-spin {
  animation: spin 4s linear infinite;
}

.animate-spin-slow {
  animation: spin 10s linear infinite;
}

.animate-float {
  animation: float 3s ease-in-out infinite;
}

.animate-pulse {
  animation: pulse-soft 2s ease-in-out infinite;
}

/* ===== UTILITY PAGE STYLES ===== */
.utility-page-content {
  position: relative;
  z-index: 1;
}

.utility-bg-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: radial-gradient(circle at center, rgba(85, 110, 230, 0.05) 0%, rgba(255, 255, 255, 0) 70%);
  z-index: 0;
  pointer-events: none;
}

.maintenance-icon-box {
  width: 80px;
  height: 80px;
  line-height: 80px;
  background: rgba(85, 110, 230, 0.1);
  border-radius: 50%;
  text-align: center;
  margin: 0 auto 20px;
  transition: all 0.3s ease;
}

.maintenance-box:hover .maintenance-icon-box {
  background: var(--bs-primary);
  transform: translateY(-5px);
}

.maintenance-box:hover .maintenance-icon-box i,
.maintenance-box:hover .maintenance-icon-box span {
  color: #fff !important;
}

.error-img {
  position: relative;
}

.error-img .error-icon {
  position: absolute;
  font-size: 4rem;
  color: var(--bs-primary);
  opacity: 0.2;
}

.error-icon-1 { top: 10%; left: 10%; animation: float 4s ease-in-out infinite; }
.error-icon-2 { bottom: 10%; right: 10%; animation: float 5s ease-in-out infinite reverse; }
.error-icon-3 { top: 50%; left: 50%; transform: translate(-50%, -50%); animation: pulse-soft 3s infinite; }

/* ===== CARD GROUP CUSTOMIZATION ===== */
@media (min-width: 576px) {
  /* 1. Card: Not Last Child -> Remove Right Radius */
  .card-group > .card:not(:last-child) {
    border-top-right-radius: 0 !important;
    border-bottom-right-radius: 0 !important;
  }
  /* Image: Not Last Child -> Remove Top-Right Radius */
  .card-group > .card:not(:last-child) .card-img-top {
    border-top-right-radius: 0 !important;
  }

  /* 2. Card: Not First Child -> Remove Left Radius */
  .card-group > .card:not(:first-child) {
    border-top-left-radius: 0 !important;
    border-bottom-left-radius: 0 !important;
  }
  /* Image: Not First Child -> Remove Top-Left Radius */
  .card-group > .card:not(:first-child) .card-img-top {
    border-top-left-radius: 0 !important;
  }

  /* 3. Enforce Radius on Outer Corners (Optional but good for consistency) */
  .card-group > .card:first-child {
    border-top-left-radius: var(--custom-card-radius) !important;
    border-bottom-left-radius: var(--custom-card-radius) !important;
  }
  .card-group > .card:first-child .card-img-top {
    border-top-left-radius: var(--custom-card-radius) !important;
  }

  .card-group > .card:last-child {
    border-top-right-radius: var(--custom-card-radius) !important;
    border-bottom-right-radius: var(--custom-card-radius) !important;
  }
  .card-group > .card:last-child .card-img-top {
    border-top-right-radius: var(--custom-card-radius) !important;
  }
}


/* ===== ICON CUSTOMIZATION ===== */
/* Hide center dot in icons (e.g., mdi-vector-circle-variant) */
.hide-center-dot {
  position: relative;
  display: inline-block !important;
}
.hide-center-dot::after {
  content: '';
  position: absolute;
  bottom: calc(15% + 4px);
  right: calc(15% - 5px);
  width: 14px;
  height: 14px;
  background: #F9F9F9;
  border-radius: 50%;
  z-index: 10;
  pointer-events: none;
}

/* ===== GLOBAL FONT FAMILY ===== */
/* Set Poppins as default font for text elements only */
body,
p,
span:not([class*="bx"]):not([class*="mdi"]):not([class*="material-symbols"]),
div:not([class*="bx"]):not([class*="mdi"]):not([class*="material-symbols"]),
a:not([class*="bx"]):not([class*="mdi"]):not([class*="material-symbols"]),
button:not([class*="bx"]):not([class*="mdi"]):not([class*="material-symbols"]),
input,
textarea,
select,
label,
td, th,
.form-control,
.form-label,
.form-select,
.btn:not(.btn-icon),
.card-text,
.badge,
.alert,
.modal-body {
  font-family: var(--bs-body-font-family, 'Poppins', sans-serif) !important;
}

/* ===== ANIMATIONS FOR POS PAGE ===== */
@keyframes slideInRight {
  from {
    transform: translateX(100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: scale(0.95);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

/* ซ่อน body overflow เมื่อ cart เปิด - ป้องกัน scrollbar ซ้อนกัน */
body.cart-open {
  overflow: hidden !important;
}

body.cart-open .main-content {
  overflow: hidden !important;
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Offcanvas สำหรับ POS - Full Screen & Clean Scrollbar */
.offcanvas-pos-cart {
  width: 480px !important;
  height: 100vh !important;
  top: 0 !important;
  border-left: 1px solid rgba(0,0,0,0.1) !important;
}

/* ปรับ scrollbar ใน offcanvas ให้สวยงาม */
.offcanvas-pos-cart .offcanvas-body::-webkit-scrollbar {
  width: 8px;
}

.offcanvas-pos-cart .offcanvas-body::-webkit-scrollbar-track {
  background: transparent;
}

.offcanvas-pos-cart .offcanvas-body::-webkit-scrollbar-thumb {
  background: rgba(0,0,0,0.1);
  border-radius: 10px;
}

.offcanvas-pos-cart .offcanvas-body::-webkit-scrollbar-thumb:hover {
  background: rgba(0,0,0,0.2);
}

/* ซ่อน scrollbar ภายใน cart items แต่ยังเลื่อนได้ */
.cart-items-container {
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(0,0,0,0.1) transparent;
}

.cart-items-container::-webkit-scrollbar {
  width: 6px;
}

.cart-items-container::-webkit-scrollbar-track {
  background: transparent;
}

.cart-items-container::-webkit-scrollbar-thumb {
  background: rgba(0,0,0,0.08);
  border-radius: 10px;
}

/* ===== DEV SIDEBAR MENU ===== */
.dev-sidebar-menu {
  padding: 10px;
}

.dev-sidebar-menu .nav-link {
  color: var(--bs-gray-700);
  padding: 1rem 1rem;
  border-radius: 4px;
  transition: none !important; /* Force disable transition */
  display: flex;
  align-items: center;
  justify-content: space-between;
  border: none !important;
  font-weight: 600;
  margin-bottom: 0.25rem;
  width: 100%;
}

.dev-sidebar-menu .nav-link:hover {
  color: var(--bs-info);
  background-color: rgba(80, 165, 241, 0.05) !important; /* Lighter Info color (50% of active) */
}

.dev-sidebar-menu .nav-link.active {
  color: var(--bs-info) !important;
  background-color: rgba(80, 165, 241, 0.1) !important;
  font-weight: 700;
}

.dev-sidebar-menu .menu-arrow {
  font-size: 18px;
  transition: transform 0.3s;
  color: var(--bs-gray-400);
}

.dev-sidebar-menu .nav-link[aria-expanded="true"] .menu-arrow {
  transform: rotate(90deg);
  color: var(--bs-info);
}

.dev-sidebar-menu .sub-menu {
  padding-left: 0;
  list-style: none;
  margin-top: 0;
  margin-bottom: 0;
  padding-bottom: 0;
}

.dev-sidebar-menu .sub-menu .nav-link {
  padding-left: 1.5rem;
  padding-top: 8px;
  padding-bottom: 8px;
  font-size: 0.9rem;
  color: var(--bs-gray-600);
  font-weight: 500;
  background-color: var(--bs-gray-50);
  margin-bottom: 0; /* No space between items */
  border-radius: 0; /* Square corners for continuous look */
  transition: none !important; /* Force disable transition */
}

/* Round corners for first and last item in submenu for cleaner look */
.dev-sidebar-menu .sub-menu li:first-child .nav-link {
  border-top-left-radius: 4px;
  border-top-right-radius: 4px;
}

.dev-sidebar-menu .sub-menu li:last-child .nav-link {
  border-bottom-left-radius: 4px;
  border-bottom-right-radius: 4px;
}

.dev-sidebar-menu .sub-menu .nav-link:hover {
  color: var(--bs-info);
  background-color: rgba(80, 165, 241, 0.05) !important; /* Lighter Info color */
}

.dev-sidebar-menu .sub-menu .nav-link.active {
  color: var(--bs-info) !important;
  background-color: rgba(80, 165, 241, 0.1) !important;
  font-weight: 600;
}

/* ===== DEV SIDEBAR DARK MODE ===== */
[data-bs-theme="dark"] .dev-sidebar-menu .nav-link {
  color: var(--bs-gray-400);
}

[data-bs-theme="dark"] .dev-sidebar-menu .nav-link:hover {
  background-color: var(--bs-gray-700) !important;
  color: var(--bs-info);
}

[data-bs-theme="dark"] .dev-sidebar-menu .sub-menu .nav-link {
  background-color: rgba(0, 0, 0, 0.2);
  color: var(--bs-gray-500);
}

[data-bs-theme="dark"] .dev-sidebar-menu .sub-menu .nav-link:hover {
  background-color: var(--bs-gray-700) !important;
  color: var(--bs-info);
}

[data-bs-theme="dark"] .dev-sidebar-menu .sub-menu .nav-link.active {
  background-color: rgba(80, 165, 241, 0.15) !important;
  color: var(--bs-info) !important;
}

/* ===== SIDEBAR SIMPLEBAR SCROLLBAR ===== */
/* Scrollbar แบบบางสำหรับ Sticky Sidebar (เหมือน Right Sidebar) */
.sidebar-simplebar .simplebar-scrollbar::before {
  background-color: rgba(0, 0, 0, 0.15);
  border-radius: 3px;
}

.sidebar-simplebar .simplebar-scrollbar.simplebar-visible::before {
  opacity: 1;
}

.sidebar-simplebar .simplebar-track.simplebar-vertical {
  width: 6px;
  right: 2px;
}

[data-bs-theme="dark"] .sidebar-simplebar .simplebar-scrollbar::before {
  background-color: rgba(255, 255, 255, 0.15);
}

.cart-items-container::-webkit-scrollbar-thumb:hover {
  background: rgba(0,0,0,0.15);
}

h1, h2, h3, h4, h5, h6,
.card-title,
.modal-title {
  font-family: var(--bs-heading-font-family, 'Poppins', sans-serif) !important;
}

/* Dynamic Font Sizes for Headings (Controlled by RightSidebar Settings) */
h1, .h1 { font-size: var(--bs-h1-font-size, 2.03125rem); }
h2, .h2 { font-size: var(--bs-h2-font-size, 1.625rem); }
h3, .h3 { font-size: var(--bs-h3-font-size, 1.42188rem); }
h4, .h4 { font-size: var(--bs-h4-font-size, 1.21875rem); }
h5, .h5 { font-size: var(--bs-h5-font-size, 1.01563rem); }
h6, .h6 { font-size: var(--bs-h6-font-size, 0.8125rem); }

.card {
  border-radius: var(--custom-card-radius);
  overflow: visible !important; /* Disable overflow hidden to prevent anti-aliasing artifacts */
  background-color: var(--bs-card-bg);
}

/* 
   Fix White Edge Artifact (User Analysis):
   When card-header radius equals card radius, a white line appears due to anti-aliasing/clipping.
   Reducing the header radius by ~5px (e.g., 22px -> 17px) eliminates this artifact.
   We use max(0px, ...) to prevent negative values for small radii.
*/
.card-header:first-child {
  border-radius: max(0px, calc(var(--custom-card-radius) - 5px)) max(0px, calc(var(--custom-card-radius) - 5px)) 0 0 !important;
}

.card-footer:last-child {
  border-radius: 0 0 max(0px, calc(var(--custom-card-radius) - 5px)) max(0px, calc(var(--custom-card-radius) - 5px)) !important;
}

.card-img-top {
  border-top-left-radius: max(0px, calc(var(--custom-card-radius) - 5px)) !important;
  border-top-right-radius: max(0px, calc(var(--custom-card-radius) - 5px)) !important;
}

/* Welcome Card Gradient Header - Fix white edge artifact */
.welcome-header-gradient {
  border-top-left-radius: max(0px, calc(var(--custom-card-radius) - 1px)) !important;
  border-top-right-radius: max(0px, calc(var(--custom-card-radius) - 1px)) !important;
  /* Fix anti-aliasing artifacts */
  transform: translateZ(0);
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
  margin: -1px;
  margin-bottom: 0;
  padding-top: 1px;
}

.modal-content {
  border-radius: var(--custom-modal-radius) !important;
  overflow: hidden !important;
}

.modal-header {
  border-top-left-radius: var(--custom-modal-radius) !important;
  border-top-right-radius: var(--custom-modal-radius) !important;
}

.modal-footer {
  border-bottom-left-radius: var(--custom-modal-radius) !important;
  border-bottom-right-radius: var(--custom-modal-radius) !important;
}

/* ===== BUTTON CUSTOMIZATION ===== */
body .btn {
  /* Force height to 36px */
  height: var(--bs-btn-md-height) !important;
  /* Center content */
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  /* Adjust padding to be minimal so height is controlled by height property or line-height */
  padding-top: 0 !important;
  padding-bottom: 0 !important;
  /* Use variable for font size */
  font-size: var(--bs-btn-md-font-size) !important;
  /* Use variable for border radius - REMOVED !important to allow inline styles for preview */
  border-radius: var(--custom-btn-radius);
}

/* Adjust icon buttons if needed */
body .btn-icon {
  width: var(--bs-btn-md-height) !important;
  height: var(--bs-btn-md-height) !important;
  padding: 0 !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
}

body .btn-icon.btn-lg {
  width: var(--bs-btn-lg-height) !important;
  height: var(--bs-btn-lg-height) !important;
}

body .btn-icon.btn-sm {
  width: var(--bs-btn-sm-height) !important;
  height: var(--bs-btn-sm-height) !important;
}

/* Icon size inside btn-icon - Auto adjust based on button size */
body .btn .material-symbols-rounded,
body .btn .bx,
body .btn .mdi,
body .btn i {
  font-size: 18px !important;
}

body .btn-icon.btn-sm .material-symbols-rounded,
body .btn-icon.btn-sm .bx,
body .btn-icon.btn-sm .mdi,
body .btn-icon.btn-sm i {
  font-size: 16px !important;
}

body .btn-icon.btn-lg .material-symbols-rounded,
body .btn-icon.btn-lg .bx,
body .btn-icon.btn-lg .mdi,
body .btn-icon.btn-lg i {
  font-size: 20px !important;
}

/* ===== ICON FONT SIZE STANDARDS ===== */
/* Icon with text (inline icons) */
.material-symbols-rounded.me-1,
.material-symbols-rounded.me-2,
.material-symbols-rounded.ms-1,
.material-symbols-rounded.ms-2 {
  font-size: 18px;
}

/* Align middle icons */
.material-symbols-rounded.align-middle {
  font-size: 18px;
  vertical-align: middle;
}

/* Adjust sizes */
body .btn-lg {
  height: var(--bs-btn-lg-height) !important;
  font-size: var(--bs-btn-lg-font-size) !important;
}

body .btn-sm {
  height: var(--bs-btn-sm-height) !important;
  font-size: var(--bs-btn-sm-font-size) !important;
}

/* ===== MAIN SIDEBAR CUSTOMIZATIONS ===== */

/* Sidebar font sizes */
#sidebar-menu ul li a {
  font-size: 14.5px !important;
  transition: all 0.3s ease !important;
}

#sidebar-menu ul li a i,
#sidebar-menu ul li a .material-symbols-rounded {
  font-size: 18px !important;
  display: inline-block;
  min-width: 1.75rem;
  width: 1.75rem;
  vertical-align: middle;
}



#sidebar-menu .menu-title {
  font-size: 11px !important;
}

/* Submenu styles - Fixed height 44px per item */
#sidebar-menu ul li ul.sub-menu li a {
  font-size: 13.5px !important;
  padding: 12px 1.5rem !important;
  line-height: 20px !important;
  min-height: 44px !important;
  display: flex !important;
  align-items: center !important;
  transition: all 0.3s ease !important;
  background-color: rgba(0, 0, 0, 0.15) !important;
  white-space: nowrap !important;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
  box-sizing: border-box !important;
  max-width: 100% !important;
}

#sidebar-menu ul li ul.sub-menu li a:hover {
  background-color: rgba(62, 146, 204, 0.15) !important;
}

/* Submenu ชั้นที่ 2 (nested submenu) */
#sidebar-menu ul li ul.sub-menu li ul.sub-menu li a {
  background-color: rgba(0, 0, 0, 0.3) !important;  
  padding: 0 1.5rem 0 2rem !important;  
  border-left: 3px solid rgba(62, 146, 204, 0.3) !important; /* Left border */
  margin-left: 0 !important; /* Indent the whole item */
}

#sidebar-menu ul li ul.sub-menu li ul.sub-menu li a:hover {
  background-color: rgba(62, 146, 204, 0.2) !important;
  border-left-color: rgba(62, 146, 204, 0.8) !important; /* Brighter border on hover */
  color: #ffffff !important;
}

/* Metismenu collapse animation */
#sidebar-menu ul li ul.sub-menu.mm-collapse {
  display: none;
}

#sidebar-menu ul li ul.sub-menu.mm-show {
  display: block;
}

#sidebar-menu ul li ul.sub-menu.mm-collapsing {
  position: relative;
  height: 0;
  overflow: hidden;
  transition-timing-function: ease;
  transition-duration: 0.35s;
  transition-property: height, visibility;
}

/* Arrow rotation & Styling (Left Sidebar) */
#sidebar-menu ul li a {
  display: flex !important;
  align-items: center !important;
}

#sidebar-menu .has-arrow:after {
  content: "\e313"; /* keyboard_arrow_down */
  font-family: 'Material Symbols Rounded';
  display: block !important;
  float: none !important;
  transition: transform 0.35s ease;
  font-size: 1.2rem;
  font-weight: normal;
  font-style: normal;
  line-height: 1;
  margin-left: auto !important;
}

#sidebar-menu .mm-active > .has-arrow:after {
  transform: rotate(180deg);
}

/* Fix for Collapsed Sidebar - Hide Arrow */
body.vertical-collpsed #sidebar-menu .has-arrow:after {
  display: none !important;
}

/* Fix for Collapsed Sidebar - Restore Block Display for correct icon alignment */
body.vertical-collpsed #sidebar-menu ul li a {
  display: block !important;
}

/* Click and hover effects */
#sidebar-menu ul li a:active,
#sidebar-menu ul li a.active-menu-click {
  background-color: rgba(62, 146, 204, 0.1) !important;
}

#sidebar-menu ul li a:hover {
  background-color: rgba(255, 255, 255, 0.05) !important;
  transition: background-color 0.2s ease !important;
}

/* Dark sidebar submenu backgrounds */
body[data-sidebar=dark].vertical-collpsed .vertical-menu #sidebar-menu>ul>li:hover>ul {
  background-color: var(--bs-gray-800) !important;
}

body[data-sidebar=dark].vertical-collpsed .vertical-menu #sidebar-menu>ul>li:hover>a {
  background: var(--bs-gray-700) !important;
}

/* Add padding to submenu items in collapsed hover state */
body[data-sidebar=dark].vertical-collpsed .vertical-menu #sidebar-menu>ul>li:hover>ul a {
  padding-left: 10px !important;
}

/* Fix submenu width and text overflow in collapsed hover state */
.vertical-collpsed .vertical-menu #sidebar-menu > ul > li:hover > ul {
  width: 220px !important;
}

.vertical-collpsed .vertical-menu #sidebar-menu > ul > li:hover > ul a {
  width: 220px !important;
  white-space: nowrap !important;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
  padding-right: 20px !important;
}

/* Style disabled menu items - very transparent */
.vertical-menu #sidebar-menu > ul > li.menu-disabled > a {
  opacity: 0.15 !important;
  cursor: not-allowed !important;
}

/* Completely disable hover on menu-disabled items in expanded state */
.vertical-menu #sidebar-menu > ul > li.menu-disabled:hover > a {
  background-color: transparent !important;
  color: inherit !important;
  pointer-events: none !important;
}

.vertical-menu #sidebar-menu > ul > li.menu-disabled:hover > a i,
.vertical-menu #sidebar-menu > ul > li.menu-disabled:hover > a .material-symbols-rounded {
  color: inherit !important;
}

/* Hide submenu of disabled menu items in collapsed state */
.vertical-collpsed .vertical-menu #sidebar-menu > ul > li.menu-disabled:hover > ul,
.vertical-collpsed .vertical-menu #sidebar-menu > ul > li.menu-disabled > ul {
  display: none !important;
}

/* Prevent hover effect on disabled items in collapsed state - keep centered icon */
.vertical-collpsed .vertical-menu #sidebar-menu > ul > li.menu-disabled > a {
  text-align: center !important;
  padding: 15px 0 !important;
}

.vertical-collpsed .vertical-menu #sidebar-menu > ul > li.menu-disabled:hover > a {
  width: 70px !important;
  background-color: transparent !important;
  text-align: center !important;
  padding: 15px 0 !important;
}

.vertical-collpsed .vertical-menu #sidebar-menu > ul > li.menu-disabled:hover > a span {
  display: none !important;
}

.vertical-collpsed .vertical-menu #sidebar-menu > ul > li.menu-disabled:hover > a i,
.vertical-collpsed .vertical-menu #sidebar-menu > ul > li.menu-disabled:hover > a .material-symbols-rounded {
  margin-left: 0 !important;
  margin-right: 0 !important;
  position: static !important;
  left: auto !important;
}

/* Fix: Remove unnecessary min-height from Skote */
body[data-sidebar=dark].vertical-collpsed {
  min-height: auto !important;
}

/* ===== COLLAPSED SIDEBAR STATE ===== */

/* Fix Logo in Collapsed Mode */
body.vertical-collpsed .navbar-brand-box {
  width: 70px !important;
  background-color: var(--bs-gray-800) !important;
  border: none !important; /* Remove all borders */
  padding: 0 !important;
  margin: 0 !important;
}

body.vertical-collpsed .navbar-brand-box .logo-sm {
  display: flex !important;
  justify-content: center;
  align-items: center;
  width: 70px;
  height: 70px;
  background-color: var(--bs-gray-800) !important; /* Ensure background covers everything */
}

/* ==========================================================================
   FIX: SIDEBAR COLLAPSED MODE SUBMENUS (CRITICAL)
   ========================================================================== */

/* 
   ⚠️ CRITICAL WARNING: DO NOT MODIFY THIS SECTION WITHOUT TESTING SIDEBAR COLLAPSED MODE! ⚠️
   
   The following rules force 'overflow: visible' on all sidebar containers.
   This is REQUIRED for the submenus to "pop out" correctly when the sidebar is collapsed (minimized).
   
   If you remove '.custom-scroll-area' or any other class from this list, 
   the submenus will be clipped/hidden inside the sidebar container.
   
   DO NOT CHANGE 'overflow: visible' TO 'hidden' or 'auto' FOR THESE CLASSES!
*/

/* 1. Force Overflow Visible on ALL Sidebar Containers */
body.vertical-collpsed .vertical-menu,
body.vertical-collpsed .vertical-menu .custom-scroll-area,
body.vertical-collpsed .vertical-menu .simplebar-wrapper,
body.vertical-collpsed .vertical-menu .simplebar-mask,
body.vertical-collpsed .vertical-menu .simplebar-offset,
body.vertical-collpsed .vertical-menu .simplebar-content-wrapper,
body.vertical-collpsed .vertical-menu .simplebar-content,
body.vertical-collpsed .vertical-menu #sidebar-menu,
body.vertical-collpsed .vertical-menu #sidebar-menu > ul {
    overflow: visible !important;
}

/* Hide Scrollbars in Collapsed Mode (Since we forced overflow: visible) */
body.vertical-collpsed .vertical-menu .simplebar-content-wrapper {
    -ms-overflow-style: none !important;  /* IE and Edge */
    scrollbar-width: none !important;  /* Firefox */
}
body.vertical-collpsed .vertical-menu .simplebar-content-wrapper::-webkit-scrollbar {
    display: none !important;
}

/* Ensure Sidebar stays fixed and on top */
body.vertical-collpsed .vertical-menu {
    position: fixed !important;
    z-index: 1005 !important;
    width: 70px !important;
}

/* 2. Level 1 Item Positioning */
body.vertical-collpsed .vertical-menu #sidebar-menu > ul > li {
    position: relative !important;
    overflow: visible !important; /* Ensure submenu can overflow */
}

/* 3. Level 2 Submenu (The Popup) */
body.vertical-collpsed .vertical-menu #sidebar-menu > ul > li:hover > ul.sub-menu {
    display: block !important;
    position: absolute !important;
    left: 70px !important;
    top: 0 !important;
    width: 220px !important; /* Slightly wider for better readability */
    height: auto !important;
    background-color: var(--bs-gray-800) !important;
    box-shadow: 4px 4px 10px rgba(0, 0, 0, 0.2) !important;
    padding: 8px 0 !important;
    border-radius: 0 6px 6px 0 !important;
    z-index: 9999 !important;
    visibility: visible !important;
    opacity: 1 !important;
    pointer-events: auto !important;
    border: 1px solid rgba(255, 255, 255, 0.1) !important;
}

/* Override MetisMenu collapse/collapsing classes */
body.vertical-collpsed .vertical-menu #sidebar-menu > ul > li:hover > ul.sub-menu.mm-collapse,
body.vertical-collpsed .vertical-menu #sidebar-menu > ul > li:hover > ul.sub-menu.mm-collapsing {
    display: block !important;
    height: auto !important;
    visibility: visible !important;
    overflow: visible !important;
}

/* Level 2 Items */
body.vertical-collpsed .vertical-menu #sidebar-menu > ul > li:hover > ul.sub-menu > li {
    display: block !important;
    position: relative !important; /* For Level 3 positioning */
    width: 100% !important;
}

body.vertical-collpsed .vertical-menu #sidebar-menu > ul > li:hover > ul.sub-menu > li > a {
    padding: 10px 20px !important;
    width: 100% !important;
    display: flex !important;
    align-items: center !important;
    color: var(--bs-gray-400) !important;
    background-color: transparent !important;
    white-space: nowrap !important;
    text-align: left !important;
    font-size: 13.5px !important;
}

body.vertical-collpsed .vertical-menu #sidebar-menu > ul > li:hover > ul.sub-menu > li > a:hover {
    color: #ffffff !important;
    background-color: rgba(255, 255, 255, 0.05) !important;
}

/* 4. Level 3 Submenu (Nested Popup) */
body.vertical-collpsed .vertical-menu #sidebar-menu > ul > li > ul.sub-menu > li:hover > ul.sub-menu {
    display: block !important;
    position: absolute !important;
    left: 100% !important; /* Position to the right of Level 2 */
    top: -5px !important; /* Align slightly higher */
    width: 200px !important;
    background-color: var(--bs-gray-800) !important;
    box-shadow: 4px 4px 10px rgba(0, 0, 0, 0.2) !important;
    padding: 8px 0 !important;
    border-radius: 4px !important;
    z-index: 10000 !important; /* Higher than Level 2 */
    visibility: visible !important;
    opacity: 1 !important;
    border: 1px solid rgba(255, 255, 255, 0.1) !important;
    margin-left: 0px !important;
}

/* Override MetisMenu for Level 3 */
body.vertical-collpsed .vertical-menu #sidebar-menu > ul > li > ul.sub-menu > li:hover > ul.sub-menu.mm-collapse {
    display: block !important;
    height: auto !important;
    visibility: visible !important;
}

/* 5. Fix Profile Menu in Collapsed Mode */
body.vertical-collpsed .sidebar-profile .dropdown-menu {
    left: 70px !important; /* Open to the side */
    bottom: 0 !important;
    top: auto !important;
    margin-bottom: 0 !important;
    border-radius: 0 4px 0 0 !important;
    box-shadow: 4px -4px 10px rgba(0, 0, 0, 0.2) !important;
}

/* ===== BROWSER NATIVE SCROLLBAR (ซ่อน - ใช้ SimpleBar แทน) ===== */

/* ซ่อน native scrollbar ของ html/body */
html, body {
  overflow: hidden;
  height: 100%;
}

/* Main content SimpleBar - ให้ทำงานเหมือน div.main-content เดิม */
.main-content-simplebar {
  height: calc(100vh - 70px) !important; /* ลบ topbar height */
  margin-top: 70px; /* ชดเชย topbar */
}

.main-content-simplebar .simplebar-content-wrapper {
  overflow-x: hidden !important;
}

/* SimpleBar content - ให้เต็มความสูง เพื่อ footer ชิดล่าง */
.main-content-simplebar .simplebar-content {
  min-height: 100%;
  display: flex;
  flex-direction: column;
}

/* Page content - ขยายเต็มพื้นที่ */
.main-content-simplebar .page-content {
  flex: 1;
  padding-top: calc(24px + 0px) !important; /* ลบ padding-top ที่เกิน */
  padding-bottom: 12px !important; /* เท่ากับ container-fluid padding */
  margin-top: 0 !important;
}

/* Footer ใน SimpleBar - ชิดล่างเสมอ */
.main-content-simplebar .footer {
  position: relative;
  left: 0;
  bottom: 0;
  right: 0;
  margin-top: auto; /* ดัน footer ลงล่างสุด */
}

/* SimpleBar scrollbar styling */
.main-content-simplebar > .simplebar-track.simplebar-vertical {
  width: 10px !important;
  right: 0 !important;
}

.main-content-simplebar > .simplebar-track.simplebar-vertical .simplebar-scrollbar::before {
  background-color: rgba(0, 0, 0, 0.15) !important;
  width: 6px !important;
  left: 2px !important;
  border-radius: 10px !important;
}

.main-content-simplebar > .simplebar-track.simplebar-vertical:hover .simplebar-scrollbar::before,
.main-content-simplebar > .simplebar-track.simplebar-vertical .simplebar-scrollbar:hover::before {
  background-color: rgba(0, 0, 0, 0.3) !important;
}

/* Dark Mode */
[data-bs-theme="dark"] .main-content-simplebar > .simplebar-track.simplebar-vertical .simplebar-scrollbar::before {
  background-color: rgba(255, 255, 255, 0.2) !important;
}

[data-bs-theme="dark"] .main-content-simplebar > .simplebar-track.simplebar-vertical:hover .simplebar-scrollbar::before,
[data-bs-theme="dark"] .main-content-simplebar > .simplebar-track.simplebar-vertical .simplebar-scrollbar:hover::before {
  background-color: rgba(255, 255, 255, 0.4) !important;
}


/* ===== TABLE STICKY HEADER (หัวตารางตรึงใต้ Topbar) ===== */

/* Wrapper ไม่มี overflow เพื่อให้ sticky ทำงาน */
.table-responsive-wrapper {
  width: 100%;
}

.table-sticky-header {
  position: relative;
}

.table-sticky-header thead th {
  position: sticky;
  top: -1px; /* ชดเชย border ให้ชิดสนิท */
  z-index: 10;
  background-color: var(--bs-tertiary-bg) !important;
}

/* Dark Mode */
[data-bs-theme="dark"] .table-sticky-header thead th {
  background-color: var(--bs-tertiary-bg) !important;
}


/* ===== SCROLL TO TOP BUTTON ===== */

.scroll-to-top-btn {
  position: fixed;
  bottom: 30px;
  right: 30px;
  width: 48px;
  height: 48px;
  background-color: var(--bs-primary);
  color: #fff;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  opacity: 0;
  visibility: hidden;
  transform: translateY(20px);
  transition: all 0.3s ease-in-out;
  z-index: 1050;
  box-shadow: 0 4px 12px rgba(var(--bs-primary-rgb), 0.4);
}

.scroll-to-top-btn.show {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.scroll-to-top-btn:hover {
  background-color: var(--bs-primary);
  transform: translateY(-3px);
  box-shadow: 0 6px 20px rgba(var(--bs-primary-rgb), 0.5);
}

.scroll-to-top-btn .material-symbols-rounded {
  font-size: 28px;
  line-height: 1;
}

/* Scroll to top button - push when Right Sidebar is open */
body.right-bar-enabled .scroll-to-top-btn {
  right: 280px; /* 30px + 250px (sidebar width) */
  transition: right 0.3s ease-in-out, opacity 0.3s ease-in-out, visibility 0.3s ease-in-out, transform 0.3s ease-in-out;
}

@media (max-width: 991.98px) {
  body.right-bar-enabled .scroll-to-top-btn {
    right: 30px; /* No push on mobile */
  }
}


/* ===== SIDEBAR SCROLLBAR (SimpleBar - Gemini/Modern Style) ===== */

/* 1. Track (รางเลื่อน) - พื้นที่สำหรับคลิก */
.simplebar-track.simplebar-vertical {
  width: 14px !important; /* กว้างพอให้กดง่าย (Hit Area) */
  background-color: transparent !important; /* โปร่งใส ไม่รบกวนสายตา */
  z-index: 100; /* อยู่บนสุด */
}

/* 2. Thumb (ตัวเลื่อน) - ปรับให้เป็น "แคปซูลลอยตัว" ตรงกลางราง */
.simplebar-scrollbar::before {
  background-color: rgba(255, 255, 255, 0.25) !important; /* สีขาวจางๆ แบบ Gemini */
  border-radius: 10px !important; /* กลมมน */
  width: 6px !important; /* ความกว้างจริงที่ตาเห็น (เล็กกว่าราง) */
  left: 4px !important; /* จัดกึ่งกลาง: (14px - 6px) / 2 = 4px */
  right: auto !important;
  top: 2px !important;
  bottom: 2px !important;
  opacity: 1 !important; /* ให้ SimpleBar จัดการ opacity เอง (มันจะ fade in/out) */
  transition: background-color 0.2s ease !important;
}

/* 3. Hover Effects - เมื่อเอาเมาส์ชี้ที่ราง หรือ ตัวเลื่อน */
.simplebar-track.simplebar-vertical:hover .simplebar-scrollbar::before,
.simplebar-scrollbar:hover::before {
  background-color: rgba(255, 255, 255, 0.5) !important; /* สว่างขึ้นชัดเจน */
}

/* 4. Right Sidebar Specifics (ปรับสีให้เข้ากับพื้นหลังที่เข้มกว่า) */
.offcanvas-end .simplebar-scrollbar::before,
.right-bar .simplebar-scrollbar::before {
  background-color: rgba(255, 255, 255, 0.2) !important;
}

.offcanvas-end .simplebar-track.simplebar-vertical:hover .simplebar-scrollbar::before,
.right-bar .simplebar-track.simplebar-vertical:hover .simplebar-scrollbar::before {
  background-color: rgba(255, 255, 255, 0.4) !important;
}

/* 5. Hide Native Scrollbar (ซ่อนของเดิมให้มิดชิด) */
.simplebar-content-wrapper::-webkit-scrollbar,
.custom-scroll-area::-webkit-scrollbar {
  display: none !important;
  width: 0 !important;
}

/* 6. Fix SimpleBar Height Calculation (ป้องกัน Scrollbar โผล่เมื่อไม่จำเป็น) */
.simplebar-content-wrapper {
  height: 100% !important;
}
.simplebar-placeholder {
  width: auto !important;
}

/* ===== TOPBAR LOGO CUSTOMIZATIONS ===== */

/* Remove border lines from navbar-brand-box */
.navbar-brand-box {
  border: none !important;
}

/* Keep background but remove the visual border effect */
body[data-sidebar=dark] .navbar-brand-box {
  background: var(--bs-gray-800) !important;
  border: none !important;
}

body[data-sidebar=colored] .navbar-brand-box {
  border: none !important;
}

/* Logo transition */
.navbar-brand-box .logo .logo-sm,
.navbar-brand-box .logo .logo-lg {
  transition: all 0.3s ease-in-out;
}

/* Default state - show large logo, hide small logo */
.navbar-brand-box .logo .logo-sm {
  display: none !important;
}

.navbar-brand-box .logo .logo-lg {
  display: block !important;
}

/* When sidebar is collapsed - show small logo, hide large logo */
body.vertical-collpsed .navbar-brand-box .logo .logo-sm {
  display: flex !important;
  justify-content: center;
  align-items: center;
  width: 70px;
  height: 70px;
  position: absolute;
  left: 0;
  top: 0;
}

body.vertical-collpsed .navbar-brand-box .logo .logo-lg {
  display: none !important;
}

/* Material Symbols in header buttons - match icon size */
/* FIX: Increase specificity to override global btn styles (body .btn ...) */
body .header-item .material-symbols-rounded,
body .navbar-header .btn .material-symbols-rounded {
  font-size: 24px !important;
  line-height: 1;
  vertical-align: middle;
  position: relative;
  top: 0px;
}

/* Right sidebar close button */
.offcanvas-end .btn-close {
  filter: invert(1);
  opacity: 0.8;
}

.offcanvas-end .btn-close:hover {
  opacity: 1;
}

/* ===== SIDEBAR PROFILE SECTION ===== */

/* Adjust simplebar height for profile */
.vertical-menu > [data-simplebar] {
  height: calc(100% - 60px) !important;
  overflow-y: auto !important;
}

/* Ensure sidebar menu area is scrollable */
.vertical-menu #sidebar-menu {
  overflow-y: auto !important;
  overflow-x: hidden !important;
  max-height: 100% !important;
}

/* Sidebar menu scrollbar customization */
.vertical-menu #sidebar-menu::-webkit-scrollbar {
  width: 6px;
}

.vertical-menu #sidebar-menu::-webkit-scrollbar-thumb {
  background-color: rgba(255, 255, 255, 0.15);
  border-radius: 10px;
}

.vertical-menu #sidebar-menu::-webkit-scrollbar-thumb:hover {
  background-color: rgba(255, 255, 255, 0.25);
}

.vertical-menu #sidebar-menu::-webkit-scrollbar-track {
  background-color: rgba(0, 0, 0, 0.1);
}

/* Profile container */
.sidebar-profile {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 250px;
  height: 60px;
  background-color: var(--bs-gray-800) !important;
  z-index: 100;
}

/* Profile toggle button */
.sidebar-profile-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 60px;
  padding: 10px 16px !important;
  background: none !important;
  border: none !important;
  cursor: pointer;
  color: var(--bs-gray-400) !important;
  transition: background-color 0.2s;
}

.sidebar-profile-toggle:hover {
  background-color: var(--bs-gray-700) !important;
  color: var(--bs-white) !important;
}

.sidebar-profile-toggle:focus,
.sidebar-profile-toggle:active {
  color: var(--bs-white) !important;
  background-color: var(--bs-gray-700) !important;
  box-shadow: none !important;
  outline: none !important;
}

.sidebar-profile-toggle::after {
  display: none !important;
}

/* Profile info text */
.sidebar-profile-info h6 {
  color: var(--bs-white) !important;
  margin-bottom: 2px;
  line-height: 1.2;
}

.sidebar-profile-info p {
  color: var(--bs-gray-500) !important;
  line-height: 1.2;
}

/* Profile status indicator */
.sidebar-profile-status {
  position: absolute;
  top: 0;
  right: 0;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: 2px solid var(--bs-gray-800) !important;
  background-color: var(--bs-success) !important;
}

/* Profile dropdown menu */
.sidebar-profile-menu {
  width: 100%;
  margin: 0;
  border-radius: 4px 4px 0 0;
  background-color: var(--bs-gray-800) !important;
  border: 1px solid var(--bs-gray-700) !important;
}

.sidebar-profile-menu .dropdown-item {
  color: var(--bs-gray-400) !important;
  background-color: transparent !important;
  transition: all 0.3s;
  font-size: 13.5px !important;
  padding: 0.625rem 1rem !important;
}

.sidebar-profile-menu .dropdown-item:hover {
  background-color: var(--bs-gray-700) !important;
  color: var(--bs-white) !important;
}

.sidebar-profile-menu .dropdown-item.text-danger {
  color: var(--bs-danger) !important;
}

.sidebar-profile-menu .dropdown-item.text-danger:hover {
  background-color: rgba(var(--bs-danger-rgb), 0.1) !important;
  color: var(--bs-danger) !important;
}

.sidebar-profile-menu .dropdown-divider {
  border-color: var(--bs-gray-700) !important;
}

/* Profile in collapsed state */
body.vertical-collpsed .sidebar-profile {
  width: 70px;
}

body.vertical-collpsed .sidebar-profile-toggle {
  justify-content: center !important;
  padding: 10px 0 !important;
}

body.vertical-collpsed .sidebar-profile-info,
body.vertical-collpsed .sidebar-profile .ms-3,
body.vertical-collpsed .sidebar-profile .mdi-chevron-up {
  display: none !important;
}

body.vertical-collpsed .sidebar-profile .dropdown-menu {
  left: 0 !important;
  right: auto !important;
}

/* ===== RIGHT SIDEBAR (PUSH LAYOUT MODE) ===== */

/* Override Skote's .right-bar default positioning and z-index */
.right-bar {
  position: fixed !important;
  right: -260px !important;
  top: 70px !important; /* Below Topbar */
  bottom: 0 !important;
  width: 250px !important;
  z-index: 1001 !important; /* Below Topbar (1002) but above content */
  height: calc(100vh - 70px) !important;
  background-color: var(--bs-gray-800) !important;
  box-shadow: -2px 0 4px rgba(0, 0, 0, 0.05) !important;
  transition-property: right !important;
  transition-duration: 0.35s !important;
  transition-timing-function: ease !important;
  display: block !important;
}

/* When Right Bar is Enabled - Push layout to left */
body.right-bar-enabled .right-bar {
  right: 0 !important;
}

/* Main Content Transition */
.main-content {
  transition-property: margin-left, margin-right !important;
  transition-duration: 0.35s !important;
  transition-timing-function: ease !important;
}

/* Push main content when Right Sidebar is open */
body.right-bar-enabled .main-content {
  margin-right: 250px !important;
}

/* Fix sticky positioning by allowing overflow */
.main-content {
  overflow: visible !important;
}

/* Hide overlay backdrop (clean push effect without darkening) */
.rightbar-overlay {
  display: none !important;
}

/* Mobile Responsive - No push, overlay mode */
@media (max-width: 991.98px) {
  .right-bar {
    overflow: auto !important;
    width: 100% !important;
    right: -100% !important;
  }
  
  body.right-bar-enabled .right-bar {
    right: 0 !important;
  }
  
  /* No push on mobile */
  body.right-bar-enabled .main-content {
    margin-right: 0 !important;
  }
}

/* For React Bootstrap Offcanvas (if used) */
.offcanvas-end {
  z-index: 1001 !important;
  top: 70px !important;
  height: calc(100vh - 70px) !important;
}

.offcanvas-backdrop {
  z-index: 1000 !important;
}

/* App Dropdown Menu - Ensure it's above Right Sidebar */
.app-dropdown-menu {
  z-index: 1005 !important;
  margin-top: 0 !important;
  border-top-left-radius: 0 !important;
  border-top-right-radius: 0 !important;
  top: 100% !important;
  transform: none !important;
}

/* Notification Dropdown - Align with Topbar */
#page-header-notifications-dropdown + .dropdown-menu {
  margin-top: 0 !important;
  border-top-left-radius: 0 !important;
  border-top-right-radius: 0 !important;
  top: 100% !important;
  transform: none !important;
}

/* Header Dropdowns - Make them align with navbar bottom */
#page-header-user-dropdown + .dropdown-menu,
header .dropdown-menu.show {
  margin-top: 0 !important;
  border-top-left-radius: 0 !important;
  border-top-right-radius: 0 !important;
}

/* ===== ADD MORE CUSTOMIZATIONS BELOW ===== */

/* ===== Global Search Modal Styles ===== */
/* Modal dialog */
.global-search-modal .modal-dialog {
  max-width: 600px;
  margin-top: 10vh;
}

.global-search-modal .modal-content {
  border-radius: var(--bs-modal-border-radius);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  border: none;
  overflow: hidden;
}

/* Search input wrapper */
.search-input-wrapper {
  position: relative;
  padding: 20px;
  border-bottom: none;
  background: var(--bs-body-bg);
}

.search-icon {
  position: absolute;
  left: 28px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 20px;
  color: var(--bs-primary);
  opacity: 0.9;
}

/* Search input - OVERRIDE font-size to 14px */
.search-input {
  padding-left: 48px !important;
  padding-right: 100px !important;
  height: 48px;
  font-size: 14px !important;
  border: 2px solid var(--bs-border-color);
  border-radius: 10px;
  background: var(--bs-body-bg);
  color: var(--bs-body-color);
  transition: all 0.2s ease;
}

/* Light Mode search input */
[data-bs-theme="light"] .search-input {
  border-color: #dee2e6;
  background: #fff;
}

[data-bs-theme="light"] .search-input:focus {
  border-color: var(--bs-primary);
  background: #fff;
}

/* Dark Mode search input */
[data-bs-theme="dark"] .search-input {
  border-color: #495057;
  background: #2b3035;
}

[data-bs-theme="dark"] .search-input:focus {
  border-color: #7b8cff;
  background: #343a40;
}

/* Topbar search box font-size */
.app-search .form-control {
  font-size: 14px !important;
}

/* ===== TOPBAR MENU BUTTON ALIGNMENT =====
/* Fix menu button (3-bar icon) alignment */
#vertical-menu-btn {
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  padding:2.25rem 1.125rem !important;  
}

/* Search input focus state */
.search-input:focus {
  box-shadow: 0 0 0 3px rgba(var(--bs-primary-rgb), 0.15);
  outline: none;
}

/* Search spinner - override Bootstrap spinner animation */
.search-spinner {
  position: absolute;
  right: 120px;
  top: 50%;
  margin-top: -10px; /* Half of height for centering */
  width: 20px !important;
  height: 20px !important;
  border: 3px solid var(--bs-primary) !important;
  border-right-color: transparent !important;
  border-radius: 50% !important;
  animation: spinner-rotate 0.75s linear infinite !important;
}

@keyframes spinner-rotate {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* Light Mode spinner fix */
[data-bs-theme="light"] .search-spinner {
  border-color: var(--bs-primary) !important;
  border-right-color: transparent !important;
}

/* Dark Mode spinner fix */
[data-bs-theme="dark"] .search-spinner {
  border-color: #7b8cff !important;
  border-right-color: transparent !important;
}

/* Search shortcuts */
.search-shortcuts {
  position: absolute;
  right: 28px;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  gap: 8px;
  align-items: center;
  font-size: 13px;
  color: var(--bs-secondary);
}

.search-shortcuts kbd {
  padding: 3px 6px;
  font-size: 11px;
  background: var(--bs-secondary-bg);
  color: var(--bs-body-color);
  border: 1px solid var(--bs-border-color);
  border-radius: 4px;
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.08);
  font-weight: 500;
}

/* Search section (Recent Searches) */
.search-section {
  padding: 12px 0;
  margin: 0 16px;
  border-top: 1px solid var(--bs-border-color);
}

.search-section-title {
  padding: 8px 8px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--bs-secondary);
  letter-spacing: 0.8px;
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}

/* Light Mode search section */
[data-bs-theme="light"] .search-section {
  background: #f8f9fa;
  border-radius: 8px;
  border: 1px solid #e9ecef;
  margin-top: 8px;
}

[data-bs-theme="light"] .search-section-title {
  color: #6c757d;
}

/* Dark Mode search section */
[data-bs-theme="dark"] .search-section {
  background: #2b3035;
  border-radius: 8px;
  border: 1px solid #3d4349;
  margin-top: 8px;
}

[data-bs-theme="dark"] .search-section-title {
  color: #adb5bd;
}

/* Search result items */
.search-result-item {
  padding: 10px 12px;
  cursor: pointer;
  transition: all 0.2s;
  border: none;
  border-left: 3px solid transparent;
  border-radius: 6px;
  margin: 2px 4px;
}

.search-result-item:hover {
  background: rgba(var(--bs-primary-rgb), 0.08);
  border-left-color: var(--bs-primary);
}

.search-result-item.active {
  background: rgba(var(--bs-primary-rgb), 0.12);
  border-left-color: var(--bs-primary);
}

.result-icon {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  background: var(--bs-tertiary-bg);
  margin-right: 12px;
  flex-shrink: 0;
}

.search-result-item.active .result-icon {
  background: rgba(var(--bs-primary-rgb), 0.15);
  color: var(--bs-primary);
}

/* Template item styling */
.search-result-item[data-type="template"] .result-icon {
  background: rgba(var(--bs-info-rgb), 0.1);
  color: var(--bs-info);
}

.search-result-item[data-type="template"].active .result-icon {
  background: rgba(var(--bs-info-rgb), 0.2);
  color: var(--bs-info);
}

.search-result-item[data-type="template"]:hover .result-icon {
  background: rgba(var(--bs-info-rgb), 0.15);
}

/* Search results container */
.search-results {
  max-height: 400px;
  overflow-y: auto;
}

/* Empty state */
.search-empty {
  padding: 60px 20px;
  text-align: center;
}

.search-empty code {
  background: var(--bs-tertiary-bg);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 13px;
}

/* Search footer */
.search-footer {
  padding: 12px 20px;
  border-top: 1px solid var(--bs-border-color);
  background: var(--bs-tertiary-bg);
}

.search-tips {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 12px;
  color: var(--bs-body-color);
  opacity: 0.8;
}

.search-tips kbd {
  padding: 3px 6px;
  font-size: 11px;
  background: var(--bs-secondary-bg);
  color: var(--bs-body-color);
  border: 1px solid var(--bs-border-color);
  border-radius: 4px;
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.08);
  min-width: 24px;
  text-align: center;
  font-weight: 500;
}

/* Scrollbar */
.search-results::-webkit-scrollbar {
  width: 6px;
}

.search-results::-webkit-scrollbar-track {
  background: transparent;
}

.search-results::-webkit-scrollbar-thumb {
  background: var(--bs-border-color);
  border-radius: 3px;
}

.search-results::-webkit-scrollbar-thumb:hover {
  background: var(--bs-secondary);
}

/* ===== Light Mode specific fixes for Global Search ===== */
[data-bs-theme="light"] .search-shortcuts kbd,
[data-bs-theme="light"] .search-tips kbd {
  background: #e9ecef;
  color: #495057;
  border-color: #dee2e6;
}

[data-bs-theme="light"] .search-footer {
  background: #f8f9fa;
}

[data-bs-theme="light"] .search-tips {
  color: #495057;
}

[data-bs-theme="light"] .search-shortcuts {
  color: #6c757d;
}

/* ===== Dark Mode specific fixes for Global Search ===== */
[data-bs-theme="dark"] .search-shortcuts kbd,
[data-bs-theme="dark"] .search-tips kbd {
  background: #343a40;
  color: #e9ecef;
  border-color: #495057;
}

[data-bs-theme="dark"] .search-footer {
  background: #2b3035;
}

[data-bs-theme="dark"] .search-tips {
  color: #ced4da;
}

[data-bs-theme="dark"] .search-shortcuts {
  color: #adb5bd;
}

/* ==========================================================================
   ANIMATIONS FOR EMPTY STATE
   ========================================================================== */
@keyframes ripple-search {
  0% { box-shadow: 0 0 0 0 rgba(13, 110, 253, 0.4); }
  70% { box-shadow: 0 0 0 15px rgba(13, 110, 253, 0); }
  100% { box-shadow: 0 0 0 0 rgba(13, 110, 253, 0); }
}

@keyframes float-icon {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}

.anim-float-icon {
  animation: float-icon 3s ease-in-out infinite;
}

.anim-ripple-search {
  animation: ripple-search 2s infinite;
}

/* ===== TAB NAV WITH ICONS - PADDING ADJUSTMENT ===== */
/* Card tabs with icons need padding-left adjustment */
.nav-tabs-custom .nav-link:has(.material-symbols-rounded),
.nav-tabs-custom .nav-link:has(i[class*="mdi-"]),
.nav-tabs-custom .nav-link:has(i[class*="bx-"]) {
  padding-left: 5px !important;
}

/* ===== RIGHT SIDEBAR CUSTOMIZATIONS ===== */

/* FORCE Dark Theme for Right Sidebar - Always dark regardless of body theme */
.right-bar,
.offcanvas-end {
  background-color: var(--bs-gray-800) !important;
  color: var(--bs-gray-400) !important;
  /* Override any light theme variables */
  --bs-body-bg: var(--bs-gray-800) !important;
  --bs-body-color: var(--bs-gray-400) !important;
  --bs-border-color: rgba(255, 255, 255, 0.1) !important;
  --bs-tertiary-bg: var(--bs-gray-900) !important;
}

/* Override light theme styles */
[data-bs-theme="light"] .right-bar,
[data-bs-theme="light"] .offcanvas-end {
  background-color: var(--bs-gray-800) !important;
  color: var(--bs-gray-400) !important;
}

/* Right Sidebar Header */
.rightbar-title {
  height: 72px !important;
  min-height: 72px !important;
  background-color: var(--bs-gray-800) !important;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1) !important;
}

.rightbar-title h5 {
  font-size: 14.5px !important;
  color: var(--bs-gray-400) !important;
  margin: 0 !important;
}

/* Right Sidebar Tab Navigation */
.right-sidebar-tabs {
  background-color: var(--bs-gray-800) !important;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1) !important;
  padding: 0 !important;
  margin: 0 !important;
}

.right-sidebar-tabs .nav-item {
  flex: 1 !important;
}

.right-sidebar-tabs .nav-link {
  color: var(--bs-gray-400) !important;
  background: transparent !important;
  border: none !important;
  border-radius: 0 !important;
  border-bottom: 3px solid transparent !important;
  padding: 14px 8px !important;
  text-align: center !important;
  transition: all 0.3s ease !important;
  font-size: 14.5px !important;
}

.right-sidebar-tabs .nav-link:hover {
  color: #ffffff !important;
  background: rgba(255, 255, 255, 0.05) !important;
}

.right-sidebar-tabs .nav-link.active {
  color: #3E92CC !important;
  background: transparent !important;
  border-bottom-color: #3E92CC !important;
}

.right-sidebar-tabs .nav-link .material-symbols-rounded {
  font-size: 22px !important;
  display: block !important;
  color: inherit !important;
}

/* Right Sidebar Accordion Menu Items */
.right-sidebar-accordion .accordion-item {
  background-color: var(--bs-gray-800) !important;
  border-color: rgba(255, 255, 255, 0.1) !important;
}

.right-sidebar-accordion .accordion-header {
  font-size: 14.5px !important;
  background-color: var(--bs-gray-800) !important;
}

.right-sidebar-accordion .accordion-header button {
  font-size: 14.5px !important;
  color: var(--bs-gray-400) !important;
  background-color: var(--bs-gray-800) !important;
  border-color: rgba(255, 255, 255, 0.1) !important;
  transition: all 0.3s ease !important;
  height: 44px !important;
  min-height: 44px !important;
  padding: 0 1.5rem !important;
  display: flex !important;
  align-items: center !important;
}

.right-sidebar-accordion .accordion-header button:hover {
  color: #ffffff !important;
  background-color: rgba(255, 255, 255, 0.05) !important;
}

.right-sidebar-accordion .accordion-header button:not(.collapsed) {
  color: #ffffff !important;
  background-color: var(--bs-gray-800) !important;
  box-shadow: none !important;
}

.right-sidebar-accordion .accordion-header button:focus {
  box-shadow: none !important;
}

/* Accordion Arrow - เหมือน main sidebar */
.right-sidebar-accordion .accordion-button::after {
  background-image: none !important;
  content: "\F0140" !important;
  font-family: "Material Design Icons" !important;
  font-size: 18px !important;
  color: var(--bs-gray-400) !important;
  transition: transform 0.35s ease !important;
  width: auto !important;
  height: auto !important;
}

.right-sidebar-accordion .accordion-button:hover::after {
  color: #ffffff !important;
}

.right-sidebar-accordion .accordion-button:not(.collapsed)::after {
  transform: rotate(180deg) !important;
  color: #ffffff !important;
}

/* คัดลอกจาก Main Sidebar submenu - #sidebar-menu ul li ul.sub-menu li a */
.right-sidebar-accordion .accordion-body {
  font-size: 13.5px !important;
  padding:0!important;
  background-color: var(--bs-gray-900) !important;
}

.right-sidebar-accordion .accordion-body * {
  font-size: 13.5px !important;
}

.right-sidebar-accordion .accordion-body ul {
  list-style: none !important;
  padding: 0 !important;
  margin: 0 !important;
}

.right-sidebar-accordion .accordion-body li {
  margin: 0 !important;
  padding: 0 !important;
}

.right-sidebar-accordion .accordion-body .list-unstyled {
  margin: 0 !important;
  padding: 0 !important;
}

.right-sidebar-menu-link {
  font-size: 13.5px !important;
  padding: 0 1.5rem !important;
  line-height: 20px !important;
  height: 44px !important;
  min-height: 44px !important;
  display: flex !important;
  align-items: center !important;
  transition: all 0.3s ease !important;
  white-space: nowrap !important;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
  box-sizing: border-box !important;
  max-width: 100% !important;
  color: var(--bs-gray-400) !important;
  text-decoration: none !important;
}

/* Adjust icon margin to match Accordion Header */
.right-sidebar-menu-link .material-symbols-rounded {
  margin-right: 0.5rem !important; /* Match me-2 (0.5rem) */
}

.right-sidebar-menu-link:hover {
  background-color: rgba(255, 255, 255, 0.05) !important;
  color: #ffffff !important;
}

.right-sidebar-menu-link i,
.right-sidebar-menu-link .bx,
.right-sidebar-menu-link .material-symbols-rounded {
  font-size: 1.25rem !important;
  min-width: 1.75rem !important;
  display: inline-block !important;
  vertical-align: middle !important;
}

.right-sidebar-form-check label {
  font-size: 14.5px !important;
  color: var(--bs-gray-400) !important;
}

.right-sidebar-form-check.active {
  background-color: rgba(62, 146, 204, 0.1) !important;
  border-radius: 4px !important;
}

.right-sidebar-select {
  font-size: 14.5px !important;
  background-color: var(--bs-gray-800) !important;
  color: var(--bs-gray-400) !important;
  border-color: rgba(255, 255, 255, 0.1) !important;
}

.right-sidebar-accordion .form-label {
  font-size: 14.5px !important;
  color: rgba(255, 255, 255, 0.5) !important;
}

/* Right Sidebar Content - All tabs */
.right-sidebar-content {
  font-size: 14.5px !important;
  background-color: var(--bs-gray-800) !important;
  color: var(--bs-gray-400) !important;
}

.right-sidebar-content span.material-symbols-rounded {
  font-size:18px!important;
  color: var(--bs-gray-400) !important;
}

.right-sidebar-content .btn {
  font-size: 14.5px !important;
  background-color: #3E92CC !important;
  border-color: #3E92CC !important;
  color: #ffffff !important;
}

.right-sidebar-content .btn-secondary {
  background-color: var(--bs-gray-600) !important;
  border-color: var(--bs-gray-600) !important;
  color: #ffffff !important;
}

.right-sidebar-content small {
  font-size: 12px !important;
  color: rgba(255, 255, 255, 0.5) !important;
}

.right-sidebar-content .badge {
  font-size: 11px !important;
}

.right-sidebar-content .text-muted {
  color: rgba(255, 255, 255, 0.5) !important;
}

/* Force dark theme colors in Right Sidebar form controls */
.right-sidebar-content .form-control,
.right-sidebar-content .form-select {
  background-color: var(--bs-gray-900) !important;
  border-color: rgba(255, 255, 255, 0.1) !important;
  color: var(--bs-gray-400) !important;
}

.right-sidebar-content .form-control:focus,
.right-sidebar-content .form-select:focus {
  background-color: var(--bs-gray-900) !important;
  border-color: #3E92CC !important;
  color: #ffffff !important;
  box-shadow: 0 0 0 0.15rem rgba(62, 146, 204, 0.25) !important;
}

/* Right Sidebar form labels */
.right-sidebar-content .form-label {
  color: rgba(255, 255, 255, 0.8) !important;
}

/* Right Sidebar dividers */
.right-sidebar-content hr {
  border-color: rgba(255, 255, 255, 0.1) !important;
}

/* Right Sidebar card components */
.right-sidebar-content .card {
  background-color: var(--bs-gray-900) !important;
  border-color: rgba(255, 255, 255, 0.1) !important;
}

.right-sidebar-content .card-header {
  background-color: var(--bs-gray-800) !important;
  border-bottom-color: rgba(255, 255, 255, 0.1) !important;
  color: #ffffff !important;
}

.right-sidebar-content .card-body {
  color: var(--bs-gray-400) !important;
}

/* Right Sidebar list groups */
.right-sidebar-content .list-group-item {
  background-color: var(--bs-gray-900) !important;
  border-color: rgba(255, 255, 255, 0.1) !important;
  color: var(--bs-gray-400) !important;
}

.right-sidebar-content .list-group-item:hover {
  background-color: rgba(62, 146, 204, 0.1) !important;
  color: #ffffff !important;
}

/* Right Sidebar - Theme Mode Cards (Light/Dark buttons) */
.right-sidebar-content .theme-mode-card {
  display: flex !important;
  flex-direction: column !important;
  align-items: center !important;
  justify-content: center !important;
  padding: 1rem !important;
  border: 2px solid rgba(255, 255, 255, 0.1) !important;
  border-radius: 8px !important;
  background-color: var(--bs-gray-900) !important;
  cursor: pointer !important;
  transition: all 0.3s ease !important;
  color: var(--bs-gray-400) !important;
}

.right-sidebar-content .theme-mode-card:hover {
  border-color: rgba(62, 146, 204, 0.5) !important;
  background-color: rgba(62, 146, 204, 0.05) !important;
  color: #ffffff !important;
}

.right-sidebar-content .theme-mode-card.active {
  border-color: #3E92CC !important;
  background-color: rgba(62, 146, 204, 0.15) !important;
  color: #3E92CC !important;
}

.right-sidebar-content .theme-mode-card .material-symbols-rounded {
  font-size: 32px !important;
  margin-bottom: 0.5rem !important;
  color: inherit !important;
}

.right-sidebar-content .theme-label {
  text-align: center !important;
}

.right-sidebar-content .theme-title {
  display: block !important;
  font-size: 14px !important;
  font-weight: 500 !important;
  color: inherit !important;
}

.right-sidebar-content .theme-subtitle {
  display: block !important;
  font-size: 11px !important;
  color: rgba(255, 255, 255, 0.4) !important;
  margin-top: 2px !important;
}

/* Hide radio input */
.right-sidebar-content .btn-check {
  display: none !important;
}

/* Right Sidebar - Form Check Labels */
.right-sidebar-content .form-check-label {
  color: var(--bs-gray-400) !important;
  cursor: pointer !important;
}

.right-sidebar-content .form-check-input {
  background-color: var(--bs-gray-900) !important;
  border-color: rgba(255, 255, 255, 0.2) !important;
}

.right-sidebar-content .form-check-input:checked {
  background-color: #3E92CC !important;
  border-color: #3E92CC !important;
}

.right-sidebar-content .form-check-input:focus {
  box-shadow: 0 0 0 0.15rem rgba(62, 146, 204, 0.25) !important;
  border-color: #3E92CC !important;
}

/* Right Sidebar - Border colors */
.right-sidebar-content .border-bottom {
  border-bottom-color: rgba(255, 255, 255, 0.1) !important;
}

.right-sidebar-content .border-secondary {
  border-color: rgba(255, 255, 255, 0.1) !important;
}

/* Right Sidebar - Text colors */
.right-sidebar-content .text-white-50 {
  color: rgba(255, 255, 255, 0.5) !important;
}

/* Right Sidebar - Spinner */
.right-sidebar-content .spinner-border {
  color: #3E92CC !important;
}

/* Button Label 1:1 Icon Fix */
.btn-label {
    padding-left: 48px !important; /* 36px icon + 12px spacing */
}

.btn-label .label-icon {
    width: 36px !important;
    height: 100% !important; /* Should be 36px from parent */
}

.btn-label.btn-sm {
    padding-left: 40px !important; /* 30px icon + 10px spacing */
}

.btn-label.btn-sm .label-icon {
    width: 30px !important;
}

.btn-label.btn-lg {
    padding-left: 56px !important; /* 42px icon + 14px spacing */
}

.btn-label.btn-lg .label-icon {
    width: 42px !important;
}

/* Right side label support */
.btn-label-right {
    padding-right: 48px !important;
    padding-left: 12px !important;
    position: relative !important;
}

.btn-label-right .label-icon {
    position: absolute !important;
    right: 0 !important;
    top: 0 !important;
    left: auto !important;
    width: 36px !important;
    height: 100% !important;
    border-right: 0 !important;
    border-left: 1px solid rgba(255, 255, 255, 0.1) !important;
    background-color: rgba(255, 255, 255, 0.1) !important;
}

.btn-label-right.btn-light .label-icon {
    background-color: rgba(52, 58, 64, 0.1) !important;
    border-left: 1px solid rgba(52, 58, 64, 0.2) !important;
}

.btn-label-right.btn-sm {
    padding-right: 40px !important;
}

.btn-label-right.btn-sm .label-icon {
    width: 30px !important;
}

.btn-label-right.btn-lg {
    padding-right: 56px !important;
}

.btn-label-right.btn-lg .label-icon {
    width: 42px !important;
}


/* ===== TOPBAR DROPDOWN FIX ===== */
/* Ensure dropdowns are above Right Sidebar (z-index 1001) */
.navbar-header .dropdown-menu {
  z-index: 1005 !important;
}


/* ====================================
   UNIFIED SIDEBAR SYSTEM
   (Main Sidebar & Right Sidebar)
   ==================================== */

/* 1. Base Item Layout (Structure) */
.right-sidebar-menu-container ul li a,
body[data-sidebar="dark"] #sidebar-menu ul li a {
  font-size: 14.5px !important;
  transition: all 0.3s ease !important;
  display: flex !important;
  align-items: center !important;
  padding: 0 24px !important; /* Remove vertical padding, use height for centering */
  color: var(--bs-gray-400) !important;
  position: relative !important;
  text-decoration: none !important;
  width: 100% !important;
  height: 44px !important; /* Fixed height */
  min-height: 44px !important;
}

/* 2. Icons (Size & Position) */
.right-sidebar-menu-container ul li a i,
.right-sidebar-menu-container ul li a .material-symbols-rounded,
body[data-sidebar="dark"] #sidebar-menu ul li a i,
body[data-sidebar="dark"] #sidebar-menu ul li a .material-symbols-rounded {
  font-size: 18px !important;
  display: inline-block;
  min-width: 1.75rem;
  width: 1.75rem;
  vertical-align: middle;
  color: var(--bs-gray-400)!important; /* Changed from gray-500 to match text */
  margin-right: 5px !important;
  transition: all 0.3s ease !important; /* Add transition to match text */
}

/* 3. Hover State (Background & Color) */
.right-sidebar-menu-container ul li a:hover,
body[data-sidebar="dark"] #sidebar-menu ul li a:hover {
  background-color: rgba(255, 255, 255, 0.05) !important;
  color: #ffffff !important;
}

.right-sidebar-menu-container ul li a:hover i,
.right-sidebar-menu-container ul li a:hover .material-symbols-rounded,
body[data-sidebar="dark"] #sidebar-menu ul li a:hover i,
body[data-sidebar="dark"] #sidebar-menu ul li a:hover .material-symbols-rounded {
  color: #ffffff !important;
}

/* 4. Active State (Text & Icon Color) */
.right-sidebar-menu-container .mm-active > a:not(.has-arrow),
.right-sidebar-menu-container ul li.mm-active > a:not(.has-arrow),
body[data-sidebar="dark"] #sidebar-menu ul li.mm-active > a:not(.has-arrow) {
  color: var(--bs-gray-200) !important;
}

.right-sidebar-menu-container .mm-active > a:not(.has-arrow) i,
.right-sidebar-menu-container .mm-active > a:not(.has-arrow) .material-symbols-rounded,
.right-sidebar-menu-container ul li.mm-active > a:not(.has-arrow) i,
.right-sidebar-menu-container ul li.mm-active > a:not(.has-arrow) .material-symbols-rounded,
body[data-sidebar="dark"] #sidebar-menu ul li.mm-active > a:not(.has-arrow) i,
body[data-sidebar="dark"] #sidebar-menu ul li.mm-active > a:not(.has-arrow) .material-symbols-rounded {
  color: var(--bs-gray-200) !important;
}

/* 5. Parent Menu Active State (When Submenu Open) */
.right-sidebar-menu-container .mm-active > a.has-arrow,
.right-sidebar-menu-container ul li.mm-active > a.has-arrow,
body[data-sidebar="dark"] #sidebar-menu ul li.mm-active > a.has-arrow {
  color: var(--bs-gray-400) !important;
}

.right-sidebar-menu-container .mm-active > a.has-arrow i,
.right-sidebar-menu-container .mm-active > a.has-arrow .material-symbols-rounded,
.right-sidebar-menu-container ul li.mm-active > a.has-arrow i,
.right-sidebar-menu-container ul li.mm-active > a.has-arrow .material-symbols-rounded,
body[data-sidebar="dark"] #sidebar-menu ul li.mm-active > a.has-arrow i,
body[data-sidebar="dark"] #sidebar-menu ul li.mm-active > a.has-arrow .material-symbols-rounded {
  color: var(--bs-gray-400) !important;
}

/* 6. Submenu Styles (Level 1) */
.right-sidebar-menu-container ul li ul.sub-menu,
body[data-sidebar="dark"] #sidebar-menu ul li ul.sub-menu,
[data-bs-theme="dark"] #sidebar-menu ul li ul.sub-menu {
  padding: 0 !important;
  list-style: none !important;
  background-color: var(--bs-sidebar-bg, var(--bs-gray-800)) !important;
}

.right-sidebar-menu-container ul li ul.sub-menu li a,
body[data-sidebar="dark"] #sidebar-menu ul li ul.sub-menu li a {  
  padding: 0 1.5rem !important; /* Match Main Sidebar padding */
  line-height: 44px !important;
  font-size: 13.5px !important;
  height: 44px !important;
  min-height: 44px !important;
  display: flex !important;
  align-items: center !important;
  transition: all 0.3s ease !important;
  background-color: rgba(0, 0, 0, 0.15) !important;
  white-space: nowrap !important;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
  box-sizing: border-box !important;
  max-width: 100% !important;
  color: var(--bs-gray-500)!important;
}

/* Ensure Level 1 Icons match text color */
.right-sidebar-menu-container ul li ul.sub-menu li a i,
.right-sidebar-menu-container ul li ul.sub-menu li a .material-symbols-rounded,
body[data-sidebar="dark"] #sidebar-menu ul li ul.sub-menu li a i,
body[data-sidebar="dark"] #sidebar-menu ul li ul.sub-menu li a .material-symbols-rounded {
  color: var(--bs-gray-500) !important;
  transition: all 0.3s ease !important;
}

.right-sidebar-menu-container ul li ul.sub-menu li a:hover,
body[data-sidebar="dark"] #sidebar-menu ul li ul.sub-menu li a:hover {
  background-color: rgba(255, 255, 255, 0.05) !important;
  color: #ffffff !important;
}

.right-sidebar-menu-container ul li ul.sub-menu li a:hover i,
.right-sidebar-menu-container ul li ul.sub-menu li a:hover .material-symbols-rounded,
body[data-sidebar="dark"] #sidebar-menu ul li ul.sub-menu li a:hover i,
body[data-sidebar="dark"] #sidebar-menu ul li ul.sub-menu li a:hover .material-symbols-rounded {
  color: #ffffff !important;
}

/* 7. Submenu Active State (Level 1) - Only for Leaf Nodes (Not Parents) */
.right-sidebar-menu-container ul li ul.sub-menu li.mm-active > a:not(.has-arrow),
body[data-sidebar="dark"] #sidebar-menu ul li ul.sub-menu li.mm-active > a:not(.has-arrow) {
  color: #ffffff !important;
}

.right-sidebar-menu-container ul li ul.sub-menu li.mm-active > a:not(.has-arrow) i,
.right-sidebar-menu-container ul li ul.sub-menu li.mm-active > a:not(.has-arrow) .material-symbols-rounded,
body[data-sidebar="dark"] #sidebar-menu ul li ul.sub-menu li.mm-active > a:not(.has-arrow) i,
body[data-sidebar="dark"] #sidebar-menu ul li ul.sub-menu li.mm-active > a:not(.has-arrow) .material-symbols-rounded {
  color: #ffffff !important;
}

/* Ensure Submenu Parents stay normal color when active */
.right-sidebar-menu-container ul li ul.sub-menu li.mm-active > a.has-arrow,
body[data-sidebar="dark"] #sidebar-menu ul li ul.sub-menu li.mm-active > a.has-arrow {
  color: var(--bs-gray-500) !important;
}

.right-sidebar-menu-container ul li ul.sub-menu li.mm-active > a.has-arrow i,
.right-sidebar-menu-container ul li ul.sub-menu li.mm-active > a.has-arrow .material-symbols-rounded,
body[data-sidebar="dark"] #sidebar-menu ul li ul.sub-menu li.mm-active > a.has-arrow i,
body[data-sidebar="dark"] #sidebar-menu ul li ul.sub-menu li.mm-active > a.has-arrow .material-symbols-rounded {
  color: var(--bs-gray-500) !important;
}

/* 8. Nested Submenu (Level 2) - Indent & Border */
.right-sidebar-menu-container ul li ul.sub-menu li ul.sub-menu li a,
body[data-sidebar="dark"] #sidebar-menu ul li ul.sub-menu li ul.sub-menu li a {
  background-color: rgba(0, 0, 0, 0.3) !important;
  padding: 0 1.5rem 0 2rem !important; /* Reduced indent from 2.5rem */  
  border-left: 3px solid rgba(62, 146, 204, 0.3) !important; /* Left border */
  margin-left: 0.05rem !important; /* Reduced margin from 1rem */
  color: var(--bs-gray-500) !important; /* Ensure text color is explicit */
}

/* Ensure Level 2 Icons match text color */
.right-sidebar-menu-container ul li ul.sub-menu li ul.sub-menu li a i,
.right-sidebar-menu-container ul li ul.sub-menu li ul.sub-menu li a .material-symbols-rounded,
body[data-sidebar="dark"] #sidebar-menu ul li ul.sub-menu li ul.sub-menu li a i,
body[data-sidebar="dark"] #sidebar-menu ul li ul.sub-menu li ul.sub-menu li a .material-symbols-rounded {
  color: var(--bs-gray-500) !important;
  transition: all 0.3s ease !important;
}

.right-sidebar-menu-container ul li ul.sub-menu li ul.sub-menu li a:hover,
body[data-sidebar="dark"] #sidebar-menu ul li ul.sub-menu li ul.sub-menu li a:hover {
  background-color: rgba(255, 255, 255, 0.05) !important;
  color: #ffffff !important;
}

.right-sidebar-menu-container ul li ul.sub-menu li ul.sub-menu li a:hover i,
.right-sidebar-menu-container ul li ul.sub-menu li ul.sub-menu li a:hover .material-symbols-rounded,
body[data-sidebar="dark"] #sidebar-menu ul li ul.sub-menu li ul.sub-menu li a:hover i,
body[data-sidebar="dark"] #sidebar-menu ul li ul.sub-menu li ul.sub-menu li a:hover .material-symbols-rounded {
  color: #ffffff !important;
}

/* 9. Metismenu Animation & Arrows */
.right-sidebar-menu-container ul li ul.sub-menu.mm-collapse {
  display: none;
}

.right-sidebar-menu-container ul li ul.sub-menu.mm-show {
  display: block;
}

.right-sidebar-menu-container ul li ul.sub-menu.mm-collapsing {
  position: relative;
  height: 0;
  overflow: hidden;
  transition-timing-function: ease;
  transition-duration: 0.35s;
  transition-property: height, visibility;
}

/* Arrow rotation (Right Sidebar) */
.right-sidebar-menu-container .has-arrow:after {
  content: "\e313"; /* keyboard_arrow_down */
  font-family: 'Material Symbols Rounded';
  display: block !important;
  float: none !important;
  transition: transform 0.2s;
  font-size: 1.2rem;
  margin-left: auto !important;
  font-weight: normal;
  font-style: normal;
  line-height: 1;
  color: var(--bs-gray-400); /* Ensure visibility */
}

.right-sidebar-menu-container .mm-active > .has-arrow:after {
  transform: rotate(180deg);
}

/* 10. Sidebar Background Colors */
body[data-sidebar="dark"] .vertical-menu,
[data-bs-theme="dark"] .vertical-menu {
    background-color: var(--bs-sidebar-bg, var(--bs-gray-800)) !important;
}

body[data-sidebar="dark"] .navbar-brand-box,
[data-bs-theme="dark"] .navbar-brand-box {
    background-color: var(--bs-sidebar-bg, var(--bs-gray-800)) !important;
}

/* ===== MATERIAL ICONS SPIN ANIMATION ===== */
@keyframes material-spin {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}

.material-symbols-rounded.spin,
span.material-symbols-rounded.spin {
  animation: material-spin 3.6s linear infinite;
}

/* ===== THEME REFERENCE PAGE - ACCORDION CUSTOMIZATIONS ===== */
/* Remove side borders but keep bottom border for separation */
.accordion-flush .accordion-item {
  border: none !important;
  border-bottom: 1px solid var(--bs-border-color) !important;
  margin-bottom: 0 !important;
  border-radius: 0 !important;
  overflow: hidden !important;
  background-color: transparent !important;
}

/* Remove border from last item */
.accordion-flush .accordion-item:last-child {
  border-bottom: none !important;
}

/* Accordion header styling */
.accordion-flush .accordion-header {
  border: none !important;
}

.accordion-flush .accordion-button {
  border: none !important;
  background-color: transparent !important;
  box-shadow: none !important;
  border-radius: 0 !important;
  padding: 1rem 1.25rem !important;
}

.accordion-flush .accordion-button:not(.collapsed) {
  background-color: var(--bs-tertiary-bg) !important;
  color: var(--bs-body-color) !important;
  box-shadow: none !important;
  border-radius: 0 !important;
}

.accordion-flush .accordion-button:focus {
  box-shadow: none !important;
  border: none !important;
}

.accordion-flush .accordion-button:hover {
  background-color: var(--bs-tertiary-bg) !important;
}

/* Accordion body - remove padding and borders */
.accordion-flush .accordion-body {
  padding: 0 !important;
  border: none !important;
}

/* Smooth slide animation for Bootstrap Accordion */
.accordion-collapse {
  transition: height 0.35s ease !important;
}

.accordion-collapse.collapsing {
  transition: height 0.35s ease !important;
}

/* ==========================================================================
   TABLE CUSTOMIZATIONS - NO VERTICAL BORDERS
   ========================================================================== */
/* เอาเส้นแนวตั้งออก เหลือแต่เส้นแนวนอน */
.table.table-bordered {
  border-left: none !important;
  border-right: none !important;
}

.table.table-bordered th,
.table.table-bordered td {
  border-left: none !important;
  border-right: none !important;
}

/* เส้นแนวนอนยังคงอยู่ */
.table.table-bordered thead th,
.table.table-bordered thead td {
  border-bottom: var(--bs-border-width) solid var(--bs-border-color) !important;
}

.table.table-bordered tbody tr {
  border-bottom: var(--bs-border-width) solid var(--bs-border-color) !important;
}

/* ==========================================================================
   TABLE SIZES
   ========================================================================== */
.table-lg th,
.table-lg td {
  padding: 1rem 1rem;
}

/* ==========================================================================
   COLOR UTILITIES (Generated for Design System)
   ========================================================================== */

/* Extended Colors */
.bg-blue { background-color: var(--bs-blue) !important; }
.bg-indigo { background-color: var(--bs-indigo) !important; }
.bg-purple { background-color: var(--bs-purple) !important; }
.bg-pink { background-color: var(--bs-pink) !important; }
.bg-red { background-color: var(--bs-red) !important; }
.bg-orange { background-color: var(--bs-orange) !important; }
.bg-yellow { background-color: var(--bs-yellow) !important; }
.bg-green { background-color: var(--bs-green) !important; }
.bg-teal { background-color: var(--bs-teal) !important; }
.bg-cyan { background-color: var(--bs-cyan) !important; }
.bg-lime { background-color: var(--bs-lime) !important; }
.bg-brown { background-color: var(--bs-brown) !important; }
.bg-slate { background-color: var(--bs-slate) !important; }

/* Gray Colors */
.bg-gray-100 { background-color: var(--bs-gray-100) !important; }
.bg-gray-200 { background-color: var(--bs-gray-200) !important; }
.bg-gray-300 { background-color: var(--bs-gray-300) !important; }
.bg-gray-400 { background-color: var(--bs-gray-400) !important; }
.bg-gray-500 { background-color: var(--bs-gray-500) !important; }
.bg-gray-600 { background-color: var(--bs-gray-600) !important; }
.bg-gray-700 { background-color: var(--bs-gray-700) !important; }
.bg-gray-800 { background-color: var(--bs-gray-800) !important; }
.bg-gray-900 { background-color: var(--bs-gray-900) !important; }

/* System Colors */
.bg-body-bg { background-color: var(--bs-body-bg) !important; }
.bg-body-color { background-color: var(--bs-body-color) !important; }
.bg-border-color { background-color: var(--bs-border-color) !important; }
.bg-card-bg { background-color: var(--bs-card-bg) !important; }

/* Sidebar Colors (Specific to Dark Sidebar) */
.bg-sidebar-bg { background-color: var(--bs-gray-800) !important; }
.bg-sidebar-hover { background-color: var(--bs-gray-700) !important; }
.bg-menu-text { background-color: var(--bs-gray-400) !important; }
.bg-menu-active { background-color: #ffffff !important; }
.bg-menu-icon { background-color: var(--bs-gray-500) !important; }
.bg-submenu-text { background-color: var(--bs-gray-500) !important; }

/* Sidebar Colors (Specific to Light Sidebar) */
.bg-sidebar-light-bg { background-color: #ffffff !important; }
.bg-sidebar-light-text { background-color: var(--bs-gray-700) !important; }
.bg-sidebar-light-active { background-color: #556ee6 !important; }
.bg-sidebar-light-hover { background-color: var(--bs-gray-800) !important; }

/* ==========================================================================
   FINAL FIX: COLLAPSED SIDEBAR (ICONS & SUBMENUS)
   ========================================================================== */

/* 0. CRITICAL: KILL SIMPLEBAR CLIPPING */
/* SimpleBar uses overflow: hidden to hide scrollbars. We MUST override this 
   so the submenu can "pop out" of the 70px container. */
body.vertical-collpsed .vertical-menu [data-simplebar],
body.vertical-collpsed .vertical-menu .simplebar-wrapper,
body.vertical-collpsed .vertical-menu .simplebar-mask,
body.vertical-collpsed .vertical-menu .simplebar-offset,
body.vertical-collpsed .vertical-menu .simplebar-content-wrapper,
body.vertical-collpsed .vertical-menu .simplebar-content {
    overflow: visible !important;
    width: 70px !important; /* Ensure it doesn't expand */
}

/* 1. Item Container (LI) */
body.vertical-collpsed .vertical-menu #sidebar-menu > ul > li {
    position: relative !important;
    width: 70px !important;
    overflow: visible !important; /* CRITICAL for submenu popup */
}

/* 2. Link Item (A) - Center the Icon */
body.vertical-collpsed .vertical-menu #sidebar-menu > ul > li > a {
    position: relative !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: 70px !important;
    height: 50px !important; /* Standard height */
    padding: 0 !important;
    margin: 0 !important;
    background-color: transparent !important;
    overflow: visible !important;
}

/* Hover state for the link */
body.vertical-collpsed .vertical-menu #sidebar-menu > ul > li:hover > a {
    background-color: var(--bs-gray-700) !important;
    width: 70px !important;
}

/* 3. Icon Visibility & Alignment */
/* Hide the text span normally */
body.vertical-collpsed .vertical-menu #sidebar-menu > ul > li > a span {
    display: none !important;
}

/* SHOW the text span ON HOVER as the HEADER */
body.vertical-collpsed .vertical-menu #sidebar-menu > ul > li:hover > a span:not(.material-symbols-rounded) {
    display: flex !important;
    align-items: center !important;
    position: absolute !important;
    left: 70px !important;
    top: 0 !important;
    width: 240px !important; /* Match submenu width */
    height: 50px !important; /* Header height - Matched to Icon Height */
    padding: 0 20px !important;
    background-color: var(--bs-gray-800) !important; /* Match submenu bg */
    color: #ffffff !important;
    font-weight: 600 !important;
    font-size: 15px !important;
    border-radius: 0 4px 0 0 !important;
    z-index: 10000 !important; /* Above submenu */
    border-bottom: 1px solid rgba(255,255,255,0.1) !important;
    pointer-events: none !important; /* Let clicks pass through if needed, though it's just a title */
    white-space: nowrap !important;
}

/* Show the icon span */
body.vertical-collpsed .vertical-menu #sidebar-menu > ul > li > a i,
body.vertical-collpsed .vertical-menu #sidebar-menu > ul > li > a span.material-symbols-rounded {
    display: inline-block !important;
    font-size: 24px !important; /* Larger icon */
    line-height: 1 !important;
    margin: 0 !important;
    padding: 0 !important;
    width: auto !important;
    min-width: auto !important;
    text-align: center !important;
}

/* 4. Submenu Popup (The "Submenu") */
body.vertical-collpsed .vertical-menu #sidebar-menu > ul > li:hover > ul.sub-menu {
    display: block !important;
    position: absolute !important;
    left: 70px !important;
    top: 0 !important;
    width: 240px !important; /* Increased width */
    background-color: var(--bs-gray-800) !important;
    box-shadow: 4px 4px 10px rgba(0, 0, 0, 0.2) !important;
    padding: 50px 0 10px 0 !important; /* Top padding for the Header Title (Matched to Header Height) */
    border-radius: 0 4px 4px 4px !important;
    z-index: 9999 !important;
    visibility: visible !important;
    opacity: 1 !important;
    pointer-events: auto !important; /* Ensure clickable */
    clip: auto !important; /* Remove any clipping */
}

/* Ensure submenu items are visible */
body.vertical-collpsed .vertical-menu #sidebar-menu > ul > li:hover > ul.sub-menu li {
    display: block !important;
    width: 100% !important;
    background: transparent !important;
}

body.vertical-collpsed .vertical-menu #sidebar-menu > ul > li:hover > ul.sub-menu li a {
    padding: 10px 20px !important;
    text-align: left !important;
    /* animation: slideUpFromBottom  0.3s ease-out; */
}

/* 5. Nested Submenu Arrow (Collapsed Mode) */
/* Show right arrow for items with submenus inside the popup */
body.vertical-collpsed .vertical-menu #sidebar-menu > ul > li > ul.sub-menu li a.has-arrow::after {
    display: block !important;
    content: "\e315"; /* keyboard_arrow_right */
    font-family: 'Material Symbols Rounded';
    margin-left: auto !important;
    font-size: 18px !important;
    line-height: 1;
    color: var(--bs-gray-500);
    font-weight: normal;
}

/* Hover state for the arrow */
body.vertical-collpsed .vertical-menu #sidebar-menu > ul > li > ul.sub-menu li a:hover::after {
    color: #ffffff !important;
}

/* 6. Nested Submenu Popup (Level 2) - Flyout to Right */
/* Ensure parent LI is relative for absolute positioning of child */
body.vertical-collpsed .vertical-menu #sidebar-menu > ul > li > ul.sub-menu li {
    position: relative !important;
}

/* The Nested Popup */
body.vertical-collpsed .vertical-menu #sidebar-menu > ul > li > ul.sub-menu li:hover > ul.sub-menu {
    display: block !important;
    position: absolute !important;
    left: 100% !important; /* Fly out to the right */
    top: 0 !important;
    min-width: 200px !important; /* Minimum width */
    width: max-content !important; /* Expand to fit text */
    background-color: var(--bs-gray-800) !important;
    box-shadow: 4px 4px 10px rgba(0, 0, 0, 0.2) !important;
    padding: 10px 0 !important;
    border-radius: 4px !important;
    z-index: 10001 !important; /* Above Level 1 */
    margin-left: -5px !important; /* Slight overlap to prevent gap */
}

/* Reset styles for items inside nested popup */
body.vertical-collpsed .vertical-menu #sidebar-menu > ul > li > ul.sub-menu li:hover > ul.sub-menu li a {
    padding: 8px 20px !important;
    background-color: transparent !important;
    border-left: none !important; /* Remove the border we added for accordion mode */
    margin-left: 0 !important;
}

body.vertical-collpsed .vertical-menu #sidebar-menu > ul > li > ul.sub-menu li:hover > ul.sub-menu li a:hover {
    background-color: var(--bs-gray-700) !important;
}

@keyframes slideUpFromBottom {
  from {
    transform: translateY(100%);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

@keyframes fadeInUp {
  from {
    transform: translateY(20px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

/* ===== CART OFFCANVAS - PUSH CONTENT LEFT ===== */
/* เมื่อเปิดตะกร้าสินค้า ให้ดันเนื้อหาไปทางซ้าย (เหมือน RightSidebar) */
body.cart-open #layout-wrapper {
  margin-right: 450px;
  transition: margin-right 0.3s ease-out;
}

/* Offcanvas cart styling */
.offcanvas.offcanvas-end {
  border-left: 1px solid rgba(0,0,0,0.1);
  box-shadow: -5px 0 20px rgba(0,0,0,0.1);
}

/* Utility class for fade-in animation */
.fade-in {
   animation: fadeIn 0.3s ease-in-out;
}

/* ===== GLOBAL ACCORDION STYLING ===== */
/* Remove default Bootstrap focus glow (purple/blue ring) */
.accordion-button:focus {
  box-shadow: none !important;
  border-color: rgba(0,0,0,0.125);
}

/* Active state styling - Soft Primary */
.accordion-button:not(.collapsed) {
  color: var(--bs-primary);
  background-color: rgba(var(--bs-primary-rgb), 0.08); /* Very soft background */
  box-shadow: none !important;
}

/* ===== FONT SIZE UTILITIES ===== */
.font-size-10 { font-size: 10px !important; }
.font-size-11 { font-size: 11px !important; }
.font-size-12 { font-size: 12px !important; }
.font-size-13 { font-size: 13px !important; }
.font-size-14 { font-size: 14px !important; }
.font-size-15 { font-size: 15px !important; }
.font-size-16 { font-size: 16px !important; }
.font-size-17 { font-size: 17px !important; }
.font-size-18 { font-size: 18px !important; }
.font-size-20 { font-size: 20px !important; }
.font-size-22 { font-size: 22px !important; }
.font-size-24 { font-size: 24px !important; }

/* ===== FONT WEIGHT UTILITIES ===== */
.fw-medium { font-weight: 500 !important; }
.fw-semibold { font-weight: 600 !important; }
.fw-bold { font-weight: 700 !important; }
.fw-bolder { font-weight: 800 !important; }




/* ====================================
   FIX: NESTED SUBMENU ARROW ALIGNMENT
   ==================================== */
/* Push the arrow (::after) to the right in nested submenus */
#sidebar-menu ul li ul.sub-menu li a.has-arrow::after {
  margin-left: auto !important;
}

/* ===== PRIVACY MODE ===== */
body.privacy-mode-active .privacy-blur {
  filter: blur(5px);
  user-select: none;
  transition: filter 0.3s ease;
}

body:not(.privacy-mode-active) .privacy-blur {
  filter: blur(0);
  transition: filter 0.3s ease;
}


/* Fix Horizontal Layout Content Alignment */
body[data-layout='horizontal'] .page-content {
  padding-left: 0 !important;
  padding-right: 0 !important;
}


/* ===== DASHBOARD WIDGETS ===== */
/* Activity Feed */
.activity-feed {
    list-style: none;
    padding: 0;
    margin: 0;
}
.activity-feed .feed-item {
    position: relative;
    padding-bottom: 24px;
    padding-left: 20px;
    border-left: 2px solid var(--bs-gray-200);
}
.activity-feed .feed-item:last-child {
    border-color: transparent;
    padding-bottom: 0;
}
.activity-feed .feed-item::after {
    content: '';
    display: block;
    position: absolute;
    top: 4px;
    left: -6px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #556ee6;
    border: 2px solid #fff;
}

/* Social Source */
.social-source {
    text-align: center;
}
.social-source .avatar-xs {
    display: inline-block;
}

/* ==========================================================================
   DYNAMIC SIDEBAR THEMING (Overrides for Design System)
   ========================================================================== */
/* Note: Most sidebar styles have been moved to "UNIFIED SIDEBAR SYSTEM" above.
   Only specific overrides or non-standard behaviors should remain here. */

/* Collapsed Sidebar Popups */
body.vertical-collpsed .vertical-menu #sidebar-menu > ul > li:hover > a span:not(.material-symbols-rounded) {
    background-color: var(--bs-gray-700) !important;
    color: var(--bs-white) !important;
    border-bottom: 1px solid var(--bs-gray-600) !important;
}

body.vertical-collpsed .vertical-menu #sidebar-menu > ul > li:hover > ul.sub-menu {
    background-color: var(--bs-gray-700) !important;
}



/* ==========================================================================
   GLOBAL DARK MODE OVERRIDES
   ========================================================================== */
[data-bs-theme="dark"] {
  /* Fallback for html scope */
  --bs-gray-900: #181920;
  --bs-gray-800: #252732;
  --bs-gray-700: #3b3e4f;
  --bs-gray-600: #4c5067;
  --bs-gray-500: #666c8a;
  --bs-gray-400: #959ab1;
}

/* Override inline styles from ThemeContext (on html/body) by applying to body explicitly */
body[data-bs-theme="dark"] {
  /* Explicit Gray Palette (Tuned) - Wins over html inline styles */
  --bs-gray-900: #181920;
  --bs-gray-800: #252732;
  --bs-gray-700: #3b3e4f;
  --bs-gray-600: #4c5067;
  --bs-gray-500: #666c8a;
  --bs-gray-400: #959ab1;
  --bs-gray-50:  #f9f9fb;

  /* Body & Main Content */
  --bs-body-bg: var(--bs-gray-900);
  --bs-body-color: var(--bs-gray-400);

  /* Header (Midpoint of Gray 800 & 900) */
  --bs-header-bg: #1F2029;
  --bs-footer-bg: #1F2029;
  
  /* Card & Components */
  --bs-card-bg: var(--bs-gray-800);
  --bs-card-border-color: var(--bs-gray-700);
  --bs-border-color: var(--bs-gray-700);
  --bs-border-color-translucent: rgba(255, 255, 255, 0.1);
  
  /* Text Colors */
  --bs-heading-color: var(--bs-gray-50);
  --bs-link-color: var(--bs-primary);
  --bs-link-hover-color: var(--bs-primary);
  
  /* Forms */
  --bs-secondary-bg: var(--bs-gray-700);
  --bs-tertiary-bg: var(--bs-gray-600);
  --bs-secondary-color: var(--bs-gray-500);
}

/* Force background color application */
body[data-bs-theme="dark"] {
  background-color: var(--bs-body-bg) !important;
  color: var(--bs-body-color) !important;
}

/* CRITICAL: Force Card and Sidebar to match (Tuned Gray 800) */
[data-bs-theme="dark"] .card {
  background-color: var(--bs-gray-800) !important;
  background-image: none !important;
  box-shadow: none !important; /* Remove shadow to ensure color match perception */
  border-color: var(--bs-gray-700) !important;
}

[data-bs-theme="dark"] .vertical-menu,
[data-bs-theme="dark"] .navbar-brand-box {
  background-color: var(--bs-sidebar-bg, var(--bs-gray-800)) !important;
  background-image: none !important;
  box-shadow: none !important; /* Remove shadow to ensure color match perception */
  border-color: var(--bs-gray-700) !important;
}

[data-bs-theme="dark"] .modal-content {
  background-color: var(--bs-gray-800) !important;
  border-color: var(--bs-border-color) !important;
}

[data-bs-theme="dark"] .form-control,
[data-bs-theme="dark"] .form-select {
  background-color: var(--bs-gray-700) !important;
  border-color: var(--bs-gray-700) !important;
  color: var(--bs-gray-400) !important;
}

[data-bs-theme="dark"] .form-control:focus,
[data-bs-theme="dark"] .form-select:focus {
  background-color: var(--bs-gray-800) !important;
  border-color: var(--bs-primary) !important;
  color: var(--bs-white) !important;
}

[data-bs-theme="dark"] .text-muted {
  color: var(--bs-gray-500) !important;
}

[data-bs-theme="dark"] .table {
  color: var(--bs-gray-400) !important;
  --bs-table-color: var(--bs-gray-400);
  --bs-table-bg: transparent;
  --bs-table-border-color: var(--bs-gray-700);
  --bs-table-striped-bg: rgba(255, 255, 255, 0.05);
  --bs-table-striped-color: var(--bs-gray-400);
  --bs-table-active-bg: rgba(255, 255, 255, 0.1);
  --bs-table-active-color: var(--bs-white);
  --bs-table-hover-bg: rgba(255, 255, 255, 0.075);
  --bs-table-hover-color: var(--bs-white);
}


/* ==========================================================================
   TOPBAR & FOOTER DARK MODE FIXES
   ========================================================================== */

/* Topbar Background */
[data-bs-theme="dark"] #page-topbar {
  background-color: var(--bs-header-bg) !important;
}

[data-bs-theme="dark"] .navbar-header {
  background-color: var(--bs-header-bg) !important;
}

/* Topbar Items (Buttons & Icons) */
[data-bs-theme="dark"] .navbar-header .btn,
[data-bs-theme="dark"] .navbar-header .header-item {
  color: var(--bs-gray-400) !important;
}

[data-bs-theme="dark"] .navbar-header .btn:hover,
[data-bs-theme="dark"] .navbar-header .header-item:hover,
[data-bs-theme="dark"] .navbar-header .show {
  color: var(--bs-white) !important;
  background-color: var(--bs-gray-700) !important;
}

/* Topbar Search */
[data-bs-theme="dark"] .app-search .form-control {
  background-color: var(--bs-gray-700) !important;
  color: var(--bs-gray-400) !important;
  border: none !important;
}

[data-bs-theme="dark"] .app-search span,
[data-bs-theme="dark"] .app-search .bx {
  color: var(--bs-gray-400) !important;
}

/* Footer */
[data-bs-theme="dark"] .footer {
  background-color: var(--bs-footer-bg) !important;
  color: var(--bs-gray-400) !important;  
}

/* Dropdowns in Topbar */
[data-bs-theme="dark"] .dropdown-menu {
  background-color: var(--bs-gray-800) !important;
  border-color: var(--bs-border-color) !important;
  box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15) !important;
}

[data-bs-theme="dark"] .dropdown-item {
  color: var(--bs-gray-400) !important;
}

[data-bs-theme="dark"] .dropdown-item:hover,
[data-bs-theme="dark"] .dropdown-item:focus {
  background-color: var(--bs-gray-700) !important;
  color: var(--bs-white) !important;
}

[data-bs-theme="dark"] .dropdown-divider {
  border-color: var(--bs-border-color) !important;
}


/* ===== SETTINGS NAVIGATION (Moved from inline styles) ===== */
.settings-nav {
  border-radius: var(--custom-card-radius);
  border: 1px solid var(--bs-border-color);
  overflow: hidden;
  position: sticky;
  top: 100px;
}

.settings-nav .nav-link {
  color: var(--bs-body-color);
  border-radius: 0;
  margin-bottom: 0;
  transition: all 0.2s ease;
  border: none;
  border-bottom: 1px solid var(--bs-border-color);
  padding: 1.25rem 1.5rem !important;
}

.settings-nav .nav-item:last-child .nav-link {
  border-bottom: none;
}

.settings-nav .nav-link:hover {
  background-color: rgb(0 0 0 / 0.1);
  color: var(--bs-primary);
}

.settings-nav .nav-link.active {
  background-color: rgba(var(--bs-primary-rgb), 0.1);
  color: var(--bs-primary);
}

.settings-nav .nav-link .icon-box {
  width: 42px;
  height: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--bs-border-radius, 0.25rem);
  background-color: var(--bs-tertiary-bg);
  color: var(--bs-secondary-color);
  transition: all 0.2s;
}

.settings-nav .nav-link:hover .icon-box {
  background-color: var(--bs-card-bg);
  color: var(--bs-primary);
  box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.settings-nav .nav-link.active .icon-box {
  background-color: var(--bs-primary);
  color: #ffffff;
}

.settings-nav .nav-link .text-content {
  transition: opacity 0.2s;
}

.settings-nav .nav-link small {
  font-size: 0.8rem;
  color: var(--bs-secondary-color);
}

.settings-nav .nav-link.active small {
  color: rgba(var(--bs-primary-rgb), 0.8);
}


/* Utility Classes */
.cursor-pointer {
  cursor: pointer !important;
}

/* Profile Page Enhancements */
.nav-pills-custom .nav-link {
    color: var(--bs-gray-600);
    background: transparent;
    border-radius: 8px;
    transition: all 0.3s ease;
}
.nav-pills-custom .nav-link.active {
    color: #fff;
    background-color: var(--bs-primary);
    box-shadow: 0 4px 12px rgba(85, 110, 230, 0.3);
}
.avatar-xl {
    height: 7.5rem;
    width: 7.5rem;
}
