/* assets/csp-frontend.css
   Scoped, theme-friendly styles for CSP fields + summary
   (No PPOM selectors; keeps native radio markup)
------------------------------------------------------------------ */

/* Scope to product pages */
body.single-product .csp-fields-wrap {
  margin: 12px 0 16px;
}

/* Field block */
body.single-product .csp-field {
  margin: 10px 0 12px;
}
body.single-product .csp-field.csp-field-hidden {
  display: none !important;
}
body.single-product .csp-field.csp-field-frontend-hidden {
  display: none !important;
}
body.single-product .csp-field > label {
  display: block;
  margin: 0 0 6px;
  font-weight: 600;
  text-align: left;
}

/* Inputs */
body.single-product .csp-field input[type="text"],
body.single-product .csp-field input[type="number"],
body.single-product .csp-field input[type="file"],
body.single-product .csp-field select,
body.single-product .csp-field textarea {
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  padding: 10px;
  border: 2px solid #d6d6d6;
  border-radius: 6px;
  font-size: 14px;
  background: #fff;
}
body.single-product .csp-field textarea { min-height: 140px; }
body.single-product .csp-fields-wrap .csp-field select,
body.single-product .csp-field.csp-type-shape select {
  appearance: none;
  -webkit-appearance: none;
  padding-right: 38px;
  background-color: #fff;
  background-image: url("data:image/svg+xml,%3Csvg width='12' height='8' viewBox='0 0 12 8' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1.41 .59 6 5.17 10.59 .59 12 2 6 8 0 2z' fill='%23374151'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 12px 8px;
}
body.single-product .csp-fields-wrap .csp-field select::-ms-expand,
body.single-product .csp-field.csp-type-shape select::-ms-expand {
  display: none;
}
body.single-product .csp-fields-wrap .csp-field select:disabled,
body.single-product .csp-field.csp-type-shape select:disabled {
  background-color: #f3f4f6;
  color: #6b7280;
}

/* Radios / Checkboxes laid out as a tidy grid (native inputs kept) */
body.single-product .csp-field.csp-type-radio,
body.single-product .csp-field.csp-type-checkbox {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 8px;
}
body.single-product .csp-field.csp-type-radio > label:first-child,
body.single-product .csp-field.csp-type-checkbox > label:first-child {
  grid-column: 1 / -1;
  margin-bottom: 2px;
}
body.single-product label.csp-opt {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 5px;
  border: 2px solid #d6d6d6;
  border-radius: 8px;
  background: #fff;
  font-weight: 600;
  cursor: pointer;
  transition: border-color .15s ease, box-shadow .15s ease, background .15s ease;
}
body.single-product label.csp-opt:hover {
  border-color: #2b6cb0;
  box-shadow: 0 0 0 3px rgba(43,108,176,.12);
}
body.single-product label.csp-opt input[type="radio"],
body.single-product label.csp-opt input[type="checkbox"] {
  margin-left: 2px;
}
body.single-product label.csp-opt .csp-opt-text {
  flex: 1 1 auto;
}
body.single-product .csp-option-qty-wrap {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-left: auto;
  font-size: 13px;
  font-weight: 600;
}
body.single-product .csp-option-qty-wrap[hidden] {
  display: none !important;
}
body.single-product .csp-option-qty-input {
  width: 76px;
  min-height: 34px;
  padding: 4px 8px;
}
body.single-product .csp-option-qty-list {
  grid-column: 1 / -1;
  margin-top: 8px;
}
body.single-product .csp-option-qty-list .csp-option-qty-wrap {
  margin-left: 0;
}
body.single-product .csp-option-qty-error {
  border-color: #b32d2e !important;
  box-shadow: 0 0 0 1px #b32d2e;
}
body.single-product .csp-option-qty-warning {
  color: #b32d2e;
  font-size: 12px;
  margin-top: 4px;
}
body.single-product .csp-shape-option-unavailable {
  display: none !important;
}

/* Dimension fields visibility (shown only when variation is “Custom”) */
body.single-product .variations_form:not(.csp-custom-on) .csp-field.csp-dim,
body.single-product .variations_form:not(.csp-custom-on) .csp-field[data-dn$="_ft"],
body.single-product .variations_form:not(.csp-custom-on) .csp-field[data-dn$="_in"],
body.single-product .variations_form:not(.csp-custom-on) .csp-field[data-dn$="_inches"] {
  display: none;
}

/* Optional small feet readout */
body.single-product .csp-ft-readout {
  display: none;
  flex: 0 0 100%;
  max-width: 100%;
  box-sizing: border-box;
  margin: 8px 0 14px;
  padding: 12px 14px;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  background: #f7f7f8;
  color: #1f2937;
  text-align: center;
  font-size: 14px;
  line-height: 1.45;
}
body.single-product .variations_form.csp-custom-on .csp-ft-readout { display: block; }
body.single-product .csp-size-helper-box {
  display: block;
}
body.single-product .csp-size-helper-max {
  color: #4b5563;
  font-size: 13px;
  margin-bottom: 2px;
}
body.single-product .csp-size-helper-current {
  color: #111827;
  font-weight: 700;
  font-size: 15px;
}
body.single-product .csp-size-helper-rate {
  color: #6b7280;
  font-size: 13px;
  margin-top: 2px;
}

/* Relation validation helper */
body.single-product .csp-field.csp-type-relation {
  flex-basis: 100%;
  max-width: 100%;
}
body.single-product .csp-field.csp-type-relation > label {
  display: none;
}
body.single-product .csp-relation-rule {
  width: 100%;
}
body.single-product .csp-relation-helper {
  margin: 6px 0 10px;
  padding: 9px 11px;
  border: 1px solid #cfe8d8;
  border-radius: 6px;
  background: #f3fbf6;
  color: #276749;
  font-size: 13px;
  line-height: 1.4;
}
body.single-product .csp-relation-helper[hidden] {
  display: none !important;
}
body.single-product .csp-relation-helper-error {
  border-color: #f1b8b8;
  background: #fff5f5;
  color: #9b1c1c;
}
.csp-relation-field-warning {
  margin: 5px 0 0;
  color: #b42318;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.35;
}
body.single-product .csp-relation-input-error,
body.single-product .csp-field.csp-relation-invalid input[type="number"],
body.single-product .csp-field.csp-relation-invalid input[type="text"] {
  border-color: #c53030 !important;
  box-shadow: 0 0 0 2px rgba(197,48,48,.12);
}
body.single-product .csp-relation-button-blocked {
  opacity: .72;
}

/* Summary table */
body.single-product .csp-summary {
  margin: 10px 0 14px;
  border: 1px solid #e2e8f0;
  background: #f9fafb;
  border-radius: 8px;
  overflow: hidden;
  width: 100%;
}
body.single-product .csp-summary .csp-sum-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  border-bottom: 1px solid #edf2f7;
}
body.single-product .csp-summary .csp-sum-row:last-child { border-bottom: 0; }
body.single-product .csp-summary .csp-sum-label { font-weight: 500; }
body.single-product .csp-summary .csp-sum-amount { font-variant-numeric: tabular-nums; }
body.single-product .csp-summary .csp-sum-total { background: #fff; }
body.single-product .csp-summary .csp-sum-total .csp-sum-label,
body.single-product .csp-summary .csp-sum-total .csp-sum-amount { font-weight: 700; }

/* Minor spacing next to theme elements */
body.single-product .single_variation_wrap { margin-top: 8px; }

/* Responsive tweaks for radio/checkbox grids */
@media (max-width: 640px){
  body.single-product .csp-field.csp-type-radio,
  body.single-product .csp-field.csp-type-checkbox {
    grid-template-columns: 1fr;
  }
}

/* ------------------------------------------------------------------
   Compatibility: Elementor Add-to-Cart flex fix on variable products
   (Prevents quantity + button from being forced into one row)
------------------------------------------------------------------ */
body.single-product
  .elementor-widget-woocommerce-product-add-to-cart form.cart.variations_form .woocommerce-variation-add-to-cart,
body.single-product
  .elementor-widget-wc-add-to-cart form.cart.variations_form .woocommerce-variation-add-to-cart {
  display: block !important;
}

/* Optional: make the Add to Cart button full width beneath qty */
body.single-product .variations_form .woocommerce-variation-add-to-cart .single_add_to_cart_button {
  width: 100%;
}

/* -------------------------------------------------------------
   Column width utilities (flex with internal gutters = no overflow)
   This avoids the 50%+50%+gap overflow issue.
-------------------------------------------------------------- */
body.single-product .csp-fields-wrap {
  --csp-gutter: 10px;
  display: flex;
  flex-wrap: wrap;
  margin-left: calc(var(--csp-gutter) * -1);
  margin-right: calc(var(--csp-gutter) * -1);
}
body.single-product .csp-fields-wrap .csp-field {
  box-sizing: border-box;
  padding-left: var(--csp-gutter);
  padding-right: var(--csp-gutter);
  flex: 0 0 100%;
  max-width: 100%;
  min-width: 0;
}

/* Column sizes (12-grid) — exact percents, gutters are internal */
body.single-product .csp-fields-wrap .csp-field.col-12 { flex-basis: 100%;      max-width: 100%; }
body.single-product .csp-fields-wrap .csp-field.col-9  { flex-basis: 75%;       max-width: 75%;  }
body.single-product .csp-fields-wrap .csp-field.col-8  { flex-basis: 66.6667%;  max-width: 66.6667%; }
body.single-product .csp-fields-wrap .csp-field.col-6  { flex-basis: 50%;       max-width: 50%;  }
body.single-product .csp-fields-wrap .csp-field.col-4  { flex-basis: 33.3333%;  max-width: 33.3333%; }
body.single-product .csp-fields-wrap .csp-field.col-3  { flex-basis: 25%;       max-width: 25%;  }
body.single-product .csp-fields-wrap .csp-field.col-2  { flex-basis: 16.6667%;  max-width: 16.6667%; }

body.single-product .csp-fields-wrap .csp-field.csp-col-desktop-12 { flex-basis: 100%;      max-width: 100%; }
body.single-product .csp-fields-wrap .csp-field.csp-col-desktop-9  { flex-basis: 75%;       max-width: 75%;  }
body.single-product .csp-fields-wrap .csp-field.csp-col-desktop-8  { flex-basis: 66.6667%;  max-width: 66.6667%; }
body.single-product .csp-fields-wrap .csp-field.csp-col-desktop-6  { flex-basis: 50%;       max-width: 50%;  }
body.single-product .csp-fields-wrap .csp-field.csp-col-desktop-4  { flex-basis: 33.3333%;  max-width: 33.3333%; }
body.single-product .csp-fields-wrap .csp-field.csp-col-desktop-3  { flex-basis: 25%;       max-width: 25%;  }
body.single-product .csp-fields-wrap .csp-field.csp-col-desktop-2  { flex-basis: 16.6667%;  max-width: 16.6667%; }

body.single-product .csp-field.csp-type-radio.csp-options-cols-desktop-1,
body.single-product .csp-field.csp-type-checkbox.csp-options-cols-desktop-1 { grid-template-columns: 1fr; }
body.single-product .csp-field.csp-type-radio.csp-options-cols-desktop-2,
body.single-product .csp-field.csp-type-checkbox.csp-options-cols-desktop-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
body.single-product .csp-field.csp-type-radio.csp-options-cols-desktop-3,
body.single-product .csp-field.csp-type-checkbox.csp-options-cols-desktop-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
body.single-product .csp-field.csp-type-radio.csp-options-cols-desktop-4,
body.single-product .csp-field.csp-type-checkbox.csp-options-cols-desktop-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }

