/* -----------------------------
   Product Add-Ons (WooCommerce Product Add-Ons)
-------------------------------- */

:root {
  --gd-pao-border: rgba(97, 125, 122, 0.35); /* fallback for muted-sage */
}

@supports (color: color-mix(in srgb, black, white)) {
  :root {
    --gd-pao-border: color-mix(in srgb, var(--wp--preset--color--muted-sage) 45%, transparent);
  }
}

/* Woo form variable overrides scoped to Product Add-Ons only */
.single-product .wc-pao-addons-container {
  --wc-form-border-radius: 10px;
  --wc-form-border-color: rgba(97, 125, 122, 0.45); /* muted-sage tint */
  --wc-form-border-width: 1px;
}

.wc-pao-addon-description,
.wc-pao-addon-description p {
  font-style: normal; /* remove any inherited italics */
}

.wc-pao-addon-description p {
  margin: 0.25rem 0 0.75rem;
  padding-left: 0;      /* flush-left */
  line-height: 1.45;
}

.single-product .wc-pao-addon-description p {
  line-height: 1.6;
  margin: 0.35rem 0 0.9rem;
}

/* Download template button (Step 2)
   NOTE: Update markup to use <a class="gd-pao-download" ...> (no nested <button>) */
.wc-pao-addon-description .gd-pao-download {
  display: inline-block;
  text-decoration: none;
  color: #fff;
  background: var(--wp--preset--color--gold, #b79d62);
  padding: 9px 12px;
  border-radius: 10px;
  font-weight: 500;
  line-height: 1;
  margin: 0 0 8px 0;
  margin-left: 0;
}

.wc-pao-addon-description .gd-pao-download:hover,
.wc-pao-addon-description .gd-pao-download:focus-visible {
  filter: brightness(0.95);
  text-decoration: none;
}

.wc-pao-addon-wrap {
  margin-top: 6px;
  padding: 0;              /* ensure no wrapper padding */
}

/* File upload input – match old site “green choose file” + rounded field */
.single-product .wc-pao-addon-file-upload {
  width: 100%;
  max-width: 100%;
  height: 44px;
  box-sizing: border-box;

  border: var(--wc-form-border-width) solid var(--wc-form-border-color);
  border-radius: var(--wc-form-border-radius);
  background: #fff;

  padding: 0 !important;     /* override Woo padding */
  overflow: hidden;          /* clip inner file button to rounded corners */
}

/* Ensure green segment sits flush */
.single-product .wc-pao-addon-file-upload::file-selector-button,
.single-product .wc-pao-addon-file-upload::-webkit-file-upload-button {
  height: 44px;
  padding: 0 18px;
  border: 0;
  border-radius: var(--wc-form-border-radius) 0 0 var(--wc-form-border-radius);
  margin: 0;
  background: var(--wp--preset--color--sage);
  color: #fff;
  font-weight: 500;
  cursor: pointer;
}

.single-product .wc-pao-addon-file-upload:hover::file-selector-button {
  filter: brightness(0.95);
}

/* Remove any unexpected internal spacing from the input itself */
.wc-pao-addon-file-upload:focus {
  outline: none;
}

.wc-pao-addon-file-upload:focus-visible {
  outline: 2px solid rgba(0,0,0,0.3);
  outline-offset: 2px;
}

/* Helper text + clear link */
.wc-pao-addon-wrap small {
  display: block;
  margin-top: 6px;
  padding-left: 0;        /* remove 20px indent for file meta text */
  opacity: 0.8;
}

.wc-pao-addon-wrap .reset_file {
  padding-left: 20px;
  text-decoration: underline;
}

/* Textarea to match inputs */
.wc-pao-addon-custom-textarea {
  width: 100%;
  border-radius: var(--wc-form-border-radius);
  border: var(--wc-form-border-width) solid var(--wc-form-border-color);
  padding: 10px 12px;
}

/* Override Woo global padding for PAO file + textarea */
.single-product .wc-pao-addon-wrap input.input-text.wc-pao-addon-field,
.single-product .wc-pao-addon-wrap textarea.wc-pao-addon-custom-textarea {
  padding: 0; /* remove inherited Woo padding */
}

.single-product .wc-pao-addon-wrap textarea.wc-pao-addon-custom-textarea {
  padding: 12px 14px; /* controlled padding for textarea only */
}

/* Space between addon blocks (Step 2/3/4) */
.single-product .wc-pao-addon-container {
  margin-top: 28px; /* was ~22px; increase for clearer separation */
}

.single-product .wc-pao-addon-name {
  display: block;          /* instead of inline-block */
  padding-bottom: 20px;    /* match h3.wp-block-heading */
  margin: 0;               /* keep clean */
}

.single-product .wc-pao-addon-description {
  margin-bottom: 12px;
}

.single-product .wc-pao-addon-wrap {
  margin-top: 0;
  margin-bottom: 24px;
}

.single-product .wc-pao-addon-custom-textarea {
  border: var(--wc-form-border-width) solid var(--wc-form-border-color);
  border-radius: var(--wc-form-border-radius);
  padding: 12px 14px;
  min-height: 120px;
}

.single-product .wc-pao-addon-file-upload {
  padding: 0 !important;
}

/* Display-only cleanup for the Product Add-Ons summary near Add to Cart. */
.single-product #product-addons-total {
  clear: both;
  margin-top: 18px;
}

