/* ==========================================================================
   WooCommerce Overrides — Phase 5: Product Archive & Single Product Quote UI
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. Product Archive
   -------------------------------------------------------------------------- */
.gb-product-archive .woocommerce-products-header {
  margin-bottom: var(--gb-space-5);
}

.gb-product-archive .woocommerce-products-header__title {
  font-family: var(--gb-font-heading);
  font-size: var(--gb-text-2xl);
  font-weight: 800;
}

/* Hide default WC result count / ordering (we provide our own toolbar) */
.gb-product-archive .woocommerce-result-count,
.gb-product-archive .woocommerce-ordering {
  display: none;
}

/* Archive toolbar */
.gb-archive-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--gb-space-3);
  padding: var(--gb-space-4);
  margin-bottom: var(--gb-space-5);
  background: var(--gb-color-surface);
  border: 1px solid var(--gb-color-border);
  border-radius: var(--gb-radius-lg);
}

.gb-archive-toolbar__search {
  flex: 1 1 240px;
  position: relative;
}

.gb-archive-toolbar__search-input {
  width: 100%;
  min-height: 40px;
  padding: var(--gb-space-2) var(--gb-space-3) var(--gb-space-2) 36px;
  background: var(--gb-color-bg);
  border: 1px solid var(--gb-color-border);
  border-radius: var(--gb-radius);
  font-size: var(--gb-text-sm);
  color: var(--gb-color-text);
  transition: border-color 0.2s;
}

.gb-archive-toolbar__search-input:focus {
  border-color: var(--gb-color-accent);
  outline: none;
  box-shadow: 0 0 0 3px var(--gb-color-accent-soft);
}

.gb-archive-toolbar__search-icon {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  color: var(--gb-color-muted);
  pointer-events: none;
}

.gb-archive-toolbar__actions {
  display: flex;
  align-items: center;
  gap: var(--gb-space-2);
}

/* Product grid */
.gb-product-archive .products {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: var(--gb-space-5);
  list-style: none;
  padding: 0;
  margin: 0;
}

.gb-product-archive .products::before,
.gb-product-archive .products::after {
  display: none;
}

