body {
  font-family: 'Inter', 'Segoe UI', Arial, sans-serif;
  background: #f5f7fa;
  color: #222;
  margin: 0;
  padding-top: 85px; /* matches navbar height */
}

.search-container {
  max-width: 1800px;
  margin: 0 auto;
  padding: 10px 20px;
}

.search-form {
  margin-bottom: 0em;
}

.search-input-group {
  display: flex;
  flex-direction: column;
  gap: 15px;
}

.search-flex-container {
  display: flex;
  flex-direction: row;
  align-items: flex-start;
  gap: 1em;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  overflow-x: hidden;
  padding: 1.5rem 1vw 1vw 1vw;
  min-width: 0;
}

.search-sidebar {
  min-width: 220px;
  max-width: 260px;
  margin-top: 0;
  box-sizing: border-box;
  padding: 1em 1em 1em 1em;
  background: #fff;
  border-radius: 0;
  box-shadow: 0 2px 12px rgba(0,0,0,0.06);
  border: 1px solid #e3e6ea;
  display: flex;
  flex-direction: column;
  gap: 1.2em;
  min-width: 0 !important;
  width: 100% !important;
}

.search-main {
  flex: 1;
  margin-top: 0;
  min-width: 0;
  box-sizing: border-box;
}

.dropdown-group {
  display: flex;
  flex-direction: column;
  gap: 0.5em;
  align-items: stretch;
}

.dropdown-field {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  min-width: 150px !important;
  margin-bottom: 0.5em;
  min-width: 0 !important;
  width: 100% !important;
  max-width: 100% !important;
  box-sizing: border-box;
}

.dropdown-field label {
  margin-bottom: 0.25em;
  font-size: 1em;
  font-weight: 500;
  color: #444;
  font-weight: 600;
}

/* Styles for standard, non-TomSelect dropdowns */
.standard-dropdown {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  background-color: #f8fafc;
  background-image: none;
  padding-right: 10px;
  border: 1px solid #d1d5db;
  border-radius: 4px !important;
  font-size: 1em;
  color: #222;
  
  width: 100%; 
  max-width: 240px; 
  box-sizing: border-box;
  min-width: 0 !important;
  width: 100% !important;
  max-width: 100% !important;

  transition: border-color 0.2s, box-shadow 0.2s;
  box-shadow: 0 1px 2px rgba(0,0,0,0.03);
}

.standard-dropdown:focus {
  border-color: #90caf9;
  outline: none;
  box-shadow: 0 0 0 2px #e3f2fd;
}

.standard-dropdown.has-selection {
  background-color: #e3f2fd;
  border-color: #2196f3;
}

/* TomSelect specific overrides to match standard-dropdown look and width */
.ts-wrapper.single { /* Constrain the wrapper */
  width: 100%;
  max-width: 240px;
  box-sizing: border-box;
  border-radius: 4px !important; /* Apply radius to wrapper itself */
  min-width: 0 !important;
  width: 100% !important;
  max-width: 100% !important;
}

.ts-wrapper.single .ts-control,
.ts-wrapper.single .ts-control input {
  font-size: 1rem !important; /* Match standard dropdown font size (~16px) */
}

/* TomSelect focus state (when dropdown is open or control is focused) */
.ts-wrapper.single.input-active .ts-control,
.ts-wrapper.single.focus .ts-control { /* .focus is a class TomSelect adds */
  border-color: #90caf9; /* Match standard-dropdown:focus */
  /* Match standard-dropdown:focus shadow, combined with base shadow */
  box-shadow: 0 0 0 2px #e3f2fd, 0 1px 2px rgba(0,0,0,0.03);
}

/* TomSelect selected state (when an item is chosen) */
.ts-wrapper.single.has-items .ts-control { /* .has-items is a class TomSelect adds to the wrapper */
  background-color: #e3f2fd !important;
  border-color: #2196f3 !important;
}

/* Style Tom-Select placeholder to match standard dropdown text */
.ts-wrapper.single:not(.has-items) .ts-control {
  font-size: 1em; /* Match standard-dropdown */
  color: #222;     /* Match standard-dropdown */
}

/* Aggressively hide original select elements controlled by TomSelect */
select[data-controller="tom-select"] {
  opacity: 0 !important;          /* Hide visually */
  width: 0 !important;           /* Collapse width */
  height: 0 !important;          /* Collapse height */
  position: absolute !important; /* Remove from normal flow but keep in DOM */
  left: -10000px !important;     /* Off-screen */
  pointer-events: none !important; /* Prevent focus */
}

