/**
 * Ngenic Partner Orders - Accessible Scoped Order Form Styles
 *
 * Scoped to .ngpo-order (and companion .ngpo-order-form).
 * Aligned with finalized markup from includes/render-form.php:
 * - Outer section: section.ngpo-order
 * - Heading: h2.ngpo-title, .ngpo-partner-logo, .ngpo-logo
 * - Result container: div.ngpo-result (inside form or .ngpo-order-form--sent)
 * - Form: form.ngpo-order-form (success: div.ngpo-order-form--sent)
 * - Fieldsets: fieldset.ngpo-fieldset (.ngpo-group-plan, .ngpo-group-accessories, .ngpo-group-delivery, .ngpo-customer, .ngpo-reference)
 * - Choices: label.ngpo-option-card with .ngpo-option-title, .ngpo-price-main, .ngpo-price-sub
 * - Text fields: div.ngpo-field-group, div.ngpo-field-row
 * - Totals: div.ngpo-totals-card with div.ngpo-totals-row (.ngpo-totals-row--highlight)
 * - Error: p.ngpo-field-error, .ngpo-has-error
 * - Button: button.ngpo-button.ngpo-submit (pill CTA, dark ink on brand amber)
 */

/* -------------------------------------------------------------------------
   CSS Custom Properties & Base Scoping (.ngpo-order)
   ------------------------------------------------------------------------- */
.ngpo-order {
  --ngpo-font-heading: 'Mohave', 'Ngenic Display', Kanit, Saira, Archivo, system-ui, sans-serif;
  --ngpo-font-body: Lato, 'Source Sans 3', 'Segoe UI', system-ui, sans-serif;

  /* Match the site's charcoal, warm-neutral surfaces and amber actions. */
  --ngpo-ink-body: #333333;
  --ngpo-ink-muted: #77736f;
  --ngpo-ink-on-light: #333333;

  --ngpo-surface: #ffffff;
  --ngpo-surface-subtle: #f6f4f3;
  --ngpo-surface-card: #ffffff;
  --ngpo-surface-selected: #f5f6f7;

  --ngpo-border: #7a858e;
  --ngpo-border-hover: #59636b;
  --ngpo-border-selected: #333333;
  --ngpo-focus-ring: #333333;

  --ngpo-amber-brand: #ffca50;
  --ngpo-amber-hover: #f6bd3e;
  --ngpo-amber-ink: #2e2e2c;

  --ngpo-error-ink: #7f1d1d;
  --ngpo-error-surface: #fef2f2;
  --ngpo-error-border: #f87171;
  --ngpo-compat-error-border: var(--ngpo-error-border);
  --ngpo-compat-error-shadow: 0 3px 12px rgba(185, 28, 28, 0.14);

  --ngpo-success-ink: #333333;
  --ngpo-success-surface: #fffaf0;
  --ngpo-success-border: #f3dfa6;
  --ngpo-success-accent: #8a6200;

  --ngpo-radius-input: 12px;
  --ngpo-radius-card: 12px;
  --ngpo-radius-pill: 9999px;
  --ngpo-control-min-height: 48px;

  box-sizing: border-box;
  font-family: var(--ngpo-font-body);
  color: var(--ngpo-ink-body);
  line-height: 1.5;
  font-size: 16px;
  max-width: 680px;
  margin: 0 auto;
  padding: 0 16px;
}

.ngpo-order *,
.ngpo-order *::before,
.ngpo-order *::after {
  box-sizing: border-box;
}

/* -------------------------------------------------------------------------
   Header & Title Elements
   ------------------------------------------------------------------------- */
.ngpo-order .ngpo-partner-logo {
  display: flex;
  margin-bottom: 24px;
}

.ngpo-order .ngpo-partner-logo--left {
  justify-content: flex-start;
}

.ngpo-order .ngpo-partner-logo--center {
  justify-content: center;
}

.ngpo-order .ngpo-partner-logo--right {
  justify-content: flex-end;
}

