/* Items (Archive) page styles */

/* Layout is controlled by page JS; avoid global overrides to keep other pages intact */

/* Shell + scroll - simplified single scroll approach */
#ab-items-shell { display:flex; flex-direction:column; flex:1 1 auto; min-height:0; border-top:1px solid #e5e7eb; position:relative; height:100%; }
#ab-items-scroll { 
  min-height:0; 
  height:calc(100% - var(--ab-pager-height, 76px)); 
  overflow:auto; 
  -webkit-overflow-scrolling:touch; 
  overscroll-behavior:contain; 
  background:#fff; 
}

/* Enhanced scrollbar visibility for all browsers */
#ab-items-scroll::-webkit-scrollbar {
  width: 12px;
  height: 12px;
}
#ab-items-scroll::-webkit-scrollbar-track {
  background: #f8fafc;
  border-radius: 6px;
}
#ab-items-scroll::-webkit-scrollbar-thumb {
  background: #94a3b8;
  border-radius: 6px;
  border: 2px solid #f8fafc;
}
#ab-items-scroll::-webkit-scrollbar-thumb:hover {
  background: #64748b;
}
#ab-items-scroll::-webkit-scrollbar-corner {
  background: #f8fafc;
}

/* Firefox scrollbar styling */
@supports (scrollbar-width: thin) {
  #ab-items-scroll {
    scrollbar-width: auto;
    scrollbar-color: #94a3b8 #f8fafc;
  }
}

/* Header - improved responsive design */
.ab-items-header { 
  gap:8px; 
  padding:.75rem 1rem; 
  background:#fff; 
  border-bottom:1px solid #e5e7eb; 
  position:sticky; 
  top:0; 
  z-index:31;
  flex-wrap: wrap;
  display: flex;
  align-items: center;
}

/* Back link styling for items header */
.ab-items-header .ab-back-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #1976D2;
  text-decoration: none;
  font-size: 1.25rem;
  line-height: 1;
  transition: color 0.15s ease;
  flex-shrink: 0;
}

.ab-items-header .ab-back-link:hover {
  color: #1565C0;
  text-decoration: none;
}

/* Reduce spacing after Archive title */
.ab-items-header h5 {
  margin-right: 0 !important;
  min-width: 0;
  flex-shrink: 0;
}

/* Header layout containers */
.ab-header-left {
  display: flex;
  align-items: center;
  flex-wrap: nowrap;
  gap: 8px;
  flex-shrink: 1;
  min-width: 0;
}

.ab-header-right {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-left: auto;
}

/* Scan Barcode input */
#ab-scan-barcode {
  border: 2px solid #d1d5db;
  border-radius: 0.375rem;
  padding: 0.5rem 0.75rem;
  font-size: 0.875rem;
  height: 38px;
  width: 200px;
  min-width: 100px;
  max-width: 200px;
  flex-shrink: 1;
  transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out, background-color 0.15s ease-in-out;
  background: #fff;
}

#ab-scan-barcode:focus {
  border-color: #1d6de6;
  outline: none;
  box-shadow: 0 0 0 0.2rem rgba(29, 109, 230, 0.25);
  background: #eff6ff;
}

#ab-scan-barcode::placeholder {
  color: #9ca3af;
  font-style: italic;
}

/* Visual feedback when scanning */
#ab-scan-barcode.scanning {
  border-color: #fbbf24;
  background: #fefce8;
  animation: pulse-scan 1.5s ease-in-out infinite;
}

@keyframes pulse-scan {
  0%, 100% {
    box-shadow: 0 0 0 0.15rem rgba(251, 191, 36, 0.2);
  }
  50% {
    box-shadow: 0 0 0 0.3rem rgba(251, 191, 36, 0.3);
  }
}

/* File filter badge - matching Export DataPreview design */
.ab-filter-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0.75rem;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  border-radius: 0.375rem;
  font-size: 0.875rem;
  color: #1e40af;
  white-space: nowrap;
}

.ab-filter-badge i {
  color: #3b82f6;
  font-size: 0.875rem;
}

.ab-filter-badge span {
  color: #1e40af;
}

.ab-filter-badge strong {
  font-weight: 600;
  color: #1e3a8a;
}

.ab-filter-badge .btn-link {
  color: #dc2626;
  text-decoration: none;
  transition: color 0.15s ease-in-out;
  line-height: 1;
}

.ab-filter-badge .btn-link:hover {
  color: #991b1b;
}