.visually-hidden {
  position: absolute !important;
  height: 1px; width: 1px;
  overflow: hidden;
  clip: rect(1px, 1px, 1px, 1px);
  white-space: nowrap;
}

.ts-rendered-item,
.item-is-placeholder {
  display: inline-block;
  vertical-align: top; /* Helps align if there are slight height differences */
}

.reset-button {
  padding: 10px 20px;
  background-color: #e3e6ea;
  color: #222;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-size: 1em;
  text-decoration: none;
  transition: background-color 0.2s, color 0.2s;
  font-weight: 500;
  margin: 0em;
  box-shadow: 0 1px 2px rgba(0,0,0,0.03);
  text-align: center;
  display: block;
}

.reset-button:hover {
  background-color: #b6d4fe;
  color: #1565c0;
  text-decoration: none;
}

.search-results {
  margin-top: 0px;
}

.table-container {
  overflow-x: auto;
  width: 100%;
  box-sizing: border-box;
  background: #fff;
  border-radius: 0;
  box-shadow: 0 2px 12px rgba(0,0,0,0.06);
  border: 1px solid #e3e6ea;
  padding: 1.5em 1em 1em 1em;
}

.products-table {
  width: 100%;
  min-width: 600px;
  border-collapse: separate;
  border-spacing: 0;
  background-color: #fff;
  border-radius: 0;
  overflow: hidden;
  font-size: 0.83em;
}

.products-table th,
.products-table td {
  padding: 7px 5px;
  text-align: left;
  border-bottom: 1px solid #f0f0f0;
}

.products-table th {
  background-color: #f8f9fa;
  font-weight: 600;
  color: #333;
  border-top: 1px solid #e3e6ea;
  font-size: 1rem;
}

.products-table tr {
  transition: background 0.15s;
}

.products-table tr:nth-child(even) {
  background-color: #f6fafd;
}

.products-table tr:hover {
  background-color: #e3f2fd;
}

.no-results {
  text-align: center;
  padding: 20px;
  color: #666;
  font-style: italic;
}

.results-limit-text {
  text-align: center;
  padding: 10px;
  color: #666;
  font-size: 0.9em;
  font-style: italic;
  border-top: 1px solid #e3e6ea;
  margin-top: 10px;
}

.site-title {
  text-align: center;
  margin-bottom: 30px;
  width: 100%;
  display: block;
}

.site-title a {
  color: #333;
  text-decoration: none;
  transition: color 0.2s;
  display: inline-block;
}

.site-title a:hover {
  color: #007bff;
  text-decoration: none;
}

.navbar {
  width: 100%;
  background: #f8f9fa;
  color: #222;
  padding: 1em 1em 1em 1em;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: 0 2px 8px rgba(0,0,0,0.04);
  margin-bottom: 0.5em;
  box-sizing: border-box;
  border-bottom: 1px solid #e3e6ea;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1000;
}

.navbar-left {
  flex: 0 0 auto;
  font-size: 2rem;
  font-weight: bold;
  letter-spacing: 1px;
}

.navbar-link {
  color: #222;
  text-decoration: none;
  transition: color 0.2s;
  font-size: 2rem;
  font-weight: bold;
  display: flex;
  align-items: center;
}

.navbar-link:hover {
  color: #007bff;
}

.navbar-logo {
  height: 2em; /* roughly matches line-height of text */
  width: auto;
  margin-right: 0.4em;
  vertical-align: middle;
}

/* Desktop Navigation */
.navbar-nav-desktop {
  display: none;
  align-items: center;
  gap: 1.5em;
  flex: 1;
  justify-content: flex-end;
}

.navbar-nav-link {
  color: #222;
  text-decoration: none;
  font-size: 1.1rem;
  font-weight: 500;
  padding: 0.75em 1.5em;
  border-radius: 8px;
  transition: all 0.2s;
}

.navbar-nav-link:hover {
  background-color: #e3f2fd;
  color: #2196f3;
  text-decoration: none;
}

/* Mobile Hamburger Menu */
.mobile-menu-toggle {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  width: 2.5em;
  height: 2.5em;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.5em;
  gap: 4px;
  border-radius: 4px;
  transition: background-color 0.2s;
  flex: 0 0 auto;
}

