/* ============================================================================
   CATALOGUE — Public Product Catalogue
   ============================================================================
   Public-facing page — no staff auth.  Matches site-wide design tokens:
     Fonts:  'Bank Gothic' (body), 'Oswald' (headings/buttons)
     BG:     animated grey gradient (#ddd → #f0f0f0)
     Cards:  white, 16 px radius, soft shadow  (same as PartsV2)
   ============================================================================ */

/* ── Page root ─────────────────────────────────────────────────────────── */

.catalogue-page {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 1rem 6rem; /* bottom padding for WhatsApp bar */
  font-family: "Bank Gothic", sans-serif;
}

.catalogue-page h1 {
  font-family: "Oswald", sans-serif;
  font-weight: 700;
  font-size: 2rem;
  margin-bottom: 0.25rem;
}

.catalogue-page h2,
.catalogue-page h3,
.catalogue-page label,
.catalogue-page .btn {
  font-family: "Oswald", sans-serif;
}

/* ── Pinned top block (logo + filters) ─────────────────────────────────── */

/* Keeps the header and filter panel in place while the results scroll under.
   The negative margins pull the background out over .catalogue-page's 1 rem
   gutters so nothing shows through at the edges, and the background repeats
   the site-wide animated gradient so the block reads as part of the page. */
.catalogue-sticky-top {
  position: sticky;
  top: 0;
  z-index: 500; /* above the cards, below the WhatsApp bar (1000) and lightbox (2000) */
  margin: 0 -1rem;
  padding: 0 1rem;
  background: linear-gradient(270deg, #dddddd, #f0f0f0);
  background-size: 400% 400%;
  animation: gradientAnimation 6s infinite alternate;
}

/* ── Logo header ───────────────────────────────────────────────────────── */

.catalogue-header {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0;
  padding: 1rem 0 0.8rem;
}

.catalogue-header img {
  height: 50px;
}

.catalogue-header h1 {
  margin: -0.15rem 0 0;
}

/* ── Filter panel ──────────────────────────────────────────────────────── */

.catalogue-filters {
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(6px);
  border-radius: 16px;
  padding: 1.25rem 1.5rem;
  margin-bottom: 1.25rem;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.06);
}

.filter-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: flex-end;
  justify-content: space-between;
}

.filter-group {
  display: flex;
  flex-direction: column;
  flex: 1 1 180px;
  min-width: 140px;
}

.filter-group label {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #555;
  margin-bottom: 0.25rem;
}

.filter-group select,
.filter-group input[type="text"] {
  font-family: "Bank Gothic", sans-serif;
  font-size: 0.9rem;
  padding: 0.5rem 0.75rem;
  border: 1px solid #ccc;
  border-radius: 10px;
  background: #fff;
  transition: border-color 0.2s;
  appearance: auto;
}

.filter-group select:focus,
.filter-group input[type="text"]:focus {
  outline: none;
  border-color: #d32f2f;
  box-shadow: 0 0 0 3px rgba(211, 47, 47, 0.15);
}

/* Container for right-aligned filter controls */
.filter-controls {
  display: flex;
  gap: 0.75rem;
  align-items: flex-end;
}

.search-wrap {
  flex: 2 1 260px;
  /* Prevent the search box from growing too wide when filters are right-aligned */
  max-width: 480px;
  flex-basis: 200px;
}

.search-wrap .search-input-wrap {
  position: relative;
}

/* ── Narrow filter dropdowns (Make, Category, Model) ───────────────────── */

#catMake,
#catCategory,
#catModel {
  max-width: 160px;
}

.search-wrap .search-input-wrap input {
  width: 100%;
  padding-right: 2.5rem;
}

