/* Sky Clinic - Custom Styles */

/* ============================================
   CSS Variables (Brand Colors)
   ============================================ */
:root {
    /* Brand Primary (Sky Clinic Blue) */
    --brand-primary: #3b82f6;
    --brand-primary-hover: #2563eb;
    --brand-primary-light: #dbeafe;

    /* Bootstrap token override */
    --bs-primary: var(--brand-primary);
    --bs-primary-rgb: 59, 130, 246;

    /* Status Colors */
    --success: #10b981;
    --success-light: #d1fae5;
    --danger: #ef4444;
    --danger-light: #fee2e2;
    --warning: #f59e0b;
    --warning-light: #fef3c7;
    --info: #3b82f6;
    --info-light: #dbeafe;
    --secondary: #6b7280;
    --secondary-light: #f3f4f6;

    /* Neutral Colors */
    --body-bg: #f3f4f6;
    --card-bg: #ffffff;
    --sidebar-bg: #3b82f6;
    --text-primary: #111827;
    --text-secondary: #6b7280;
    --text-muted: #9ca3af;
    --border-color: #e5e7eb;
    --border-light: #f3f4f6;
}

/* ============================================
   Typography
   ============================================ */
body {
    margin: 0;
    padding: 0;
    background-color: #f3f4f6;
    overflow-x: hidden;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";
    font-weight: 400;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
  }

@media (min-width: 768px) {
    body {
        font-size: 16px;
    }
}

h1, h2, h3, h4, h5, h6 {
    font-weight: 600;
    line-height: 1.3;
    color: var(--text-primary);
}


/* ============================================
   Map Components
   ============================================ */
.map-container {
    height: 600px;
    width: 100%;
}

.map-legend-icon {
    font-size: 1.5rem;
}

/* ============================================
   Common UI Patterns
   ============================================ */
/* Avatar sizes */
.avatar-sm {
    width: 32px;
    height: 32px;
    object-fit: cover;
}

.avatar-md {
    width: 40px;
    height: 40px;
    object-fit: cover;
}

/* Empty state icon */
.empty-state-icon {
    font-size: 3rem;
    color: #ccc;
}

/* Table image */
.table-image {
    width: 40px;
    height: 40px;
    object-fit: cover;
}

/* ============================================
   Layout Structure
   ============================================ */
.app-wrapper {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */

/* Sidebar Styles */
  #sidebar {
    position: fixed;
    left: 0;
    top: 0;
    width: 16rem;
    min-width: 16rem; /* Ensure minimum width */
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: visible; /* Allow toggle button to be visible outside sidebar */
    transition: width 0.3s ease, transform 0.3s ease;
    z-index: 1000;
    background-color: var(--sidebar-bg, #3b82f6);
    color: white;
    box-shadow: 2px 0 4px rgba(0, 0, 0, 0.1);
  }
  
  /* Desktop: Allow sidebar to collapse to 4rem */
  @media (min-width: 768px) {
    #sidebar {
      min-width: 4rem; /* Allow sidebar to shrink to 4rem when collapsed */
    }
  }
  
  /* Ensure sidebar nav doesn't overflow */
  #sidebar .sidebar-nav {
    overflow-x: hidden;
  }
  
  /* Mobile: Sidebar hidden by default, slides in from left */
  @media (max-width: 767.98px) {
    #sidebar {
      transform: translateX(-100%);
      width: 16rem !important;
      z-index: 1050;
      box-shadow: 2px 0 8px rgba(0, 0, 0, 0.2);
    }
    
    #sidebar.show {
      transform: translateX(0);
    }
    
    /* Overlay backdrop when sidebar is open on mobile */
    #sidebar.show::before {
      content: '';
      position: fixed;
      top: 0;
      left: 0;
      right: 0;
      bottom: 0;
      background-color: rgba(0, 0, 0, 0.5);
      z-index: -1;
      pointer-events: none;
    }
    
    /* Sidebar backdrop overlay */
    .sidebar-backdrop {
      position: fixed;
      top: 0;
      left: 0;
      right: 0;
      bottom: 0;
      background-color: rgba(0, 0, 0, 0.5);
      z-index: 1049;
      display: none;
      opacity: 0;
      transition: opacity 0.3s ease;
    }
    
    .sidebar-backdrop.show {
      display: block;
      opacity: 1;
    }
    
    /* Disable collapsed state on mobile */
    #sidebar.collapsed {
      width: 16rem !important;
    }
    
    #sidebar.collapsed .sidebar-text {
      display: block !important;
    }
    
    #sidebar.collapsed .nav-item {
      justify-content: flex-start !important;
      padding: 0.75rem 1rem !important;
    }
    
    #sidebar.collapsed .sidebar-icon {
      margin-right: 0.75rem !important;
    }
    
    /* Main content full width on mobile */
    .app-main {
      margin-left: 0 !important;
      width: 100% !important;
    }
    
    /* Hide sidebar toggle button on sidebar itself on mobile */
    #sidebar-toggle-btn {
      display: none;
    }
  }
  
  #mobile-sidebar-toggle {
    display: none;
  }
  