.mobile-menu-toggle:hover {
  background-color: #e9ecef;
}

.hamburger {
  width: 20px;
  height: 3px;
  background-color: #222;
  border-radius: 1.5px;
  transition: all 0.3s;
}

/* Mobile menu overlay */
.mobile-menu-overlay {
  position: fixed;
  top: 85px; /* below navbar */
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s, visibility 0.3s;
  z-index: 999;
}

.mobile-menu-overlay.active {
  opacity: 1;
  visibility: visible;
}

.mobile-menu-content {
  background: #fff;
  border-radius: 0 0 12px 12px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  padding: 1.5em 1em;
  display: flex;
  flex-direction: column;
  gap: 0.5em;
}

.mobile-menu-link {
  color: #222;
  text-decoration: none;
  font-size: 1.1em;
  font-weight: 500;
  padding: 0.75em 1em;
  border-radius: 8px;
  transition: background-color 0.2s;
}

.mobile-menu-link:hover {
  background-color: #f8f9fa;
  text-decoration: none;
}

/* Hamburger animation when active */
.mobile-menu-toggle.active .hamburger:nth-child(1) {
  transform: rotate(45deg) translate(5px, 5px);
}

.mobile-menu-toggle.active .hamburger:nth-child(2) {
  opacity: 0;
}

.mobile-menu-toggle.active .hamburger:nth-child(3) {
  transform: rotate(-45deg) translate(7px, -6px);
}

/* Desktop media query */
@media (min-width: 768px) {
  .navbar-nav-desktop {
    display: flex;
  }
  
  .mobile-menu-toggle {
    display: none;
  }
}

/* Mobile media query */
@media (max-width: 767px) {
  .navbar-nav-desktop {
    display: none;
  }
  
  .mobile-menu-toggle {
    display: flex;
  }
}

.ammo-table-title {
  position: static;
  transform: none;
  margin-top: 0em;
  text-align: center;
  width: 100%;
  font-size: 1.5rem;
  font-weight: 600;
  color: #333;
  display: flex;
  justify-content: center;
  align-items: center;
}

.ammo-table-title-text {
  display: inline-block;
  padding: 0.5em 1em;
  background: #f8f9fa;
  border-radius: 8px;
  border: 1px solid #e3e6ea;
  text-align: center;
}

.ts-wrapper.single:not(.has-items) .ts-control input::placeholder {
  color: #222 !important;
  font-size: 1em !important;
}

/* Prevent multi-line wrap in Tom-Select single selects */
.ts-wrapper.single .ts-control {
  flex-wrap: nowrap !important;   /* keep everything on one line */
  white-space: nowrap !important; /* prevent line break */
}

/* Truncate long selected value with ellipsis */
.ts-wrapper.single .ts-control .ts-rendered-item {
  white-space: nowrap !important;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
  max-width: 100%;
}

/* Stronger override: selected Tom-Select box */
.ts-wrapper.single.has-items .ts-control {
  background: #e3f2fd !important; /* solid blue-ish */
  background-image: none !important;
  border-color: #2196f3 !important;
}

input.standard-dropdown {
  background-color: #f8fafc;
  padding: 8px 10px;        /* same vertical padding, no arrow so 10px left & right */
  width: 100%;
  max-width: 240px;
  box-sizing: border-box;
  font-size: 1em;
  border: 1px solid #d1d5db; /* ensure same border */
  border-radius: 4px !important;
  transition: border-color 0.2s, box-shadow 0.2s;
  box-shadow: 0 1px 2px rgba(0,0,0,0.03);
}

input.standard-dropdown.has-selection {
  background-color: #e3f2fd;
  border-color: #2196f3;
}

/* Restore dropdown arrow for select elements */
select.standard-dropdown {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  background-image: url('data:image/svg+xml;utf8,<svg fill="gray" height="16" viewBox="0 0 20 20" width="16" xmlns="http://www.w3.org/2000/svg"><path d="M7.293 7.293a1 1 0 011.414 0L10 8.586l1.293-1.293a1 1 0 111.414 1.414l-2 2a1 1 0 01-1.414 0l-2-2a1 1 0 010-1.414z"/></svg>');
  background-repeat: no-repeat;
  background-position: right 0.75em center;
  background-size: 1.2em 1.2em;
  padding: 8px 2.5em 8px 10px; /* leave room for arrow */
}

