/* Shop Products Module - WooCommerce Vanilla Styling */
.mdms-csa-products {
  width: 100%;
  margin: 0 auto;
  font-family: inherit;
  /* Image fit theming variables (scoped to module root) */
  --mdms-image-object-fit: contain; /* options: contain (default), cover */
  --mdms-image-bg: #ffffff; /* letterbox/background color */
}

/* Search Widget */
.mdms-search-widget {
  margin-bottom: 30px;
}

.mdms-search-form {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-bottom: 15px;
}

.mdms-search-input {
  flex: 1;
  padding: 12px 16px;
  border: 2px solid #e5e5e5;
  border-radius: 4px;
  font-size: 15px;
  transition: border-color 0.3s ease;
}

.mdms-search-input:focus {
  outline: none;
  border-color: #007cba;
}

.mdms-search-input.searching {
  padding-right: 45px;
}

.mdms-search-loading {
  display: none;
  position: absolute;
  right: 15px;
  top: 50%;
  transform: translateY(-50%);
  width: 20px;
  height: 20px;
  border: 2px solid rgba(0, 124, 186, 0.2);
  border-top-color: #007cba;
  border-radius: 50%;
  animation: mdms-spin 0.6s linear infinite;
}

.mdms-search-loading.active {
  display: block;
}

.mdms-search-form {
  position: relative;
}

.mdms-search-button {
  padding: 12px 24px;
  background: #007cba;
  color: #fff;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 15px;
  font-weight: 600;
  transition: background 0.3s ease;
}

.mdms-search-button:hover {
  background: #005a87;
}

.mdms-search-clear {
  padding: 12px 20px;
  background: #f5f5f5;
  color: #333;
  border-radius: 4px;
  text-decoration: none;
  font-size: 14px;
  transition: background 0.3s ease;
}

.mdms-search-clear:hover {
  background: #e0e0e0;
}

.mdms-search-results-info {
  padding: 10px 15px;
  background: #e7f3ff;
  border-left: 4px solid #007cba;
  border-radius: 4px;
  font-size: 14px;
}

/* Category Filters */
.mdms-category-filters {
  margin-bottom: 25px;
  padding: 15px 0;
  border-bottom: 1px solid #e5e5e5;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.mdms-category-filter {
  display: inline-block;
  padding: 8px 16px;
  background: #f8f9fa;
  color: #495057;
  border: 1px solid #dee2e6;
  border-radius: 20px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.3s ease;
  text-decoration: none;
  white-space: nowrap;
  outline: none;
}

.mdms-category-filter:hover {
  background: #e9ecef;
  color: #495057;
  border-color: #adb5bd;
  text-decoration: none;
}

.mdms-category-filter.active {
  background: #007cba;
  color: white;
  border-color: #007cba;
}

.mdms-category-filter.active:hover {
  background: #005a87;
  border-color: #005a87;
}

/* Right-aligned view switch next to category filters */
.mdms-view-switch {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
}
.mdms-view-switch .mdms-view-btn {
  width: 34px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid #dee2e6;
  background: #f8f9fa;
  color: #495057;
  border-radius: 6px;
  cursor: pointer;
}
.mdms-view-switch .mdms-view-btn:hover {
  background: #e9ecef;
}
.mdms-view-switch .mdms-view-btn.active {
  background: #007cba;
  color: #fff;
  border-color: #007cba;
}
.mdms-view-switch .mdms-view-btn svg {
  display: block;
  fill: currentColor;
}
.mdms-visually-hidden {
  position: absolute !important;
  height: 1px;
  width: 1px;
  overflow: hidden;
  clip: rect(1px, 1px, 1px, 1px);
  white-space: nowrap;
}

.mdms-filter-results-info {
  padding: 10px 15px;
  margin-bottom: 20px;
  background: #f0f8ff;
  border-left: 4px solid #007cba;
  border-radius: 4px;
  font-size: 14px;
  color: #333;
}

@media (max-width: 480px) {
  .mdms-category-filters {
    justify-content: center;
  }

  .mdms-category-filter {
    font-size: 13px;
    padding: 6px 12px;
  }
}

.mdms-no-products {
  padding: 40px 20px;
  text-align: center;
  font-size: 16px;
  color: #666;
  background: #f9f9f9;
  border-radius: 4px;
}

/* Loading state for entire module */
.mdms-csa-products.mdms-loading {
  position: relative;
}

.mdms-csa-products.mdms-loading::before {
  content: "";
  position: absolute;
  top: 100px;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(255, 255, 255, 0.8);
  z-index: 10;
  pointer-events: none;
}

.mdms-csa-products.mdms-loading .products-grid {
  opacity: 0.5;
  pointer-events: none;
}