/* Search is run on demand, so the icon is a real button, not decoration */
.search-wrap .search-btn {
  position: absolute;
  right: 0.35rem;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: #888;
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.search-wrap .search-btn:hover {
  background: #f0f0f0;
  color: #d32f2f;
}

.search-wrap .search-btn:focus-visible {
  outline: none;
  color: #d32f2f;
  box-shadow: 0 0 0 3px rgba(211, 47, 47, 0.15);
}

/* Filters have been changed but not yet applied — pressing search will change
   what is on screen. Filled rather than merely tinted, so it reads as an action
   waiting to be taken. */
.search-wrap .search-btn.has-pending {
  background: #d32f2f;
  color: #fff;
  box-shadow: 0 0 0 4px rgba(211, 47, 47, 0.18);
}

.search-wrap .search-btn.has-pending:hover {
  background: #b71c1c;
  color: #fff;
}

/* One short nudge on appearing, then it simply stays filled — a permanent
   animation next to a search box is a distraction while typing. */
@media (prefers-reduced-motion: no-preference) {
  .search-wrap .search-btn.has-pending {
    animation: cat-search-nudge 0.45s ease-out;
  }
}

@keyframes cat-search-nudge {
  0% {
    transform: translateY(-50%) scale(1);
  }
  50% {
    transform: translateY(-50%) scale(1.18);
  }
  100% {
    transform: translateY(-50%) scale(1);
  }
}

/* ── Results info bar ──────────────────────────────────────────────────── */

.catalogue-info-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
  font-size: 0.85rem;
  color: #666;
}

.catalogue-info-bar .result-count {
  font-weight: 600;
}

/* ── Card grid ─────────────────────────────────────────────────────────── */

.catalogue-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.25rem;
}

.catalogue-card {
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.08);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition:
    transform 0.2s,
    box-shadow 0.2s;
  cursor: pointer;
}

.catalogue-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 14px 35px rgba(0, 0, 0, 0.12);
}

.catalogue-card .card-vehicle {
  font-family: "Oswald", sans-serif;
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  padding: 0.6rem 1rem 0;
  color: #333;
}

.catalogue-card .card-img-wrap {
  width: 100%;
  aspect-ratio: 4 / 3;
  background: #f5f5f5;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}

.catalogue-card .card-img-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Shown instead of a photo on parts that have no images — links to WhatsApp */
.catalogue-card .card-img-wrap .card-whatsapp-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  width: 100%;
  height: 100%;
  padding: 1rem;
  text-decoration: none;
  transition: transform 0.2s;
}

.catalogue-card .card-img-wrap .card-whatsapp-btn:hover {
  transform: scale(1.05);
}

/* Override the object-fit: cover rule used for real part photos */
.catalogue-card .card-img-wrap .card-whatsapp-btn img {
  width: 44px;
  height: 44px;
  max-width: 40%;
  object-fit: contain;
  flex-shrink: 0;
}

.catalogue-card .card-img-wrap .card-whatsapp-btn span {
  font-family: "Oswald", sans-serif;
  font-weight: 700;
  font-size: 1.05rem;
  color: #25d366;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.catalogue-card .card-img-wrap .cat-image-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: none;
  background: rgba(0, 0, 0, 0.6);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  cursor: pointer;
  transition: background 0.2s ease, opacity 0.2s ease;
  opacity: 0;
  pointer-events: none;
  z-index: 2;
}

.catalogue-card .card-img-wrap.has-multiple .cat-image-nav {
  opacity: 0.95;
  pointer-events: auto;
}

.catalogue-card .card-img-wrap .cat-image-nav:hover,
.catalogue-card .card-img-wrap .cat-image-nav:focus-visible {
  background: rgba(0, 0, 0, 0.8);
}

.catalogue-card .card-img-wrap .cat-image-nav-prev {
  left: 10px;
}

.catalogue-card .card-img-wrap .cat-image-nav-next {
  right: 10px;
}

.catalogue-card .cat-image-dots {
  position: absolute;
  bottom: 8px;
  left: 0;
  right: 0;
  display: flex;
  justify-content: center;
  gap: 0.35rem;
  z-index: 2;
}