/* Make selects blue on focus like TomSelect */
select.standard-dropdown:focus {
  border-color: #90caf9;
  outline: none;
  box-shadow: 0 0 0 2px #e3f2fd;
}

/* Card layout for mobile results */
.card-results {
  display: flex;
  flex-direction: column;
  gap: 1.2em;
}

.result-card {
  background: #fff;
  border: 1px solid #e3e6ea;
  border-radius: 12px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
  padding: 1.2em;
  cursor: pointer;
  transition: all 0.2s ease;
}

.result-card:hover {
  box-shadow: 0 4px 12px rgba(0,0,0,0.08);
  transform: translateY(-1px);
}

.result-card-header {
  display: flex;
  flex-direction: column;
  margin-bottom: 0.8em;
}

.result-card-title {
  font-size: 1.05em;
  font-weight: 600;
  margin: 0 0 0.3em 0;
  line-height: 1.4;
  color: #2c3e50;
}

.result-card-retailer {
  font-size: 0.9em;
  color: #555;
}

.result-card-meta {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.5em 0.8em;
  font-size: 0.85em;
  margin-bottom: 0.8em;
  padding: 0.6em 0;
  border-top: 1px solid #f0f0f0;
  border-bottom: 1px solid #f0f0f0;
}

.meta-item {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: #666;
  font-weight: 400;
}

.result-card-pricing {
  display: flex;
  align-items: center;
  gap: 0.5em;
  font-size: 1em;
  margin-top: 0.2em;
}

.result-card-pricing .price {
  color: #2196f3;
  font-weight: 600;
  font-size: 1.1em;
}

.result-card-pricing .price-per-round {
  font-weight: 400;
  font-size: 1.0em;
}

.result-card-pricing .checked-time {
  margin-left: auto;
  font-size: 0.8em;
  color: #777;
}

.result-card-pricing .retailer-name {
  margin-left: auto;
  font-size: 0.8em;
  color: #777;
  display: flex;
  align-items: center;
  flex-shrink: 0;
  font-weight: 500;
}

.desktop-results {
  flex: 1; /* allow results area to fill remaining space */
  min-width: 0;
}

.mobile-results {
  flex: 1;
  width: 100%;
}

/* floating action button for mobile */
.mobile-fab {
  position: fixed;
  bottom: 20px;
  right: 20px;
  width: 56px;
  height: 56px;
  border-radius: 16px;
  background: #4caf50;
  color: #fff;
  font-size: 2rem;
  display: none; /* hidden by default */
  align-items: center;
  justify-content: center;
  text-decoration: none;
  box-shadow: 0 2px 8px rgba(0,0,0,0.3);
  z-index: 1000;
}
.mobile-fab:hover {
  background: #43a047;
}

/* Desktop layout refinements: keep filters static, make results scrollable inside container */
@media (min-width: 992px) {
  /* Ensure correct component visibility */
  .mobile-results { display: none; }
  .desktop-results { display: block; }

  /* Allow full-page scrolling */
  .search-flex-container {
    padding-top: 1.5rem; /* keeps spacing below navbar */
  }

  /* Filters sidebar remains static */
  .filters,
  .search-sidebar {
    overflow: visible !important;
    width: 240px;
    min-width: 240px;
    max-width: 240px;
    flex: 0 0 240px;
  }

  /* Results column */
  .desktop-results {
    flex: 1 1 0;
  }

  /* Make table area scroll independently while keeping header sticky */
  .desktop-results .table-container {
    max-height: calc(100vh - 85px - 2rem); /* viewport height minus navbar + margin */
    overflow-y: auto;
  }

  .desktop-results .products-table thead th {
    position: sticky;
    top: 0;
    z-index: 3;
    background-color: #f8f9fa;
  }
}

/* <992 px – mobile / tablet */
@media (max-width: 991.98px) {
  .mobile-results { display: block; }
  .desktop-results { display: none; }
  .filters { display: none; }
  .mobile-fab { display: flex; }

  /* Add spacing above the first result card */
  .card-results {
    padding-top: 0.75em; /* space above first card */
  }

  /* When filters are open */
  body.filters-active .filters {
    display: block;
  }
  body.filters-active .mobile-results {
    display: block;
  }

  /* Make filters full width on mobile */
  body .filters {
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box;
  }

  .search-flex-container {
    flex-direction: column;
    gap: 1em;
    padding: 1.25rem 1vw 1vw 1vw;
  }
  .search-sidebar {
    max-width: 100%;
    width: 100%;
    margin-bottom: 1.5em;
    border-radius: 12px;
    padding: 1em 1em 1em 1em;
  }
  .table-container {
    border-radius: 12px;
    padding: 1em 0.5em 0.5em 0.5em;
  }
  body {
    padding-top: 72px; /* slightly smaller on mobile */
  }
}

