/* LogiFlow - Custom Styles */

/* ============================================
   CSS Variables (Design System)
   ============================================ */
:root {
    /* Brand Primary (LogiFlow Blue) */
    --brand-primary: #2563eb;
    --brand-primary-hover: #1d4ed8;
    --brand-primary-light: #dbeafe;
    --brand-primary-subtle: #eff6ff;

    /* Bootstrap token override */
    --bs-primary: var(--brand-primary);
    --bs-primary-rgb: 37, 99, 235;

    /* Status Colors */
    --success: #059669;
    --success-light: #d1fae5;
    --danger: #dc2626;
    --danger-light: #fee2e2;
    --warning: #d97706;
    --warning-light: #fef3c7;
    --info: #0284c7;
    --info-light: #e0f2fe;
    --secondary: #64748b;
    --secondary-light: #f1f5f9;

    /* Neutral Colors - TailAdmin gray palette */
    --body-bg: #f1f5f9;
    --card-bg: #ffffff;
    --sidebar-bg: #f9fafb; /* TailAdmin gray-50 */
    --sidebar-text: #334155;
    --sidebar-active-bg: #eff6ff;
    --sidebar-active-accent: #2563eb;
    --sidebar-active-text: #1d4ed8; /* Xanh đậm hơn cho contrast trên nền nhạt */
    --text-primary: #0f172a;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;
    --border-color: #e2e8f0;
    --border-light: #f1f5f9;

    /* Spacing & Radius */
    --radius-sm: 0.375rem;
    --radius-md: 0.5rem;
    --radius-lg: 0.75rem;
    --radius-xl: 1rem;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1);
}

/* ============================================
   Typography
   ============================================ */
body {
    margin: 0;
    padding: 0;
    background-color: var(--body-bg);
    overflow-x: hidden;
    font-family: "Plus Jakarta Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    font-weight: 400;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    color: var(--text-primary);
}

@media (min-width: 768px) {
    body {
        font-size: 15px;
    }
}

h1, h2, h3, h4, h5, h6 {
    font-weight: 600;
    line-height: 1.35;
    color: var(--text-primary);
    letter-spacing: -0.02em;
}


/* ============================================
   Layout Structure
   ============================================ */