/* WooCommerce-style Product Grid */
.mdms-csa-products .products-grid {
  display: grid;
  row-gap: 25px; /* explicit row spacing between cards */
  column-gap: 18px; /* explicit column spacing between cards (15–20px target) */
  margin: 0;
  padding: 0;
  list-style: none;
}

/* Neutralize theme margins on direct grid children so row-gap controls spacing */
.mdms-csa-products .products-grid > * {
  margin: 0 !important;
}

/* Column layouts - Match WooCommerce default gaps and structure */
.mdms-csa-products.columns-2 .products-grid {
  grid-template-columns: repeat(2, 1fr);
}

.mdms-csa-products.columns-3 .products-grid {
  grid-template-columns: repeat(3, 1fr);
}

.mdms-csa-products.columns-4 .products-grid {
  grid-template-columns: repeat(4, 1fr);
}

.mdms-csa-products.columns-6 .products-grid {
  grid-template-columns: repeat(6, 1fr);
}

/* Auto columns option: min card width 260px, fill remaining space */
.mdms-csa-products.columns-auto .products-grid {
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
}

/* Center products when fewer items than columns */
.mdms-csa-products.center-products .products-grid {
  justify-content: center;
}
.mdms-csa-products.center-products.columns-2 .products-grid {
  grid-template-columns: repeat(auto-fit, minmax(0, calc(50% - 9px)));
}
.mdms-csa-products.center-products.columns-3 .products-grid {
  grid-template-columns: repeat(auto-fit, minmax(0, calc(33.333% - 12px)));
}
.mdms-csa-products.center-products.columns-4 .products-grid {
  grid-template-columns: repeat(auto-fit, minmax(0, calc(25% - 14px)));
}
.mdms-csa-products.center-products.columns-6 .products-grid {
  grid-template-columns: repeat(auto-fit, minmax(0, calc(16.666% - 15px)));
}

/* Responsive column overrides for grid layout only (not list) */
@media (max-width: 767px) {
  .mdms-csa-products:not(.layout-list):not(.columns-auto) .products-grid {
    grid-template-columns: 1fr; /* up to 767px: 1 column */
  }
}

@media (min-width: 768px) and (max-width: 991px) {
  .mdms-csa-products:not(.layout-list):not(.columns-auto) .products-grid {
    grid-template-columns: repeat(2, 1fr); /* 768–991px: 2 columns */
  }
  .mdms-csa-products.center-products:not(.layout-list):not(.columns-auto) .products-grid {
    grid-template-columns: repeat(auto-fit, minmax(0, calc(50% - 9px)));
  }
}

@media (min-width: 992px) and (max-width: 1399px) {
  .mdms-csa-products:not(.layout-list):not(.columns-auto) .products-grid {
    grid-template-columns: repeat(3, 1fr); /* 992–1399px: 3 columns */
  }
  .mdms-csa-products.center-products:not(.layout-list):not(.columns-auto) .products-grid {
    grid-template-columns: repeat(auto-fit, minmax(0, calc(33.333% - 12px)));
  }
}
/* ≥1400px: use default columns-* settings defined above */

/* Card container: unified structure for grid & list using CSS Grid + container queries */
.mdms-csa-products .product-item {
  background: #fff;
  position: relative;
  margin-bottom: 0; /* rely solely on row-gap for inter-row spacing */
  display: grid;
  grid-template-columns: 1fr;
  grid-template-areas:
    "image"
    "details"
    "cart";
  gap: 1em;
  container-type: inline-size; /* enable container queries */
}
.mdms-csa-products .product-item .product-image {
  grid-area: image;
}
.mdms-csa-products .product-item .product-details {
  grid-area: details;
}
.mdms-csa-products .product-item .product-cart-section {
  grid-area: cart;
}

/* Grid layout (default): pin cart section to bottom within the card */
.mdms-csa-products:not(.layout-list) .product-item {
  grid-template-rows: auto 1fr auto; /* image | details grows | cart at bottom */
  padding: 1.5em; /* match list view padding */
  border: 1px solid #e8e8e8; /* match list view border */
}

/* List layout: three-column card with image | details | cart */
.mdms-csa-products.layout-list .products-grid {
  display: grid;
  grid-template-columns: 1fr;
  row-gap: 25px; /* match requested row spacing */
  column-gap: 0; /* single column list: no horizontal gap needed */
}
.mdms-csa-products.layout-list .product-item {
  grid-template-columns: 150px 1fr auto;
  grid-template-areas: "image details cart";
  align-items: start;
  text-align: left;
  padding: 1.5em;
  border: 1px solid #e8e8e8;
}

/* Column 1: Product Image */
.mdms-csa-products.layout-list .product-image {
  margin-bottom: 0;
  width: 150px;
}

.mdms-csa-products.layout-list .product-image img {
  width: 100%;
  height: 100%;
}

/* Column 2: Product Details (Title + Full Description + Price) */
.mdms-csa-products.layout-list .product-details {
  display: flex;
  flex-direction: column;
  gap: 0.75em;
}

