html {
  scrollbar-gutter: stable;
}

.necs-clear-btn {
  display: none;
  position: relative;
  z-index: 5;
  flex-shrink: 0;
}

#catalogTabs {
  list-style-type: none !important;
}

#filters {
  width: 260px;
  min-width: 240px;
  flex-shrink: 0;
}

#necs-catalog {
  flex: 1;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  align-content: start;
  gap: 1rem;
  width: 100%;
  padding-right: .3rem;
}

#necs-catalog > .table-responsive {
  grid-column: 1 / -1;
}

#ShowFiltersSmall {
  display: none;
}

#necs-main {
  display: flex;
  flex-direction: row;
}

/* override if theme restricts width */
#necs-catalog-full-width {
  width: 95vw !important;
  max-width: 95vw !important;
  margin-left: calc(-0.5 * (95vw - 100%));
  margin-right: calc(-0.5 * (95vw - 100%));
  box-sizing: border-box;
}

#necs-no-results {
    display: none;
  }

.necs-catalog-layout {
  display: flex;
  align-items: flex-start;
  flex-wrap: nowrap;
  width: 100%;
  max-width: 100%;
}

.label-over-border {
  position: relative;
  display: block;
}

.label-over-border label {
  position: absolute;
  top: -1rem;
  left: 0.75rem;
  padding: 0 !important;
  background: var(--bs-body-bg, #fff);
  pointer-events: none;
  height: 18px !important;
  font-size: 0.8rem !important;
}

.card-img-top {
  height: 220px;
  object-fit: contain;
  padding: 10px;
}

.vertical-btn {
  height: 550px;
  writing-mode: vertical-rl;
  transform: rotate(180deg);
}

.necs-catalog-card {
  min-width: 220px;
  max-width: 400px;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

#brandSearch.is-invalid,
#classSearch.is-invalid {
  background-image: none;
}

.position-relative:has(.is-invalid) + .invalid-feedback {
  display: block;
}

.necs-catalog-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 0.25rem 0.5rem rgba(0, 0, 0, 0.1);
}

.necs-catalog-brand-img,
.necs-catalog-class-img {
  max-height: 130px;
  object-fit: contain;
}

.necs-catalog-item-img-container {
  min-height: 120px;
}

.necs-catalog-item-img {
  max-height: 140px;
  object-fit: contain;
}

.necs-table-img {
  max-height: 40px;
  object-fit: contain;
}

.necs-group-divider {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin: 0.5rem 0 0.25rem;
  font-size: 0.85rem;
}

.necs-group-divider::before,
.necs-group-divider::after {
  content: '';
  flex: 1;
  border-top: 1px solid #dee2e6;
}

/* --- RESPONSIVE STYLES --- */
@media (max-width: 1200px) {
  #ShowFiltersSmall {
    display: none;
  }

  #necs-main {
    display: flex;
    flex-direction: row;
  }
}

@media (max-width: 992px) {
  #filters {
    width: 100% !important;
    min-width: 100% !important;
  }

  #showFilters {
    display: none;
  }

  #ShowFiltersSmall {
    display: block;
  }

  #necs-catalog {
    order: 2;
    width: 100%;
  }

  #necs-main {
    display: flex;
    flex-direction: column;
  }

  .necs-catalog-layout {
    flex-direction: column;
    align-items: stretch;
    flex-wrap: wrap;
  }

  .label-over-border label {
    font-size: 0.75rem !important;
  }

  .nav-tabs .nav-link {
    font-size: 1rem !important;
  }
}

@media (max-width: 576px) {

  #showFilters {
    display: none;
  }

  #ShowFiltersSmall {
    display: block;
  }

  #necs-main {
    display: flex;
    flex-direction: column;
  }

  /* Single full-width column: cards fill the width instead of being
     capped at max-width and stuck to the left. min-width:0 prevents
     horizontal overflow on very narrow phones. */
  #necs-catalog {
    grid-template-columns: 1fr;
  }

  .necs-catalog-card {
    max-width: none;
    min-width: 0;
  }

  .label-over-border label {
    font-size: 0.7rem !important;
  }

}

#mobileTabDropdown {
  order: -1;
  margin: 0.5rem;
}

