/* Reset */
*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  font-family:
    system-ui,
    -apple-system,
    sans-serif;
  margin: 0;
  padding: 1rem;
  background: #f5f5f5;
  color: #222;
}

h1 {
  text-align: center;
  margin-bottom: 1.5rem;
}

/* Layout */
.layout {
  display: flex;
  gap: 1.5rem;
  max-width: 1400px;
  margin: 0 auto;
}

/* Sidebar */
.sidebar {
  width: 240px;
  flex-shrink: 0;
  position: sticky;
  top: 1rem;
  height: fit-content;
  max-height: calc(100vh - 2rem);
  overflow-y: auto;
}

.sidebar-content {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.sidebar-section label {
  display: block;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #888;
  font-weight: 600;
  margin-bottom: 0.4rem;
}

/* Segmented control */
.segmented {
  display: flex;
  border: 1px solid #ddd;
  border-radius: 6px;
  overflow: hidden;
  background: #fff;
}

.segmented a,
.segmented span {
  flex: 1;
  padding: 0.4rem 0.5rem;
  text-align: center;
  text-decoration: none;
  font-size: 0.85rem;
  color: #333;
  white-space: nowrap;
  border-right: 1px solid #ddd;
}

.segmented a:last-child,
.segmented span:last-child {
  border-right: none;
}

.segmented a:hover {
  background: #f5f5f5;
}

.segmented .active {
  background: #333;
  color: #fff;
}

/* Pill toggles */
.pills {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.pills a,
.pills span {
  padding: 0.3rem 0.6rem;
  border-radius: 999px;
  text-decoration: none;
  font-size: 0.8rem;
  white-space: nowrap;
  border: 1px solid #ddd;
  color: #333;
  background: #fff;
}

.pills a:hover {
  background: #f5f5f5;
}

.pills .active {
  background: #333;
  color: #fff;
  border-color: #333;
}

/* Sidebar select and input */
.sidebar select,
.sidebar input {
  width: 100%;
  padding: 0.4rem 0.6rem;
  border-radius: 6px;
  border: 1px solid #ddd;
  color: #333;
  background: #fff;
  font: inherit;
  font-size: 0.85rem;
}

.sidebar select {
  cursor: pointer;
}

/* Reset link */
.reset-filters {
  display: block;
  margin-top: 0.4rem;
  padding: 0.4rem 0;
  font-size: 0.8rem;
  color: #c62828;
  text-decoration: none;
  text-align: center;
  border: 1px solid #c62828;
  border-radius: 6px;
  background: #fff;
  font-weight: 600;
}

.reset-filters:hover {
  background: #fdecea;
}

/* Result count */
.result-count {
  font-size: 0.8rem;
  color: #888;
}

/* Mobile sidebar toggle */
.sidebar-toggle {
  display: none;
}

.sidebar-backdrop {
  display: none;
}

#promotions {
  flex: 1;
  min-width: 0;
}

/* Card grid */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1rem;
}

.card {
  background: #fff;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
  transition: box-shadow 0.2s;
  text-decoration: none;
  color: inherit;
  display: flex;
  flex-direction: column;
}

.card:hover {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.card img {
  width: 100%;
  height: 200px;
  object-fit: contain;
  background: #fafafa;
  padding: 0.5rem;
}

.card .card-body {
  padding: 0.75rem;
  flex: 1;
}

.card .card-body p {
  margin: 0.5rem 0 0;
  font-size: 0.9rem;
  line-height: 1.3;
}

.card .card-body .contents-amount {
  color: #888;
  font-size: 0.8rem;
}

.card .price {
  padding: 0.5rem 0.75rem 0.75rem;
}

.card .price-original {
  text-decoration: line-through;
  color: #888;
  font-weight: 400;
  margin-right: 0.25rem;
}

.card .price-current {
  font-weight: 700;
}

.card .conditions {
  padding: 0 0.75rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.card .condition {
  background: #fdecea;
  color: #c62828;
  font-weight: 700;
  font-size: 0.8rem;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
}

.card .card-meta {
  display: flex;
  gap: 0.25rem;
  flex-wrap: wrap;
}

.card .card-meta + .card-meta {
  margin-top: 0.25rem;
}

.card .card-meta span {
  font-size: 0.7rem;
  font-weight: 600;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
}

.card .card-supermarket {
  margin-bottom: 0.25rem;
  justify-content: flex-end;
}

.card .card-supermarket .supermarket {
  font-size: 0.85rem;
  font-weight: 700;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
}

.card .supermarket-ah {
  background: #e3f2fd;
  color: #1565c0;
}

.card .supermarket-jumbo {
  background: #fff8e1;
  color: #f9a825;
}

.card .supermarket-plus {
  background: #e8f5e9;
  color: #2e7d32;
}

.card .category {
  background: #f3e8fd;
  color: #7b1fa2;
}

.card .starts-on {
  background: #fff3e0;
  color: #e65100;
}

.card .ends-on {
  background: #e3f2fd;
  color: #1565c0;
}

/* Load more */
#load-more {
  display: flex;
  justify-content: center;
  margin: 2rem 0;
}

#load-more button {
  padding: 0.4rem 2rem;
  border-radius: 6px;
  border: 1px solid #ddd;
  background: #fff;
  color: #333;
  cursor: pointer;
  font-size: 0.85rem;
}

#load-more button:hover {
  background: #f5f5f5;
}

/* Mobile responsive */
@media (max-width: 768px) {
  .layout {
    display: block;
  }

  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: 280px;
    height: 100%;
    max-height: 100%;
    background: #f5f5f5;
    z-index: 200;
    padding: 1.5rem 1rem;
    transform: translateX(-100%);
    transition: transform 0.3s;
    overflow-y: auto;
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .sidebar-toggle {
    display: block;
    position: fixed;
    bottom: 1rem;
    right: 1rem;
    z-index: 100;
    padding: 0.75rem 1.25rem;
    border-radius: 999px;
    border: none;
    background: #333;
    color: #fff;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
  }

  .sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 150;
  }

  .sidebar-backdrop.open {
    display: block;
  }

  .sidebar input {
    font-size: 16px;
  }
}