.catalogue-card .cat-image-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  border: none;
  background: rgba(255, 255, 255, 0.7);
  transition: transform 0.2s ease, background 0.2s ease;
  cursor: pointer;
  padding: 0;
}

.catalogue-card .cat-image-dot.active {
  background: #fff;
  transform: scale(1.3);
}

.catalogue-card .card-body {
  padding: 0.75rem 1rem 0.6rem;
  flex: 1;
  display: flex;
  flex-direction: column;
}

.catalogue-card .card-name {
  font-family: "Oswald", sans-serif;
  font-weight: 700;
  font-size: 1rem;
  color: #111;
  margin-bottom: 0.15rem;
}

.catalogue-card .card-code {
  font-size: 0.8rem;
  color: #777;
  margin-bottom: 0.15rem;
}

.catalogue-card .card-desc {
  font-size: 0.78rem;
  color: #999;
  margin-bottom: auto;
}

.catalogue-card .card-footer-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.5rem 1rem 0.75rem;
  border-top: 1px solid #f0f0f0;
}

.catalogue-card .card-category {
  font-size: 0.75rem;
  font-weight: 600;
  color: #d32f2f;
  text-transform: uppercase;
}

.catalogue-card .card-status {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  padding: 0.2rem 0.6rem;
  border-radius: 8px;
}

.catalogue-card .card-status.available {
  background: #e6f9ed;
  color: #1a8a42;
}

.catalogue-card .card-status.sold {
  background: #fce8e8;
  color: #c0392b;
}

/* ── Loading / empty / error states ────────────────────────────────────── */

.catalogue-state {
  display: none;
  text-align: center;
  padding: 4rem 1rem;
  color: #888;
}

.catalogue-state.active {
  display: block;
}

.catalogue-state .state-icon {
  font-size: 3rem;
  margin-bottom: 0.75rem;
}

.catalogue-spinner {
  width: 48px;
  height: 48px;
  border: 4px solid #e0e0e0;
  border-top-color: #f7941d;
  border-radius: 50%;
  animation: cat-spin 0.8s linear infinite;
  margin: 0 auto 1rem;
}

@keyframes cat-spin {
  to {
    transform: rotate(360deg);
  }
}

/* ── Pagination ────────────────────────────────────────────────────────── */

.catalogue-pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0.35rem;
  margin-top: 1.5rem;
  flex-wrap: wrap;
}

.catalogue-pagination button {
  font-family: "Oswald", sans-serif;
  font-size: 0.9rem;
  min-width: 38px;
  height: 38px;
  border: 1px solid #ddd;
  border-radius: 8px;
  background: #fff;
  color: #333;
  cursor: pointer;
  transition: all 0.15s;
}

.catalogue-pagination button:hover:not(:disabled):not(.active) {
  background: #f0f0f0;
  border-color: #bbb;
}

.catalogue-pagination button.active {
  background: #f7941d;
  color: #fff;
  border-color: #f7941d;
  font-weight: 700;
}

.catalogue-pagination button:disabled {
  opacity: 0.4;
  cursor: default;
}

/* ── Bottom bar (sort + pagesize + pagination) ─────────────────────────── */

.catalogue-bottom-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 1.25rem;
  padding: 0.75rem 0;
}

.bottom-controls {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.bottom-controls label {
  font-size: 0.8rem;
  font-weight: 600;
  color: #555;
  white-space: nowrap;
}

.bottom-controls select {
  font-family: "Bank Gothic", sans-serif;
  font-size: 0.85rem;
  padding: 0.35rem 0.5rem;
  border: 1px solid #ccc;
  border-radius: 8px;
  background: #fff;
}

/* ── WhatsApp sticky bar ───────────────────────────────────────────────── */

.whatsapp-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 1000;
  background: #25d366;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.2s;
  box-shadow: 0 -2px 12px rgba(0, 0, 0, 0.15);
}

.whatsapp-bar:hover {
  background: #1ebd5a;
}

