﻿/* ============================================================
   Product List  –  Card Grid Layout  (responsive)
   ============================================================ */

/* ============================================================
   HTMX Loading Indicator
   ============================================================ */

/* htmx hides .htmx-indicator by default via opacity */
.htmx-indicator { opacity: 0; transition: opacity 200ms ease; pointer-events: none; }
.htmx-request .htmx-indicator,
.htmx-request.htmx-indicator { opacity: 1; pointer-events: auto; }

/* Full-area overlay inside #product-results during pagination swap */
.pl-htmx-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.82);
  backdrop-filter: blur(3px);
  z-index: 10;
  gap: 14px;
  border-radius: var(--pl-radius);
  transition: opacity 200ms ease;
}

/* Initial-load variant: takes natural space (not absolute) */
.pl-htmx-overlay--initial {
  position: relative;
  min-height: 260px;
  inset: auto;
  opacity: 1 !important; /* always visible until replaced */
}

/* Spinner ring */
.pl-spinner {
  display: inline-block;
  width: 48px;
  height: 48px;
  border: 4px solid var(--pl-border);
  border-top-color: var(--pl-accent);
  border-radius: 50%;
  animation: pl-spin 0.75s linear infinite;
}

.pl-spinner-label {
  font-size: 13px;
  color: var(--pl-text-muted);
  letter-spacing: 0.02em;
}

@keyframes pl-spin {
  to { transform: rotate(360deg); }
}

/* --- Custom Properties --- */
:root {
  --pl-radius: 8px;
  --pl-shadow: 0 1px 3px rgba(63,63,68,.12), 0 0 0 1px rgba(63,63,68,.05);
}

/* --- Page Toolbar --- */
.pl-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  padding: 5px 0 5px;
  margin-bottom: 16px;
}
.pl-toolbar h1 {
  margin: 0;
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--pl-text);
  letter-spacing: -.01em;
}
.pl-toolbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.pl-limit-select {
  padding: 5px 10px;
  height: 32px;
  border: 1px solid var(--pl-border);
  border-radius: var(--pl-radius);
  background: var(--pl-surface);
  font-size: 12px;
  color: var(--pl-text);
  cursor: pointer;
  outline: none;
}
.pl-limit-select:focus { border-color: var(--pl-accent); }

/* Nappi Toggle Buttons */
.pl-nappi-btn {
  display: inline-flex;
  align-items: center;
  height: 32px;
  padding: 0 12px;
  border-radius: var(--pl-radius);
  font-size: 12px;
  font-weight: 600;
  color: #fff;
  cursor: pointer;
  text-decoration: none;
  transition: opacity .15s;
}
.pl-nappi-btn:hover { opacity: .85; color: #fff; }
#nappion  { background: var(--c-primary-dark); }
#nappioff { background: var(--c-green-vivid); }

/* --- Breadcrumb --- */
.pl-breadcrumb {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
  list-style: none;
  margin: 0 0 12px;
  padding: 0;
  font-size: 12px;
  color: var(--pl-text-muted);
}
.pl-breadcrumb li + li::before { content: "/"; margin-right: 4px; }
.pl-breadcrumb a { color: var(--pl-accent); text-decoration: none; }
.pl-breadcrumb a:hover { text-decoration: underline; }

/* ============================================================
   Card Grid
   ============================================================ */
.pl-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 16px;
}