/* Bulk select bar */
.gb-bulk-select-bar {
  display: none;
  align-items: center;
  gap: var(--gb-space-3);
  padding: var(--gb-space-3) var(--gb-space-4);
  margin-bottom: var(--gb-space-4);
  background: linear-gradient(135deg, var(--gb-color-action-soft), #fff8e1);
  border: 1px solid var(--gb-color-action);
  border-radius: var(--gb-radius-lg);
  animation: gb-slide-down 0.25s ease;
}

.gb-bulk-select-bar.is-active {
  display: flex;
}

.gb-bulk-select-bar__count {
  font-weight: 700;
  font-size: var(--gb-text-sm);
  color: var(--gb-color-slate);
  white-space: nowrap;
}

.gb-bulk-select-bar__actions {
  display: flex;
  gap: var(--gb-space-2);
  margin-left: auto;
}

/* Upload BOM promo */
.gb-bom-promo {
  display: flex;
  align-items: center;
  gap: var(--gb-space-4);
  padding: var(--gb-space-5);
  margin-bottom: var(--gb-space-5);
  background: linear-gradient(135deg, var(--gb-color-accent-soft), #e3f2fd);
  border: 1px solid var(--gb-color-accent);
  border-radius: var(--gb-radius-lg);
}

.gb-bom-promo__icon {
  flex-shrink: 0;
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--gb-color-accent);
  color: #fff;
  border-radius: var(--gb-radius);
  font-size: 1.5rem;
}

.gb-bom-promo__content {
  flex: 1;
}

.gb-bom-promo__title {
  font-family: var(--gb-font-heading);
  font-weight: 700;
  font-size: var(--gb-text-lg);
  margin-bottom: var(--gb-space-1);
}

.gb-bom-promo__desc {
  font-size: var(--gb-text-sm);
  color: var(--gb-color-muted);
}

@media (max-width: 599px) {
  .gb-bom-promo {
    flex-direction: column;
    text-align: center;
  }
}

/* --------------------------------------------------------------------------
   2. Product Card Enhancements
   -------------------------------------------------------------------------- */
.gb-product-card {
  background-color: var(--gb-color-surface);
  border: 1px solid var(--gb-color-border);
  border-radius: var(--gb-radius-lg);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: box-shadow 0.25s ease, transform 0.25s ease;
  position: relative;
}

.gb-product-card:hover {
  box-shadow: var(--gb-shadow-hover);
  transform: translateY(-2px);
}

/* Bulk checkbox overlay */
.gb-product-card__checkbox {
  position: absolute;
  top: var(--gb-space-3);
  left: var(--gb-space-3);
  z-index: 2;
  display: none;
}

.gb-bulk-mode .gb-product-card__checkbox {
  display: block;
}

.gb-product-card__checkbox input[type="checkbox"] {
  width: 20px;
  height: 20px;
  accent-color: var(--gb-color-primary);
  cursor: pointer;
}

.gb-product-card.is-selected {
  border-color: var(--gb-color-action);
  box-shadow: 0 0 0 2px var(--gb-color-action);
}

/* Stock / availability badge */
.gb-product-card__badge {
  position: absolute;
  top: var(--gb-space-3);
  right: var(--gb-space-3);
  z-index: 2;
  padding: var(--gb-space-1) var(--gb-space-2);
  border-radius: var(--gb-radius-sm);
  font-size: var(--gb-text-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.gb-product-card__badge--in-stock {
  background: var(--gb-color-success-bg);
  color: var(--gb-color-success);
}

.gb-product-card__badge--on-backorder {
  background: var(--gb-color-warning-bg);
  color: var(--gb-color-warning);
}

.gb-product-card__badge--out-of-stock {
  background: var(--gb-color-error-bg);
  color: var(--gb-color-error);
}

.gb-product-card__badge--rfq-only {
  background: var(--gb-color-info-bg);
  color: var(--gb-color-info);
}

/* Placeholder image */
.gb-product-card__placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--gb-color-bg-alt);
  color: var(--gb-color-disabled);
  font-size: 2.5rem;
}

.gb-product-card__placeholder::before {
  content: "📦";
}

/* Attributes list */
.gb-product-card__attributes {
  list-style: none;
  padding: 0;
  margin: var(--gb-space-2) 0 0;
  display: flex;
  flex-wrap: wrap;
  gap: var(--gb-space-1);
}

.gb-product-card__attribute {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px var(--gb-space-2);
  background: var(--gb-color-bg);
  border-radius: var(--gb-radius-sm);
  font-size: var(--gb-text-xs);
  color: var(--gb-color-muted);
}

.gb-product-card__attribute strong {
  color: var(--gb-color-text);
}

/* Card actions — quote button states */
.gb-product-card__actions .gb-button[data-gb-add-to-quote] {
  flex: 1;
  position: relative;
  overflow: hidden;
}

.gb-product-card__actions .gb-button[data-gb-add-to-quote].is-loading {
  pointer-events: none;
  opacity: 0.7;
}

.gb-product-card__actions .gb-button[data-gb-add-to-quote].is-success {
  background-color: var(--gb-color-success);
  color: #fff;
}

/* --------------------------------------------------------------------------
   3. Single Product
   -------------------------------------------------------------------------- */
.gb-product-single .product {
  display: grid;
  gap: var(--gb-space-6);
  padding-block: var(--gb-space-6);
}

@media (min-width: 1024px) {
  .gb-product-single .product {
    grid-template-columns: 1fr 1fr;
  }
}

/* Gallery */
.gb-product-single__gallery {
  border-radius: var(--gb-radius-lg);
  overflow: hidden;
}

.gb-product-single .woocommerce-product-gallery {
  border-radius: var(--gb-radius-lg);
  overflow: hidden;
}

.gb-product-single .woocommerce-product-gallery__image img {
  border-radius: var(--gb-radius);
}

/* Summary */
.gb-product-single__summary {
  display: flex;
  flex-direction: column;
  gap: var(--gb-space-4);
}

.gb-product-single .product_title {
  font-family: var(--gb-font-heading);
  font-size: var(--gb-text-2xl);
  font-weight: 800;
  line-height: 1.2;
}

/* Meta row (SKU + category) */
.gb-product-single__meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--gb-space-3);
}