.ab-filter-badge .btn-link i {
  font-size: 1rem;
}

/* Selected items pill - blue outlined badge - SAME HEIGHT AS BUTTONS */
#ab-selected-pill {
  display: none;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  background: #fff;
  border: 2px solid #1d6de6;
  border-radius: 0.375rem;
  font-size: 0.875rem;
  font-weight: 600;
  color: #1d6de6;
  white-space: nowrap;
  transition: all 0.15s ease-in-out;
  min-height: 38px;
  height: 38px;
  box-sizing: border-box;
}

#ab-selected-pill.visible {
  display: inline-flex;
}

#ab-selected-pill i {
  font-size: 0.9rem;
  color: #1d6de6;
}

/* Force override Bootstrap button styles with high specificity - BASE STYLES */
.ab-items-header .ab-header-btn,
.ab-items-header .btn.ab-header-btn,
.ab-items-header button.ab-header-btn { 
  padding: 0.5rem 0.9rem !important; 
  font-weight: 600 !important; 
  font-size: 0.95rem !important; 
  line-height: 1.2 !important; 
  display: inline-flex !important; 
  align-items: center !important;
  justify-content: center !important;
  white-space: nowrap !important;
  min-height: 38px !important; /* Force consistent height */
  height: 38px !important; /* Explicit height to prevent Bootstrap override */
  border: 1px solid !important;
  border-radius: 0.375rem !important;
  box-sizing: border-box !important;
  text-decoration: none !important;
  vertical-align: middle !important;
}

/* Specific button color variations with high specificity */
.ab-items-header #ab-clear-filters,
.ab-items-header .btn#ab-clear-filters {
  background: transparent !important;
  color: #6c757d !important;
  border-color: #6c757d !important;
}
.ab-items-header #ab-clear-filters:hover,
.ab-items-header .btn#ab-clear-filters:hover {
  background: #6c757d !important;
  color: #fff !important;
  border-color: #6c757d !important;
}

.ab-items-header #ab-filter-by-file-btn,
.ab-items-header .btn#ab-filter-by-file-btn {
  background: transparent !important;
  color: #1d6de6 !important;
  border-color: #1d6de6 !important;
}
.ab-items-header #ab-filter-by-file-btn:hover,
.ab-items-header .btn#ab-filter-by-file-btn:hover {
  background: #e8f0ff !important;
  color: #1d6de6 !important;
  border-color: #1d6de6 !important;
}

.ab-items-header #ab-export-selected-btn,
.ab-items-header .btn#ab-export-selected-btn {
  background: #1d6de6 !important;
  color: #fff !important;
  border-color: #1d6de6 !important;
}
.ab-items-header #ab-export-selected-btn:hover,
.ab-items-header .btn#ab-export-selected-btn:hover {
  background: #1558b7 !important;
  border-color: #1558b7 !important;
}

/* Remove any Bootstrap margin/padding that might cause differences */
.ab-items-header .ab-header-btn,
.ab-items-header .btn.ab-header-btn {
  margin: 0 !important;
}

/* Responsive header buttons */
.ab-items-header h5 {
  margin-right: auto;
  min-width: 0;
  flex-shrink: 0;
}

.ab-items-header .ms-auto {
  flex-wrap: wrap;
  gap: 0.5rem;
}

/* Button text control - ensure only one version shows for all buttons */
#ab-export-selected-btn span,
#ab-clear-filters span,
#ab-filter-by-file-btn span {
  line-height: inherit;
}