.whatsapp-bar svg {
  width: 32px;
  height: 32px;
  fill: #fff;
  flex-shrink: 0;
}

.whatsapp-bar span {
  font-family: "Oswald", sans-serif;
  font-weight: 700;
  font-size: 1.15rem;
  color: #fff;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* ── Subscribe prompt ──────────────────────────────────────────────────── */

.catalogue-subscribe {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 1500; /* above the WhatsApp bar (1000), below the lightbox (2000) */
  background: rgba(0, 0, 0, 0.55);
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.catalogue-subscribe.active {
  display: flex;
}

.catalogue-subscribe .subscribe-panel {
  position: relative;
  width: 100%;
  max-width: 420px;
  background: #fff;
  border-radius: 16px;
  padding: 1.75rem 1.5rem 1.5rem;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.3);
  font-family: "Bank Gothic", sans-serif;
}

.catalogue-subscribe h2 {
  font-family: "Oswald", sans-serif;
  font-weight: 700;
  font-size: 1.35rem;
  margin: 0 0 0.5rem;
  color: #111;
}

.catalogue-subscribe p {
  font-size: 0.88rem;
  line-height: 1.45;
  color: #555;
  margin: 0 0 1.25rem;
}

.catalogue-subscribe .subscribe-close {
  position: absolute;
  top: 0.5rem;
  right: 0.75rem;
  border: none;
  background: none;
  font-size: 1.6rem;
  line-height: 1;
  color: #999;
  cursor: pointer;
}

.catalogue-subscribe .subscribe-close:hover {
  color: #333;
}

/* Only the active step is shown; JS swaps the class */
.catalogue-subscribe .subscribe-step {
  display: none;
}

.catalogue-subscribe .subscribe-step.active {
  display: block;
}

.catalogue-subscribe .subscribe-field {
  display: flex;
  flex-direction: column;
  margin-bottom: 0.75rem;
}

.catalogue-subscribe .subscribe-field label {
  font-family: "Oswald", sans-serif;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #555;
  margin-bottom: 0.25rem;
}

.catalogue-subscribe .subscribe-field input {
  font-family: "Bank Gothic", sans-serif;
  font-size: 0.9rem;
  padding: 0.5rem 0.75rem;
  border: 1px solid #ccc;
  border-radius: 10px;
  background: #fff;
  transition: border-color 0.2s;
}

.catalogue-subscribe .subscribe-field input:focus {
  outline: none;
  border-color: #d32f2f;
  box-shadow: 0 0 0 3px rgba(211, 47, 47, 0.15);
}

.catalogue-subscribe .subscribe-error {
  display: none;
  font-size: 0.8rem;
  color: #c0392b;
  margin-bottom: 0.75rem;
}

.catalogue-subscribe .subscribe-error.active {
  display: block;
}

.catalogue-subscribe .subscribe-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.catalogue-subscribe .subscribe-btn {
  font-family: "Oswald", sans-serif;
  font-size: 0.9rem;
  font-weight: 600;
  padding: 0.55rem 1.1rem;
  border-radius: 10px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.catalogue-subscribe .subscribe-btn-yes {
  background: #d32f2f;
  color: #fff;
}

.catalogue-subscribe .subscribe-btn-yes:hover {
  background: #b71c1c;
}

.catalogue-subscribe .subscribe-btn-yes:disabled {
  opacity: 0.6;
  cursor: default;
}

.catalogue-subscribe .subscribe-btn-no {
  background: #fff;
  color: #555;
  border-color: #ccc;
}

.catalogue-subscribe .subscribe-btn-no:hover {
  background: #f0f0f0;
  color: #222;
}

/* ── Image lightbox ────────────────────────────────────────────────────── */

.catalogue-lightbox {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 2000;
  background: rgba(0, 0, 0, 0.8);
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.catalogue-lightbox.active {
  display: flex;
}

.catalogue-lightbox img {
  max-width: 90vw;
  max-height: 85vh;
  border-radius: 12px;
  box-shadow: 0 0 40px rgba(0, 0, 0, 0.5);
}

.catalogue-lightbox .lightbox-close {
  position: absolute;
  top: 1rem;
  right: 1.5rem;
  font-size: 2rem;
  color: #fff;
  cursor: pointer;
  line-height: 1;
  background: none;
  border: none;
}

.catalogue-lightbox .lightbox-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  font-size: 2.5rem;
  color: #fff;
  background: rgba(0, 0, 0, 0.3);
  border: none;
  border-radius: 50%;
  width: 50px;
  height: 50px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.2s;
}
.catalogue-lightbox .lightbox-nav:hover {
  background: rgba(0, 0, 0, 0.6);
}
.catalogue-lightbox .lightbox-prev {
  left: 1rem;
}
.catalogue-lightbox .lightbox-next {
  right: 1rem;
}

/* ── Responsive ────────────────────────────────────────────────────────── */

@media (max-width: 992px) {
  .catalogue-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 640px) {
  .catalogue-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.75rem;
  }

  .filter-row {
    display: block;
  }

  .search-wrap {
    max-width: none;
    margin-bottom: 0.35rem;
  }

  /* The three dropdowns share one row rather than stacking — stacked, the
     pinned block would swallow most of a phone screen. */
  .filter-controls {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.4rem;
    width: 100%;
  }

  .filter-controls .filter-group {
    width: 100%;
    min-width: 0;
    align-items: flex-start;
  }

  #catMake,
  #catCategory,
  #catModel {
    max-width: none;
    font-size: 0.8rem;
    padding: 0.4rem 0.5rem;
  }

  /* Trim the pinned block's height on small screens */
  .catalogue-header {
    padding: 0.5rem 0 0.4rem;
  }

  .catalogue-header img {
    height: 36px;
  }

  .catalogue-filters {
    padding: 0.75rem 0.9rem;
    margin-bottom: 0.75rem;
  }

  .catalogue-bottom-bar {
    flex-direction: column;
    align-items: stretch;
  }

  .catalogue-pagination {
    justify-content: center;
  }

  .catalogue-page h1 {
    font-size: 1.5rem;
  }

  .catalogue-card .card-vehicle {
    font-size: 0.7rem;
    padding: 0.4rem 0.6rem 0;
  }

  .catalogue-card .card-img-wrap {
    aspect-ratio: 1 / 1;
  }

  .catalogue-card .card-img-wrap .cat-image-nav {
    width: 26px;
    height: 26px;
    font-size: 0.95rem;
  }

  /* Two narrow cards per row — shrink the button so it stays on one line */
  .catalogue-card .card-img-wrap .card-whatsapp-btn {
    gap: 0.35rem;
    padding: 0.5rem;
  }

  .catalogue-card .card-img-wrap .card-whatsapp-btn img {
    width: 28px;
    height: 28px;
  }

  .catalogue-card .card-img-wrap .card-whatsapp-btn span {
    font-size: 0.8rem;
  }

  .catalogue-card .cat-image-dots {
    bottom: 6px;
    gap: 0.25rem;
  }

  .catalogue-card .cat-image-dot {
    width: 6px;
    height: 6px;
  }

  .catalogue-card .card-body {
    padding: 0.5rem 0.6rem 0.4rem;
  }

  .catalogue-card .card-name {
    font-size: 0.85rem;
  }

  .catalogue-card .card-code {
    font-size: 0.7rem;
  }

  .catalogue-card .card-footer-row {
    padding: 0.4rem 0.6rem 0.55rem;
  }

  .catalogue-card .card-category {
    font-size: 0.65rem;
  }

  .catalogue-card .card-status {
    font-size: 0.62rem;
    padding: 0.15rem 0.45rem;
  }
}

@media (max-width: 400px) {
  .catalogue-filters {
    padding: 0.7rem 0.75rem;
    border-radius: 12px;
  }

  .catalogue-card .card-name {
    font-size: 0.9rem;
  }
}