.gb-product-single__sku {
  font-family: var(--gb-font-mono);
  font-size: var(--gb-text-sm);
  color: var(--gb-color-muted);
  padding: var(--gb-space-1) var(--gb-space-2);
  background: var(--gb-color-bg);
  border-radius: var(--gb-radius-sm);
}

.gb-product-single__categories {
  font-size: var(--gb-text-sm);
  color: var(--gb-color-muted);
}

.gb-product-single__categories a {
  color: var(--gb-color-accent);
  text-decoration: none;
}

.gb-product-single__categories a:hover {
  text-decoration: underline;
}

/* Short description */
.gb-product-single .woocommerce-product-details__short-description {
  color: var(--gb-color-muted);
  font-size: var(--gb-text-sm);
  line-height: 1.7;
}

.gb-product-single .woocommerce-product-details__short-description p {
  margin-bottom: var(--gb-space-3);
}

/* Remove default cart form */
.gb-product-single .cart,
.gb-product-single form.cart {
  display: none !important;
}

/* Sticky quote panel on single product desktop */
@media (min-width: 1024px) {
  .gb-product-single__quote-panel {
    position: sticky;
    top: calc(64px + var(--gb-space-5));
    align-self: start;
  }
}

/* Specs table */
.gb-product-specs {
  margin-top: var(--gb-space-6);
  padding-top: var(--gb-space-6);
  border-top: 1px solid var(--gb-color-border);
}

.gb-product-specs__title {
  font-family: var(--gb-font-heading);
  font-size: var(--gb-text-xl);
  font-weight: 700;
  margin-bottom: var(--gb-space-4);
}

.gb-product-specs__table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  border: 1px solid var(--gb-color-border);
  border-radius: var(--gb-radius);
  overflow: hidden;
}

.gb-product-specs__table th,
.gb-product-specs__table td {
  padding: var(--gb-space-3) var(--gb-space-4);
  text-align: left;
  font-size: var(--gb-text-sm);
  border-bottom: 1px solid var(--gb-color-border);
}

.gb-product-specs__table th {
  width: 35%;
  background: var(--gb-color-bg);
  font-weight: 600;
  color: var(--gb-color-text);
}

.gb-product-specs__table td {
  color: var(--gb-color-muted);
}

.gb-product-specs__table tr:last-child th,
.gb-product-specs__table tr:last-child td {
  border-bottom: none;
}

/* Related products */
.gb-related-products {
  margin-top: var(--gb-space-7);
  padding-top: var(--gb-space-6);
  border-top: 1px solid var(--gb-color-border);
}

.gb-related-products__title {
  font-family: var(--gb-font-heading);
  font-size: var(--gb-text-xl);
  font-weight: 700;
  margin-bottom: var(--gb-space-5);
}

.gb-related-products .products {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: var(--gb-space-4);
  list-style: none;
  padding: 0;
}

/* --------------------------------------------------------------------------
   4. Quote Panel (enhanced for Phase 5)
   -------------------------------------------------------------------------- */
.gb-quote-panel {
  background: linear-gradient(145deg, var(--gb-color-bg), #f8f9fb);
  border: 1px solid var(--gb-color-border);
  border-radius: var(--gb-radius-lg);
  padding: var(--gb-space-5);
  display: flex;
  flex-direction: column;
  gap: var(--gb-space-4);
  box-shadow: var(--gb-shadow-sm);
}

.gb-quote-panel__title {
  font-family: var(--gb-font-heading);
  font-size: var(--gb-text-xl);
  font-weight: 700;
  margin-bottom: 0;
  display: flex;
  align-items: center;
  gap: var(--gb-space-2);
}

.gb-quote-panel__title::before {
  content: "📋";
  font-size: 1.2em;
}

.gb-quote-panel__row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--gb-space-3);
}