.ngpo-order .ngpo-logo {
  max-width: 100%;
  width: auto;
  height: auto;
  max-height: 56px;
  display: block;
}

/* A configured width replaces the default height cap; height follows the image's aspect ratio. */
.ngpo-order .ngpo-partner-logo--sized .ngpo-logo {
  width: min(var(--ngpo-logo-min-width), 100%);
  max-height: none;
}

.ngpo-order .ngpo-partner-logo--full-width .ngpo-logo {
  width: 100%;
  height: auto;
  max-height: none;
}

.ngpo-order .ngpo-title {
  font-family: var(--ngpo-font-heading);
  font-size: 24px;
  font-weight: 600;
  font-style: italic;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  color: var(--ngpo-ink-body);
  margin: 0 0 12px 0;
  line-height: 1.25;
}

.ngpo-order .ngpo-campaign {
  margin-bottom: 32px;
  padding: 20px;
  border-radius: var(--ngpo-radius-card);
  background: var(--ngpo-surface-subtle);
  overflow-wrap: anywhere;
}

.ngpo-order .ngpo-campaign-heading {
  margin: 0;
  font-family: var(--ngpo-font-body);
  font-size: 24px;
  font-weight: 700;
  line-height: 1.3;
}

.ngpo-order .ngpo-campaign-text {
  margin: 0;
}

.ngpo-order .ngpo-campaign-heading + .ngpo-campaign-text {
  margin-top: 8px;
}

.ngpo-order .ngpo-campaign-text p {
  margin: 0 0 12px 0;
}

.ngpo-order .ngpo-campaign-text > :first-child {
  margin-top: 0;
}

.ngpo-order .ngpo-campaign-text > :last-child {
  margin-bottom: 0;
}

.ngpo-order .ngpo-campaign-text ul,
.ngpo-order .ngpo-campaign-text ol {
  margin: 0 0 12px 0;
  padding-left: 20px;
}

.ngpo-order .ngpo-campaign-text li + li {
  margin-top: 4px;
}

.ngpo-order .ngpo-campaign-text strong,
.ngpo-order .ngpo-campaign-text b {
  font-weight: 700;
}

.ngpo-order .ngpo-campaign-text a {
  color: var(--ngpo-ink-body);
  text-decoration: underline;
  text-underline-offset: 2px;
  font-weight: 500;
}

.ngpo-order .ngpo-campaign-text a:hover {
  color: var(--ngpo-ink-on-light);
}

.ngpo-order .ngpo-campaign-text a:focus-visible {
  outline: 2px solid var(--ngpo-focus-ring);
  outline-offset: 2px;
}

.ngpo-order .ngpo-vat-label {
  font-size: 14px;
  color: var(--ngpo-ink-muted);
  margin: 0 0 24px 0;
}

/* -------------------------------------------------------------------------
   Result Region (div.ngpo-result inside form or .ngpo-order-form--sent)
   ------------------------------------------------------------------------- */
.ngpo-order .ngpo-result {
  margin-bottom: 24px;
  border-radius: var(--ngpo-radius-input);
  font-size: 15px;
  line-height: 1.5;
  transition: opacity 0.2s ease;
}

.ngpo-order .ngpo-result:empty,
.ngpo-order .ngpo-result[hidden] {
  display: none !important;
}

.ngpo-order .ngpo-result:focus {
  outline: none;
  outline-offset: 0;
}

.ngpo-order .ngpo-result--success {
  background-color: var(--ngpo-success-surface);
  border: 1px solid var(--ngpo-success-border);
  border-radius: 16px;
  color: var(--ngpo-success-ink);
  padding: 28px 24px 24px;
  text-align: center;
}

.ngpo-order .ngpo-result--error {
  background-color: var(--ngpo-error-surface);
  border: 1.5px solid var(--ngpo-error-border);
  color: var(--ngpo-error-ink);
  padding: 20px 24px;
}