/* Table styles - improved responsive column sizing */
.ab-items-table { border-collapse: separate; border-spacing:0; table-layout:fixed; width:max-content; min-width:100%; }
.ab-items-table { visibility:hidden; }
.ab-items-table.ab-ready { visibility:visible; }
.ab-items-table th, .ab-items-table td { padding:.5rem .7rem; font-size:.9375rem; vertical-align:middle; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; min-width:0; box-sizing:border-box; }
.ab-items-table thead th { background:#f5f7fa; color:#475467; font-weight:600; vertical-align:middle; border-bottom:1px solid #dde3ea; border-right:1px solid #dde3ea; position:sticky; top:0; z-index:15; overflow:hidden; min-width:120px; }
.ab-items-table thead th:first-child { position:sticky; left:0; z-index:16; box-shadow: 1px 0 0 #e5e7eb inset; min-width:48px; max-width:48px; }
.ab-items-table tbody td { border-top:0; border-bottom:1px solid #eef1f4; border-right:1px solid #e6e9ee; overflow:hidden; background:#fff; }
.ab-items-table tbody td:first-child { position:sticky; left:0; z-index:4; background:#fff; border-left:1px solid #e6e9ee; min-width:48px; max-width:48px; }

/* Header content: title on left, icon on right */
.ab-th-wrap { display:flex; align-items:center; justify-content:flex-start; gap:8px; min-width:0; padding:0 .75rem; overflow:hidden; }
.ab-th-title { overflow:hidden; text-overflow:ellipsis; white-space:nowrap; min-width:0; display:block; }
.ab-th-filter { appearance:none; background:transparent; border:0; padding:0; color:#98a2b3; line-height:1; cursor:pointer; position:static; transform:none; margin-left:6px; flex:0 0 auto; }
.ab-th-filter:hover { color:#1f2937; }
.ab-th-filter.active { color:#1d6de6; }

/* Show sort direction arrow on active sort */
.ab-th-filter[data-sortdir="asc"]::after { content:"\25B2"; position:relative; top:-1px; margin-left:2px; font-size:10px; color:#1d6de6; }
.ab-th-filter[data-sortdir="desc"]::after { content:"\25BC"; position:relative; top:-1px; margin-left:2px; font-size:10px; color:#1d6de6; }

/* Zebra striping */
.ab-items-table tbody tr:nth-child(even) td { background:#fbfcfe; }
.ab-items-table tbody tr:nth-child(even) td:first-child { background:#fbfcfe; }
.ab-items-table tbody tr:nth-child(even) .ab-actions-cell { background:#fbfcfe; }

/* Hover and selected row states */
.ab-row-hover:hover td,
.ab-row-hover:hover td:first-child,
.ab-row-hover:hover .ab-actions-cell { background:#f3f6fb !important; }

/* Selected row */
.ab-row-selected, .ab-row-selected>td, .ab-row-selected>td:first-child, .ab-row-selected .ab-actions-cell { background:#E7F1FF !important; }
.ab-row-selected input[type="checkbox"]{ accent-color:#1d6de6; }

/* Measurement span used by autosize logic */
.ab-measure { position:absolute; left:-99999px; top:-99999px; visibility:hidden; white-space:nowrap; }

/* Boolean readonly checkbox visuals */
.ab-checkbox{ display:inline-flex; align-items:center; gap:0; }
.ab-checkbox input[type="checkbox"]{ width:14px; height:14px; accent-color:#2563eb; }
.ab-checkbox span{ color:#6b7280; }

/* Filter popup */
.ab-filter-pop { position:absolute; z-index:1050; background:#fff; border:1px solid #e5e7eb; border-radius:8px; box-shadow:0 8px 28px rgba(0,0,0,.12); width:300px; padding:10px; }
.ab-filter-actions { display:flex; justify-content:space-between; gap:6px; margin-top:8px; }
.ab-filter-actions .btn { flex:1 1 0; }

/* Export dropdown */
.ab-export-dropdown { position: relative; display: inline-block; }
.ab-export-dropdown-menu { 
  display: none; 
  position: fixed;
  left: auto;
  right: auto;
  top: auto;
  margin-top: 0.25rem; 
  background: white; 
  border: 1px solid #e5e7eb; 
  border-radius: 0.375rem; 
  box-shadow: 0 10px 25px -5px rgba(0,0,0,0.2), 0 8px 10px -6px rgba(0,0,0,0.1); 
  z-index: 10000 !important;
  min-width: 160px;
  white-space: nowrap;
}
.ab-export-dropdown-menu.show { display: block; }
.ab-export-dropdown-menu button { 
  display: block; 
  width: 100%; 
  text-align: left; 
  padding: 0.5rem 1rem; 
  border: none; 
  background: white; 
  cursor: pointer; 
  font-size: 0.875rem; 
  transition: background-color 0.15s;
  white-space: nowrap;
}
.ab-export-dropdown-menu button:hover { background-color: #f3f4f6; }
.ab-export-dropdown-menu button:first-child { border-radius: 0.375rem 0.375rem 0 0; }
.ab-export-dropdown-menu button:last-child { border-radius: 0 0 0.375rem 0.375rem; }
.ab-export-dropdown-menu button i { margin-right: 0.5rem; width: 16px; text-align: center; }

/* Responsive Pagination - matching History page style */
body:has(#ab-items-shell) .ab-pager { 
  border-top: 1px solid #eaecf0;
  background: #ffffff;
  flex-shrink: 0 !important;
  flex-grow: 0 !important;
  z-index: 200;
  position: fixed;
  left: var(--ab-main-left, 0);
  right: var(--ab-main-right, 0);
  bottom: 0;
  width: auto;
  height: 76px;
  min-height: 76px;
  max-height: 76px;
  display: flex !important;
  align-items: center;
  justify-content: space-between;
  flex-wrap: nowrap;
  padding: 1rem 2.5rem;
  overflow: visible;
  gap: 1rem;
  box-shadow: 0 -1px 3px 0 rgba(0, 0, 0, 0.05);
}

body:has(#ab-items-shell) .ab-page-info {
  flex: 0 0 auto;
  font-size: 0.875rem;
  color: #667085;
  white-space: nowrap;
  font-weight: 400;
}

body:has(#ab-items-shell) .ab-page-nav {
  flex: 0 1 auto;
  min-width: 0;
  display: inline-flex;
  gap: 0;
  justify-content: center;
  margin: 0 auto;
  overflow: visible;
  flex-wrap: wrap;
}

body:has(#ab-items-shell) .ab-page-tools {
  flex: 0 1 auto;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  white-space: nowrap;
  overflow: visible;
  flex-wrap: wrap;
}

body:has(#ab-items-shell) .ab-pager .btn {
  border: 1px solid #d0d5dd;
  color: #344054;
  background: #ffffff;
  min-width: 38px;
  height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.875rem;
  padding: 0 12px;
  border-radius: 0;
  margin: 0;
  transition: all 0.15s;
  font-weight: 500;
}

/* Use first/last child inside the nav group to handle mixed <a>/<span> buttons */
body:has(#ab-items-shell) .ab-page-nav .btn:first-child {
  border-radius: 8px 0 0 8px;
}

body:has(#ab-items-shell) .ab-page-nav .btn:last-child {
  border-radius: 0 8px 8px 0;
}

/* Avoid double borders between adjacent pager buttons */
body:has(#ab-items-shell) .ab-page-nav .btn + .btn {
  margin-left: -1px;
}

/* Make non-current pager buttons more prominent */
body:has(#ab-items-shell) .ab-page-nav .btn:not(.btn-current):not(.disabled):not(:disabled) {
  color: #344054;
  border-color: #d0d5dd;
  background: #ffffff;
}

body:has(#ab-items-shell) .ab-page-nav .btn:not(.btn-current):not(.disabled):not(:disabled):hover {
  background: #f9fafb;
  border-color: #d0d5dd;
  color: #101828;
}

body:has(#ab-items-shell) .ab-page-nav .btn:not(.btn-current):not(.disabled):not(:disabled):focus {
  outline: none;
  box-shadow: 0 0 0 4px rgba(21, 112, 239, 0.12);
  border-color: #1570ef;
}

body:has(#ab-items-shell) .ab-pager .btn.disabled,
body:has(#ab-items-shell) .ab-pager .btn:disabled,
body:has(#ab-items-shell) .ab-pager .btn[aria-disabled="true"] {
  opacity: 0.4;
  cursor: not-allowed;
  background: #ffffff;
  color: #98a2b3;
}

body:has(#ab-items-shell) .ab-pager .btn-current,
body:has(#ab-items-shell) .ab-page-nav .btn.btn-current,
body:has(#ab-items-shell) .ab-page-nav .btn.btn-current:hover,
body:has(#ab-items-shell) .ab-page-nav .btn.btn-current:focus {
  background: #1570ef;
  color: #ffffff;
  border-color: #1570ef;
  font-weight: 600;
}

body:has(#ab-items-shell) .ab-pager .form-select {
  width: auto;
  min-width: 120px;
  height: 38px;
  font-size: 0.875rem;
  padding: 0.5rem 2.5rem 0.5rem 0.875rem;
  border: 1px solid #d0d5dd;
  border-radius: 8px;
  background-color: #ffffff;
  transition: border-color 0.15s;
  font-weight: 400;
  color: #344054;
}

body:has(#ab-items-shell) .ab-pager .form-select:hover {
  border-color: #98a2b3;
}

body:has(#ab-items-shell) .ab-pager .form-select:focus {
  border-color: #1570ef;
  outline: none;
  box-shadow: 0 0 0 4px rgba(21, 112, 239, 0.12);
}

body:has(#ab-items-shell) .ab-pager .input-group {
  min-width: 160px !important;
  flex: 0 1 auto;
  white-space: nowrap;
}

body:has(#ab-items-shell) .ab-pager .input-group-text {
  font-size: 0.875rem;
  background: #ffffff;
  border: 1px solid #d0d5dd;
  color: #344054;
  padding: 0.5rem 0.875rem;
  border-radius: 8px 0 0 8px;
  font-weight: 400;
}

body:has(#ab-items-shell) .ab-pager .form-control {
  height: 38px;
  font-size: 0.875rem;
  border: 1px solid #d0d5dd;
  padding: 0.5rem 0.875rem;
  border-radius: 0 8px 8px 0;
  transition: border-color 0.15s;
  color: #344054;
}

body:has(#ab-items-shell) .ab-pager .form-control:focus {
  border-color: #1570ef;
  outline: none;
  box-shadow: 0 0 0 4px rgba(21, 112, 239, 0.12);
}

body:has(#ab-items-shell) .ab-pager .btn-ellipsis {
  pointer-events: none;
  color: #98a2b3;
  border-color: #d0d5dd;
  background: #ffffff;
}

/* On smaller screens adjust layout */
@media (max-width: 1200px) {
  body:has(#ab-items-shell) .ab-pager {
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.75rem;
    height: auto;
    min-height: 100px;
    max-height: none;
    padding: 0.75rem 2rem;
  }
  
  body:has(#ab-items-shell) .ab-page-info {
    order: 1;
    width: 100%;
    text-align: center;
  }
  body:has(#ab-items-shell) .ab-page-nav {
    order: 2;
    flex: 0 1 auto;
    max-width: 100%;
    row-gap: 4px;
  }
  body:has(#ab-items-shell) .ab-page-tools {
    order: 3;
    justify-content: center;
    width: 100%;
  }
}

/* Medium screens/high zoom */
@media (max-width: 900px) {
  body:has(#ab-items-shell) .ab-pager {
    height: auto;
    min-height: 110px;
    padding: 0.75rem 1.5rem;
  }
  
  body:has(#ab-items-shell) .ab-pager .btn {
    min-width: 34px;
    height: 34px;
    font-size: 0.8125rem;
  }
  body:has(#ab-items-shell) .ab-pager .form-select {
    min-width: 110px;
    height: 34px;
    font-size: 0.8125rem;
  }
  body:has(#ab-items-shell) .ab-pager .form-control {
    height: 34px;
    font-size: 0.8125rem;
  }
  body:has(#ab-items-shell) .ab-pager .input-group-text {
    padding: 0.4rem 0.65rem;
    font-size: 0.8125rem;
  }
}

@media (max-width: 640px) {
  body:has(#ab-items-shell) .ab-pager {
    padding: 0.75rem 1rem;
    height: auto;
    min-height: 120px;
  }
}

/* Sticky actions column on the right - OPTIMIZED WIDTH FOR "Actions" TEXT */
.ab-actions-head { 
  position:sticky; 
  right:0; 
  top:0; 
  z-index:17; 
  background:#f5f7fa; 
  border-left:1px solid #dde3ea; 
  min-width:70px; 
  width:70px; 
  box-shadow: -1px 0 0 #e5e7eb inset;
  padding: .5rem .3rem;
  text-align: center;
}

.ab-actions-cell { 
  position:sticky; 
  right:0; 
  z-index:7; 
  background:#fff; 
  border-left:1px solid #e6e9ee; 
  min-width:70px; 
  width:70px; 
  padding:.4rem .2rem;
  text-align: center;
}

/* Prevent resizer overlay for fixed Actions column */
.ab-actions-head .ab-col-resizer { display:none; }

/* Actions cell button adjustments for narrower column */
.ab-actions-cell .btn { 
  padding:.35rem .45rem; 
  font-size:.75rem;
  white-space: nowrap;
}
.ab-actions-cell .bi { font-size:.9rem; }

/* Mobile Actions column - proportional reductions */
@media (max-width: 768px) {
  .ab-actions-head { min-width:60px; width:60px; padding: .4rem .2rem; }
  .ab-actions-cell { min-width:60px; width:60px; padding:.35rem .15rem; }
  .ab-actions-cell .btn { padding:.3rem .35rem; font-size:.7rem; }
  .ab-actions-cell .bi { font-size:.85rem; }
}

@media (max-width: 480px) {
  .ab-actions-head { min-width:55px; width:55px; padding: .35rem .15rem; }
  .ab-actions-cell { min-width:55px; width:55px; padding:.3rem .1rem; }
  .ab-actions-cell .btn { padding:.25rem .3rem; font-size:.65rem; }
  .ab-actions-cell .bi { font-size:.8rem; }
}

/* Responsive improvements for different screen sizes */
@media (max-width: 1440px) {
  .ab-items-table thead th { min-width: 100px; }
  
  /* Adjust barcode input width */
  #ab-scan-barcode {
    width: 160px;
    max-width: 160px;
  }
  
  /* Improved header layout to prevent wrapping */
  .ab-items-header {
    gap: 6px;
    padding: 0.65rem 0.9rem;
  }
  
  .ab-header-left {
    gap: 6px;
  }
  
  .ab-header-right {
    gap: 6px;
  }
  
  /* Slightly smaller buttons to prevent wrapping */
  .ab-items-header .ab-header-btn,
  .ab-items-header .btn.ab-header-btn,
  .ab-items-header button.ab-header-btn {
    padding: 0.45rem 0.7rem !important;
    font-size: 0.875rem !important;
  }
  
  /* Match selected pill height to buttons */
  #ab-selected-pill {
    min-height: 38px;
    height: 38px;
    padding: 0.45rem 0.7rem;
    font-size: 0.875rem;
  }
  
  #ab-selected-pill i {
    font-size: 0.9rem;
  }
}

@media (max-width: 1200px) {
  .ab-items-table thead th { min-width: 90px; }
  .ab-th-wrap { padding: 0 .5rem; }
  .ab-items-table th, .ab-items-table td { padding: .45rem .6rem; }
  
  /* Adjust barcode input width */
  #ab-scan-barcode {
    width: 140px;
    max-width: 140px;
    font-size: 0.8rem;
  }
  
  /* More compact buttons to prevent wrapping */
  .ab-items-header .ab-header-btn,
  .ab-items-header .btn.ab-header-btn,
  .ab-items-header button.ab-header-btn {
    padding: 0.4rem 0.6rem !important;
    font-size: 0.8rem !important;
    min-height: 36px !important;
    height: 36px !important;
  }
  
  /* Match selected pill height to buttons */
  #ab-selected-pill {
    min-height: 36px;
    height: 36px;
    padding: 0.4rem 0.6rem;
    font-size: 0.8rem;
  }
  
  #ab-selected-pill i {
    font-size: 0.85rem;
  }
  
  /* Ensure header stays single row */
  .ab-items-header {
    gap: 5px;
    padding: 0.6rem 0.75rem;
  }
  
  .ab-header-left {
    gap: 5px;
  }
  
  .ab-header-right {
    gap: 5px;
  }
}

/* Medium screens - tablet range improvements */
@media (max-width: 900px) {
  /* Unified button sizing for tablet with high specificity */
  .ab-items-header .ab-header-btn,
  .ab-items-header .btn.ab-header-btn,
  .ab-items-header button.ab-header-btn {
    padding: 0.35rem 0.5rem !important;
    font-size: 0.75rem !important;
    min-height: 34px !important; 
    height: 34px !important; /* Force consistent height for all buttons */
  }
  
  /* Match selected pill height to buttons */
  #ab-selected-pill {
    min-height: 34px;
    height: 34px;
    padding: 0.35rem 0.5rem;
    font-size: 0.75rem;
  }
  
  #ab-selected-pill i {
    font-size: 0.8rem;
  }
  
  /* Compact header layout */
  .ab-items-header {
    padding: 0.5rem 0.7rem;
    gap: 5px;
  }
  
  .ab-header-left {
    gap: 5px;
  }
  
  .ab-header-right {
    gap: 5px;
  }
  
  /* Adjust barcode input for tablet */
  #ab-scan-barcode {
    width: 120px;
    max-width: 120px;
    font-size: 0.75rem;
    height: 34px;
    padding: 0.4rem 0.6rem;
  }
}

/* Critical range: 767px to 480px - IMPROVED LAYOUT */
@media (max-width: 767px) and (min-width: 481px) {
  /* Table adjustments */
  .ab-items-table thead th { min-width: 70px; }
  .ab-items-table th, .ab-items-table td { padding: .4rem .45rem; font-size: .85rem; }
  .ab-th-wrap { padding: 0 .3rem; }
  
  /* Header improvements */
  .ab-items-header {
    padding: 0.6rem 0.75rem;
    gap: 6px;
  }
  
  .ab-items-header h5 {
    font-size: 0.95rem;
  }
  
  /* Left side: make barcode and filter button smaller */
  .ab-header-left {
    gap: 6px;
  }
  
  #ab-scan-barcode {
    width: 110px;
    font-size: 0.75rem;
    height: 32px;
    padding: 0.35rem 0.5rem;
  }
  
  /* Right side: smaller gap */
  .ab-header-right {
    gap: 6px;
  }
  
  /* Selected pill smaller - MATCH BUTTON HEIGHT */
  #ab-selected-pill {
    font-size: 0.7rem;
    padding: 0.35rem 0.5rem;
    min-height: 32px;
    height: 32px;
  }
  
  #ab-selected-pill i {
    font-size: 0.75rem;
  }
  
  /* All buttons smaller */
  .ab-items-header .ab-header-btn,
  .ab-items-header .btn.ab-header-btn,
  .ab-items-header button.ab-header-btn {
    padding: 0.3rem 0.5rem !important;
    font-size: 0.75rem !important;
    min-height: 32px !important; 
    height: 32px !important;
  }
  
  #ab-export-selected-btn .bi-download {
    margin-right: 0.2rem;
    font-size: 0.8rem;
  }
  
  /* Filter badge smaller */
  .ab-filter-badge {
    font-size: 0.75rem;
    padding: 0.3rem 0.5rem;
    gap: 0.3rem;
  }
  
  .ab-filter-badge i {
    font-size: 0.75rem;
  }
  
  /* Pagination fixes */
  body:has(#ab-items-shell) .ab-pager {
    padding: 0.5rem 0.75rem;
  }
  
  body:has(#ab-items-shell) .ab-pager .form-select {
    min-width: 70px;
    padding: 0.3rem 2rem 0.3rem 0.5rem;
    font-size: 0.8rem;
  }
  
  body:has(#ab-items-shell) .ab-pager .ab-page-tools {
    gap: 0.5rem;
  }
  
  body:has(#ab-items-shell) .ab-pager .input-group {
    min-width: 120px;
  }
  
  body:has(#ab-items-shell) #ab-go-to {
    width: 60px;
    font-size: 0.8rem;
  }
  
  body:has(#ab-items-shell) .ab-pager .btn {
    padding: 0.25rem 0.4rem;
    font-size: 0.75rem;
  }
}

/* Mobile-first responsive pagination */
@media (max-width: 768px) {
  .ab-items-table thead th { min-width: 65px; }
  .ab-items-table th, .ab-items-table td { padding: .35rem .35rem; font-size: .8rem; }
  .ab-th-wrap { padding: 0 .25rem; }
  
  /* Mobile header adjustments - stack everything */
  .ab-items-header {
    flex-direction: column;
    align-items: stretch;
    gap: 0.6rem;
    padding: 0.6rem;
  }
  
  .ab-items-header h5 {
    order: 1;
    font-size: 0.95rem;
  }
  
  /* Left side: barcode + filter button - second row */
  .ab-header-left {
    order: 2;
    width: 100%;
    gap: 0.5rem;
  }
  
  #ab-scan-barcode {
    flex: 1;
    width: auto;
    min-width: 0;
    height: 36px;
    font-size: 0.8rem;
  }
  
  #ab-filter-by-file-btn {
    flex-shrink: 0;
  }
  
  /* Right side: reset + export - third row */
  .ab-header-right {
    order: 3;
    width: 100%;
    justify-content: space-between;
    margin-left: 0 !important;
  }
  
  /* Filter badge takes full width when present */
  .ab-filter-badge {
    order: 0;
    width: 100%;
    margin-bottom: 0.4rem;
    font-size: 0.8rem;
  }
  
  /* Selected pill on mobile - full width above buttons - MATCH BUTTON HEIGHT */
  #ab-selected-pill {
    order: 1;
    width: 100%;
    justify-content: center;
    margin-bottom: 0.4rem;
    font-size: 0.75rem;
    padding: 0.45rem 0.65rem;
    min-height: 36px;
    height: 36px;
  }
  
  #ab-selected-pill i {
    font-size: 0.8rem;
  }
  
  /* Unified button sizing for mobile with high specificity */
  .ab-items-header .ab-header-btn,
  .ab-items-header .btn.ab-header-btn,
  .ab-items-header button.ab-header-btn {
    padding: 0.45rem 0.65rem !important;
    font-size: 0.75rem !important;
    min-height: 36px !important; 
    height: 36px !important;
  }
  
  /* Adjust button widths on mobile */
  #ab-filter-by-file-btn {
    flex: 0 0 auto;
    min-width: 70px;
  }
  
  #ab-clear-filters {
    flex: 1;
    max-width: 48%;
  }
  
  #ab-export-selected-btn {
    flex: 1;
    max-width: 48%;
  }
  
  /* Mobile pagination layout */
  body:has(#ab-items-shell) .ab-pager {
    flex-direction: column;
    gap: 0.5rem;
    padding: 0.6rem;
  }
  
  body:has(#ab-items-shell) .ab-pager .ab-page-info {
    order: 1;
    text-align: center;
    font-size: 0.7rem;
  }
  
  body:has(#ab-items-shell) .ab-pager .ab-page-nav {
    order: 2;
    justify-self: center;
  }
  
  body:has(#ab-items-shell) .ab-pager .ab-page-nav .btn {
    padding: 0.2rem 0.4rem;
    font-size: 0.7rem;
  }
  
  body:has(#ab-items-shell) .ab-pager .ab-page-tools {
    order: 3;
    justify-content: center;
    flex-wrap: wrap;
    gap: 0.6rem;
    width: 100%;
  }
  
  body:has(#ab-items-shell) .ab-pager .ab-page-tools .input-group {
    min-width: 120px;
    font-size: 0.75rem;
    flex: 1;
  }
  
  body:has(#ab-items-shell) .ab-pager .ab-page-tools .form-select {
    font-size: 0.75rem;
    padding: 0.35rem 2rem 0.35rem 0.5rem;
    min-width: 65px;
  }
}

@media (max-width: 480px) {
  /* Extra small screens - more compact */
  .ab-items-table thead th { min-width: 60px; }
  .ab-items-table th, .ab-items-table td { padding: .3rem .3rem; font-size: .75rem; }
  
  /* Selected pill smaller on very small screens - MATCH BUTTON HEIGHT */
  #ab-selected-pill {
    font-size: 0.7rem;
    padding: 0.35rem 0.5rem;
    min-height: 32px;
    height: 32px;
  }
  
  #ab-selected-pill i {
    font-size: 0.75rem;
  }
  
  /* Extra small pagination */
  body:has(#ab-items-shell) .ab-pager {
    padding: 0.5rem;
  }
  
  body:has(#ab-items-shell) .ab-pager .ab-page-nav .btn {
    padding: 0.15rem 0.3rem;
    font-size: 0.65rem;
  }
  
  /* Hide page numbers on very small screens, keep only prev/next */
  body:has(#ab-items-shell) .ab-pager .ab-page-nav .btn:not(:first-child):not(:nth-child(2)):not(:nth-last-child(2)):not(:last-child) {
    display: none;
  }
  
  body:has(#ab-items-shell) .ab-pager .ab-page-tools {
    width: 100%;
    flex-direction: column;
    gap: 0.5rem;
  }
  
  body:has(#ab-items-shell) .ab-pager .ab-page-tools .input-group {
    flex: 1;
    min-width: auto;
  }
  
  body:has(#ab-items-shell) .ab-pager .ab-page-tools .form-select {
    padding: 0.3rem 1.8rem 0.3rem 0.4rem;
    min-width: 60px;
    font-size: 0.7rem;
  }
  
  /* Ultra-compact header for very small screens */
  .ab-items-header {
    padding: 0.5rem;
  }
  
  .ab-items-header h5 {
    font-size: 0.9rem;
  }
  
  /* Unified button sizing for extra small screens with high specificity */
  .ab-items-header .ab-header-btn,
  .ab-items-header .btn.ab-header-btn,
  .ab-items-header button.ab-header-btn {
    padding: 0.35rem 0.5rem !important;
    font-size: 0.7rem !important;
    min-height: 32px !important; 
    height: 32px !important;
  }
  
  /* Full width buttons on very small screens */
  #ab-clear-filters,
  #ab-export-selected-btn {
    max-width: 100% !important;
  }
  
  /* Barcode input adjustments */
  #ab-scan-barcode {
    height: 32px;
    font-size: 0.75rem;
  }
  
  /* Stack barcode and filter button vertically on very small screens */
  .ab-header-left {
    flex-direction: column;
    gap: 0.4rem;
  }
  
  #ab-filter-by-file-btn {
    width: 100%;
  }
  
  /* Filter badge even smaller */
  .ab-filter-badge {
    font-size: 0.7rem;
    padding: 0.25rem 0.4rem;
  }
}