@media (max-width: 767.98px) {
  nav .d-flex.justify-content-between {
    flex-direction: column;
    align-items: stretch !important;
  }
  
  #mobileTabDropdown {
    width: 100%;
    margin: 0 0 0.5rem 0;
  }
  
  #mobileTabDropdown .dropdown-toggle {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
  }
  
  #mobileTabDropdown .dropdown-toggle::after {
    margin-left: auto;
  }
  
  nav .d-flex.align-items-center.flex-wrap.gap-3 {
    order: 1;
    justify-content: space-between;
    width: 100%;
  }
}

#necs-catalog .table-responsive {
  display: block;
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

#necs-catalog .table-responsive table {
  min-width: 700px;
}

@media (max-width: 768px) {
  #necs-catalog .table-responsive {
    margin: 0 -12px;
    padding: 0 12px;
    width: calc(100% + 24px);
  }
}
/* --- END RESPONSIVE STYLES --- */

/* --- STICKY HEADER --- */

/* When sticky is DISABLED - explicitly override any theme sticky styles */
.necs-catalog-wrapper:not(.necs-sticky-enabled) > nav {
  position: static !important;
  top: auto !important;
}

.necs-catalog-wrapper:not(.necs-sticky-enabled) #filters > div,
.necs-catalog-wrapper:not(.necs-sticky-enabled) #showFilters,
.necs-catalog-wrapper:not(.necs-sticky-enabled) .table-responsive thead th {
  position: static !important;
  top: auto !important;
}

@media (min-width: 992px) {
  .necs-sticky-enabled > nav {
    position: -webkit-sticky !important;
    position: sticky !important;
    top: 32px !important; 
    z-index: 100 !important;
    background-color: #fff !important;
  }

  body:not(.admin-bar) .necs-sticky-enabled > nav {
    top: 0 !important;
  }

  .necs-catalog-wrapper.necs-sticky-enabled #filters > div {
    position: -webkit-sticky !important;
    position: sticky !important;
    top: 130px !important; 
  }

  body:not(.admin-bar) .necs-catalog-wrapper.necs-sticky-enabled #filters > div {
    top: 80px !important; 
  }

  .necs-catalog-wrapper.necs-sticky-enabled #showFilters {
    position: -webkit-sticky !important;
    position: sticky !important;
    top: 130px !important;
    align-self: flex-start !important;
  }

  body:not(.admin-bar) .necs-catalog-wrapper.necs-sticky-enabled #showFilters {
    top: 80px !important;
  }

  .necs-sticky-enabled .table-responsive {
    overflow-x: visible !important;
    overflow-y: visible !important;
  }

  .necs-sticky-enabled #necs-catalog {
    overflow: visible !important;
  }

  .necs-sticky-enabled #necs-main > main {
    overflow: visible !important;
  }

  .necs-catalog-wrapper.necs-sticky-enabled .table-responsive thead th {
    position: -webkit-sticky !important;
    position: sticky !important;
    top: 113px !important;
    background-color: #f8f9fa !important;
  }

  body:not(.admin-bar) .necs-catalog-wrapper.necs-sticky-enabled .table-responsive thead th {
    top: 68px !important;
  }
}

/* --- END STICKY HEADER --- */
/* Ensure modal displays above backdrop when theme has older Bootstrap */
#itemDetailsModal {
  z-index: 1060 !important;
}

#itemDetailsModal .modal-dialog {
  z-index: 1061 !important;
  pointer-events: auto;
}

#itemDetailsModal .modal-content {
  z-index: 1062 !important;
  pointer-events: auto;
}

.modal-backdrop {
  z-index: 1055 !important;
}

#itemDetailsModal.show {
  display: block !important;
  opacity: 1 !important;
  visibility: visible !important;
}

#itemDetailsModal.show .modal-dialog {
  transform: none !important;
  opacity: 1 !important;
}
/* --- END MODAL FIX --- */


body.modal-open {
  padding-right: 0 !important;
}

#itemDetailsModal.show::before {
	content: "";
	position: fixed;
	inset: 0;
	background: rgba(0, 0, 0, 0.6);
	z-index: -1;
}

body.necs-modal-open .modal-backdrop {
	display: none !important;
}