.ngpo-order .ngpo-result-kicker {
  color: var(--ngpo-success-accent);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin: 0 0 8px 0;
}

.ngpo-order .ngpo-result-message {
  font-weight: 700;
  font-size: 16px;
  margin: 0 0 8px 0;
}

.ngpo-order .ngpo-result--success .ngpo-result-message {
  max-width: 460px;
  margin: 0 auto 14px;
}

.ngpo-order .ngpo-result-ack {
  font-size: 14px;
  margin: 4px 0 8px 0;
}

.ngpo-order .ngpo-result--success .ngpo-result-ack {
  display: inline-block;
  font-size: 13px;
  margin: 0;
}

.ngpo-order .ngpo-result-summary {
  margin-top: 20px;
  padding-top: 20px;
  border-top: 1px solid var(--ngpo-success-border);
  text-align: left;
}

.ngpo-order .ngpo-result-summary-title {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin: 0 0 10px 0;
}

.ngpo-order .ngpo-result-totals {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
}

.ngpo-order .ngpo-result-total {
  display: flex;
  flex-direction: column;
  gap: 2px;
  background-color: var(--ngpo-surface);
  border: 1px solid var(--ngpo-border);
  border-radius: var(--ngpo-radius-card);
  padding: 14px 16px;
}

.ngpo-order .ngpo-result-total-label {
  font-size: 13px;
  font-weight: 600;
}

.ngpo-order .ngpo-result-total-value {
  font-family: var(--ngpo-font-heading);
  font-size: 24px;
  font-weight: 600;
  font-style: italic;
  text-transform: uppercase;
  line-height: 1.2;
}

.ngpo-order .ngpo-result-vat {
  color: var(--ngpo-ink-muted);
  font-size: 13px;
  text-align: center;
  margin: 10px 0 0 0;
}

.ngpo-order .ngpo-result-contact {
  font-size: 14px;
  margin: 8px 0 0 0;
}

.ngpo-order .ngpo-result-contact a {
  color: inherit;
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.ngpo-order .ngpo-error-list {
  margin: 12px 0 0 0;
  padding-left: 20px;
  font-size: 14px;
  list-style-type: disc;
}

.ngpo-order .ngpo-error-list li {
  margin-bottom: 4px;
}

.ngpo-order .ngpo-error-list a {
  color: var(--ngpo-error-ink);
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 2px;
}

/* Success wrapper: hides remaining form controls so only success notice displays */
.ngpo-order .ngpo-order-form--sent > *:not([data-ngpo-result]) {
  display: none !important;
}

/* -------------------------------------------------------------------------
   Fieldsets (.ngpo-fieldset)
   ------------------------------------------------------------------------- */
.ngpo-order .ngpo-fieldset {
  border: 0;
  margin: 0 0 32px 0;
  padding: 0;
  min-inline-size: 0;
}

.ngpo-order .ngpo-fieldset legend {
  display: block;
  font-family: var(--ngpo-font-heading);
  font-size: 18px;
  font-weight: 600;
  font-style: italic;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  color: var(--ngpo-ink-body);
  margin-bottom: 14px;
  padding: 0;
  width: 100%;
}

.ngpo-order .ngpo-fieldset legend .ngpo-required {
  font-family: var(--ngpo-font-body);
  font-size: 13px;
  font-weight: 400;
  color: var(--ngpo-ink-muted);
  text-transform: none;
  letter-spacing: normal;
  margin-left: 6px;
}

/* -------------------------------------------------------------------------
   Option Cards (label.ngpo-option-card) - Plans, Accessories, Delivery
   ------------------------------------------------------------------------- */
.ngpo-order .ngpo-plans-grid,
.ngpo-order .ngpo-options-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 14px;
  margin-bottom: 10px;
}

.ngpo-order label.ngpo-option-card {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  position: relative;
  background-color: var(--ngpo-surface-card);
  border: 1.5px solid var(--ngpo-border);
  border-radius: var(--ngpo-radius-card);
  padding: 18px 20px;
  min-height: 56px;
  cursor: pointer;
  transition: border-color 0.2s ease, background-color 0.2s ease, box-shadow 0.2s ease;
  margin: 0;
}