.app-wrapper {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */

/* Sidebar Styles */
  /* Sidebar - TailAdmin style */
  #sidebar {
    position: fixed;
    left: 0;
    top: 0;
    width: 16rem;
    min-width: 16rem;
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: visible;
    transition: width 0.3s ease, transform 0.3s ease;
    z-index: 1000;
    background-color: var(--sidebar-bg);
    color: var(--sidebar-text);
    border-right: 1px solid var(--border-color);
    box-shadow: none;
  }
  
  /* 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 - visible for menu-group-items để line + bullet không bị clip */
  #sidebar .sidebar-nav {
    overflow-x: hidden;
  }
  #sidebar .sidebar-nav > ul {
    overflow: visible;
  }
  
  /* First nav item (Trang chủ) spacing */
  #sidebar .sidebar-nav > ul > li:first-child {
    margin-bottom: 0.25rem;
  }
  
  /* Mobile: Drawer style - Angular Tailwind Admin / TailAdmin */
  @media (max-width: 767.98px) {
    #sidebar {
      position: fixed;
      top: 0;
      left: 0;
      bottom: 0;
      transform: translateX(-100%);
      width: min(85vw, 18rem) !important;
      max-width: 18rem;
      min-width: 16rem;
      height: 100vh;
      height: 100dvh;
      z-index: 1050;
      box-shadow: 16px 0 40px rgba(0, 0, 0, 0.15);
      transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), visibility 0.3s;
      background: #ffffff !important;
      background-color: #ffffff !important;
      overflow-y: auto;
      overflow-x: hidden;
      -webkit-overflow-scrolling: touch;
      will-change: transform;
    }
    
    #sidebar.show {
      transform: translateX(0);
      box-shadow: 24px 0 48px rgba(0, 0, 0, 0.2);
      visibility: visible;
    }
    
    /* Safe area for notched phones */
    #sidebar {
      padding-top: env(safe-area-inset-top);
      padding-bottom: env(safe-area-inset-bottom);
    }
    
    /* Overlay backdrop - Angular Tailwind Admin style */
    #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 - click to close */
    .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;
      cursor: pointer;
    }
    
    .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: Luôn hiển thị đầy đủ menu groups (NGHIỆP VỤ, Hệ thống...) - bỏ qua trạng thái collapsed của desktop */
    #sidebar .menu-group,
    #sidebar.collapsed .menu-group {
      display: block !important;
    }
    #sidebar.collapsed .menu-group-toggle {
      display: flex !important;
    }
    #sidebar.collapsed .menu-group-toggle .menu-group-icon {
      display: inline-block !important;
    }
    
    /* Mobile: dùng cùng style active như Desktop (nền xanh nhạt + chữ xanh đậm + viền trái) */
    #sidebar .nav-item.active {
      border-left: 3px solid var(--sidebar-active-accent);
      padding-left: calc(1rem - 3px);
    }
    
    /* Mobile: chevron và tên nhóm menu luôn hiển thị */
    #sidebar .menu-group-toggle .menu-group-icon,
    #sidebar .menu-group-toggle .sidebar-text {
      display: inline-block !important;
      visibility: visible !important;
      opacity: 1 !important;
    }
  }
  
  #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-brand-text,
    #sidebar.collapsed .sidebar-title span {
      display: none;
    }
    
    /* Keep brand icon visible when collapsed */
    #sidebar.collapsed .sidebar-brand-icon,
    #sidebar.collapsed .sidebar-title i {
      display: flex !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;
      border-left: none;
      padding-left: 0.75rem;
    }
    
    /* 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;
    }
    
    /* Collapsed: hiển thị menu group items dạng icon-only */
    #sidebar.collapsed .menu-group-items {
      display: block !important;
      max-height: 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 - TailAdmin style */
  .sidebar-header {
    padding: 1.5rem 1.25rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
    gap: 0.5rem;
  }
  
  #sidebar.app-sidebar-light .sidebar-header {
    border-bottom-color: var(--border-color);
    background: var(--sidebar-bg);
  }
  
  @media (max-width: 767.98px) {
    .sidebar-header {
      padding: 1rem 1.25rem;
      min-height: 60px;
      flex-shrink: 0;
    }
    #sidebar .sidebar-header,
    #sidebar .sidebar-nav {
      background: #ffffff !important;
      background-color: #ffffff !important;
    }
  }

  /* Sidebar close button - mobile only (44px touch target) */
  .sidebar-close-btn {
    display: none;
    width: 44px;
    height: 44px;
    min-width: 44px;
    min-height: 44px;
    padding: 0;
    border: none;
    border-radius: 0.5rem;
    background: var(--border-light);
    color: var(--text-secondary);
    cursor: pointer;
    align-items: center;
    justify-content: center;
    transition: background 0.2s ease, color 0.2s ease, transform 0.15s ease;
  }
  .sidebar-close-btn:hover {
    background: var(--border-color);
    color: var(--text-primary);
  }
  .sidebar-close-btn:active {
    transform: scale(0.95);
  }
  .sidebar-close-btn i {
    font-size: 1.25rem;
  }
  @media (max-width: 767.98px) {
    .sidebar-close-btn.d-md-none {
      display: flex !important;
    }
  }
  
  /* Sidebar brand - TailAdmin style */
  .sidebar-brand {
    color: var(--text-primary);
    font-weight: 700;
    font-size: 1.25rem;
    letter-spacing: -0.02em;
  }
  
  .sidebar-brand:hover {
    color: var(--text-primary);
  }
  
  .sidebar-brand-icon {
    width: 2.25rem;
    height: 2.25rem;
    border-radius: 0.5rem;
    background: linear-gradient(135deg, var(--brand-primary) 0%, var(--brand-primary-hover) 100%);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    flex-shrink: 0;
  }
  
  .sidebar-brand-text {
    font-weight: 700;
  }
  
  /* Collapsed: chỉ hiện icon */
  #sidebar.collapsed .sidebar-brand-text {
    display: none;
  }
  
  #sidebar.collapsed .sidebar-brand-icon {
    margin: 0;
  }
  
  /* Legacy .sidebar-title support */
  .sidebar-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0;
    display: flex;
    align-items: center;
    gap: 0.5rem;
  }
  
  @media (max-width: 767.98px) {
    .sidebar-brand { font-size: 1.125rem; }
    .sidebar-brand-icon { width: 2rem; height: 2rem; font-size: 1.125rem; }
  }
  
  /* 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 - TailAdmin style */
  .sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 0.75rem 0.5rem;
  }
  
  @media (max-width: 767.98px) {
    .sidebar-nav {
      padding: 0.75rem 0.5rem;
      -webkit-overflow-scrolling: touch;
    }
  }
  
  .sidebar-nav ul {
    list-style: none;
    padding: 0;
    margin: 0;
  }
  
  /* Sidebar icon - TailAdmin: icon đơn giản, không box (hoặc box rất nhẹ khi hover/active) */
  .sidebar-icon {
    width: 1.5rem;
    height: 1.5rem;
    font-size: 1.125rem;
    margin-right: 0.5rem;
    text-align: center;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    flex-grow: 0;
    border-radius: 0.375rem;
    background: transparent;
    color: var(--text-secondary);
    transition: background 0.2s ease, color 0.2s ease;
  }
  
  .nav-item:hover .sidebar-icon {
    color: var(--text-primary);
  }
  
  .nav-item.active .sidebar-icon {
    background: rgba(37, 99, 235, 0.15);
    color: var(--sidebar-active-text);
  }
  
  /* Sidebar text styles */
  .sidebar-text {
    font-weight: 500;
    font-size: 0.9375rem;
    line-height: 1.5;
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  
  /* Nav item - TailAdmin flat style */
  .nav-item {
    display: flex;
    align-items: center;
    padding: 0.5rem 0.75rem;
    margin: 0.125rem 0.25rem;
    color: var(--sidebar-text);
    text-decoration: none;
    border-radius: 0.5rem;
    transition: background-color 0.2s ease, color 0.2s ease;
    min-width: 0;
    overflow: hidden;
    position: relative;
  }
  
  .nav-item:hover {
    background-color: var(--border-light);
    color: var(--text-primary) !important;
    position: relative;
    z-index: 10;
  }
  
  #sidebar.app-sidebar-light .nav-item:hover .sidebar-icon,
  #sidebar.app-sidebar-light .nav-item:hover .sidebar-text {
    color: var(--text-primary) !important;
    visibility: visible !important;
    opacity: 1 !important;
  }
  
  @media (max-width: 767.98px) {
    .nav-item {
      padding: 0.75rem 1rem;
      margin: 0.125rem 0.5rem;
      min-height: 44px;
      align-items: center;
    }
  }
  
  /* Menu group - TailAdmin: flat, không bullet/đường dọc */
  .menu-group-items {
    list-style: none;
    padding: 0;
    margin: 0;
    margin-left: 0;
    padding-left: 0;
    border-left: none;
    position: relative;
    overflow: visible;
  }
  
  .menu-group-items li {
    list-style: none;
    position: relative;
    overflow: visible;
  }
  
  .menu-group-items li::before {
    display: none;
  }
  
  .menu-group-items .nav-item {
    padding-left: 0.75rem;
    font-size: 0.9375rem;
    margin-left: 0.25rem;
    margin-right: 0.25rem;
  }
  
  /* Sub-item indent - icon nhỏ hơn chút cho sub-items */
  .menu-group-items .nav-item .sidebar-icon {
    width: 1.375rem;
    height: 1.375rem;
    font-size: 1rem;
  }
  
  /* Sidebar toggle button - circular button on right edge */
  #sidebar-toggle-btn {
    position: absolute;
    right: -16px;
    top: 50%;
    transform: translateY(-50%);
    width: 32px;
    height: 32px;
    background: #ffffff !important;
    border: 1px solid #e5e7eb !important;
    border-radius: 50%;
    color: var(--sidebar-active-accent) !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);
  }
  
  /* Collapsed: hiển thị menu-group và icon của sub-items */
  #sidebar.collapsed .menu-group {
    display: block !important;
    margin-top: 0.25rem;
    padding-top: 0.25rem;
    border-top: 1px solid var(--border-color);
  }
  
  /* Sidebar dividers */
  .sidebar-divider {
    height: 1px;
    background-color: rgba(255, 255, 255, 0.2);
    margin: 0.5rem 1rem;
    list-style: none;
  }
  
  /* Menu group styles - separator ngang giữa các nhóm */
  .menu-group {
    margin-top: 0.5rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--border-color);
  }
  
  #sidebar.app-sidebar-light .menu-group {
    border-top-color: var(--border-color);
  }
  
  @media (max-width: 767.98px) {
    .menu-group {
      margin-top: 0.75rem;
      padding-top: 1rem;
    }
  }
  
  /* Nhóm đầu tiên (NGHIỆP VỤ) không có separator phía trên */
  .sidebar-nav > ul > li:first-child + li.menu-group {
    margin-top: 0.5rem;
    padding-top: 0;
    border-top: none;
  }
  
  /* Menu group toggle - TailAdmin: label đơn giản, uppercase */
  .menu-group-toggle {
    cursor: pointer;
    transition: color 0.2s ease;
    border: none;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    width: 100%;
    margin: 0 0.25rem 0.5rem;
    padding: 0.25rem 0.5rem;
    color: var(--text-muted);
    text-decoration: none;
    background: transparent;
    font-size: 0.6875rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    font-weight: 600;
    text-align: left;
  }
  
  #sidebar.app-sidebar-light .menu-group-toggle {
    color: var(--text-secondary);
  }
  
  /* Tên nhóm menu + chevron: luôn hiển thị */
  #sidebar.app-sidebar-light .menu-group-toggle .sidebar-text,
  #sidebar.app-sidebar-light .menu-group-toggle .menu-group-icon {
    display: inline-block !important;
    visibility: visible !important;
    opacity: 1 !important;
  }
  
  /* Menu group toggle text - align left */
  .menu-group-toggle .sidebar-text {
    text-align: left;
    flex: 1;
  }
  
  /* Menu group icon - align right, luôn hiển thị */
  .menu-group-toggle .menu-group-icon {
    margin-left: auto;
    flex-shrink: 0;
    min-width: 1rem;
  }
  
  /* TailAdmin: group header không có background, chỉ đổi màu khi expand */
  .menu-group-toggle[aria-expanded="true"],
  .menu-group-toggle.active,
  .menu-group-toggle.has-active {
    color: var(--text-secondary) !important;
  }
  
  #sidebar.app-sidebar-light .menu-group-toggle[aria-expanded="true"],
  #sidebar.app-sidebar-light .menu-group-toggle.has-active {
    color: var(--text-primary) !important;
  }
  
  .menu-group-toggle:hover {
    color: var(--text-secondary) !important;
  }
  
  /* Theme overrides - TailAdmin dùng app-sidebar-light, giữ fallback cho theme khác */
  
  .menu-group-icon {
    transition: transform 0.3s ease;
    color: var(--sidebar-text) !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;
  }
  
  #sidebar.app-sidebar-light .menu-group-toggle[aria-expanded="true"] .menu-group-icon,
  #sidebar.app-sidebar-light .menu-group-toggle.has-active .menu-group-icon {
    color: var(--sidebar-active-accent) !important;
    display: inline-block !important;
    visibility: visible !important;
    opacity: 1 !important;
  }
  
  /* Chevron luôn hiển thị khi menu ẩn (aria-expanded=false) */
  #sidebar.app-sidebar-light .menu-group-toggle[aria-expanded="false"] .menu-group-icon {
    color: var(--text-secondary) !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,
  #sidebar.app-sidebar-light .menu-group-items .nav-item.active {
    color: var(--sidebar-active-text) !important;
    background-color: var(--sidebar-active-bg) !important;
    border-left: 3px solid var(--sidebar-active-accent);
    padding-left: calc(0.75rem - 3px);
  }
  
  #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);
  }
  
  #sidebar.app-sidebar-light .menu-group-items .nav-item.active:hover {
    background-color: #dbeafe !important;
    color: var(--sidebar-active-text) !important;
  }
  
  #sidebar.app-sidebar-light .menu-group-items .nav-item.active:hover .sidebar-icon,
  #sidebar.app-sidebar-light .menu-group-items .nav-item.active:hover .sidebar-text {
    color: var(--sidebar-active-text) !important;
  }
  
  .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;
  }
  
  /* TailAdmin: flat list, không border giữa items */
  .menu-group-items li:not(:last-child) .nav-item {
    border-bottom: none;
  }
  
  .menu-group-items li:last-child .nav-item {
    border-bottom: none;
    margin-bottom: 0;
  }
  
  .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;
  }
  
  /* Ẩn đường dọc + bullet khi sidebar collapsed */
  #sidebar.collapsed .menu-group-items {
    margin-left: 0;
    padding-left: 0;
    border-left: none;
  }
  
  #sidebar.collapsed .menu-group-items li::before {
    display: none;
  }
  
  #sidebar.collapsed .menu-group-toggle {
    display: none !important;
  }
  
  #sidebar.collapsed .menu-group-icon {
    display: none;
  }
  
  /* Ensure standalone nav items (like Trang chủ) are visible when collapsed */
  #sidebar.collapsed > nav > ul > li:not(.menu-group) > .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: #f3f4f6;
  }
  
  #sidebar nav::-webkit-scrollbar-thumb {
    background: #d1d5db;
    border-radius: 3px;
  }
  
  #sidebar nav::-webkit-scrollbar-thumb:hover {
    background: #9ca3af;
  }
  
  /* Light theme sidebar scrollbar */
  #sidebar.bg-light nav::-webkit-scrollbar-track,
  #sidebar.app-sidebar-light nav::-webkit-scrollbar-track {
    background: #f3f4f6;
  }
  
  #sidebar.bg-light nav::-webkit-scrollbar-thumb,
  #sidebar.app-sidebar-light nav::-webkit-scrollbar-thumb {
    background: #d1d5db;
  }
  
  #sidebar.bg-light nav::-webkit-scrollbar-thumb:hover,
  #sidebar.app-sidebar-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;
  }
  
  /* Active nav item - TailAdmin: viền trái 3px + bg xanh nhạt */
  .nav-item.active {
    background-color: var(--sidebar-active-bg) !important;
    color: var(--sidebar-active-text) !important;
    font-weight: 600 !important;
    transition: all 0.2s ease;
    border-left: 3px solid var(--sidebar-active-accent);
    padding-left: calc(0.75rem - 3px); /* bù padding khi có border */
  }
  
  .nav-item.active::after {
    display: none;
  }
  
  .nav-item.active .sidebar-text {
    color: var(--sidebar-active-text) !important;
    font-weight: 600 !important;
  }
  
  .nav-item.active .sidebar-icon {
    background: rgba(37, 99, 235, 0.15) !important;
    color: var(--sidebar-active-text) !important;
  }
  
  /* Active + Hover state */
  .nav-item.active:hover {
    background-color: #dbeafe !important;
  }
  
  /* Active state cho các theme khác (fallback) */
  #sidebar.bg-success .nav-item.active,
  #sidebar.bg-secondary .nav-item.active,
  #sidebar.bg-primary .nav-item.active {
    background-color: var(--sidebar-active-bg) !important;
    color: var(--sidebar-active-text) !important;
    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: #dbeafe !important;
    box-shadow: inset 0 0 0 1px rgba(59, 130, 246, 0.15);
  }
  
  #sidebar.bg-success .nav-item.active i,
  #sidebar.bg-secondary .nav-item.active i,
  #sidebar.bg-primary .nav-item.active i {
    color: var(--sidebar-active-text) !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(--card-bg);
    border-bottom: 1px solid var(--border-color);
    padding: 1rem 1.25rem;
    box-shadow: var(--shadow-sm);
    color: var(--text-primary);
    position: relative;
}