/* Sidebar collapse functionality - Desktop only */
@media (min-width: 768px) {
  #sidebar.collapsed {
    width: 4rem !important;
    min-width: 4rem !important;
  }
}
  
  /* Desktop: Collapsed sidebar styles */
  @media (min-width: 768px) {
    /* Hide text when collapsed */
    #sidebar.collapsed .sidebar-title span {
      display: none;
    }
    
    /* Keep icon visible in title when collapsed */
    #sidebar.collapsed .sidebar-title i {
      display: inline-block !important;
      margin: 0 !important;
      opacity: 1 !important;
      visibility: visible !important;
    }
    
    #sidebar.collapsed .sidebar-text {
      display: none;
    }
    
    /* Nav items - center icons when collapsed */
    #sidebar.collapsed .nav-item {
      justify-content: center;
      padding: 0.75rem;
      display: flex !important;
    }
    
    /* Ensure ALL icons are visible when collapsed */
    #sidebar.collapsed .nav-item i,
    #sidebar.collapsed .nav-item .sidebar-icon,
    #sidebar.collapsed .nav-item .bi {
      display: inline-block !important;
      margin: 0 !important;
      margin-right: 0 !important;
      width: auto !important;
      font-size: 1.25rem !important;
      opacity: 1 !important;
      visibility: visible !important;
    }
    
    /* Hide menu group items when collapsed */
    #sidebar.collapsed .menu-group-items {
      display: none !important;
    }
    
    /* Universal icon visibility rule for collapsed sidebar */
    #sidebar.collapsed i,
    #sidebar.collapsed .bi,
    #sidebar.collapsed .sidebar-icon {
      display: inline-block !important;
      opacity: 1 !important;
      visibility: visible !important;
      width: auto !important;
      height: auto !important;
      flex-shrink: 0 !important;
      flex-grow: 0 !important;
    }
  }
  
  /* Sidebar header */
  .sidebar-header {
    padding: 1rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    align-items: center;
    flex-shrink: 0;
  }
  
  /* Sidebar title */
  .sidebar-title {
    font-size: 1.125rem;
    font-weight: 600;
    color: white;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 0.5rem;
  }
  
  .sidebar-title i {
    font-size: 1.5rem;
    display: inline-block;
  }
  
  .sidebar-title span {
    font-weight: 600;
  }
  
  /* Sidebar title adjustments - reduce font sizes and weight */
  .sidebar-title h1 {
    font-size: 1rem !important;
    font-weight: 500 !important; /* Giảm từ 700 xuống 500 */
    line-height: 1.3;
    margin-bottom: 0.125rem;
  }
  
  .sidebar-title p {
    font-size: 0.75rem !important;
    line-height: 1.2;
    margin-top: 0;
  }
  
  /* Sidebar navigation */
  .sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 0.75rem 0;
  }
  
  .sidebar-nav ul {
    list-style: none;
    padding: 0;
    margin: 0;
  }
  
  /* Sidebar icon styles */
  .sidebar-icon {
    width: 1.25rem;
    font-size: 1.25rem;
    margin-right: 0.75rem;
    text-align: center;
    display: inline-block;
    flex-shrink: 0;
    flex-grow: 0;
    min-width: 1.25rem; /* Prevent icon from shrinking */
  }
  
  /* Sidebar text styles */
  .sidebar-text {
    font-weight: 500;
    line-height: 1.5;
    flex: 1;
    min-width: 0; /* Allow text to shrink */
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  
  /* Nav item base styles */
  .nav-item {
    display: flex;
    align-items: center;
    padding: 0.75rem 1rem;
    color: white;
    text-decoration: none;
    transition: background-color 0.2s ease, color 0.2s ease, border-left 0.2s ease;
    border-left: 3px solid transparent;
    min-width: 0; /* Allow flex item to shrink */
    overflow: hidden; /* Prevent text overflow */
  }
  
  .nav-item:hover {
    background-color: rgba(255, 255, 255, 0.1);
    color: white;
  }
  
  /* Menu group items nav items - indented */
  .menu-group-items .nav-item {
    padding-left: 1.5rem;
    font-size: 0.875rem;
  }
  
  /* Menu group items container */
  .menu-group-items {
    list-style: none;
    padding: 0;
    margin: 0;
  }
  
  .menu-group-items li {
    list-style: none;
  }
  
  /* Sidebar toggle button - circular button on right edge, centered in header */
  #sidebar-toggle-btn {
    position: absolute;
    right: -16px;
    top: 50%;
    transform: translateY(-50%);
    width: 32px;
    height: 32px;
    background: #ffffff !important;
    border: none !important;
    border-radius: 50%;
    color: var(--brand-primary) !important;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 !important;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    transition: all 0.2s ease;
    z-index: 1001;
    cursor: pointer;
  }
  
  #sidebar-toggle-btn:hover {
    background: #f8f9fa !important;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    transform: translateY(-50%) scale(1.1);
  }
  
  #sidebar-toggle-btn:focus {
    background: #f8f9fa !important;
    box-shadow: 0 0 0 0.2rem rgba(59, 130, 246, 0.25) !important;
    outline: none !important;
    transform: translateY(-50%);
  }
  
  #sidebar-toggle-btn:active {
    background: #e9ecef !important;
    transform: translateY(-50%) scale(0.95);
  }
  
  #sidebar-toggle-btn i {
    font-size: 1rem;
    display: inline-block;
    transition: transform 0.3s ease;
    line-height: 1;
  }
  
  #sidebar.collapsed #sidebar-toggle-btn {
    right: -16px;
  }
  
  #sidebar.collapsed #sidebar-toggle-btn i {
    transform: rotate(180deg);
  }
  
  #sidebar.collapsed .menu-group-header {
    display: none;
  }
  
  /* Sidebar dividers */
  .sidebar-divider {
    height: 1px;
    background-color: rgba(255, 255, 255, 0.2);
    margin: 0.5rem 1rem;
    list-style: none;
  }
  
  /* Menu group styles */
  .menu-group-header {
    margin-top: 0.5rem;
  }
  
  /* Menu group toggle button styles */
  .menu-group-toggle {
    cursor: pointer;
    transition: background-color 0.2s ease;
    border: none;
    border-radius: 0.25rem;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    width: 100%;
    padding: 0.75rem 1rem;
    color: rgba(255, 255, 255, 0.95);
    text-decoration: none;
    background: transparent;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.02em;
    font-weight: 600;
    margin: 0;
    text-align: left;
  }
  
  /* Menu group toggle text - align left */
  .menu-group-toggle .sidebar-text {
    text-align: left;
    flex: 1;
  }
  
  /* Menu group icon - align right */
  .menu-group-toggle .menu-group-icon {
    margin-left: auto;
    flex-shrink: 0;
  }
  
  /* Active/expanded menu group toggle - background highlight */
  .menu-group-toggle[aria-expanded="true"],
  .menu-group-toggle.active {
    background-color: rgba(255, 255, 255, 0.15) !important;
    border: none !important;
  }
  
  /* Highlight menu group header when it contains active item */
  .menu-group-toggle.has-active {
    background-color: rgba(255, 255, 255, 0.15) !important;
    border: none !important;
  }
  
  /* Hover states - only for non-active/expanded */
  .menu-group-toggle:hover:not([aria-expanded="true"]):not(.active):not(.has-active) {
    background-color: rgba(255, 255, 255, 0.08) !important;
  }
  
  /* Hover for active/expanded - slightly darker */
  .menu-group-toggle[aria-expanded="true"]:hover,
  .menu-group-toggle.active:hover,
  .menu-group-toggle.has-active:hover {
    background-color: rgba(255, 255, 255, 0.2) !important;
  }
  
  /* Light theme hover */
  #sidebar.bg-light .menu-group-toggle:hover {
    background-color: #e5e7eb !important;
  }
  
  /* Green theme hover */
  #sidebar.bg-success .menu-group-toggle:hover {
    background-color: rgba(255, 255, 255, 0.1) !important;
  }
  
  /* Gray theme hover */
  #sidebar.bg-secondary .menu-group-toggle:hover {
    background-color: rgba(255, 255, 255, 0.1) !important;
  }
  
  /* Blue theme hover */
  #sidebar.bg-primary .menu-group-toggle:hover {
    background-color: rgba(255, 255, 255, 0.1) !important;
  }
  
  .menu-group-icon {
    transition: transform 0.3s ease;
    color: rgba(255, 255, 255, 0.9) !important;
    font-size: 0.875rem !important;
    display: inline-block !important;
    visibility: visible !important;
    opacity: 1 !important;
    width: auto !important;
    height: auto !important;
    line-height: 1 !important;
    font-family: "bootstrap-icons" !important;
    font-style: normal !important;
    font-weight: normal !important;
    font-variant: normal !important;
    text-transform: none !important;
    -webkit-font-smoothing: antialiased !important;
    -moz-osx-font-smoothing: grayscale !important;
  }
  
  /* Green theme menu group icon */
  #sidebar.bg-success .menu-group-icon {
    color: rgba(255, 255, 255, 0.7);
  }
  
  /* Gray theme menu group icon */
  #sidebar.bg-secondary .menu-group-icon {
    color: rgba(255, 255, 255, 0.7);
  }
  
  /* Blue theme menu group icon - Improved contrast */
  #sidebar.bg-primary .menu-group-icon {
    color: rgba(255, 255, 255, 0.9) !important;
    display: inline-block !important;
    visibility: visible !important;
    opacity: 1 !important;
    font-size: 0.875rem !important;
  }
  
  .menu-group-toggle.active .menu-group-icon,
  .menu-group-toggle[aria-expanded="true"] .menu-group-icon {
    transform: rotate(180deg);
    color: rgba(255, 255, 255, 1) !important;
    display: inline-block !important;
    visibility: visible !important;
    opacity: 1 !important;
  }
  
  /* Ensure icons are visible in expanded menu group toggle */
  .menu-group-toggle[aria-expanded="true"] .menu-group-icon,
  .menu-group-toggle[aria-expanded="true"] i,
  .menu-group-toggle.active .menu-group-icon,
  .menu-group-toggle.active i,
  .menu-group-toggle.has-active .menu-group-icon,
  .menu-group-toggle.has-active i {
    display: inline-block !important;
    visibility: visible !important;
    opacity: 1 !important;
  }
  
  /* Theme-specific highlights - all use background instead of border */
  #sidebar.bg-success .menu-group-toggle.has-active,
  #sidebar.bg-success .menu-group-toggle[aria-expanded="true"],
  #sidebar.bg-secondary .menu-group-toggle.has-active,
  #sidebar.bg-secondary .menu-group-toggle[aria-expanded="true"],
  #sidebar.bg-primary .menu-group-toggle.has-active,
  #sidebar.bg-primary .menu-group-toggle[aria-expanded="true"] {
    background-color: rgba(255, 255, 255, 0.15) !important;
    border: none !important;
  }
  
  /* Ensure icons are visible in theme-specific expanded states */
  #sidebar.bg-success .menu-group-toggle[aria-expanded="true"] .menu-group-icon,
  #sidebar.bg-success .menu-group-toggle[aria-expanded="true"] i,
  #sidebar.bg-secondary .menu-group-toggle[aria-expanded="true"] .menu-group-icon,
  #sidebar.bg-secondary .menu-group-toggle[aria-expanded="true"] i,
  #sidebar.bg-primary .menu-group-toggle[aria-expanded="true"] .menu-group-icon,
  #sidebar.bg-primary .menu-group-toggle[aria-expanded="true"] i,
  #sidebar.bg-success .menu-group-toggle.has-active .menu-group-icon,
  #sidebar.bg-success .menu-group-toggle.has-active i,
  #sidebar.bg-secondary .menu-group-toggle.has-active .menu-group-icon,
  #sidebar.bg-secondary .menu-group-toggle.has-active i,
  #sidebar.bg-primary .menu-group-toggle.has-active .menu-group-icon,
  #sidebar.bg-primary .menu-group-toggle.has-active i {
    display: inline-block !important;
    visibility: visible !important;
    opacity: 1 !important;
  }
  
  /* Theme-specific hover for expanded */
  #sidebar.bg-success .menu-group-toggle[aria-expanded="true"]:hover,
  #sidebar.bg-secondary .menu-group-toggle[aria-expanded="true"]:hover,
  #sidebar.bg-primary .menu-group-toggle[aria-expanded="true"]:hover,
  #sidebar.bg-success .menu-group-toggle.has-active:hover,
  #sidebar.bg-secondary .menu-group-toggle.has-active:hover,
  #sidebar.bg-primary .menu-group-toggle.has-active:hover {
    background-color: rgba(255, 255, 255, 0.2) !important;
  }
  
  /* Improved text contrast for menu group headers */
  #sidebar.bg-primary .menu-group-toggle .sidebar-text {
    color: #ffffff !important;
    font-weight: 500 !important; /* Giảm từ 600 xuống 500 */
    letter-spacing: 0.02em;
    line-height: 1.5;
  }
  
  /* Improved text contrast for sub-menu items */
  #sidebar.bg-primary .menu-group-items .nav-item:not(.active) {
    color: #ffffff !important;
  }
  
  #sidebar.bg-primary .menu-group-items .nav-item:hover:not(.active) {
    color: #ffffff !important;
    background-color: rgba(255, 255, 255, 0.15) !important;
    transition: background-color 0.2s ease;
  }
  
  #sidebar.bg-primary .menu-group-items .nav-item.active {
    color: #0F172A !important; /* Slate 900 - tối hơn để tăng contrast */
    background-color: #E8F1FF !important;
    border-left: 3px solid #2563EB !important;
  }
  
  #sidebar.bg-primary .menu-group-items .nav-item.active:hover {
    background-color: #D4E4FF !important;
    box-shadow: inset 0 0 0 1px rgba(37, 99, 235, 0.1);
  }
  
  .menu-group-items {
    list-style: none;
    padding: 0;
    margin: 0;
    overflow: hidden;
  }
  
  /* Bootstrap collapse integration */
  .menu-group-items.collapse:not(.show) {
    display: none;
  }
  
  .menu-group-items.collapse.show {
    display: block;
    max-height: 1000px;
    opacity: 1;
    transition: max-height 0.3s ease, opacity 0.3s ease;
  }
  
  /* Add border between menu items within a group */
  .menu-group-items li:not(:last-child) .nav-item {
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  }
  
  /* Add border after last item in menu group */
  .menu-group-items li:last-child .nav-item {
    border-bottom: 1px solid rgba(255, 255, 255, 0.15);
    margin-bottom: 0.25rem;
  }
  
  .menu-group-items li {
    margin: 0;
  }
  
  /* When collapsed, show menu group items as icon-only */
  #sidebar.collapsed .menu-group-items {
    display: block !important;
    max-height: none !important;
    opacity: 1 !important;
    visibility: visible !important;
  }
  
  #sidebar.collapsed .menu-group-items li {
    display: block !important;
  }
  
  #sidebar.collapsed .menu-group-items .nav-item {
    display: flex !important;
    visibility: visible !important;
    justify-content: center;
    align-items: center;
    padding-left: 0.75rem;
    padding-right: 0.75rem;
  }
  
  #sidebar.collapsed .menu-group-toggle {
    display: none !important;
  }
  
  #sidebar.collapsed .menu-group-icon {
    display: none;
  }
  
  /* Ensure standalone nav items (like Dashboard) are visible when collapsed */
  #sidebar.collapsed > nav > ul > li:not(.menu-group-header) > .nav-item {
    display: flex !important;
    visibility: visible !important;
  }
  
  /* Ensure icons are visible when sidebar is collapsed */
  #sidebar.collapsed .nav-item .fas,
  #sidebar.collapsed .nav-item .fa,
  #sidebar.collapsed .nav-item i,
  #sidebar.collapsed .nav-item .bi {
    display: inline-block !important;
    margin: 0 !important;
    margin-right: 0 !important;
    width: auto !important;
    font-size: 1.25rem;
    visibility: visible !important;
    opacity: 1 !important;
  }
  
  /* Ensure menu group items icons are visible when sidebar is collapsed */
  #sidebar.collapsed .menu-group-items .nav-item i,
  #sidebar.collapsed .menu-group-items .nav-item .bi,
  #sidebar.collapsed .menu-group-items .sidebar-icon {
    display: inline-block !important;
    visibility: visible !important;
    opacity: 1 !important;
    margin: 0 !important;
    font-size: 1.25rem !important;
  }
  
  /* Sidebar scrollbar */
  #sidebar nav::-webkit-scrollbar {
    width: 6px;
  }
  
  #sidebar nav::-webkit-scrollbar-track {
    background: #1f2937;
  }
  
  #sidebar nav::-webkit-scrollbar-thumb {
    background: #4b5563;
    border-radius: 3px;
  }
  
  #sidebar nav::-webkit-scrollbar-thumb:hover {
    background: #9ca3af;
  }
  
  /* Light theme sidebar scrollbar */
  #sidebar.bg-light nav::-webkit-scrollbar-track {
    background: #f3f4f6;
  }
  
  #sidebar.bg-light nav::-webkit-scrollbar-thumb {
    background: #d1d5db;
  }
  
  #sidebar.bg-light nav::-webkit-scrollbar-thumb:hover {
    background: #9ca3af;
  }
  
  /* Green theme sidebar scrollbar */
  #sidebar.bg-success nav::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.1);
  }
  
  #sidebar.bg-success nav::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.3);
  }
  
  #sidebar.bg-success nav::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.5);
  }
  
  /* Gray theme sidebar scrollbar */
  #sidebar.bg-secondary nav::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.1);
  }
  
  #sidebar.bg-secondary nav::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.3);
  }
  
  #sidebar.bg-secondary nav::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.5);
  }
  
  /* Blue theme sidebar scrollbar */
  #sidebar.bg-primary nav::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.1);
  }
  
  #sidebar.bg-primary nav::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.3);
  }
  
  #sidebar.bg-primary nav::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.5);
  }
  
  /* Nav item hover */
  .nav-item.hover-bg-secondary:hover,
  .nav-item.hover-bg-secondary:focus {
    background-color: #374151;
  }
  
  .nav-item.hover-bg-light:hover,
  .nav-item.hover-bg-light:focus {
    background-color: #e5e7eb;
  }
  
  .nav-item.hover-bg-success-subtle:hover,
  .nav-item.hover-bg-success-subtle:focus {
    background-color: rgba(255, 255, 255, 0.1);
  }
  
  .nav-item.hover-bg-secondary-subtle:hover,
  .nav-item.hover-bg-secondary-subtle:focus {
    background-color: rgba(255, 255, 255, 0.1);
  }
  
  .nav-item.hover-bg-primary-subtle:hover,
  .nav-item.hover-bg-primary-subtle:focus {
    background-color: #3B82F6; /* Blue 500 theo guideline */
  }
  
  /* Sidebar nav item hover - theo guideline (chỉ cho non-active items) */
  #sidebar .nav-item:hover:not(.active) {
    background-color: rgba(255, 255, 255, 0.15) !important; /* Subtle white overlay */
    color: #ffffff !important;
    transition: background-color 0.2s ease, color 0.2s ease;
  }
  
  /* Smooth transition cho tất cả nav items */
  #sidebar .nav-item {
    transition: background-color 0.2s ease, color 0.2s ease, border-left 0.2s ease;
  }
  
  /* Active nav item - theo guideline */
  .nav-item.active {
    background-color: #E8F1FF !important; /* Light blue theo guideline */
    border-left: 3px solid #2563EB !important; /* Blue 600 border theo guideline */
    color: #0F172A !important; /* Slate 900 - tối hơn để tăng contrast với background #E8F1FF */
    font-weight: 600 !important; /* Bold cho active theo guideline */
    transition: all 0.2s ease;
  }
  
  .nav-item.active .sidebar-text {
    color: #0F172A !important; /* Slate 900 - tối hơn để tăng contrast, đảm bảo WCAG AA */
    font-weight: 600 !important;
  }
  
  .nav-item.active i,
  .nav-item.active .sidebar-icon {
    color: #2563EB !important; /* Blue 600 icon theo guideline */
  }
  
  /* Active + Hover state - subtle darken để feedback */
  .nav-item.active:hover {
    background-color: #D4E4FF !important; /* Slightly darker than active */
    box-shadow: inset 0 0 0 1px rgba(37, 99, 235, 0.1);
  }
  
  /* Active state cho các theme khác - giữ nguyên cho compatibility */
  #sidebar.bg-success .nav-item.active,
  #sidebar.bg-secondary .nav-item.active,
  #sidebar.bg-primary .nav-item.active {
    background-color: #E8F1FF !important;
    border-left: 3px solid #2563EB !important;
    color: #0F172A !important; /* Slate 900 - tối hơn để tăng contrast */
    font-weight: 600 !important;
    transition: all 0.2s ease;
  }
  
  #sidebar.bg-success .nav-item.active:hover,
  #sidebar.bg-secondary .nav-item.active:hover,
  #sidebar.bg-primary .nav-item.active:hover {
    background-color: #D4E4FF !important;
    box-shadow: inset 0 0 0 1px rgba(37, 99, 235, 0.1);
  }
  
  #sidebar.bg-success .nav-item.active i,
  #sidebar.bg-secondary .nav-item.active i,
  #sidebar.bg-primary .nav-item.active i {
    color: #2563EB !important;
  }
  
  /* Hover cho non-active items trong các theme */
  #sidebar.bg-success .nav-item:hover:not(.active),
  #sidebar.bg-secondary .nav-item:hover:not(.active),
  #sidebar.bg-primary .nav-item:hover:not(.active) {
    background-color: rgba(255, 255, 255, 0.15) !important;
    transition: background-color 0.2s ease;
  }