.ngpo-order label.ngpo-option-card:hover {
  border-color: var(--ngpo-border-hover);
  background-color: var(--ngpo-surface-subtle);
}

.ngpo-order label.ngpo-option-card:has(input:checked) {
  border-color: var(--ngpo-border-selected);
  background-color: var(--ngpo-surface-selected);
  box-shadow: 0 0 0 1px var(--ngpo-border-selected);
}

.ngpo-order label.ngpo-option-card:has(input:focus-visible) {
  outline: 2px solid var(--ngpo-focus-ring);
  outline-offset: 2px;
}

.ngpo-order label.ngpo-option-card input[type="radio"],
.ngpo-order label.ngpo-option-card input[type="checkbox"] {
  position: absolute;
  top: 18px;
  right: 18px;
  margin: 0;
  width: 20px;
  height: 20px;
  min-height: 20px;
  accent-color: var(--ngpo-ink-body);
  cursor: pointer;
}

.ngpo-order label.ngpo-option-card input[type="radio"]:focus,
.ngpo-order label.ngpo-option-card input[type="checkbox"]:focus {
  outline: none;
}

.ngpo-order .ngpo-option-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding-right: 32px;
  margin-bottom: 8px;
}

.ngpo-order .ngpo-option-title {
  font-weight: 700;
  font-size: 16px;
  color: var(--ngpo-ink-body);
  line-height: 1.3;
}

.ngpo-order .ngpo-option-pricing {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.ngpo-order .ngpo-price-main {
  font-size: 17px;
  font-weight: 700;
  color: var(--ngpo-ink-on-light);
}

.ngpo-order .ngpo-price-sub {
  font-size: 13px;
  font-weight: 400;
  color: var(--ngpo-ink-muted);
}

/* -------------------------------------------------------------------------
   Totals Card (div.ngpo-totals-card, div.ngpo-totals-row)
   ------------------------------------------------------------------------- */
.ngpo-order .ngpo-totals-card {
  background-color: var(--ngpo-surface-subtle);
  border: 1.5px solid var(--ngpo-border);
  border-radius: var(--ngpo-radius-card);
  padding: 22px 24px;
  margin: 32px 0;
}

.ngpo-order .ngpo-totals-title {
  font-family: var(--ngpo-font-heading);
  font-size: 18px;
  font-weight: 600;
  font-style: italic;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin: 0 0 16px 0;
  color: var(--ngpo-ink-body);
}

.ngpo-order .ngpo-totals-card dl {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 0;
  padding: 0;
}

.ngpo-order .ngpo-totals-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 6px 0;
  border-bottom: 1px solid rgba(0, 0, 0, 0.06);
  font-size: 15px;
}

.ngpo-order .ngpo-totals-row:last-child {
  border-bottom: none;
}

.ngpo-order .ngpo-totals-row--highlight {
  font-size: 18px;
  font-weight: 700;
  padding-top: 10px;
  margin-top: 2px;
}

.ngpo-order .ngpo-totals-card dt {
  color: var(--ngpo-ink-body);
  margin: 0;
}

.ngpo-order .ngpo-totals-card dd {
  font-weight: 700;
  color: var(--ngpo-ink-on-light);
  font-variant-numeric: tabular-nums;
  margin: 0;
  text-align: right;
}

/* -------------------------------------------------------------------------
   Customer Details & Fields (div.ngpo-field-group, div.ngpo-field-row)
   ------------------------------------------------------------------------- */
.ngpo-order .ngpo-field-row {
  display: flex;
  gap: 16px;
  margin-bottom: 18px;
}

.ngpo-order .ngpo-field-group {
  flex: 1;
  display: flex;
  flex-direction: column;
  margin-bottom: 18px;
  min-width: 0;
}