.mobile-fab svg {
  width: 24px;
  height: 24px;
}

/* Make selects full width on mobile */
.standard-dropdown,
.ts-wrapper.single {
  max-width: 100% !important;
}

/* Allow Tom-Select input to shrink in narrow sidebars */
.ts-control > input {
  min-width: 0 !important;
}

/* Ensure parent flex containers allow shrinking */
.search-flex-container,
.desktop-results {
  min-width: 0;
}

/* Star rating styles */
.star-rating, .star-rating-inline {
  display: flex;
  align-items: center;
  gap: 2px;
  font-size: 0.9em;
  margin-top: 2px;
  text-decoration: none; /* Remove underline from links */
  color: inherit; /* Keep original text color */
}

.star-rating:hover, .star-rating-inline:hover {
  text-decoration: none; /* Ensure no underline on hover */
}

.star-rating-inline {
  display: inline-flex;
  margin-left: 0.5em;
  flex-shrink: 0;
}

.star {
  color: #ccc;
  font-size: 0.9em;
  transition: color 0.2s;
}
.star.filled {
  color: #FFD700; /* gold */
}
.review-count {
  color: #888;
  font-size: 0.9em;
  margin-left: 2px;
}

/* Casing material color tags */
.casing-tag {
  display: inline-block;
  padding: 3px 7px;
  border-radius: 6px;
  font-size: 0.75em;
  font-weight: 600;
  text-align: center;
  min-width: 45px;
  border: 1px solid transparent;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.casing-brass {
  background-color: #FFD700;
  color: #8B6914;
  border-color: #DAA520;
}

.casing-steel {
  background-color: #C0C0C0;
  color: #2F4F4F;
  border-color: #A9A9A9;
}

.casing-aluminum {
  background-color: #E6E6FA;
  color: #483D8B;
  border-color: #D8BFD8;
}

.casing-nickel-plated {
  background-color: #F0F8FF;
  color: #2F4F4F;
  border-color: #B0C4DE;
}

.casing-polymer {
  background-color: #98FB98;
  color: #006400;
  border-color: #90EE90;
}

.casing-alloy {
  background-color: #FFF8DC;
  color: #8B7355;
  border-color: #F5DEB3;
}

.casing-copper {
  background-color: #FF7F50;
  color: #8B4513;
  border-color: #CD853F;
}

.casing-default {
  background-color: #F5F5F5;
  color: #696969;
  border-color: #D3D3D3;
}

/* Ensure mobile search card layout is preserved */
.mobile-results .result-card-pricing {
  display: flex !important;
  align-items: center !important;
  gap: 0.5em !important;
  font-size: 1em !important;
  margin-top: 0.2em !important;
}

.mobile-results .result-card-pricing .price {
  color: #2196f3 !important;
  font-weight: 600 !important;
  font-size: 1.1em !important;
}

.mobile-results .result-card-pricing .retailer-name {
  margin-left: auto !important;
  font-size: 0.8em !important;
  color: #777 !important;
  display: flex !important;
  align-items: center !important;
  flex-shrink: 0 !important;
  font-weight: 500 !important;
}

/* Purchase limit red circle styling */
.purchase-limit-circle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  background-color: #c82333;
  border-radius: 50%;
  color: #ffffff;
  font-size: 0.85em;
  font-weight: 600;
  text-align: center;
  line-height: 1;
}

/* Purchase limit warning text styling */
.limit-warning {
  color: #c82333 !important;
  font-weight: 600;
}

/* Free shipping styling */
.free-shipping-indicator {
  background-color: #e8f5e8;
  color: #2e7d32;
  padding: 1px 4px;
  border-radius: 3px;
  font-size: 0.8em;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

/* Mobile specific adjustments */
@media (max-width: 991.98px) {
  .free-shipping-indicator {
    font-size: 0.75em;
    padding: 1px 3px;
  }
}