@media (max-width: 480px) {
  .gb-quote-panel__row {
    grid-template-columns: 1fr;
  }
}

.gb-quote-panel__submit {
  width: 100%;
  min-height: 48px;
  font-size: var(--gb-text-base);
  font-weight: 700;
  position: relative;
  overflow: hidden;
}

.gb-quote-panel__submit.is-loading {
  pointer-events: none;
  opacity: 0.75;
}

.gb-quote-panel__submit.is-loading::after {
  content: "";
  position: absolute;
  width: 20px;
  height: 20px;
  top: 50%;
  left: 50%;
  margin: -10px 0 0 -10px;
  border: 2px solid transparent;
  border-top-color: currentColor;
  border-radius: 50%;
  animation: gb-spin 0.6s linear infinite;
}

.gb-quote-panel__submit.is-success {
  background: var(--gb-color-success) !important;
  color: #fff !important;
}

.gb-quote-panel__urgent {
  width: 100%;
  text-align: center;
}

.gb-quote-panel__divider {
  display: flex;
  align-items: center;
  gap: var(--gb-space-3);
  font-size: var(--gb-text-xs);
  color: var(--gb-color-disabled);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.gb-quote-panel__divider::before,
.gb-quote-panel__divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--gb-color-border);
}

.gb-quote-panel__trust {
  font-size: var(--gb-text-sm);
  color: var(--gb-color-muted);
  text-align: center;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--gb-space-2);
}

.gb-quote-panel__trust::before {
  content: "✓";
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--gb-color-success-bg);
  color: var(--gb-color-success);
  font-size: 10px;
  font-weight: 700;
  flex-shrink: 0;
}

/* --------------------------------------------------------------------------
   5. Toast Notifications
   -------------------------------------------------------------------------- */
.gb-toast-container {
  position: fixed;
  bottom: var(--gb-space-5);
  right: var(--gb-space-5);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: var(--gb-space-2);
  pointer-events: none;
}

.gb-toast {
  display: flex;
  align-items: center;
  gap: var(--gb-space-3);
  min-width: 280px;
  max-width: 400px;
  padding: var(--gb-space-3) var(--gb-space-4);
  background: var(--gb-color-surface);
  border: 1px solid var(--gb-color-border);
  border-radius: var(--gb-radius-lg);
  box-shadow: var(--gb-shadow-lg);
  font-size: var(--gb-text-sm);
  animation: gb-slide-up 0.3s ease;
  pointer-events: auto;
}

.gb-toast.is-exiting {
  animation: gb-slide-out 0.25s ease forwards;
}

.gb-toast--success {
  border-left: 3px solid var(--gb-color-success);
}

.gb-toast--error {
  border-left: 3px solid var(--gb-color-error);
}

.gb-toast--info {
  border-left: 3px solid var(--gb-color-info);
}

.gb-toast__icon {
  flex-shrink: 0;
  font-size: 1.2em;
}

.gb-toast__content {
  flex: 1;
}

.gb-toast__title {
  font-weight: 700;
  margin-bottom: 2px;
}

.gb-toast__message {
  color: var(--gb-color-muted);
}

.gb-toast__action {
  color: var(--gb-color-accent);
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
}

.gb-toast__action:hover {
  text-decoration: underline;
}

.gb-toast__close {
  flex-shrink: 0;
  background: none;
  border: none;
  padding: var(--gb-space-1);
  cursor: pointer;
  color: var(--gb-color-muted);
  font-size: 1.1em;
  line-height: 1;
}

/* --------------------------------------------------------------------------
   6. Cart/Checkout Suppression (Quote-First Rule)
   -------------------------------------------------------------------------- */
