/**
 * MARKETPLACE MOBILE STYLES
 * Mobile-first responsive filters and layout
 */

/* ===== MOBILE FILTER TOGGLE ===== */
.mobile-filter-toggle {
  display: none;
  width: 100%;
  min-height: 48px; /* Touch-friendly */
  padding: 14px 20px;
  background: linear-gradient(135deg, #1a2b3c 0%, #2d3e50 100%);
  border: none;
  border-radius: 10px;
  color: #fff;
  font-family: inherit;
  font-size: 16px; /* Prevents iOS zoom */
  font-weight: 600;
  cursor: pointer;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
  transition: all 0.2s ease;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.mobile-filter-toggle:hover {
  background: linear-gradient(135deg, #2d3e50 0%, #3d4e60 100%);
}

.mobile-filter-toggle svg {
  width: 20px;
  height: 20px;
  transition: transform 0.3s ease;
}

.mobile-filter-toggle[aria-expanded="true"] svg {
  transform: rotate(180deg);
}

.mobile-filter-toggle .filter-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  background: #f9cb00;
  color: #1a2b3c;
  border-radius: 11px;
  font-size: 12px;
  font-weight: 700;
  margin-left: 8px;
}

.mobile-filter-toggle .filter-count:empty {
  display: none;
}

/* ===== FILTERS CONTAINER ===== */
.filters-bar {
  transition: all 0.3s ease;
}

/* ===== RESPONSIVE BREAKPOINTS ===== */

/* Tablet */
@media (max-width: 991px) {
  .filters-inner {
    flex-wrap: wrap;
    gap: 12px;
  }

  .search-box {
    flex: 1 1 100%;
    min-width: unset;
    order: 1;
  }

  .filter-select {
    flex: 1 1 calc(50% - 6px);
    min-width: unset;
  }

  .location-btn {
    flex: 1 1 100%;
    justify-content: center;
    order: 10;
  }

  .results-info {
    flex: 1 1 100%;
    justify-content: space-between;
    margin-left: 0;
    order: 11;
  }
}

/* Mobile - Show toggle, hide filters */
@media (max-width: 768px) {
  .mobile-filter-toggle {
    display: flex;
  }

  .mobile-view-toggle {
    display: flex !important;
  }

  /* Hide the original view toggle on mobile */
  .results-info .view-toggle {
    display: none !important;
  }

  /* List view card styles for mobile */
  .slab-grid.list-view {
    gap: 16px !important;
  }

  .slab-grid.list-view .slab-card {
    display: flex;
    flex-direction: row;
    align-items: stretch;
    overflow: hidden;
  }

  .slab-grid.list-view .slab-card-image {
    width: 110px;
    min-width: 110px;
    min-height: 140px;
    height: auto;
    border-radius: 12px 0 0 12px;
    position: relative;
  }

  .slab-grid.list-view .slab-card-body {
    flex: 1;
    padding: 14px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 6px;
    min-width: 0;
  }

  .slab-grid.list-view .slab-distributor {
    font-size: 10px;
    margin-bottom: 2px;
    opacity: 0.7;
  }

  .slab-grid.list-view .slab-title {
    font-size: 15px;
    font-weight: 600;
    margin-bottom: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .slab-grid.list-view .slab-brand {
    font-size: 12px;
    opacity: 0.7;
    margin-bottom: 4px;
  }

  .slab-grid.list-view .slab-details {
    display: none;
  }

  .slab-grid.list-view .slab-price {
    font-size: 24px;
    font-weight: 800;
    margin: 6px 0;
    color: #1a1a2e;
  }

  .slab-grid.list-view .slab-price span {
    font-size: 13px;
    font-weight: 500;
  }

  .slab-grid.list-view .slab-actions {
    flex-direction: row;
    gap: 6px;
    margin-top: auto;
  }

  .slab-grid.list-view .slab-btn {
    padding: 4px 8px !important;
    font-size: 10px !important;
    min-height: 26px !important;
    flex: 1;
    justify-content: center;
  }

  .slab-grid.list-view .slab-btn.secondary {
    padding: 3px 6px !important;
    min-height: 24px !important;
    font-size: 9px !important;
  }

  .slab-grid.list-view .slab-badges {
    position: absolute;
    top: 6px;
    left: 6px;
    flex-direction: column;
    gap: 4px;
  }

  .slab-grid.list-view .slab-badge {
    font-size: 8px;
    padding: 3px 6px;
  }

  .slab-grid.list-view .slab-favorite {
    display: none;
  }

  .slab-grid.list-view .slab-trust-badges {
    display: none;
  }

  .filters-bar {
    padding: 12px 16px;
  }

  .filters-inner {
    flex-direction: column;
    gap: 0;
  }

  /* Hide filters by default on mobile */
  .filters-inner .search-box,
  .filters-inner .filter-select,
  .filters-inner .location-btn {
    display: none;
    width: 100%;
    margin-bottom: 12px;
  }

  /* Show filters when expanded */
  .filters-bar.mobile-expanded .search-box,
  .filters-bar.mobile-expanded .filter-select,
  .filters-bar.mobile-expanded .location-btn {
    display: flex;
  }

  .filters-bar.mobile-expanded .filter-select {
    flex: 1 1 100%;
  }

  /* Always show results info */
  .results-info {
    display: flex !important;
    width: 100%;
    padding-top: 12px;
    border-top: 1px solid #e5e5e5;
    margin-top: 12px;
  }

  .filters-bar:not(.mobile-expanded) .results-info {
    margin-top: 0;
    padding-top: 0;
    border-top: none;
  }

  /* Product grid - default 2 columns, but allow JS to override for list view */
  .slab-grid,
  .product-grid,
  .marketplace-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
  }

  /* Smaller cards */
  .slab-card,
  .product-card {
    border-radius: 12px;
  }

  .slab-card-image {
    min-height: 150px;
    background-size: cover;
    background-position: center;
  }

  .slab-card-body {
    padding: 12px;
  }

  .slab-title {
    font-size: 14px;
  }

  .slab-price {
    font-size: 16px;
  }

  /* Hero adjustments - reduced padding since body has padding-top from unified-nav */
  .hero {
    padding: 32px 16px 32px;
    min-height: auto;
  }

  .hero h1 {
    font-size: 1.5rem;
  }

  .hero p {
    font-size: 0.95rem;
  }

  .hero-stats {
    gap: 20px;
  }

  .hero-stat-value {
    font-size: 1.5rem;
  }
}

/* Small mobile */
@media (max-width: 480px) {
  /* Only list view gets single column - grid view keeps 2 columns */
  .slab-grid.list-view,
  .product-grid.list-view,
  .marketplace-grid.list-view {
    grid-template-columns: 1fr !important;
  }

  /* Grid view stays 2 columns on small mobile */
  .slab-grid:not(.list-view),
  .product-grid:not(.list-view),
  .marketplace-grid:not(.list-view) {
    grid-template-columns: repeat(2, 1fr) !important;
  }

  .hero-stats {
    flex-direction: column;
    gap: 12px;
  }

  .filter-select {
    font-size: 16px; /* Prevents iOS zoom */
    min-height: 44px;
    padding: 12px 36px 12px 14px;
  }

  /* Grid view cards - compact for 2-column layout */
  .slab-grid:not(.list-view) .slab-card {
    min-height: unset;
  }

  .slab-grid:not(.list-view) .slab-card-body {
    padding: 10px;
  }

  .slab-grid:not(.list-view) .slab-title {
    font-size: 12px;
    line-height: 1.3;
    margin-bottom: 4px;
  }

  .slab-grid:not(.list-view) .slab-price {
    font-size: 14px;
    margin: 4px 0;
  }

  .slab-grid:not(.list-view) .slab-details {
    display: none;
  }

  .slab-grid:not(.list-view) .slab-btn {
    min-height: 32px;
    padding: 6px 8px;
    font-size: 11px;
  }

  .slab-grid:not(.list-view) .slab-badge {
    font-size: 9px;
    padding: 2px 6px;
  }

  .slab-grid:not(.list-view) .slab-card-image {
    min-height: 100px;
    aspect-ratio: 4/3;
  }

  /* List view cards - keep compact buttons */
  .slab-grid.list-view .slab-btn {
    min-height: 26px !important;
    padding: 4px 8px !important;
    font-size: 10px !important;
    width: auto;
  }
}

/* ===== ACTIVE FILTER INDICATOR ===== */
.filters-bar.has-active-filters .mobile-filter-toggle {
  background: linear-gradient(135deg, #f9cb00 0%, #cca600 100%);
  color: #1a2b3c;
}

.filters-bar.has-active-filters .mobile-filter-toggle svg {
  stroke: #1a2b3c;
}

/* Pulse animation for active filters */
@keyframes filter-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(249, 203, 0, 0.4); }
  50% { box-shadow: 0 0 0 8px rgba(249, 203, 0, 0); }
}

.filters-bar.has-active-filters .mobile-filter-toggle {
  animation: filter-pulse 2s ease-in-out 1;
}