.ngpo-order .ngpo-field-row .ngpo-field-group {
  margin-bottom: 0;
}

.ngpo-order .ngpo-field-group label,
.ngpo-order .ngpo-label {
  display: block;
  font-weight: 600;
  font-size: 14px;
  color: var(--ngpo-ink-body);
  margin-bottom: 6px;
}

.ngpo-order .ngpo-required,
.ngpo-order .ngpo-optional {
  font-weight: 400;
  font-size: 13px;
  color: var(--ngpo-ink-muted);
  margin-left: 4px;
}

.ngpo-order input[type="text"],
.ngpo-order input[type="email"],
.ngpo-order input[type="tel"],
.ngpo-order select,
.ngpo-order textarea {
  display: block;
  width: 100%;
  min-height: var(--ngpo-control-min-height);
  padding: 10px 16px;
  font-family: var(--ngpo-font-body);
  /* Minimum 16px font size to prevent iOS zoom on 390px screens */
  font-size: 16px;
  line-height: 1.5;
  color: var(--ngpo-ink-body);
  background-color: var(--ngpo-surface);
  border: 1.5px solid var(--ngpo-border);
  border-radius: var(--ngpo-radius-input);
  transition: border-color 0.2s ease, box-shadow 0.2s ease, background-color 0.2s ease;
  -webkit-appearance: none;
  appearance: none;
}

.ngpo-order .ngpo-field-heating {
  --ngenic-max-width: 100%;
}

.ngpo-order .ngpo-field-heating > ngenic-compatibility {
  display: block;
  width: 100%;
}

.ngpo-order .ngpo-field-heating > ngenic-compatibility:focus {
    outline: none;
}

.ngpo-order input:hover,
.ngpo-order select:hover,
.ngpo-order textarea:hover {
  border-color: var(--ngpo-border-hover);
}

.ngpo-order input:focus,
.ngpo-order select:focus,
.ngpo-order textarea:focus,
.ngpo-order input:focus-visible,
.ngpo-order select:focus-visible,
.ngpo-order textarea:focus-visible {
  outline: 2px solid var(--ngpo-focus-ring);
  border-color: var(--ngpo-focus-ring);
}

/* -------------------------------------------------------------------------
   Field Error States (p.ngpo-field-error, .ngpo-has-error)
   ------------------------------------------------------------------------- */
.ngpo-order .ngpo-has-error input[type="text"],
.ngpo-order .ngpo-has-error input[type="email"],
.ngpo-order .ngpo-has-error input[type="tel"],
.ngpo-order input[aria-invalid="true"],
.ngpo-order select[aria-invalid="true"],
.ngpo-order textarea[aria-invalid="true"] {
  border-color: var(--ngpo-error-border);
  outline-color: var(--ngpo-error-border);
  background-color: var(--ngpo-error-surface);
  color: var(--ngpo-error-ink);
}

.ngpo-order .ngpo-field-error {
  font-size: 13px;
  font-weight: 500;
  color: var(--ngpo-error-ink);
  margin-top: 6px;
  margin-bottom: 0;
}

.ngpo-order .ngpo-field-heating > ngenic-compatibility[aria-invalid="true"] {
  border-radius: var(--ngpo-radius-card);
  outline: 1px solid var(--ngpo-compat-error-border);
  outline-offset: 1px;
  box-shadow: var(--ngpo-compat-error-shadow);
}

.ngpo-order .ngpo-field-error:empty {
  display: none;
}

/* -------------------------------------------------------------------------
   Consent & Links (.ngpo-consent-group, .ngpo-checkbox-label)
   ------------------------------------------------------------------------- */
.ngpo-order .ngpo-consent-group {
  margin: 24px 0 16px 0;
}

.ngpo-order .ngpo-checkbox-label {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  font-size: 14px;
  line-height: 1.45;
  cursor: pointer;
  color: var(--ngpo-ink-body);
}