.mdms-csa-products.layout-list .product-title {
  text-align: left;
  font-size: 1.25em;
  font-weight: 600;
  margin: 0;
  line-height: 1.3;
}

.mdms-csa-products.layout-list .product-description {
  color: #666;
  font-size: 0.9em;
  line-height: 1.5;
  margin: 0;
}

.mdms-csa-products.layout-list .product-description p {
  margin: 0 0 0.5em 0;
}

.mdms-csa-products.layout-list .product-description p:last-child {
  margin-bottom: 0;
}

.mdms-csa-products.layout-list .product-price {
  text-align: left;
  font-size: 1.1em;
  font-weight: 600;
  margin: 0;
}

/* Column 3: Cart Section (Quantity + Add to Cart) */
.mdms-csa-products.layout-list .product-cart-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: 10px; /* match inline update controls spacing */
  width: 240px; /* widen to prevent add-to-cart combo overflow */
  align-self: center; /* center the whole cart column vertically in list rows */
}

.mdms-csa-products.layout-list .product-cart-section .cart {
  display: flex;
  flex-direction: row; /* place qty and add-to-cart side-by-side */
  align-items: center;
  justify-content: flex-start;
  gap: 10px; /* consistent with update combo */
  width: 100%;
  flex-wrap: nowrap;
}

.mdms-csa-products.layout-list .quantity {
  margin: 0;
  display: flex;
  justify-content: center;
}

.mdms-csa-products.layout-list .quantity input[type="number"] {
  width: 4em;
  text-align: center;
}

.mdms-csa-products.layout-list .add_to_cart_button {
  width: auto; /* avoid full-width expansion in list */
  text-align: center;
  padding: 0.7em 1em; /* align with Update button */
  border-radius: 6px; /* match card controls */
}