/* Make non-field blocks (like the summary) span full row in this layout */
body.single-product .csp-fields-wrap > .csp-summary,
body.single-product .csp-fields-wrap > .single_variation_wrap {
  flex: 0 0 100%;
  max-width: 100%;
}

/* Stack on small screens */
@media (max-width: 640px){
  body.single-product .csp-fields-wrap .csp-field[class*="col-"] {
    flex-basis: 100%;
    max-width: 100%;
  }
}

@media (max-width: 1024px){
  body.single-product .csp-fields-wrap .csp-field.csp-col-tablet-12 { flex-basis: 100%;      max-width: 100%; }
  body.single-product .csp-fields-wrap .csp-field.csp-col-tablet-9  { flex-basis: 75%;       max-width: 75%;  }
  body.single-product .csp-fields-wrap .csp-field.csp-col-tablet-8  { flex-basis: 66.6667%;  max-width: 66.6667%; }
  body.single-product .csp-fields-wrap .csp-field.csp-col-tablet-6  { flex-basis: 50%;       max-width: 50%;  }
  body.single-product .csp-fields-wrap .csp-field.csp-col-tablet-4  { flex-basis: 33.3333%;  max-width: 33.3333%; }
  body.single-product .csp-fields-wrap .csp-field.csp-col-tablet-3  { flex-basis: 25%;       max-width: 25%;  }
  body.single-product .csp-fields-wrap .csp-field.csp-col-tablet-2  { flex-basis: 16.6667%;  max-width: 16.6667%; }

  body.single-product .csp-field.csp-type-radio.csp-options-cols-tablet-1,
  body.single-product .csp-field.csp-type-checkbox.csp-options-cols-tablet-1 { grid-template-columns: 1fr; }
  body.single-product .csp-field.csp-type-radio.csp-options-cols-tablet-2,
  body.single-product .csp-field.csp-type-checkbox.csp-options-cols-tablet-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  body.single-product .csp-field.csp-type-radio.csp-options-cols-tablet-3,
  body.single-product .csp-field.csp-type-checkbox.csp-options-cols-tablet-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  body.single-product .csp-field.csp-type-radio.csp-options-cols-tablet-4,
  body.single-product .csp-field.csp-type-checkbox.csp-options-cols-tablet-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

@media (max-width: 767px){
  body.single-product .csp-fields-wrap .csp-field.csp-col-mobile-12 { flex-basis: 100%;      max-width: 100%; }
  body.single-product .csp-fields-wrap .csp-field.csp-col-mobile-9  { flex-basis: 75%;       max-width: 75%;  }
  body.single-product .csp-fields-wrap .csp-field.csp-col-mobile-8  { flex-basis: 66.6667%;  max-width: 66.6667%; }
  body.single-product .csp-fields-wrap .csp-field.csp-col-mobile-6  { flex-basis: 50%;       max-width: 50%;  }
  body.single-product .csp-fields-wrap .csp-field.csp-col-mobile-4  { flex-basis: 33.3333%;  max-width: 33.3333%; }
  body.single-product .csp-fields-wrap .csp-field.csp-col-mobile-3  { flex-basis: 25%;       max-width: 25%;  }
  body.single-product .csp-fields-wrap .csp-field.csp-col-mobile-2  { flex-basis: 16.6667%;  max-width: 16.6667%; }

  body.single-product .csp-field.csp-type-radio.csp-options-cols-mobile-1,
  body.single-product .csp-field.csp-type-checkbox.csp-options-cols-mobile-1 { grid-template-columns: 1fr; }
  body.single-product .csp-field.csp-type-radio.csp-options-cols-mobile-2,
  body.single-product .csp-field.csp-type-checkbox.csp-options-cols-mobile-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  body.single-product .csp-field.csp-type-radio.csp-options-cols-mobile-3,
  body.single-product .csp-field.csp-type-checkbox.csp-options-cols-mobile-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  body.single-product .csp-field.csp-type-radio.csp-options-cols-mobile-4,
  body.single-product .csp-field.csp-type-checkbox.csp-options-cols-mobile-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

/* ---------- CSP Uploader ---------- */
.csp-uploader{
  border:1px dashed #c3c4c7;
  background:#fbfbfc;
  border-radius:10px;
  padding:12px;
  position:relative;
}
.csp-uploader__drop{
  display:flex;
  align-items:center;
  justify-content:center;
  gap:10px;
  background:#fff;
  border:1px solid #e6e7ea;
  border-radius:8px;
  padding:14px;
  cursor:pointer;
  user-select:none;
  outline:none;
}
.csp-uploader__drop:hover{background:#f8f9fb}
.csp-uploader.is-dragover .csp-uploader__drop{border-color:#2271b1;background:#eef6ff}
.csp-uploader__icon{width:22px;height:22px;flex:0 0 22px;opacity:.75}
.csp-uploader__text{font-weight:600}
.csp-uploader__hint{margin-top:6px;font-size:12px;color:#6b7280;text-align:center}
.csp-uploader__list{list-style:none;margin:10px 0 0;padding:0;display:grid;gap:8px}
.csp-uploader__item{
  display:grid;
  grid-template-columns:44px 1fr auto;
  align-items:center;
  gap:10px;
  background:#fff;
  border:1px solid #e6e7ea;
  border-radius:8px;
  padding:8px;
}
.csp-uploader__thumb{width:44px;height:44px;border-radius:6px;object-fit:cover;background:#f1f1f1;display:block}
.csp-uploader__name{font-weight:600;word-break:break-all}
.csp-uploader__size{font-size:12px;color:#6b7280;margin-top:2px}
.csp-uploader__remove{display:inline-block;color:#a00;text-decoration:none;font-weight:700;padding:2px 8px;border-radius:6px}
.csp-uploader__remove:hover{background:#fbeaea}
.csp-uploader__clear{margin-top:5px !important;margin-right:16px !important;}
.csp-native-file{position:absolute !important;left:-9999px !important;width:1px;height:1px;overflow:hidden}

.single-product .quantity {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.single-product .quantity .csp-qty-label{
  display: inline-block;
  font-weight: 600;
}
.single-product .quantity .screen-reader-text{
  position: absolute !important;
  width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}

/* Show only the CSP price on single product pages */
.single-product .summary .price,
.single-product .single_variation .price,
.single-product .woocommerce-variation .price,
.single-product .woocommerce-variation-price .price { display:none !important; }

.single-product .summary .csp-managed-price { display:block !important; }
