/* ───────── Category Navigation ───────── */
.cat-nav {
  display: flex;
  gap: 12px;
  align-items: baseline;
  margin-bottom: 8px;
}

.cat-link {
  color: #9ca3af;
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
  font-size: 0.95rem;
}

.cat-link.active {
  color: #111827;
  font-size: 1.3rem;
}

/* ───────── Controls Layout ───────── */
.controls-wrapper {
  padding: 0 var(--gap);
  margin-bottom: 10px;
}

.controls-row {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toggles-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.sorting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.button-toggles {
  display: flex;
  align-items: center;
}

.controls {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: center;
}

/* ───────── Price Change Row Container ───────── */
.price-change-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ───────── Sorting Buttons ───────── */
.sorting-buttons {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: flex-start;
}

.btn {
  font-size: 0.70rem;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  padding: 2px 6px;
  background: #fff;
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}

.btn.active {
  background: #dbeafe;
  border-color: #60a5fa;
  color: #1d4ed8;
}

/* ───────── Display Toggles ───────── */
.toggles {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.8rem;
  flex-wrap: nowrap;
}

.toggle {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  user-select: none;
  position: relative;
}

.toggle input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.switch {
  width: 30px;
  height: 16px;
  background: #e5e7eb;
  border-radius: 9999px;
  position: relative;
  transition: background 0.2s;
  flex-shrink: 0;
}

.switch::before {
  content: "";
  position: absolute;
  left: 2px;
  top: 2px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #fff;
  transition: transform 0.2s;
}

.toggle input:checked + .switch {
  background: #4ade80;
}

.toggle input:checked + .switch::before {
  transform: translateX(14px);
}

.label {
  line-height: 16px;
  white-space: nowrap;
  font-size: 0.8rem;
}

/* ───────── Button Toggles (Price Change, Currency, and Supply) ───────── */
.price-change-toggle,
.price-change-currency-toggle,
.supply-toggle {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.8rem;
}

.price-change-toggle {
  margin-right: 0px;
}

.price-change-currency-toggle {
  margin-right: 12px;
}

.price-change-toggle-label,
.supply-toggle-label {
  white-space: nowrap;
  font-size: 0.8rem;
  line-height: 16px;
}

.price-change-buttons,
.price-change-currency-buttons,
.supply-buttons {
  display: flex;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  overflow: hidden;
  background: #fff;
}

.price-change-btn,
.price-change-currency-btn,
.supply-btn {
  padding: 3px 8px;
  font-size: 0.7rem;
  border: none;
  background: #fff;
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
  transition: background 0.2s, color 0.2s;
  border-right: 1px solid #d1d5db;
}

.price-change-currency-btn {
  padding: 3px 6px;
  min-width: 32px;
}

.price-change-btn:last-child,
.price-change-currency-btn:last-child,
.supply-btn:last-child {
  border-right: none;
}

.price-change-btn.active,
.price-change-currency-btn.active,
.supply-btn.active {
  background: #dbeafe;
  color: #1d4ed8;
}

.price-change-btn:hover:not(.active),
.price-change-currency-btn:hover:not(.active),
.supply-btn:hover:not(.active) {
  background: #f9fafb;
}

/* ───────── Search Functionality ───────── */

/* Desktop Search */
.search-wrapper {
  position: relative;
  width: 240px;
  flex-shrink: 0;
}

.search-input {
  width: 100%;
  padding: 4px 24px 4px 8px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font-size: 0.8rem;
  background: #fff;
  outline: none;
  box-sizing: border-box;
}

.search-input:focus {
  border-color: #60a5fa;
  box-shadow: 0 0 0 1px #60a5fa;
}

.search-clear {
  position: absolute;
  right: 4px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  font-size: 16px;
  color: #9ca3af;
  cursor: pointer;
  padding: 2px;
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
}

.search-clear:hover {
  color: #6b7280;
  background: #f3f4f6;
}

.search-icon {
  width: 18px;
  height: 18px;
  opacity: 0.7;
}

/* ───────── Mobile Controls ───────── */
.mobile-buttons {
  display: none;
  gap: 8px;
  margin-bottom: 12px;
}

.mobile-btn {
  flex: 1;
  padding: 12px 16px;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  background: #fff;
  cursor: pointer;
  user-select: none;
  font-size: 0.9rem;
  font-weight: 600;
}

.mobile-btn.active {
  background: #dbeafe;
  border-color: #60a5fa;
  color: #1d4ed8;
}

.mobile-search-toggle {
  width: 48px;
  height: 48px;
  padding: 8px;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  background: #fff;
  cursor: pointer;
  user-select: none;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.mobile-search-toggle.active {
  background: #dbeafe;
  border-color: #60a5fa;
}

.mobile-search-toggle.active .search-icon {
  opacity: 1;
}

.mobile-controls {
  display: none;
  padding: 12px;
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  margin-bottom: 12px;
}

/* Mobile Search */
.mobile-search {
  display: none;
  margin-bottom: 12px;
}

.mobile-search-wrapper {
  position: relative;
  display: flex;
  align-items: stretch;
  background: #fff;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  overflow: hidden;
}

.mobile-search-input {
  flex: 1;
  padding: 10px 12px;
  border: none;
  font-size: 1rem;
  background: transparent;
  outline: none;
}

.mobile-search-clear {
  background: none;
  border: none;
  font-size: 20px;
  color: #9ca3af;
  cursor: pointer;
  padding: 10px 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 40px;
}

.mobile-search-clear:hover {
  color: #6b7280;
  background: #f9fafb;
}

.mobile-search-submit {
  background: #f3f4f6;
  border: none;
  border-left: 1px solid #d1d5db;
  font-size: 18px;
  color: #6b7280;
  cursor: pointer;
  padding: 10px 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 40px;
}

.mobile-search-submit:hover {
  background: #e5e7eb;
}

/* ───────── Responsive Breakpoints ───────── */
@media (max-width: 1280px) {
  .toggles-row,
  .sorting-row {
    flex-wrap: wrap;
    gap: 8px;
  }
  
  .controls-row {
    flex-direction: column;
    gap: 8px;
  }
  
  .search-wrapper {
    align-self: flex-start;
    width: 200px;
  }
}

@media (max-width: 700px) {
  .cat-nav {
    justify-content: center;
  }
  
  .cat-link {
    font-size: 0.9rem;
  }
  
  .cat-link.active {
    font-size: 1.1rem;
  }

  .controls-row {
    display: none;
  }

  .mobile-buttons {
    display: flex;
  }

  .mobile-search {
    display: block;
    display: none; /* Hide by default */
  }

  .mobile-search.active {
    display: block;
  }

  .mobile-controls.show {
    display: block;
  }

  /* FIXED: Only apply mobile-specific styles when actually in mobile layout */
  @media (max-width: 700px) {
    .mobile-controls .controls,
    .mobile-controls .toggles {
      justify-content: flex-start;
      gap: 6px;
    }

    .mobile-controls .toggles {
      flex-direction: column;
      align-items: flex-start;
      gap: 8px;
      margin-bottom: 8px;
    }

    .mobile-controls .toggle {
      width: 100%;
    }

    .mobile-controls .label {
      flex: 1;
    }
  }

  .button-toggles-mobile {
    display: flex;
    flex-direction: column;
    gap: 8px;
  }

  /* Mobile price change row - aligned to full width like other controls */
  .button-toggles-mobile .price-change-row {
    display: flex;
    gap: 8px;
    align-items: flex-start;
    width: 100%;
  }

  .button-toggles-mobile .price-change-toggle {
    flex: 1;
    margin-right: 0;
  }

  .button-toggles-mobile .price-change-currency-toggle {
    margin-right: 0;
  }

  .supply-toggle,
  .price-change-toggle,
  .price-change-currency-toggle {
    width: 100%;
    margin-right: 0;
  }

  /* Enhanced mobile font sizes */
  .mobile-btn {
    font-size: 1.1rem;
  }

  .mobile-controls .btn {
    font-size: 0.85rem;
  }

  .mobile-controls .toggle {
    font-size: 0.95rem;
  }

  .mobile-controls .label {
    font-size: 0.95rem;
  }

  .mobile-controls .switch {
    width: 36px;
    height: 20px;
  }

  .mobile-controls .switch::before {
    width: 16px;
    height: 16px;
  }

  .mobile-controls .toggle input:checked + .switch::before {
    transform: translateX(16px);
  }

  .mobile-controls .supply-btn,
  .mobile-controls .price-change-btn,
  .mobile-controls .price-change-currency-btn {
    padding: 7px 10px;
    font-size: 0.8rem;
  }

  .mobile-controls .supply-toggle-label,
  .mobile-controls .price-change-toggle-label {
    font-size: 0.95rem;
  }

  .supply-btn,
  .price-change-btn,
  .price-change-currency-btn {
    padding: 4px 6px;
    font-size: 0.65rem;
  }
}

@media (min-width: 701px) {
  .cat-nav {
    justify-content: flex-start;
  }
}

@media (max-width: 400px) {
  .cat-link {
    font-size: 0.8rem;
  }

  .cat-link.active {
    color: #111827;
    font-size: 1rem;
  }
  .mobile-btn {
    padding: 6px 8px; 
  }
}

@media (max-width: 370px) {
  .cat-nav {
    gap: 6px;
  }

  .cat-link {
    font-size: 0.7rem;
  }

  .cat-link.active {
    font-size: 0.8rem;
  }

  .mobile-btn {
    font-size: 0.9rem;
    padding: 4px 6px;
  }

  .mobile-search-toggle {
    width: 42px;
    height: 42px;
  }

  .mobile-controls .label {
    font-size: 0.85rem;
  }

  .mobile-controls .supply-toggle-label,
  .mobile-controls .price-change-toggle-label {
    font-size: 0.85rem;
  }

  .mobile-controls .switch {
    width: 32px;
    height: 18px;
  }

  .mobile-controls .switch::before {
    width: 14px;
    height: 14px;
  }

  .mobile-controls .toggle input:checked + .switch::before {
    transform: translateX(14px);
  }

  .mobile-controls .supply-btn,
  .mobile-controls .price-change-btn,
  .mobile-controls .price-change-currency-btn {
    padding: 6px 6px;
    font-size: 0.7rem;
  }
}