/* WooCommerce Product Image */
.mdms-csa-products .product-image {
  display: block;
  position: relative;
  margin-bottom: 0; /* rely on grid row-gap for inter-row spacing */
  overflow: hidden;
  /* Force square media area; height follows width across breakpoints */
  aspect-ratio: 1 / 1;
  background: var(--mdms-image-bg, #ffffff);
}

.mdms-csa-products .product-image a {
  display: block;
  width: 100%;
  height: 100%;
}

.mdms-csa-products .product-image img {
  width: 100%;
  height: 100%;
  display: block;
  margin: 0 auto;
  /* Default: show full image with letterboxing if not square */
  object-fit: var(--mdms-image-object-fit, contain);
  object-position: center center;
}

/* Badges */
.mdms-csa-products .mdms-badge {
  position: absolute;
  top: 10px;
  left: 10px;
  z-index: 2;
  display: inline-block;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 12px;
  line-height: 1;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
}

.mdms-csa-products .mdms-badge-oos {
  background: #a00;
  color: #fff;
}

/* In-cart badge */
.mdms-csa-products .mdms-badge-in-cart {
  background: #0f834d; /* Woo success green-ish */
  color: #fff;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.mdms-csa-products .mdms-badge-in-cart .mdms-badge-icon {
  display: inline-flex;
  align-items: center;
  line-height: 1;
}
.mdms-csa-products .mdms-badge-in-cart .mdms-badge-icon svg {
  width: 14px;
  height: 14px;
  display: block;
}

/* Card highlight when item is in cart */
.mdms-csa-products .product-item.is-in-cart {
  border: 1px solid #0f834d !important; /* ensure overrides base border */
  box-shadow: 0 0 0 2px rgba(15, 131, 77, 0.12) inset;
}

/* WooCommerce Product Details */
.mdms-csa-products .product-details {
  display: flex;
  flex-direction: column;
}

/* WooCommerce Product Title */
.mdms-csa-products .product-title {
  font-size: 1em;
  font-weight: 400;
  margin: 0 0 0.5em 0;
  line-height: 1.3;
  color: #43454b;
}

.mdms-csa-products .product-title a {
  color: inherit;
  text-decoration: none;
}

.mdms-csa-products .product-title a:hover {
  color: #000;
}

/* WooCommerce Product Description (both grid and list) */
.mdms-csa-products .product-description {
  margin-bottom: 1em;
  font-size: 0.9em;
  line-height: 1.4;
  color: #43454b;
  opacity: 0.8;
}

.mdms-csa-products .product-description p {
  margin: 0 0 0.5em 0;
}

.mdms-csa-products .product-description p:last-child {
  margin-bottom: 0;
}

/* Grid layout specific description styling */
.mdms-csa-products:not(.layout-list) .product-description p {
  /* Remove margins in grid layout to prevent unnecessary fade effects on short descriptions */
  margin: 0;
}

/* Grid layout specific description styling (truncate in grid) */
.mdms-csa-products:not(.layout-list) .product-description {
  /* Limit height for grid cards to maintain consistent card sizes */
  /* Increased to accommodate descriptions up to ~50 words (like Mini Cannolis description + buffer) */
  max-height: 6em;
  overflow: hidden;
  position: relative;
}

.mdms-csa-products:not(.layout-list) .product-description::after {
  /* Fade out effect for truncated content in grid */
  content: "";
  position: absolute;
  bottom: 0;
  right: 0;
  left: 0;
  height: 1em;
  background: linear-gradient(transparent, #fff);
  pointer-events: none;
}

/* WooCommerce Product Price */
.mdms-csa-products .product-price {
  color: #43454b;
  display: block;
  font-size: 1.25em;
  font-weight: 600;
  margin-bottom: 1em;
}

/* Stock status/quantity (uses Woo's .stock classes) */
.mdms-csa-products .stock {
  margin: 0 0 0.75em 0;
  font-size: 0.95em;
}

.mdms-csa-products .product-price del {
  color: rgba(67, 69, 75, 0.5);
  font-weight: 400;
  margin-right: 0.5em;
}

.mdms-csa-products .product-price ins {
  background: none;
  font-weight: 700;
  text-decoration: none;
}

/* WooCommerce Cart Form */
.mdms-csa-products .cart {
  margin-top: auto;
  display: block;
}

.mdms-csa-products .quantity {
  display: inline-block;
  margin: 0 0.5em 0.5em 0;
  vertical-align: top;
}

.mdms-csa-products .quantity input[type="number"],
.mdms-csa-products .mdms-cart-qty,
.mdms-csa-products input.qty {
  width: 78px; /* fits 3+ digits comfortably */
  padding: 0.618em;
  text-align: center;
  font-size: 1em;
  line-height: 1;
  border: 1px solid #d3ced2;
  background-color: #ffffff; /* unify base bg */
  color: #43454b;
  border-radius: 6px;
  box-shadow: none;
  margin-right: 0 !important; /* override ET global input margin */
}
/* prevent flicker on hover/focus where themes change bg/border */
.mdms-csa-products .quantity input[type="number"]:hover,
.mdms-csa-products .mdms-cart-qty:hover,
.mdms-csa-products input.qty:hover,
.mdms-csa-products .quantity input[type="number"]:focus,
.mdms-csa-products .mdms-cart-qty:focus,
.mdms-csa-products input.qty:focus {
  background-color: #ffffff;
  border-color: #d3ced2;
  outline: none;
  box-shadow: 0 0 0 2px rgba(0, 124, 186, 0.08);
}

/* WooCommerce Button Styling */
.mdms-csa-products .button,
.mdms-csa-products .add_to_cart_button {
  background-color: #007cba; /* align with site palette / mini-cart */
  border: 0;
  border-radius: 6px; /* keep rounded corners by default */
  color: #fff;
  cursor: pointer;
  display: inline-block;
  font-size: 1em;
  font-weight: 700;
  line-height: 1 !important; /* override Woo theme rule (1.7em !important) */
  margin: 0;
  overflow: visible;
  padding: 1em 1.41575em;
  position: relative;
  text-align: center;
  text-decoration: none;
  text-transform: none; /* keep natural casing: e.g., "Add to Cart" */
  transition: background-color 0.15s ease, color 0.15s ease,
    border-color 0.15s ease; /* avoid size animations */
  transform: none; /* neutralize theme scale animations */
  vertical-align: middle;
  white-space: nowrap;
  width: auto;
  box-sizing: border-box;
}

.mdms-csa-products .button:hover,
.mdms-csa-products .add_to_cart_button:hover {
  background-color: #005a87;
  color: #fff;
  text-decoration: none;
  transform: none; /* ensure no hover scale */
}

.mdms-csa-products .add_to_cart_button.loading {
  opacity: 0.25;
  cursor: not-allowed;
}

.mdms-csa-products .add_to_cart_button.added {
  background-color: #0f834d;
}

.mdms-csa-products .add_to_cart_button.added::after {
  content: "✓";
  margin-left: 0.5em;
}

/*
  Scoped resets so Woo/Theme styles don’t override our buttons inside
  product-card controls on Shop/Cart. Also mirror hover styles to avoid flicker.
*/
.mdms-csa-products .mdms-card-controls .button,
.mdms-csa-products .mdms-card-controls .button.button:disabled,
.mdms-csa-products .mdms-card-controls .button.button:disabled[disabled],
.mdms-csa-products .mdms-card-controls .button[aria-disabled="true"],
.mdms-csa-products .mdms-card-controls .button.alt,
.mdms-csa-products .mdms-card-controls .button.alt:disabled,
.mdms-csa-products .mdms-card-controls .button.alt:disabled[disabled],
.mdms-csa-products .mdms-card-controls input.button,
.mdms-csa-products .mdms-card-controls input.button:disabled,
.mdms-csa-products .mdms-card-controls input.button:disabled[disabled],
.mdms-csa-products .mdms-card-controls .add_to_cart_button,
.mdms-csa-products .mdms-card-controls .add_to_cart_button:disabled,
.mdms-csa-products .mdms-card-controls .add_to_cart_button:disabled[disabled],
.mdms-csa-products
  .mdms-card-controls
  .add_to_cart_button[aria-disabled="true"],
.mdms-csa-products .mdms-card-controls .add_to_cart_button.alt,
.mdms-csa-products .mdms-card-controls .add_to_cart_button.alt:disabled,
.mdms-csa-products
  .mdms-card-controls
  .add_to_cart_button.alt:disabled[disabled] {
  border: none !important;
  background-image: none !important;
  box-shadow: none !important;
  text-decoration: none !important;
  color: #fff !important;
  background-color: #007cba !important;
  padding: 0.7em 1em !important; /* match Update button size */
  border-radius: 6px !important; /* keep rounded corners */
  line-height: 1 !important;
  width: auto !important; /* avoid 100% width variants in list */
  transition: background-color 0.15s ease, color 0.15s ease,
    border-color 0.15s ease !important; /* no size animation */
  transform: none !important; /* prevent scale animations from theme */
  text-transform: none !important; /* ensure natural casing inside controls */
  font-weight: 600 !important; /* match Update button weight for consistency */
}
.mdms-csa-products .mdms-card-controls .button:hover,
.mdms-csa-products .mdms-card-controls .add_to_cart_button:hover,
.mdms-csa-products .mdms-card-controls .button.alt:hover,
.mdms-csa-products .mdms-card-controls .add_to_cart_button.alt:hover {
  color: #fff !important;
  background-color: #005a87 !important;
  border: none !important;
  box-shadow: none !important;
  padding: 0.7em 1em !important; /* keep size stable */
  border-radius: 6px !important; /* keep rounded corners on hover */
  transform: none !important;
}
.mdms-csa-products .mdms-card-controls .button:focus,
.mdms-csa-products .mdms-card-controls .add_to_cart_button:focus {
  outline: 2px solid rgba(0, 124, 186, 0.25);
  outline-offset: 2px;
}

/* Remove theme-added arrow pseudo-elements that cause width shifts/flicker */
.mdms-csa-products .mdms-card-controls .button::after,
.mdms-csa-products .mdms-card-controls .add_to_cart_button::after,
.mdms-csa-products .mdms-card-controls .button::before,
.mdms-csa-products .mdms-card-controls .add_to_cart_button::before,
.mdms-csa-products .mdms-card-controls .button:hover::after,
.mdms-csa-products .mdms-card-controls .add_to_cart_button:hover::after {
  content: none !important;
}

/* List layout: ensure Add to Cart matches Update size (no full-width) */
.mdms-csa-products.layout-list .product-cart-section .add_to_cart_button,
.mdms-csa-products.layout-list
  .product-cart-section
  .button.add_to_cart_button {
  width: auto !important;
  padding: 0.7em 1em !important;
  border-radius: 6px !important;
  line-height: 1 !important; /* ensure compact height in list view too */
}

/* Shared card-controls layout across modules (Shop & Cart) */
.mdms-card-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: nowrap;
}
.mdms-card-controls > * {
  margin: 0 !important; /* neutralize theme margins inside row */
}
.mdms-card-controls .quantity {
  margin: 0;
}
/* Prevent any size/scale animation on freshly swapped inline controls */
.mdms-csa-products .mdms-inline-cart-controls .button,
.mdms-csa-products .mdms-inline-cart-controls .mdms-cart-update-btn {
  transition: none !important;
  transform: none !important;
  padding: 0.7em 1em !important;
  border-radius: 6px !important;
  line-height: 1 !important;
}
/* Force consistent qty visuals next to Add to Cart and Update buttons */
.mdms-csa-products .mdms-card-controls .quantity input[type="number"],
.mdms-csa-products .mdms-card-controls input.qty,
.mdms-csa-products .mdms-card-controls .mdms-cart-qty {
  width: 78px !important;
  padding: 0.618em !important;
  text-align: center !important;
  font-size: 1em !important;
  line-height: 1 !important;
  border: 1px solid #d3ced2 !important;
  background-color: #ffffff !important;
  color: #43454b !important;
  border-radius: 6px !important;
  box-shadow: none !important;
  margin-right: 0 !important; /* neutralize ET input margin in controls */
}
.mdms-csa-products .mdms-card-controls input.qty:hover,
.mdms-csa-products .mdms-card-controls input.qty:focus,
.mdms-csa-products .mdms-card-controls .quantity input[type="number"]:hover,
.mdms-csa-products .mdms-card-controls .quantity input[type="number"]:focus,
.mdms-csa-products .mdms-card-controls .mdms-cart-qty:hover,
.mdms-csa-products .mdms-card-controls .mdms-cart-qty:focus {
  background-color: #ffffff !important;
  border-color: #d3ced2 !important;
  outline: none !important;
  box-shadow: 0 0 0 2px rgba(0, 124, 186, 0.08) !important;
}
.mdms-card-controls .mdms-cart-update-btn {
  padding: 0.7em 1em !important;
  background: #f5f5f5 !important;
  color: #222 !important;
  border-radius: 6px !important;
  border: 1px solid #e5e5e5 !important;
  text-transform: none !important; /* prevent uppercase from generic .button */
  font-weight: 600 !important; /* avoid extra bold size jump */
  box-shadow: none !important;
}
.mdms-card-controls .mdms-cart-update-btn:hover {
  /* mirror base to avoid hover flicker from theme */
  background: #f5f5f5 !important;
  color: #222 !important;
  border-color: #e5e5e5 !important;
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.02) !important;
}
.mdms-card-controls .mdms-cart-update-btn.is-dirty {
  background: #007cba !important;
  border-color: #007cba !important;
  color: #fff !important;
}
.mdms-card-controls .mdms-cart-update-btn.is-dirty:hover {
  background: #005a87 !important;
  border-color: #005a87 !important;
  color: #fff !important;
}
.mdms-card-controls .mdms-cart-remove {
  border: none;
  background: transparent;
  color: #f05a5a;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  padding: 0 2px;
  text-decoration: none !important;
}
.mdms-card-controls .mdms-cart-remove:hover {
  color: #d64545;
  transform: scale(1.06);
  text-decoration: none !important;
}
.mdms-card-controls .mdms-cart-remove:focus {
  outline: 2px solid rgba(0, 124, 186, 0.15);
  outline-offset: 2px;
  border-radius: 4px;
}

