/**
 * GF-Woo UI Overrides
 * Hide native WooCommerce elements on product pages that use
 * Gravity Forms as the frontend layer.
 *
 * @package GFWoo_Core
 */

/* 1. Hide the static product price */
.single-product div.product .summary > p.price,
.single-product div.product .summary > span.price {
  display: none !important;
}

/* 2. Keep the native variation select active, but visually hidden */
.single-product form.variations_form table.variations {
  position: absolute !important;
  left: -99999px !important;
  top: auto !important;
  width: 1px !important;
  height: 1px !important;
  overflow: hidden !important;
}

/* 3. Hide helper blocks rendered by Woo for the variation */
.single-product form.variations_form .reset_variations,
.single-product form.variations_form .woocommerce-variation-description,
.single-product form.variations_form .woocommerce-variation-availability,
.single-product form.variations_form .woocommerce-variation-price {
  display: none !important;
}

/* 4. Empty state before the user picks a variation */
.gfwoo-variant-price.gfwoo-price-empty {
  font-style: italic;
  opacity: 0.5;
}

/* 5. Hide native add-to-cart button and quantity when GF form is assigned */
.gfwoo-has-form .single_add_to_cart_button {
  display: none !important;
}

/* 6. Keep native Woo quantity visible and align GF submit beside it */
.gfwoo-has-form .woocommerce-variation-add-to-cart,
.gfwoo-has-form form.cart {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 0;
  padding-top: 16px;
}

.gfwoo-has-form .woocommerce-variation-add-to-cart .quantity,
.gfwoo-has-form form.cart .quantity {
  display: block !important;
  margin: 0 !important;
  padding: 0 !important;
}

.gfwoo-has-form .gfwoo-submit-proxy {
  margin-left: 12px !important;
}

.gfwoo-has-form .gfwoo-submit-proxy .gfwoo-submit-proxy-button {
  margin: 0 !important;
}

.gfwoo-has-form .gfwoo-footer-hidden {
  display: none !important;
}