/* Header title - centered using flexbox (desktop) */
@media (min-width: 768px) {
    .app-header .header-title {
        color: var(--text-primary);
        font-weight: 600;
        margin: 0;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        max-width: 100%;
        text-align: center;
        font-size: 1.125rem;
    }
    
    .app-header .header-subtitle {
        color: var(--text-secondary);
        font-size: 0.875rem;
        margin-top: 0.25rem;
        display: block !important;
    }
    
    .app-header .dropdown-toggle span {
        display: inline !important;
    }
    
    .app-header .dropdown-toggle::after {
        display: inline-block !important;
        border-top-color: var(--text-primary);
    }
    
    .app-header .btn-link {
        color: var(--text-primary) !important;
    }
    
    .app-header .btn-link:hover {
        color: var(--text-secondary) !important;
    }
    
    .app-header .dropdown-toggle {
        color: var(--text-primary) !important;
        padding: 0.5rem 0.75rem !important;
        min-width: auto;
    }
    
    .app-header .dropdown-toggle:hover {
        color: var(--text-secondary) !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 */
.app-header .btn-link {
    color: var(--text-primary) !important;
}

.app-header .btn-link:hover {
    color: var(--text-secondary) !important;
}

.app-header .dropdown-toggle {
    color: var(--text-primary) !important;
}

.app-header .dropdown-toggle:hover {
    color: var(--text-secondary) !important;
}

.app-content {
    flex: 1;
    padding: 1rem 1.25rem;
    min-width: 0;
    overflow-x: visible;
}

/* ============================================
   Statistics Cards (TailAdmin style)
   ============================================ */
.stat-card {
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
    transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
    border-color: var(--border-color);
}

.stat-card-link {
    display: block;
    cursor: pointer;
}

.stat-card-link:hover .stat-card {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.dashboard-metric-clickable {
    display: block;
    cursor: pointer;
    border-radius: var(--radius);
    margin: 0 -0.5rem;
    padding: 0.25rem 0.5rem;
}

.dashboard-metric-clickable:hover {
    background: rgba(0,0,0,0.03);
}

.clickable-row {
    cursor: pointer;
}

.clickable-row:hover {
    background-color: rgba(0,0,0,0.04) !important;
}

/* ============================================
   Dashboard Widgets
   ============================================ */
.dashboard-widgets .widget {
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
    transition: box-shadow 0.2s ease;
}

.dashboard-widgets .widget:hover {
    box-shadow: var(--shadow-md);
}

.dashboard-widgets .widget-filter {
    background: var(--card-bg);
}

.dashboard-widgets .widget-card .stat-card {
    padding: 1rem;
}

.dashboard-widgets .widget-card .stat-card-value {
    font-size: 1.5rem;
}

.dashboard-widgets .widget-chart .card-header,
.dashboard-widgets .widget-table .card-header,
.dashboard-widgets .widget-summary .card-header {
    padding: 0.75rem 1rem;
    background: transparent;
    border-bottom: 1px solid var(--border-color);
}

.dashboard-widgets .widget-chart .card-header h6,
.dashboard-widgets .widget-table .card-header h6,
.dashboard-widgets .widget-summary .card-header h6 {
    font-size: 0.9rem;
    font-weight: 600;
}

.dashboard-widgets .widget-welcome {
    background: linear-gradient(135deg, rgba(37, 99, 235, 0.06) 0%, transparent 100%);
    border-color: rgba(37, 99, 235, 0.2);
}

.stat-card-inner {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex: 1;
    min-width: 0;
}

.stat-card-icon {
    width: 3.5rem;
    height: 3.5rem;
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    color: white;
    flex-shrink: 0;
}

.stat-card-primary .stat-card-icon {
    background: linear-gradient(135deg, var(--brand-primary) 0%, #1d4ed8 100%);
}

.stat-card-success .stat-card-icon {
    background: linear-gradient(135deg, var(--success) 0%, #047857 100%);
}

.stat-card-danger .stat-card-icon {
    background: linear-gradient(135deg, var(--danger) 0%, #b91c1c 100%);
}

.stat-card-warning .stat-card-icon {
    background: linear-gradient(135deg, var(--warning) 0%, #b45309 100%);
}

.stat-card-info .stat-card-icon {
    background: linear-gradient(135deg, var(--info) 0%, #0369a1 100%);
}

.stat-card-secondary .stat-card-icon {
    background: linear-gradient(135deg, var(--secondary) 0%, #475569 100%);
}

.stat-card-content {
    flex: 1;
    min-width: 0;
}

.stat-card-value {
    font-size: 2rem;
    font-weight: 700;
    margin: 0;
    color: var(--text-primary);
    letter-spacing: -0.03em;
    line-height: 1.2;
}

.stat-card-label {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin: 0.25rem 0 0 0;
    font-weight: 500;
}

/* Trend badge - TailAdmin style */
.stat-card-trend {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.25rem;
    font-size: 0.75rem;
    font-weight: 600;
    padding: 0.25rem 0.5rem;
    min-width: 5.5rem;
    border-radius: 9999px;
    margin-top: 0.5rem;
}

.stat-card-trend.up {
    background: var(--success-light);
    color: var(--success);
}

.stat-card-trend.down {
    background: var(--danger-light);
    color: var(--danger);
}

.stat-card-trend.neutral {
    background: var(--border-light);
    color: var(--text-secondary);
}

/* ============================================
   Dashboard (TailAdmin style)
   ============================================ */
.dashboard-tailadmin .card {
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
}

.dashboard-card .card-header {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border-color);
}

.dashboard-card .card-body {
    padding: 1.25rem;
}

.chart-container {
    position: relative;
    width: 100%;
}

.dashboard-metric-item .progress {
    background-color: var(--border-light);
    border-radius: 9999px;
    overflow: hidden;
}

.dashboard-metric-item .progress-bar {
    border-radius: 9999px;
    transition: width 0.5s ease;
}



/* ============================================
   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: 1060; /* Above Bootstrap modal (1055) for correct positioning */
}

.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: 1060;
}

/* Select2 trong modal: dropdown append vào modal-content, ô tìm kiếm tích hợp ngay trên danh sách */
.modal .modal-content {
    position: relative;
}
.modal .select2-dropdown {
    z-index: 1060 !important;
}

/* 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);
    font-weight: 500;
    border-radius: var(--radius-md);
}

.btn-primary:hover {
    background-color: var(--brand-primary-hover);
    border-color: var(--brand-primary-hover);
}

.btn-outline-secondary {
    border-radius: var(--radius-md);
    font-weight: 500;
}

.btn-outline-secondary:hover {
    background-color: var(--secondary-light);
    border-color: var(--secondary);
    color: var(--text-primary);
}

/* Header sidebar toggle - better touch target */
#sidebarToggle {
    min-width: 44px;
    min-height: 44px;
    border-radius: var(--radius-md);
    transition: background 0.2s ease;
}
#sidebarToggle:hover {
    background: var(--border-light);
}

/* ============================================
   Cards (global override)
   ============================================ */
.card {
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
}

.card-header {
    background: var(--card-bg);
    border-bottom: 1px solid var(--border-color);
    padding: 1rem 1.25rem;
    font-weight: 600;
    font-size: 1rem;
}

.card-body {
    padding: 1.25rem;
}

/* ============================================
   Forms
   ============================================ */
.form-label {
    font-weight: 500;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}

.form-control, .form-select {
    border-radius: var(--radius-md);
    border-color: var(--border-color);
}

.form-control:focus, .form-select:focus {
    border-color: var(--brand-primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

/* ============================================
   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;
        background: #ffffff !important;
        color: var(--text-primary) !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;
        font-weight: 600;
        line-height: 1.3;
        margin: 0;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        color: var(--text-primary) !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 - 44px touch target (Angular Tailwind Admin) */
    #sidebarToggle {
        padding: 0.5rem !important;
        min-width: 44px;
        min-height: 44px;
        flex-shrink: 0;
        touch-action: manipulation;
    }
    
    #sidebarToggle i {
        font-size: 1.375rem !important;
    }
    
    /* User dropdown - hide text, show only icon on mobile */
    .app-header .dropdown-toggle {
        padding: 0.5rem !important;
        min-width: 44px;
        min-height: 44px;
        flex-shrink: 0;
        color: var(--text-primary) !important;
        border-radius: var(--radius-md) !important;
    }
    
    .app-header .dropdown-toggle:hover {
        color: var(--text-primary) !important;
        background: var(--border-light) !important;
        border-color: var(--border-color) !important;
    }
    
    .app-header .dropdown-toggle span {
        display: none !important;
    }
    
    .app-header .dropdown-toggle i.bi-person-circle {
        font-size: 1.5rem !important;
        margin: 0 !important;
    }
    
    .app-header .dropdown-toggle i.bi-chevron-down {
        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: 1rem;
    }
    
    /* 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)
   ============================================ */
/* Cho phép scroll ngang khi bảng rộng hơn màn hình.
   z-index cao hơn .pagination-footer để menu thao tác không bị phân trang đè. */
.card-body .table-responsive {
    overflow-x: auto !important;
    overflow-y: visible;
    -webkit-overflow-scrolling: touch;
    position: relative;
    z-index: 2;
}

/* Phân trang nằm dưới vùng bảng + dropdown (z-index thấp hơn) */
.card-body .pagination-footer {
    position: relative;
    z-index: 1;
}

/* Trip parcels pagination: button giống link, tránh style mặc định của button */
.pagination .trip-parcels-pagination-btn {
    cursor: pointer;
    font: inherit;
}

/* Ensure dropdown menus appear above scrollbar and other elements */
.card-body .table-responsive .dropdown-menu {
    z-index: 1070 !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 + sticky */
.card-body .table-responsive table.table thead th {
    text-transform: uppercase;
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.05em;
    position: sticky;
    top: 0;
    z-index: 5;
    background: var(--body-bg);
    box-shadow: 0 2px 0 0 var(--border-color);
    color: var(--text-secondary);
    padding: 0.875rem 1rem;
}

.card-body .table-responsive table.table tbody td {
    padding: 0.875rem 1rem;
    vertical-align: middle;
}

.card-body .table-responsive table.table tbody tr:hover {
    background-color: var(--brand-primary-subtle);
}

/* ============================================
   Table column widths - đồng nhất toàn hệ thống
   ============================================ */
.col-stt {
    width: 62px !important;
    min-width: 62px !important;
    max-width: 62px !important;
    text-align: center !important;
}
.col-actions {
    width: 100px !important;
    min-width: 100px !important;
    max-width: 100px !important;
    text-align: center !important;
    white-space: nowrap !important;
}

/* Bookings table - chiều rộng cột hợp lý */
.table-bookings .col-status,
.table-bookings th.col-status,
.table-bookings td.col-status {
    width: 1%;
    min-width: 100px;
    white-space: nowrap;
}
.table-bookings .col-booking-code,
.table-bookings th.col-booking-code,
.table-bookings td.col-booking-code {
    width: 1%;
    min-width: 105px;
    white-space: nowrap;
}
.table-bookings .col-route,
.table-bookings th.col-route,
.table-bookings td.col-route {
    min-width: 140px;
}
.table-bookings .col-time,
.table-bookings th.col-time,
.table-bookings td.col-time {
    width: 1%;
    min-width: 65px;
    white-space: nowrap;
}
.table-bookings .col-passenger,
.table-bookings th.col-passenger,
.table-bookings td.col-passenger {
    min-width: 110px;
}
.table-bookings .col-phone,
.table-bookings th.col-phone,
.table-bookings td.col-phone {
    width: 1%;
    min-width: 105px;
    white-space: nowrap;
}
.table-bookings .col-seats,
.table-bookings th.col-seats,
.table-bookings td.col-seats {
    width: 1%;
    min-width: 70px;
    text-align: center;
}
.table-bookings .col-amount,
.table-bookings th.col-amount,
.table-bookings td.col-amount {
    width: 1%;
    min-width: 95px;
    white-space: nowrap;
}
.table-bookings .col-date,
.table-bookings th.col-date,
.table-bookings td.col-date {
    width: 1%;
    min-width: 120px;
    white-space: nowrap;
}

/* Badge colors for gender */
.badge.bg-pink {
    background-color: #e91e63 !important;
    color: white;
}

/* ============================================
   Empty State
   ============================================ */
.empty-state {
    min-height: 200px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.empty-state-icon {
    width: 4rem;
    height: 4rem;
    border-radius: 50%;
    background: var(--border-light);
    color: var(--text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
}

/* ============================================
   Report Filter Form - đồng nhất chiều cao controls
   ============================================ */
.report-filter-form .form-control,
.report-filter-form .form-select,
.report-filter-form .btn {
    height: 2.375rem;
    min-height: 2.375rem;
}

.report-filter-form .form-check {
    min-height: 2.375rem;
    display: flex;
    align-items: center;
}

/* ============================================
   Filters Section
   ============================================ */
.filters-section .card {
    border-radius: var(--radius-lg);
}

.filters-section .form-control,
.filters-section .form-select {
    border-radius: var(--radius-md);
}

/* Toggle buttons - when only filters visible, full rounded */
.btn-group:has(.toggle-stats-btn.d-none) .toggle-filters-btn {
    border-radius: var(--radius-md) !important;
}

/* ============================================
   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 3px rgba(37, 99, 235, 0.2);
}

/* Dropdown menu polish */
.dropdown-menu {
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-lg);
    padding: 0.25rem;
}

.dropdown-item {
    border-radius: var(--radius-sm);
    padding: 0.5rem 1rem;
}

.dropdown-item:hover {
    background: var(--brand-primary-subtle);
}

/* Modal polish */
.modal-content {
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-lg);
}

.modal-header {
    border-bottom-color: var(--border-color);
    padding: 1.25rem 1.5rem;
}

.modal-body {
    padding: 1.5rem;
}

.modal-footer {
    border-top-color: var(--border-color);
    padding: 1rem 1.5rem;
}

/* ============================================
   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;
  }

/* ============================================
   Login Page (đồng bộ UI/UX với các trang khác)
   ============================================ */
body.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  background: linear-gradient(135deg, var(--brand-primary) 0%, var(--brand-primary-hover) 50%, #1e40af 100%);
}

.login-page .login-container {
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  padding: 0;
  width: 100%;
  max-width: 420px;
  overflow: hidden;
}

.login-page .login-container .card-header {
  background: var(--card-bg);
  border-bottom: 1px solid var(--border-color);
  padding: 2rem 2.5rem 1.5rem;
  text-align: center;
}

.login-page .login-container .card-header h1 {
  color: var(--brand-primary);
  font-weight: 600;
  font-size: 1.75rem;
  margin: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

.login-page .login-container .card-header p {
  font-size: 0.9375rem;
  color: var(--text-secondary);
  margin: 0.25rem 0 0;
  font-weight: 400;
}

.login-page .login-container .card-body {
  padding: 1.5rem 2.5rem 2.5rem;
}

.login-page .login-container .form-control {
  border-radius: var(--radius-md);
  padding: 0.625rem 1rem;
  border-color: var(--border-color);
}

.login-page .login-container .form-control:focus {
  border-color: var(--brand-primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.login-page .login-container .btn-primary {
  background: var(--brand-primary);
  border: none;
  padding: 0.75rem 1.5rem;
  font-weight: 500;
  border-radius: var(--radius-md);
}

.login-page .login-container .btn-primary:hover {
  background: var(--brand-primary-hover);
}

.login-page .login-container .alert {
  border-radius: var(--radius-md);
}

/* Trip Map - OpenStreetMap markers */
.trip-map-marker { background: none; border: none; }
.trip-map-marker-station .marker-num {
  display: inline-flex; align-items: center; justify-content: center;
  width: 26px; height: 26px; border-radius: 50%;
  background: var(--brand-primary, #2563eb); color: #fff;
  font-size: 12px; font-weight: 600;
  border: 2px solid #fff; box-shadow: 0 1px 4px rgba(0,0,0,0.3);
}
.trip-map-marker-delivery .marker-pin { font-size: 20px; }

/* Station map - autocomplete gợi ý vị trí */
.station-map-suggestions {
  top: 100%;
  margin-top: 2px;
  border-radius: 6px;
  border: 1px solid var(--bs-border-color, #dee2e6);
}
.station-map-suggestions .list-group-item {
  border-left: 0;
  border-right: 0;
  white-space: normal;
}
.station-map-suggestions .list-group-item:first-child {
  border-top: 0;
}

/* Sortable - kéo thả trạm tuyến */
.sortable-handle { touch-action: none; }
.sortable-ghost { opacity: 0.4; background: var(--brand-primary, #2563eb) !important; color: #fff !important; }
.sortable-chosen { background: var(--brand-primary-subtle, #eff6ff) !important; }
.sortable-drag { opacity: 1; }