/* Temporary UI lock when preventing rapid add clicks */
.mdms-csa-products.mdms-add-locked .add_to_cart_button,
.mdms-csa-products.mdms-add-locked .mdms-add-to-cart {
  pointer-events: none; /* block clicks during short lock window */
  opacity: 1 !important; /* keep visuals unchanged across cards */
}

/* Inline spinner + badge when a button is busy (lock window) */
.mdms-csa-products .mdms-add-to-cart[aria-busy="true"],
.mdms-csa-products .add_to_cart_button[aria-busy="true"] {
  position: relative; /* anchor pseudo elements */
}

/* Spinner placed inside the button (right aligned) */
.mdms-csa-products .mdms-add-to-cart[aria-busy="true"]::before,
.mdms-csa-products .add_to_cart_button[aria-busy="true"]::before {
  content: "";
  position: absolute;
  top: 50%;
  right: 10px;
  transform: translateY(-50%);
  width: 12px;
  height: 12px;
  border: 2px solid #bbb;
  border-top-color: #888;
  border-radius: 50%;
  animation: mdms-spin 0.8s linear infinite;
}

/* "Adding…" pill sits to the right of the button when wrapped by .mdms-card-controls */
.mdms-csa-products .mdms-add-to-cart[aria-busy="true"]::after,
.mdms-csa-products .add_to_cart_button[aria-busy="true"]::after {
  content: "Adding…";
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  left: calc(100% + 8px);
  background: #f5f5f7;
  color: #444;
  border: 1px solid #ddd;
  border-radius: 10px;
  padding: 2px 8px;
  font-size: 11px;
  line-height: 1.4;
  white-space: nowrap;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

/* Container query: in wide cards (e.g., 560px+), auto arrange image|details|cart horizontally even in grid */
@container (min-width: 560px) {
  .mdms-csa-products:not(.layout-list) .product-item {
    grid-template-columns: 180px 1fr auto;
    grid-template-areas: "image details cart";
    align-items: start;
    text-align: left;
    padding: 1.5em; /* keep parity with list view */
    border: 1px solid #e8e8e8; /* keep parity with list view */
  }
  .mdms-csa-products:not(.layout-list) .product-image {
    width: 180px;
  }
  .mdms-csa-products:not(.layout-list) .product-title {
    text-align: left;
    font-size: 1.1em;
  }
}

/* Success check flash after unlock (triggered via JS class) */
.mdms-csa-products .mdms-add-to-cart.mdms-add-success,
.mdms-csa-products .add_to_cart_button.mdms-add-success {
  position: relative;
}
.mdms-csa-products .mdms-add-to-cart.mdms-add-success::after,
.mdms-csa-products .add_to_cart_button.mdms-add-success::after {
  content: "\2713"; /* ✓ */
  position: absolute;
  top: 50%;
  right: -20px; /* closer than the pill */
  transform: translateY(-50%);
  color: #0f834d;
  font-weight: 700;
  opacity: 0;
  animation: mdms-success-fade 0.6s ease forwards;
}

@keyframes mdms-spin {
  to {
    transform: rotate(360deg);
  }
}

@keyframes mdms-success-fade {
  0% {
    opacity: 0;
    transform: translateY(-50%) scale(0.9);
  }
  25% {
    opacity: 1;
    transform: translateY(-50%) scale(1);
  }
  100% {
    opacity: 0;
    transform: translateY(-50%) scale(0.98);
  }
}

/* WooCommerce Responsive Layout (columns overrides removed; handled above by new breakpoints and columns-auto) */

@media (max-width: 768px) {
  .mdms-csa-products .products-grid {
    row-gap: 25px; /* keep consistent row spacing on tablet */
    column-gap: 18px; /* maintain horizontal spacing when 2 cols present */
  }

  /* List layout tablet responsive - Adjust cart section */
  .mdms-csa-products.layout-list .product-item {
    grid-template-columns: 120px 1fr; /* image | (details+cart stacked) */
    grid-template-rows: auto auto;
    grid-template-areas:
      "image details"
      "image cart";
    gap: 1em;
    padding: 1em;
  }

  .mdms-csa-products.layout-list .product-image {
    width: 120px;
  }

  .mdms-csa-products.layout-list .product-cart-section {
    width: auto; /* allow cart to fill the right column */
    align-self: stretch; /* stretch within the right column */
    justify-content: flex-start;
    align-items: flex-start;
  }

  /* Keep controls inline on tablet, allow wrapping if space is tight */
  .mdms-csa-products.layout-list .product-cart-section .cart {
    flex-direction: row;
    align-items: center;
    justify-content: flex-start;
    flex-wrap: wrap;
    gap: 0.75em 0.5em;
  }

  .mdms-csa-products.layout-list .product-description {
    font-size: 0.85em;
  }
}

@media (max-width: 480px) {
  .mdms-search-form {
    flex-direction: column;
  }

  .mdms-search-input,
  .mdms-search-button,
  .mdms-search-clear {
    width: 100%;
  }

  /* List layout mobile responsive - Stack to single column */
  .mdms-csa-products.layout-list .product-item {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto auto;
    grid-template-areas:
      "image"
      "details"
      "cart";
    text-align: center;
    gap: 1em;
  }

  .mdms-csa-products.layout-list .product-image {
    width: 200px;
    justify-self: center;
  }

  .mdms-csa-products.layout-list .product-details {
    text-align: center;
  }

  .mdms-csa-products.layout-list .product-title,
  .mdms-csa-products.layout-list .product-price {
    text-align: center;
  }

  .mdms-csa-products.layout-list .product-description {
    text-align: left;
  }

  .mdms-csa-products.layout-list .product-cart-section {
    width: 100%;
    align-items: center;
    justify-self: center;
  }

  /* On mobile, stack qty and button vertically for better fit */
  .mdms-csa-products.layout-list .product-cart-section .cart {
    flex-direction: column;
    align-items: center;
  }
}

/* Pagination Styles */
.mdms-pagination {
  margin-top: 40px;
  padding-top: 30px;
  border-top: 1px solid #e5e5e5;
}

/* Numbered pagination */
.mdms-pagination .page-numbers {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  list-style: none;
  margin: 0;
  padding: 0;
  flex-wrap: wrap;
}

.mdms-pagination .page-numbers li {
  margin: 0;
}

.mdms-pagination .page-numbers a,
.mdms-pagination .page-numbers span {
  display: inline-block;
  padding: 10px 16px;
  min-width: 44px;
  text-align: center;
  border: 1px solid #e5e5e5;
  border-radius: 4px;
  color: #333;
  text-decoration: none;
  transition: all 0.3s ease;
  font-size: 14px;
  font-weight: 500;
}

.mdms-pagination .page-numbers a:hover {
  background: #007cba;
  color: #fff;
  border-color: #007cba;
}

.mdms-pagination .page-numbers .current {
  background: #007cba;
  color: #fff;
  border-color: #007cba;
}

.mdms-pagination .page-numbers .dots {
  border: none;
  pointer-events: none;
}

.mdms-pagination .page-numbers .prev,
.mdms-pagination .page-numbers .next {
  padding: 10px 20px;
  min-width: auto;
}

/* Load More Button */
.mdms-load-more {
  display: block;
  width: 100%;
  max-width: 300px;
  margin: 0 auto;
  padding: 14px 28px;
  background: #007cba;
  color: #fff;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 16px;
  font-weight: 600;
  transition: background 0.3s ease;
}

.mdms-load-more:hover {
  background: #005a87;
}

.mdms-load-more.loading {
  opacity: 0.6;
  pointer-events: none;
  position: relative;
}

.mdms-load-more.loading::after {
  content: "";
  position: absolute;
  right: 20px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: mdms-spin 0.6s linear infinite;
}

@keyframes mdms-spin {
  to {
    transform: translateY(-50%) rotate(360deg);
  }
}

/* Add to cart toast */
.mdms-toast {
  position: fixed;
  left: 50%;
  bottom: 30px;
  transform: translateX(-50%) translateY(20px);
  background: #1f2937; /* slate-800 */
  color: #fff;
  padding: 12px 18px;
  border-radius: 8px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
  opacity: 0;
  z-index: 9999;
  transition: opacity 0.25s ease, transform 0.25s ease;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
}

.mdms-toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.mdms-toast .mdms-toast-icon {
  width: 18px;
  height: 18px;
  display: inline-block;
  border-radius: 50%;
  background: #10b981; /* emerald-500 */
  position: relative;
}

.mdms-toast .mdms-toast-icon::after {
  content: "";
  position: absolute;
  left: 5px;
  top: 2px;
  width: 6px;
  height: 10px;
  border: solid #fff;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

/* Pagination responsive */
@media (max-width: 480px) {
  .mdms-pagination .page-numbers a,
  .mdms-pagination .page-numbers span {
    padding: 8px 12px;
    min-width: 36px;
    font-size: 13px;
  }

  .mdms-pagination .page-numbers .prev,
  .mdms-pagination .page-numbers .next {
    padding: 8px 12px;
  }
}

/* CSA Products Toast Notification */
.mdms-csa-toast {
  position: fixed;
  top: 20px;
  right: 20px;
  background: #10b981;
  color: white;
  padding: 12px 20px;
  border-radius: 8px;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
  opacity: 0;
  transform: translateX(100%);
  z-index: 99999;
  transition: opacity 0.3s ease, transform 0.3s ease;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  font-weight: 500;
  max-width: 350px;
}

.mdms-csa-toast.show {
  opacity: 1;
  transform: translateX(0);
}

.mdms-csa-toast svg {
  flex-shrink: 0;
}

/* CSA Products Lock State */
.mdms-csa-products.mdms-add-locked .mdms-add-to-cart {
  pointer-events: none;
  opacity: 0.7;
}

/* CSA Products Loading State */
.mdms-csa-products .mdms-add-to-cart.loading {
  position: relative;
  color: transparent !important;
}

.mdms-csa-products .mdms-add-to-cart.loading::after {
  content: "";
  position: absolute;
  width: 16px;
  height: 16px;
  top: 50%;
  left: 50%;
  margin-left: -8px;
  margin-top: -8px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: mdms-spin 0.6s linear infinite;
}

/* In Cart Notice styling */
.mdms-csa-products .mdms-in-cart-notice {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.mdms-csa-products .mdms-cart-remove {
  color: #dc2626;
  text-decoration: none;
  font-size: 14px;
  cursor: pointer;
}

.mdms-csa-products .mdms-cart-remove:hover {
  text-decoration: underline;
}

/* CSA In-Cart Controls (View Cart / Remove) */
.mdms-csa-products .mdms-csa-in-cart {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.mdms-csa-products .mdms-view-cart-btn {
  display: inline-block;
}

.mdms-csa-products .mdms-csa-in-cart .mdms-cart-remove {
  color: #dc2626;
  text-decoration: none;
  font-size: 14px;
  cursor: pointer;
}

.mdms-csa-products .mdms-csa-in-cart .mdms-cart-remove:hover {
  text-decoration: underline;
}

/* Enrollment Notice for CSA shares not yet available */
.mdms-csa-products .mdms-enrollment-notice {
  margin-bottom: 10px;
  padding: 8px 12px;
  background: #fff7ed;
  border-left: 3px solid #f59e0b;
  border-radius: 4px;
  font-size: 13px;
}

.mdms-csa-products .mdms-enrollment-notice .enrollment-status {
  color: #92400e;
  font-weight: 500;
}

/* Style the button when enrollment is not open */
.mdms-csa-products .mdms-read-more {
  display: inline-block;
  width: 100%;
  text-align: center;
  background: #e5e7eb;
  color: #4b5563;
  border: none;
}

.mdms-csa-products .mdms-read-more:hover {
  background: #d1d5db;
  color: #374151;
}

/* Enrollment Status Badges */
.mdms-csa-products .product-image .mdms-badge-enrollment {
  position: absolute;
  top: auto;
  bottom: 10px;
  left: 10px;
  padding: 4px 10px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  z-index: 2;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
  line-height: 1;
}

.mdms-csa-products .mdms-badge-enrollment-open {
  background: #dcfce7;
  color: #166534;
}

.mdms-csa-products .mdms-badge-enrollment-closed {
  background: #fee2e2;
  color: #991b1b;
}

.mdms-csa-products .mdms-badge-enrollment-scheduled {
  background: #fef3c7;
  color: #92400e;
}