/* Main Content */
.app-main {
    flex: 1;
    margin-left: 16rem;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    transition: margin-left 0.3s ease;
    width: calc(100% - 16rem);
}

.app-wrapper:has(#sidebar.collapsed) .app-main {
    margin-left: 4rem;
    width: calc(100% - 4rem);
}

.app-header {
    background: var(--brand-primary, #3b82f6);
    border-bottom: none;
    padding: 1rem 1.5rem;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    color: white;
    position: relative;
}

/* Header title - centered using flexbox (desktop) */
@media (min-width: 768px) {
    .app-header .header-title {
        color: white;
        font-weight: 600;
        margin: 0;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        max-width: 100%;
        text-align: center;
        font-size: 1.125rem; /* Normal size on desktop */
    }
    
    .app-header .header-subtitle {
        color: rgba(255, 255, 255, 0.9);
        font-size: 0.875rem;
        margin-top: 0.25rem;
        display: block !important;
    }
    
    /* Desktop: Show user name text */
    .app-header .dropdown-toggle span {
        display: inline !important;
    }
    
    /* Desktop: Show dropdown arrow */
    .app-header .dropdown-toggle::after {
        display: inline-block !important;
        border-top-color: white;
    }
    
    /* Desktop: Header buttons - white color on primary background */
    .app-header .btn-link {
        color: white !important;
    }
    
    .app-header .btn-link:hover {
        color: rgba(255, 255, 255, 0.8) !important;
    }
    
    .app-header .dropdown-toggle {
        color: white !important;
        padding: 0.5rem 0.75rem !important;
        min-width: auto;
    }
    
    .app-header .dropdown-toggle:hover {
        color: rgba(255, 255, 255, 0.8) !important;
    }
    
    .app-header .dropdown-toggle span {
        display: inline !important;
    }
    
    .app-header .dropdown-toggle i {
        font-size: 1.5rem;
        margin-right: 0.5rem;
    }
}

/* Header buttons - default (will be overridden in media queries) */
.app-header .btn-link {
    color: white !important;
}

.app-header .btn-link:hover {
    color: rgba(255, 255, 255, 0.8) !important;
}

.app-header .dropdown-toggle {
    color: white !important;
}

.app-header .dropdown-toggle:hover {
    color: rgba(255, 255, 255, 0.8) !important;
}

.app-content {
    flex: 1;
    padding: 0.5rem;
}

/* ============================================
   Statistics Cards
   ============================================ */
.stat-card {
    background: white;
    border-radius: 0.5rem;
    padding: 1.5rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.stat-card-icon {
    width: 3rem;
    height: 3rem;
    border-radius: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    color: white;
}

.stat-card-primary .stat-card-icon {
    background: var(--brand-primary);
}

.stat-card-success .stat-card-icon {
    background: var(--success);
}

.stat-card-danger .stat-card-icon {
    background: var(--danger);
}

.stat-card-warning .stat-card-icon {
    background: var(--warning);
}

.stat-card-info .stat-card-icon {
    background: var(--info);
}

.stat-card-secondary .stat-card-icon {
    background: var(--secondary);
}

.stat-card-content {
    flex: 1;
}

.stat-card-value {
    font-size: 1.75rem;
    font-weight: 600;
    margin: 0;
    color: var(--text-primary);
}

.stat-card-label {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin: 0.25rem 0 0 0;
}



/* ============================================
   Select2 Customization (UI/UX Compliance)
   ============================================ */
.select2-container--default .select2-selection--single {
    height: 38px;
    border: 1px solid #ced4da;
    border-radius: 0.375rem;
    display: flex;
    align-items: center;
}

.select2-container--default .select2-selection--single .select2-selection__rendered {
    line-height: 1.5;
    padding-left: 12px;
    padding-right: 50px; /* Space for clear button (x) and arrow */
    color: #212529;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    height: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    width: 100%;
}

.select2-container--default .select2-selection--single .select2-selection__arrow {
    height: 100%;
    right: 8px;
    top: 0;
    width: 20px;
    display: flex !important;
    align-items: center;
    justify-content: center;
    position: absolute;
    z-index: 2; /* Higher than clear button */
    pointer-events: none; /* Allow clicks to pass through to select */
}

.select2-container--default .select2-selection--single .select2-selection__arrow b {
    border-color: #6c757d transparent transparent transparent;
    border-style: solid;
    border-width: 5px 4px 0 4px;
    height: 0;
    left: 50%;
    margin-left: -4px;
    margin-top: -2px;
    position: absolute;
    top: 50%;
    width: 0;
}

/* Clear button (X) styling - position after text */
.select2-container--default .select2-selection--single .select2-selection__clear {
    position: absolute;
    right: 30px; /* Position before arrow */
    top: 50%;
    transform: translateY(-50%);
    cursor: pointer;
    font-size: 1.2rem;
    line-height: 1;
    color: #6c757d;
    width: 18px;
    height: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1; /* Lower than arrow */
}

.select2-container--default .select2-selection--single .select2-selection__clear:hover {
    color: #212529;
}

.select2-container--default .select2-selection--single .select2-selection__placeholder {
    color: #6c757d;
    line-height: 1.5;
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    width: 100%;
    text-align: center;
}

.select2-container--default.select2-container--focus .select2-selection--single {
    border-color: var(--brand-primary);
    box-shadow: 0 0 0 0.2rem rgba(59, 130, 246, 0.25);
}

.select2-dropdown {
    border: 1px solid #ced4da;
    border-radius: 0.375rem;
    z-index: 1055; /* Ensure dropdown appears above modals */
}

.select2-results__option--highlighted {
    background-color: var(--brand-primary);
    color: white;
}

.select2-container--default .select2-results__option[aria-selected=true] {
    background-color: var(--brand-primary);
    color: white;
}

/* Select2 Bootstrap 5 Theme Compatibility */
.select2-container--bootstrap-5 .select2-selection {
    border: 1px solid #ced4da;
    border-radius: 0.375rem;
    min-height: 38px;
    display: flex;
    align-items: center;
    position: relative; /* For absolute positioning of clear button and arrow */
}

.select2-container--bootstrap-5 .select2-selection--single {
    height: 38px;
}

.select2-container--bootstrap-5 .select2-selection--single .select2-selection__rendered {
    line-height: 1.5;
    padding-left: 12px;
    padding-right: 50px; /* Space for clear button (x) and arrow */
    color: #212529;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    height: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    width: 100%;
    position: relative;
}

.select2-container--bootstrap-5 .select2-selection--single .select2-selection__arrow {
    height: 100%;
    right: 8px;
    top: 0;
    width: 20px;
    display: flex !important;
    align-items: center;
    justify-content: center;
    position: absolute;
    z-index: 2; /* Higher than clear button */
    pointer-events: none; /* Allow clicks to pass through to select */
}

.select2-container--bootstrap-5 .select2-selection--single .select2-selection__arrow b {
    border-color: #6c757d transparent transparent transparent;
    border-style: solid;
    border-width: 5px 4px 0 4px;
    height: 0;
    left: 50%;
    margin-left: -4px;
    margin-top: -2px;
    position: absolute;
    top: 50%;
    width: 0;
}

/* Clear button (X) styling for Bootstrap 5 theme */
.select2-container--bootstrap-5 .select2-selection--single .select2-selection__clear {
    position: absolute;
    right: 30px; /* Position before arrow */
    top: 50%;
    transform: translateY(-50%);
    cursor: pointer;
    font-size: 1.2rem;
    line-height: 1;
    color: #6c757d;
    width: 18px;
    height: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1;
}

.select2-container--bootstrap-5 .select2-selection--single .select2-selection__clear:hover {
    color: #212529;
}

/* Placeholder center alignment for Bootstrap 5 */
.select2-container--bootstrap-5 .select2-selection--single .select2-selection__placeholder {
    color: #6c757d;
    line-height: 1.5;
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    width: 100%;
    text-align: center;
}

.select2-container--bootstrap-5.select2-container--focus .select2-selection {
    border-color: var(--brand-primary);
    box-shadow: 0 0 0 0.2rem rgba(59, 130, 246, 0.25);
}

.select2-container--bootstrap-5 .select2-dropdown {
    border: 1px solid #ced4da;
    border-radius: 0.375rem;
    z-index: 1055;
}

/* Ensure dropdown menus appear above pagination */
.card-body .table-responsive .dropdown-menu {
    z-index: 1050 !important;
}

/* ============================================
   Buttons
   ============================================ */

.btn-primary {
    background-color: var(--brand-primary);
    border-color: var(--brand-primary);
}

.btn-primary:hover {
    background-color: var(--brand-primary-hover);
    border-color: var(--brand-primary-hover);
}

/* ============================================
   Forms
   ============================================ */
.form-label {
    font-weight: 500;
    margin-bottom: 0.5rem;
}

.form-control:focus {
    border-color: var(--brand-primary);
    box-shadow: 0 0 0 0.2rem rgba(59, 130, 246, 0.25);
}

/* ============================================
   Breadcrumb
   ============================================ */
.breadcrumb {
    background: transparent;
    padding: 0;
    margin-bottom: 1rem;
}

.breadcrumb-item a {
    color: var(--brand-primary);
    text-decoration: none;
}

.breadcrumb-item.active {
    color: var(--text-secondary);
}

/* ============================================
   Responsive
   ============================================ */
@media (max-width: 767.98px) {
    /* Mobile sidebar styles are defined above in the main #sidebar section */
    /* This section handles app-main and scroll behavior */
    .app-wrapper {
        min-height: 100vh;
        height: auto;
        display: block; /* Change from flex to block for natural flow */
    }
    
    .app-main {
        margin-left: 0 !important;
        width: 100% !important;
        min-height: 100vh;
        height: auto; /* Allow height to grow with content */
        overflow: visible; /* Let body handle scrolling */
        display: block; /* Change from flex to block */
    }
    
    .app-header {
        position: sticky;
        top: 0;
        z-index: 100;
        padding: 0.75rem 1rem !important; /* Reduced padding on mobile */
        background: var(--brand-primary, #3b82f6) !important;
        color: white !important;
    }
    
    /* Mobile header layout improvements */
    .app-header .d-flex {
        gap: 0.75rem !important; /* Reduced gap */
    }
    
    /* Title section - centered and truncate long titles */
    .app-header .header-title {
        font-size: 1rem !important; /* Smaller font on mobile */
        font-weight: 600;
        line-height: 1.3;
        margin: 0;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        color: white !important;
        max-width: 100%;
        text-align: center;
    }
    
    /* Hide subtitle on mobile to save space */
    .app-header .header-subtitle {
        display: none !important;
    }
    
    /* Adjust flex layout for mobile */
    .app-header .d-flex.flex-grow-1 {
        gap: 0.5rem !important;
    }
    
    .app-header .flex-grow-1 {
        min-width: 0; /* Allow flex item to shrink */
    }
    
    /* Balance spacer width on mobile */
    .app-header .d-flex.flex-grow-1 > div:last-child {
        width: 40px !important;
    }
    
    /* Sidebar toggle button - smaller on mobile */
    #sidebarToggle {
        padding: 0.5rem !important;
        min-width: 40px;
        flex-shrink: 0;
    }
    
    #sidebarToggle i {
        font-size: 1.25rem !important; /* Slightly smaller icon */
    }
    
    /* User dropdown - hide text, show only icon on mobile */
    .app-header .dropdown-toggle {
        padding: 0.5rem !important;
        min-width: 40px;
        flex-shrink: 0;
        color: white !important;
    }
    
    .app-header .dropdown-toggle:hover {
        color: rgba(255, 255, 255, 0.8) !important;
    }
    
    .app-header .dropdown-toggle span {
        display: none !important; /* Hide user name text on mobile */
    }
    
    .app-header .dropdown-toggle i {
        font-size: 1.5rem !important;
        margin: 0 !important;
        color: white !important;
    }
    
    /* Remove dropdown arrow on mobile */
    .app-header .dropdown-toggle::after {
        display: none !important;
    }
    
    /* User dropdown menu - full width on mobile */
    .app-header .dropdown-menu {
        min-width: 200px;
        right: 0;
        left: auto;
    }
    
    .app-content {
        min-height: auto;
        overflow: visible;
        padding: 0.5rem;
    }
    
    /* Ensure body and html can scroll on mobile */
    body {
        overflow-y: auto !important;
        overflow-x: hidden !important;
        position: relative !important;
        height: auto !important;
        min-height: 100vh;
    }
    
    html {
        overflow-y: auto !important;
        overflow-x: hidden !important;
        height: auto !important;
    }
}

/* ============================================
   Table Rules (UI/UX Compliance)
   ============================================ */
/* Table minimum height - ensure at least 5 rows height for dropdown visibility */
.card-body .table-responsive {
    padding-bottom: 250px;
    margin-bottom: -250px;
    /* Allow dropdown menus to overflow */
    overflow: visible !important;
}

/* Ensure dropdown menus appear above pagination and other elements */
.card-body .table-responsive .dropdown-menu {
    z-index: 1060 !important;
    position: absolute !important;
}

/* Ensure dropdown toggle button has proper positioning context */
.card-body .table-responsive .dropdown {
    position: static !important;
}

/* Make sure dropdown menu can escape table boundaries */
.card-body .table-responsive table {
    position: relative;
}

.card-body .table-responsive table tbody tr {
    position: relative;
}

.card-body .table-responsive table tbody tr td .dropdown {
    position: static;
}


/* Ensure text doesn't overflow in fixed layout */
.card-body .table-responsive table.table td {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Allow wrapping for long text in name column */
.card-body .table-responsive table.table td:nth-child(5) {
    white-space: normal;
    word-wrap: break-word;
}

/* Make all table headers uppercase */
.card-body .table-responsive table.table thead th {
    text-transform: uppercase;
    font-weight: 600;
    letter-spacing: 0.5px;
}

/* Badge colors for gender */
.badge.bg-pink {
    background-color: #e91e63 !important;
    color: white;
}

/* ============================================
   Utilities
   ============================================ */
.container-fluid.p-0.m-0 {
    padding: 0 !important;
    margin: 0 !important;
}

/* Focus styles */
.btn:focus,
.btn:active:focus,
.btn-link.nav-link:focus,
.form-control:focus,
.form-check-input:focus {
    box-shadow: 0 0 0 0.1rem white, 0 0 0 0.25rem var(--brand-primary);
}

/* ============================================
   SPA Navigation Loading Overlay
   ============================================ */
.spa-loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(255, 255, 255, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    backdrop-filter: blur(2px);
}

.spa-loading-content {
    text-align: center;
}

.spa-loading-content .spinner-border {
    width: 3rem;
    height: 3rem;
}

.app-content {
    position: relative;
    min-height: 400px;
    transition: opacity 0.3s ease;
}


/* Improved badge contrast - reduced font weight */
.badge.bg-info {
    background-color: #0dcaf0 !important;
    color: #fff !important;
    font-weight: 500; /* Giảm từ 600 xuống 500 */
  }
  
  .badge.bg-warning {
    background-color: #ffc107 !important;
    color: #000 !important;
    font-weight: 500; /* Giảm từ 600 xuống 500 */
  }
  
  .badge.bg-secondary {
    background-color: #6c757d !important;
    color: #fff !important;
    font-weight: 500; /* Giảm từ 600 xuống 500 */
  }
  
  .badge.bg-success {
    background-color: #198754 !important;
    color: #fff !important;
    font-weight: 500; /* Giảm từ 600 xuống 500 */
  }
  
  .badge.bg-danger {
    background-color: #dc3545 !important;
    color: #fff !important;
    font-weight: 500; /* Giảm từ 600 xuống 500 */
  }
  
  .badge.bg-primary {
    background-color: #0d6efd !important;
    color: #fff !important;
    font-weight: 500; /* Giảm từ 600 xuống 500 */
  }
  
  .badge.bg-dark {
    background-color: #212529 !important;
    color: #fff !important;
    font-weight: 500; /* Giảm từ 600 xuống 500 */
  }
  
  /* Enhanced badge styling for detail pages */
  .detail-badge,
  .card-body .badge,
  dl .badge {
    padding: 0.5rem 0.75rem;
    font-size: 0.875rem;
    font-weight: 500; /* Giảm từ 600 xuống 500 */
    border-radius: 0.375rem;
    letter-spacing: 0.025em;
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
  }