.woocommerce-cart .wc-proceed-to-checkout,
.woocommerce-cart .checkout-button,
.woocommerce-checkout .checkout,
.woocommerce-checkout .woocommerce-checkout-payment,
.gb-product-archive .add_to_cart_button,
.gb-product-archive .ajax_add_to_cart,
.gb-product-archive .product_type_simple,
.gb-product-single .single_add_to_cart_button,
.gb-product-single .quantity,
.gb-product-archive .price,
.gb-product-archive .star-rating,
.gb-product-archive .woocommerce-loop-product__title + .price,
.gb-product-archive .woocommerce-loop-product__link .price {
  display: none !important;
}

/* Hide default WC single add-to-cart form */
.gb-product-single .woocommerce-variation-add-to-cart,
.gb-product-single .single_add_to_cart_button,
.gb-product-single .woocommerce-variation-price {
  display: none !important;
}

/* --------------------------------------------------------------------------
   7. Account Pages
   -------------------------------------------------------------------------- */
.woocommerce-account .woocommerce-MyAccount-navigation ul {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: var(--gb-space-2);
  margin-bottom: var(--gb-space-5);
  padding-bottom: var(--gb-space-4);
  border-bottom: 1px solid var(--gb-color-border);
}

.woocommerce-account .woocommerce-MyAccount-navigation a {
  display: inline-flex;
  align-items: center;
  padding: var(--gb-space-2) var(--gb-space-4);
  border-radius: var(--gb-radius);
  font-size: var(--gb-text-sm);
  font-weight: 600;
  color: var(--gb-color-muted);
  text-decoration: none;
  transition: background-color 0.2s, color 0.2s;
}

.woocommerce-account .woocommerce-MyAccount-navigation a:hover {
  background-color: var(--gb-color-bg);
  color: var(--gb-color-text);
}

.woocommerce-account .woocommerce-MyAccount-navigation .is-active a {
  background-color: var(--gb-color-primary);
  color: #fff;
}

/* --------------------------------------------------------------------------
   8. Animations
   -------------------------------------------------------------------------- */
@keyframes gb-spin {
  to { transform: rotate(360deg); }
}

@keyframes gb-slide-down {
  from { opacity: 0; transform: translateY(-8px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes gb-slide-up {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes gb-slide-out {
  from { opacity: 1; transform: translateX(0); }
  to   { opacity: 0; transform: translateX(100%); }
}

@keyframes gb-pulse {
  0%, 100% { transform: scale(1); }
  50%      { transform: scale(1.08); }
}

/* Pagination */
.gb-product-archive .woocommerce-pagination {
  margin-top: var(--gb-space-6);
  display: flex;
  justify-content: center;
}

.gb-product-archive .woocommerce-pagination ul {
  display: flex;
  gap: var(--gb-space-1);
  list-style: none;
}

.gb-product-archive .woocommerce-pagination a,
.gb-product-archive .woocommerce-pagination span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 40px;
  min-height: 40px;
  padding: var(--gb-space-1) var(--gb-space-2);
  border-radius: var(--gb-radius);
  font-size: var(--gb-text-sm);
  font-weight: 600;
  color: var(--gb-color-muted);
  border: 1px solid var(--gb-color-border);
  text-decoration: none;
  transition: background-color 0.2s, color 0.2s, border-color 0.2s;
}

.gb-product-archive .woocommerce-pagination a:hover {
  border-color: var(--gb-color-primary);
  color: var(--gb-color-primary);
}

.gb-product-archive .woocommerce-pagination span.current {
  background: var(--gb-color-primary);
  color: #fff;
  border-color: var(--gb-color-primary);
}

/* --------------------------------------------------------------------------
   9. Responsive Overrides
   -------------------------------------------------------------------------- */
@media (max-width: 767px) {
  .gb-product-archive .products {
    grid-template-columns: 1fr;
  }

  .gb-archive-toolbar {
    flex-direction: column;
  }

  .gb-archive-toolbar__search {
    width: 100%;
  }

  .gb-toast-container {
    left: var(--gb-space-3);
    right: var(--gb-space-3);
  }

  .gb-toast {
    min-width: auto;
    max-width: none;
  }
}

@media (min-width: 768px) and (max-width: 1023px) {
  .gb-product-archive .products {
    grid-template-columns: repeat(2, 1fr);
  }
}