/* --- Product Card --- */
.pl-card {
  background: var(--pl-surface);
  border: 1px solid var(--pl-border);
  border-radius: var(--pl-radius);
  box-shadow: var(--pl-shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: box-shadow .2s, transform .2s;
}
.pl-card:hover {
  box-shadow: 0 4px 20px rgba(63,63,68,.18), 0 1px 4px rgba(63,63,68,.08);
  transform: translateY(-2px);
}
.pl-card.pl-card-oos { opacity: .72; }
.pl-card.pl-card-oos .pl-card-img { filter: grayscale(.4); }

/* --- Image Area --- */
.pl-card-img-wrap {
  position: relative;
  background: var(--c-bg-subtle);
  aspect-ratio: 1 / 1;
  overflow: hidden;
  border-bottom: 1px solid var(--pl-border);
}
.pl-card-img-link {
  display: block;
  overflow: hidden;
  box-sizing: border-box;
}

.pl-card-img {
  width: 100%;
}
.pl-card:hover .pl-card-img { transform: scale(1.04); }

/* Type badge overlaying image (top-left) */
.pl-card-type-badge {
  position: absolute;
  top: 8px;
  left: 8px;
  padding: 3px 7px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
  text-decoration: none;
  z-index: 2;
  line-height: 1;
}
.pl-ctb-exp { background: #fff3cd; color: #856404; border: 1px solid #ffc107; }
.pl-ctb-web { background: #cfe2ff; color: #084298; border: 1px solid #9ec5fe; }
.pl-ctb-pro { background: var(--c-green-lt); color: var(--c-green-dark); border: 1px solid #a3cfbb; }
.pl-ctb-new { background: #d1e7dd; color: #0f5132; border: 1px solid #a3cfbb; }

.pl-ctb-exp:hover { background: #fff3cd; color: #856404; border: 1px solid #ffc107; text-decoration: underline;}
.pl-ctb-web:hover { background: #cfe2ff; color: #084298; border: 1px solid #9ec5fe; text-decoration: underline;}
.pl-ctb-pro:hover { background: var(--c-green-lt); color: var(--c-green-dark); border: 1px solid #a3cfbb; text-decoration: underline;}
.pl-ctb-new:hover { background: #d1e7dd; color: #0f5132; border: 1px solid #a3cfbb; text-decoration: underline;}


.pl-ctb-exp:visited { background: #fff3cd; color: #856404; border: 1px solid #ffc107; text-decoration: none;}
.pl-ctb-web:visited { background: #cfe2ff; color: #084298; border: 1px solid #9ec5fe; text-decoration: none;}
.pl-ctb-pro:visited { background: var(--c-green-lt); color: var(--c-green-dark); border: 1px solid #a3cfbb; text-decoration: none;}
.pl-ctb-new:visited { background: #d1e7dd; color: #0f5132; border: 1px solid #a3cfbb; text-decoration: none;}

/* Clickable card link (public listing) */
a.pl-card-link {
  display: flex;
  flex-direction: column;
  text-decoration: none !important;
  color: inherit;
  cursor: pointer;
}
a.pl-card-link:hover .web-view-product-btn {
  background: var(--c-primary);
  color: #fff !important;
}

/* Saving % badge (top-right on image) */
.pl-card-saving-badge {
  position: absolute;
  top: 8px;
  right: 8px;
  background: var(--pl-red);
  color: #fff;
  padding: 4px 7px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 700;
  z-index: 2;
  letter-spacing: -.01em;
  line-height: 1.2;
}

/* --- Card Body --- */
.pl-card-body {
  padding: 12px 12px 8px;
  display: flex;
  flex-direction: column;
  gap: 5px;
  flex: 1;
}

/* Codes row */
.pl-card-codes {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 8px;
  align-items: center;
}
.pl-card-model {
  font-family:"Open Sans", sans-serif;
  font-size: 10px;
  color: var(--pl-text-muted);
  letter-spacing: .02em;
}
.pl-card-nappi {
  font-size: 10px;
  color: var(--c-primary-dark);
  font-weight: 600;
  margin-left: auto;
  text-align: right;
  white-space: nowrap;
}
.pl-nappi-label {
  font-weight: 400;
  color: var(--c-primary-dark);
  opacity: .7;
  margin-right: 2px;
}

/* Product name */
a.pl-card-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--pl-text);
  text-decoration: none;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  transition: color .15s;
  /* must always be height of two lines */
  height: calc(2.8em);
}
a.pl-card-name:hover {   color: var(--pl-text); text-decoration: underline; }
a.pl-card-name:visited {   color: var(--pl-text); text-decoration: none; }

/* --- Badge Indicators --- */
.pl-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
  min-height: 4px;
}
.pl-badge {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 20px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  white-space: nowrap;
  text-decoration: none;
  letter-spacing: .03em;
  cursor: default;
}
a.pl-badge { cursor: pointer; }
a.pl-badge:hover { opacity: .8; }

.pl-badge-alt  { background: #e2d9f3; color: #432874; border: 1px solid #c5b3e6; }
.pl-badge-ows  { background: #fff3cd; color: #856404; border: 1px solid #ffc107; }
.pl-badge-ovr  { background: #f8d7da; color: #842029; border: 1px solid #f1aeb5; }
.pl-badge-flag { background: #fde8d8; color: #7d3c0a; border: 1px solid #f4a261; }

/* Promo deal tag */
.pl-card-promo-deal {
  font-size: 11px;
  color: var(--pl-green);
  font-weight: 500;
  background: var(--pl-green-bg);
  padding: 3px 8px;
  border-radius: 4px;
  display: inline-block;
  align-self: flex-start;
  cursor: pointer;
  /* no text select */
  user-select: none;
  
}

/* Stock status */
.pl-card-stock { font-size: 11px; }
.pl-instock    { color: var(--pl-green); font-weight: 600; }
.pl-oos-label  { color: var(--pl-red);  font-weight: 600; }
.pl-onhand-num { color: var(--pl-text-muted); font-size: 11px; }

/* Price row — pushed to bottom of body */
.pl-card-price-row {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 6px;
  margin-top: auto;
  padding-top: 8px;
}
.pl-price-special { font-size: 17px; font-weight: 700; color: var(--pl-green); }
.pl-price-regular { font-size: 17px; font-weight: 700; color: var(--pl-text); }
.pl-price-old     { text-decoration: line-through; color: var(--pl-text-muted); font-size: 12px; }
.pl-price-saving  { color: var(--pl-red); font-size: 11px; font-weight: 700; }
.pl-price-label   { color: var(--pl-text-muted); font-size: 10px; margin-left: auto; align-self: center; }

/* --- Card Footer: qty + cart actions --- */
.pl-card-footer {
  padding: 8px 10px 10px;
  border-top: 1px solid var(--pl-border);
  background: var(--c-bg-light);
}

.pl-qty-group {
  display: flex;
  align-items: stretch;
  gap: 4px;
  margin-right: 8px;
}

.pl-qty-input {
  flex: 1;
  min-width: 0;
  height: 30px;
  padding: 0 4px;
  border: 1px solid var(--pl-border);
  border-right: none;
  border-radius: var(--pl-radius) 0 0 var(--pl-radius);
  font-size: 13px;
  text-align: center;
  color: var(--pl-text);
  background: var(--pl-surface);
  -moz-appearance: textfield;
  transition: border-color .15s, box-shadow .15s;
}
.pl-qty-input::-webkit-outer-spin-button,
.pl-qty-input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.pl-qty-input:focus {
  outline: none;
  border-color: var(--pl-accent);
  box-shadow: 0 0 0 2px rgba(92,106,196,.2);
}

.pl-qty-arrows {
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  width: 22px;
  border: 1px solid var(--pl-border);
  border-left: none;
  border-radius: 0 var(--pl-radius) var(--pl-radius) 0;
  overflow: hidden;
  background: var(--pl-bg);
  margin-left: -4px;
}
.pl-qty-arrow {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 1;
  width: 22px;
  background: var(--pl-bg);
  border: none;
  border-radius: 0;
  cursor: pointer;
  font-size: 7px;
  color: var(--pl-text-muted);
  user-select: none;
  transition: background .1s;
}
.pl-qty-arrow + .pl-qty-arrow { border-top: 1px solid var(--pl-border); }
.pl-qty-arrow:hover { background: var(--c-border); color: var(--pl-text); }
.pl-qty-arrow i { pointer-events: none; }

/* Cart button — flex:1 fills available width */
.pl-btn-cart {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  flex: 1;
  height: 30px;
  padding: 0 6px;
  background: #ddd;
  color: #888;
  border: none;
  border-radius: var(--pl-radius);
  font-size: 11px;
  font-weight: 700;
  cursor: not-allowed;
  text-decoration: none !important;
  white-space: nowrap;
  transition: background .15s, color .15s;
  min-width: 0;
}
.pl-btn-cart:hover,.pl-btn-cart:visited,.pl-btn-cart:focus,.pl-btn-cart:active { text-decoration: none !important; }
.pl-btn-cart[style*="green"] {
  background: var(--pl-green) !important;
  color: #fff !important;
  cursor: pointer;
}
.pl-btn-cart[style*="green"]:hover { background: var(--c-green-dark) !important; }

/* Public view: "View Product" action */
.pl-card-footer-public { display: flex; }
.pl-btn-view {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  flex: 1;
  height: 38px;
  padding: 0 16px;
  background: var(--pl-primary-dark);
  color: #fff !important;
  border: none;
  border-radius: var(--pl-radius);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: .01em;
  text-decoration: none !important;
  cursor: pointer;
  overflow: hidden;
  box-shadow: var(--pl-shadow);
  transition: background .18s ease, transform .18s ease, box-shadow .18s ease;
}
.pl-btn-view,
.pl-btn-view:link,
.pl-btn-view:visited,
.pl-btn-view:hover,
.pl-btn-view:focus,
.pl-btn-view:active {
  background: var(--pl-primary-dark) !important;
  color: #fff !important;
  text-decoration: none !important;
}
.pl-btn-view-arrow { transition: transform .18s ease; }
.pl-btn-view:hover .pl-btn-view-arrow { transform: translateX(4px); }

/* Favourite button */
.pl-btn-fav {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  flex-shrink: 0;
  background: none;
  border: 1px solid var(--c-danger);
  border-radius: var(--pl-radius);
  color: var(--c-danger);
  cursor: pointer;
  font-size: 12px;
  text-decoration: none !important;
  transition: color .15s, border-color .15s, background .15s;
}
.pl-btn-fav:hover,.pl-btn-fav:visited,.pl-btn-fav:focus,.pl-btn-fav:active { text-decoration: none !important; }
.pl-btn-fav:hover                              { color: #fff; border-color: #fff; background-color: var(--c-danger);}
.pl-btn-fav.pl-fav-active                      { color: #fff; border-color: #fff; background-color: var(--c-danger);}
.pl-btn-fav.pl-fav-active:hover                { color: #c53030; border-color: #c53030; background: var(--c-red-lt); }

/* --- Action Bar (Add all / View Cart) --- */
.pl-action-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 12px;
  padding: 16px 0 12px;
}
.pl-btn-primary {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 24px;
  background: var(--pl-primary);
  color: #fff;
  border: none;
  border-bottom: 3px solid var(--pl-primary-dark);
  border-radius: var(--pl-radius);
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
  transition: background .15s, transform .1s;
  box-shadow: 0 2px 6px rgba(61,61,151,.25);
}
.pl-btn-primary:hover { background: var(--pl-primary-dark); color: #fff; transform: translateY(-1px); }

.pl-btn-secondary {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 24px;
  background: var(--pl-surface);
  color: var(--pl-primary);
  border: 1.5px solid var(--pl-primary);
  border-radius: var(--pl-radius);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: background .15s, color .15s;
}
.pl-btn-secondary:hover { background: var(--pl-primary); color: #fff; }

/* --- Pagination wrapper --- */
.pl-pagination {
  display: flex;
  justify-content: center;
  margin-top: 8px;
  padding-bottom: 8px;
  position: relative; /* anchor the htmx overlay */
}

/* #product-results needs relative so the pagination overlay is contained */
#product-results { position: relative; }

/* --- Empty State --- */
.pl-empty {
  padding: 60px 24px;
  text-align: center;
  color: var(--pl-text-muted);
  font-size: 15px;
}
.pl-empty i { font-size: 42px; margin-bottom: 16px; display: block; opacity: .4; }

/* --- Nappi visibility toggle --- */
.nappi2 { /* visible by default */ }

/* ============================================================
   RESPONSIVE
   ============================================================ */

/* 3 columns  (992px – 1199px) */
@media (max-width: 1199px) {
  .pl-grid { grid-template-columns: repeat(3, 1fr); gap: 14px; }
}

/* 2 columns  (480px – 991px  — tablet / large phone) */
@media (max-width: 991px) {
  .pl-grid { grid-template-columns: repeat(2, 1fr); gap: 12px; }
  .pl-toolbar           { flex-direction: column; align-items: flex-start; }
  .pl-toolbar-right     { width: 100%; }
  .pl-action-bar        { flex-direction: column; }
  .pl-btn-primary,
  .pl-btn-secondary     { width: 100%; justify-content: center; }
}

/* 1 column  (< 480px  — small phones) */
@media (max-width: 479px) {
  .pl-grid { grid-template-columns: 1fr; gap: 10px; }
}