/* 7. List field placeholders: hide column labels only for opted-in GF List fields */
.gfield.gfwoo-list-placeholders .gfield_list thead {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

.gfield.gfwoo-list-placeholders .gfield_list td::before {
  display: none !important;
}

/* 8. Nested Forms table polish */
.gpnf-nested-entries-container {
  border: 1px solid var(--theme-form-field-border-initial-color);
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 16px;
}

.gpnf-nested-entries,
.table.gpnf-nested-entries {
  width: 100%;
  border-collapse: collapse;
  font-family: Rubik !important;
}

.gpnf-nested-entries {
  --theme-table-border-style: none;
  --theme-table-border-width: 0;
  --theme-table-border-color: transparent;
  border: none !important;
}

.gpnf-nested-entries thead tr {
  background: #f0f4f8;
  border-bottom: 2px solid #d9e2ec;
}

.gpnf-nested-entries thead th {
  font-family: Rubik !important;
  font-weight: 500 !important;
  font-size: 13px;
  color: #334e68;
  text-align: left;
  padding: 12px 16px;
  white-space: nowrap;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.gpnf-nested-entries tbody td {
  font-family: Rubik !important;
  font-weight: 300 !important;
  font-size: 14px;
  color: var(--theme-text-color);
  padding: 12px 16px;
  border-bottom: 1px solid #e8edf2;
}

.gpnf-nested-entries tbody tr:last-child td {
  border-bottom: none;
}

.gpnf-nested-entries tbody tr:hover td {
  background: #f7fafc;
}

.gpnf-nested-entries thead th:first-child,
.gpnf-nested-entries tbody td:first-child {
  padding-left: 20px;
  padding-right: 20px;
}

form.cart td:last-child,
form.cart th:last-child {
  padding-inline-end: 20px !important;
}

.gpnf-row-actions {
  width: 80px;
  text-align: center;
}

/* Turniej: ukryj niedzialajace akcje edycji w tabeli nested forms. */
.gpnf-row-actions .gpnf-edit-entry,
.gpnf-row-actions a[href*="gpnf-edit"] {
  display: none !important;
}

.gpnf-no-entries td {
  text-align: center;
  padding: 24px 16px !important;
  color: #829ab1;
  font-style: italic;
  font-weight: 300 !important;
}

.gpnf-add-entry.ct-button-ghost {
  margin: 20px 0 20px 20px;
}

.gpnf-add-entry-max {
  font-family: Rubik !important;
  font-size: 13px;
  color: #829ab1;
  margin-top: 8px;
}

/* 9. Generic Gravity Forms validation polish */
.gform_wrapper.gravity-theme .gfield_validation_message,
.gform_wrapper.gravity-theme .validation_message,
.gform_wrapper .gfield_description.validation_message {
  font-size: 13px;
  font-weight: 400 !important;
}

/* 10. Turnstile layout */
.gfwoo-turnstile-wrap {
  width: 100%;
  margin: 0 0 12px;
}

.gfwoo-turnstile-wrap .cf-turnstile {
  display: block;
  max-width: 300px;
}

.gform_wrapper .gform_footer,
.gform_wrapper .gform_page_footer {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  row-gap: 12px;
}

.gform_wrapper .gform_footer .gfwoo-turnstile-wrap,
.gform_wrapper .gform_page_footer .gfwoo-turnstile-wrap {
  flex: 0 0 100%;
}

.gform_wrapper .gform_footer input[type="submit"],
.gform_wrapper .gform_page_footer input[type="submit"] {
  margin-top: 0 !important;
}

/* 11. Image choice cards */
.ginput_container_image_choice .gfield_radio {
  display: flex !important;
  flex-wrap: nowrap !important;
  gap: 12px !important;
  justify-content: stretch !important;
}

.gform_wrapper.gravity-theme .ginput_container_image_choice .gchoice {
  flex: 1 1 0 !important;
  width: auto !important;
  margin: 0 !important;
  max-inline-size: 100% !important;
}

.gform_wrapper.gravity-theme .gfield-choice-input {
  display: none !important;
}

.ginput_container_image_choice .gfield-image-choice-wrapper-outer {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  width: 100%;
  min-height: 100%;
  padding: 16px;
  border: 1px solid var(--theme-form-field-border-initial-color);
  border-radius: 3px;
  background: #fff;
  box-sizing: border-box;
}

.gform_wrapper.gravity-theme .ginput_container_image_choice .gfield-choice-image-wrapper {
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  min-height: 120px;
  max-width: 100px !important;
  align-self: center;
  margin-bottom: 10px;
  margin-left: auto !important;
  margin-right: auto !important;
}

.ginput_container_image_choice .gfield-choice-image {
  display: block;
  max-width: 120px;
  max-height: 120px;
  width: auto;
  height: auto;
  object-fit: contain !important;
  margin: 0 auto;
}

.ginput_container_image_choice .gfield-image-choice-wrapper-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.ginput_container_image_choice .gfield-image-choice-wrapper-inner label {
  text-align: center;
  margin: 0;
  line-height: 1.4;
}

.ginput_container_image_choice .gchoice:hover .gfield-image-choice-wrapper-outer {
  border-color: #9fb3c8 !important;
  background: #fafbfc !important;
}

.ginput_container_image_choice .gchoice:has(input:checked) .gfield-image-choice-wrapper-outer {
  border-color: var(--theme-palette-color-3, #115679) !important;
  background-color: #fff !important;
}

.ginput_container_image_choice .gchoice input:checked + label,
.ginput_container_image_choice .gchoice input:checked ~ label {
  color: var(--theme-text-color) !important;
}

.ginput_container_image_choice .gchoice:has(input:checked) .gfield-image-choice-wrapper-outer::before {
  content: "Wybrane";
  position: absolute;
  top: 10px;
  right: 10px;
  padding: 3px 8px;
  border-radius: 999px;
  background: var(--theme-palette-color-3, #115679);
  color: #fff;
  font-size: 11px;
  font-weight: 500;
}

.ginput_container_image_choice .gchoice .gfield-choice-image-wrapper::after,
.ginput_container_image_choice .gchoice .gfield-image-choice-wrapper-outer::after {
  box-shadow: none !important;
}

.gform_wrapper.gravity-theme .ginput_container_image_choice .gchoice:where(:has(input:checked))::after {
  display: none !important;
}

.gform_wrapper.gravity-theme .ginput_container_image_choice .gchoice:where(:focus-within) .gfield-choice-image-wrapper::before {
  border-color: transparent !important;
}

/* 12. Responsive nested table */
@media (max-width: 640px) {
  .ginput_container_image_choice .gfield_radio {
    flex-wrap: wrap !important;
  }

  .gform_wrapper.gravity-theme .ginput_container_image_choice .gchoice {
    flex: 1 1 100% !important;
  }

  .ginput_container_radio .gfield_radio {
    flex-wrap: wrap !important;
    row-gap: 12px;
  }

  .gpnf-nested-entries thead {
    display: none;
  }

  .gpnf-nested-entries tbody td {
    display: block;
    padding: 10px 20px;
    text-align: left;
    border-bottom: 1px solid #e8edf2;
  }

  .gpnf-nested-entries tbody td::before {
    content: attr(data-heading);
    display: block;
    font-family: Rubik !important;
    font-weight: 500 !important;
    font-size: 11px;
    color: #334e68;
    text-transform: uppercase;
    letter-spacing: 0.02em;
    margin-bottom: 4px;
  }

  .gpnf-nested-entries tbody tr {
    border-bottom: 2px solid #d9e2ec;
    padding: 0;
  }

  .gpnf-nested-entries tbody td.gpnf-row-actions {
    width: 100% !important;
    border-bottom: none;
    padding-top: 12px;
  }

  .gpnf-nested-entries tbody td.gpnf-row-actions ul {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    list-style: none;
    margin: 0;
    padding: 0;
  }

  .gpnf-nested-entries tbody td.gpnf-row-actions::before {
    display: none;
  }
}

@media only screen and (max-width: 760px), (min-device-width: 760px) and (max-device-width: 1024px) {
  form:not(.gpnf-disable-responsive-table) .gpnf-nested-entries tr {
    border: 0 !important;
  }
}