.ngpo-order .ngpo-checkbox-label input[type="checkbox"] {
  width: 20px;
  height: 20px;
  min-height: 20px;
  margin-top: 2px;
  border-radius: 4px;
  accent-color: var(--ngpo-ink-body);
  cursor: pointer;
  flex-shrink: 0;
}

.ngpo-order .ngpo-checkbox-label input[type="checkbox"]:focus-visible {
  outline: 2px solid var(--ngpo-focus-ring);
  outline-offset: 2px;
}

.ngpo-order .ngpo-checkbox-label a,
.ngpo-order .ngpo-legal-links a,
.ngpo-order .ngpo-withdrawal a {
  color: var(--ngpo-ink-body);
  text-decoration: underline;
  text-underline-offset: 2px;
  font-weight: 500;
}

.ngpo-order .ngpo-checkbox-label a:hover,
.ngpo-order .ngpo-legal-links a:hover,
.ngpo-order .ngpo-withdrawal a:hover {
  color: var(--ngpo-ink-on-light);
}

.ngpo-order .ngpo-withdrawal {
  font-size: 13px;
  color: var(--ngpo-ink-muted);
  margin: 0 0 16px 0;
}

.ngpo-order .ngpo-legal-links {
  list-style: none;
  padding: 0;
  margin: 0 0 8px;
  font-size: 13px;
  color: var(--ngpo-ink-muted);
}

.ngpo-order .ngpo-legal-links li + li {
  margin-top: 8px;
}

.ngpo-order .ngpo-handoff {
  font-size: 13px;
  color: var(--ngpo-ink-muted);
  line-height: 1.45;
  margin: 20px 0 16px 0;
}

/* -------------------------------------------------------------------------
   CTA Actions & Button (.ngpo-actions, button.ngpo-button.ngpo-submit)
   ------------------------------------------------------------------------- */
.ngpo-order .ngpo-actions {
  margin-top: 24px;
}

.ngpo-order .ngpo-button.ngpo-submit {
  display: block;
  width: 100%;
  min-height: var(--ngpo-control-min-height);
  padding: 14px 32px;
  font-family: var(--ngpo-font-body);
  font-size: 16px;
  font-weight: 600;
  text-align: center;
  border: 0;
  border-radius: var(--ngpo-radius-pill);
  background-color: var(--ngpo-amber-brand);
  color: var(--ngpo-amber-ink);
  box-shadow: none;
  cursor: pointer;
  transition: background-color 0.2s ease, transform 0.1s ease, box-shadow 0.2s ease, opacity 0.2s ease;
  line-height: 1.3;
}

.ngpo-order .ngpo-button.ngpo-submit:hover {
  background-color: var(--ngpo-amber-hover);
}

.ngpo-order .ngpo-button.ngpo-submit:active {
  transform: translateY(1px);
}

.ngpo-order .ngpo-button.ngpo-submit:focus-visible {
  outline: 2px solid var(--ngpo-focus-ring);
  outline-offset: 2px;
}

.ngpo-order .ngpo-button.ngpo-submit:disabled,
.ngpo-order .ngpo-button.ngpo-submit[aria-disabled="true"] {
  opacity: 0.6;
  cursor: not-allowed;
  box-shadow: none;
  transform: none;
}

.ngpo-order-form.ngpo-is-submitting .ngpo-submit {
  cursor: wait;
}

/* -------------------------------------------------------------------------
   Mobile Responsiveness (390px viewport adaptation)
   ------------------------------------------------------------------------- */
@media (max-width: 640px) {
  .ngpo-order {
    padding: 0 12px;
  }

  .ngpo-order .ngpo-field-row {
    flex-direction: column;
    gap: 0;
  }

  .ngpo-order .ngpo-field-row .ngpo-field-group {
    margin-bottom: 18px;
  }

  .ngpo-order .ngpo-plans-grid,
  .ngpo-order .ngpo-options-grid {
    grid-template-columns: 1fr;
  }

  .ngpo-order .ngpo-totals-card {
    padding: 18px 20px;
  }
}