.single-product #product-addons-total .product-addon-totals {
  margin: 18px 0 22px;
  padding: 16px 0 0;
  border-top: 1px solid var(--gd-pao-border);
  border-bottom: 0;
  overflow: visible;
}

.single-product #product-addons-total .product-addon-totals.gd-pao-summary-has-details::before {
  content: "Personalization details";
  display: block;
  margin: 0 0 8px;
  color: rgba(0, 0, 0, 0.68);
  font-size: 0.82rem;
  font-weight: 700;
  line-height: 1.2;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.single-product #product-addons-total .product-addon-totals ul {
  display: grid;
  gap: 7px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.single-product #product-addons-total .product-addon-totals li {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px;
  align-items: baseline;
  padding: 0;
  line-height: 1.35;
}

.single-product #product-addons-total .wc-pao-col1,
.single-product #product-addons-total .wc-pao-col2 {
  min-width: 0;
}

.single-product #product-addons-total .wc-pao-col1 strong,
.single-product #product-addons-total .wc-pao-col2 strong {
  font-weight: 600;
}

.single-product #product-addons-total .gd-pao-summary-detail-row {
  grid-template-columns: minmax(0, 1fr);
  color: rgba(0, 0, 0, 0.76);
  font-size: 0.95rem;
}

.single-product #product-addons-total .product-addon-totals li:not(.gd-pao-summary-detail-row) + .gd-pao-summary-detail-row {
  margin-top: 7px;
}

.single-product #product-addons-total .gd-pao-summary-zero-cost-row .wc-pao-col2 {
  display: none;
}

.single-product #product-addons-total .gd-pao-summary-detail-row .wc-pao-col1 {
  display: block;
}

.single-product #product-addons-total .gd-pao-summary-detail-label {
  color: rgba(0, 0, 0, 0.58);
  font-size: 0.9em;
  font-weight: 600;
  margin-right: 0.35em;
}

.single-product #product-addons-total .gd-pao-summary-detail-value {
  display: inline;
  min-width: 0;
  overflow-wrap: anywhere;
  font-weight: 400;
}

.single-product #product-addons-total .product-addon-totals li.wc-pao-subtotal-line {
  display: flex;
  justify-content: flex-end;
  gap: 0;
  row-gap: 0;
  column-gap: 0;
  margin-top: 10px;
  padding-top: 17px;
  border-top: 1px solid rgba(0, 0, 0, 0.1);
  text-align: right;
}

.single-product div.product #product-addons-total .wc-pao-subtotal-line p.price,
.single-product #product-addons-total .wc-pao-subtotal-line strong {
  margin: 0;
  color: inherit;
  font-size: 1rem;
  font-weight: 700;
  line-height: 1.25;
}

@media (max-width: 520px) {
  .single-product .wc-pao-addons-container,
  .single-product .wc-pao-addon-container,
  .single-product .wc-pao-addon-wrap,
  .single-product .wc-pao-addon-description,
  .single-product .wc-pao-addon-description p {
    max-width: 100%;
    min-width: 0;
    box-sizing: border-box;
    overflow-wrap: anywhere;
  }

  .single-product .wc-pao-addon-wrap input,
  .single-product .wc-pao-addon-wrap select,
  .single-product .wc-pao-addon-wrap textarea,
  .single-product .wc-pao-addon-custom-textarea,
  .single-product .wc-pao-addon-file-upload {
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
  }

  .single-product .wc-pao-addon-description .gd-pao-download {
    max-width: 100%;
    white-space: normal;
    text-align: center;
  }

  .single-product .wc-pao-addon-wrap .reset_file {
    display: inline-block;
    max-width: 100%;
    padding-left: 0;
    overflow-wrap: anywhere;
  }

  .single-product #product-addons-total .product-addon-totals li {
    gap: 8px;
  }

  .single-product #product-addons-total .wc-pao-subtotal-line {
    justify-content: flex-start;
  }
}
