/**
 * HubSpot Request Demo Form Styles
 * Styles for the externally embedded HubSpot form
 */

/* Form Container */
.hbspt-form {
  width: 100%;
  max-width: 100%;
}

.hs-form {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-12);
  width: 100%;
}

/* Field Containers */
.hs-form-field {
  display: flex;
  flex-direction: column;
  gap: 0;
  width: 100%;
}

/* Hide Labels (using placeholders instead) — show for dropdowns & checkboxes */
.hs-form-field label {
  display: none;
}

/* Show label above select/dropdown fields and fields without placeholders */
.hs-form-field:has(select) label:not(.hs-form-booleancheckbox-display),
.hs_how_did_you_hear_about_us label {
  display: block;
  font-size: var(--typo-body-small);
  font-weight: var(--font-weight-medium);
  font-family: var(--font-family-base);
  color: var(--color-text-default-soft);
  margin-bottom: var(--spacing-6);
}

/* Override HubSpot's inline red on required-field label spans */
.hs_how_did_you_hear_about_us label span {
  color: inherit !important;
}

.hs-form-field label.hs-form-booleancheckbox-display {
  display: flex;
}

/* Input Wrapper */
.hs-form-field .input {
  width: 100%;
}

/* Text Inputs */
.hs-form-field input[type='text'],
.hs-form-field input[type='email'],
.hs-input {
  width: 100%;
  padding: var(--spacing-16) var(--spacing-24);
  font-size: var(--typo-body-medium);
  font-weight: var(--font-weight-regular);
  color: var(--color-text-default-default);
  background-color: var(--color-bg-default-default);
  border: 1px solid var(--color-border-default-default);
  border-radius: var(--border-radius-12);
  outline: none;
  transition:
    border-color 0.2s ease,
    box-shadow 0.2s ease;
  font-family: var(--font-family-base);
  line-height: 1.5;
}

/* Placeholder Styles */
.hs-form-field input::placeholder {
  color: var(--color-text-default-muted);
  opacity: 1;
}

/* Focus State */
.hs-form-field input[type='text']:focus,
.hs-form-field input[type='email']:focus,
.hs-input:focus {
  border-color: var(--color-border-brand-primary-hover);
  box-shadow: 0 0 0 3px rgba(114, 60, 87, 0.1);
}

/* Select / Dropdown — matches text input styling, Safari/iOS safe */
.hs-form-field select {
  width: 100%;
  padding: var(--spacing-16) var(--spacing-24);
  padding-right: var(--spacing-48);
  font-size: var(--typo-body-medium);
  font-weight: var(--font-weight-regular);
  color: var(--color-text-default-muted);
  background-color: var(--color-bg-default-default);
  border: 1px solid var(--color-border-default-default);
  border-radius: var(--border-radius-12);
  outline: none;
  font-family: var(--font-family-base);
  line-height: 1.5;
  cursor: pointer;
  transition:
    border-color 0.2s ease,
    box-shadow 0.2s ease;

  /* Reset native appearance for consistent cross-browser styling */
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;

  /* Custom chevron arrow */
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' viewBox='0 0 24 24'%3E%3Cpath fill='%232e2428' d='M12 16l-6-6h12l-6 6z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right var(--spacing-16) center;
  background-size: 16px;
}

/* Once a real value is selected, show dark text */
.hs-form-field select.is-placeholder,
.hs-form-field select:invalid {
  color: var(--color-text-default-muted);
}

.hs-form-field select:not(.is-placeholder):valid,
.hs-form-field select:focus {
  color: var(--color-text-default-default);
}

/* Style the placeholder option */
.hs-form-field select option[value=''] {
  color: var(--color-text-default-muted);
}

.hs-form-field select option:not([value='']) {
  color: var(--color-text-default-default);
}

.hs-form-field select:focus {
  border-color: var(--color-border-brand-primary-hover);
  box-shadow: 0 0 0 3px rgba(114, 60, 87, 0.1);
}

.hs-form-field select.invalid,
.hs-form-field select.error {
  border-color: var(--color-border-danger-default);
}

.hs-form-field select.invalid:focus,
.hs-form-field select.error:focus {
  border-color: var(--color-border-danger-default);
  box-shadow: 0 0 0 3px rgba(152, 0, 0, 0.1);
}

/* Textarea — same styling as inputs */
.hs-form-field textarea {
  width: 100%;
  padding: var(--spacing-16) var(--spacing-24);
  font-size: var(--typo-body-medium);
  font-weight: var(--font-weight-regular);
  color: var(--color-text-default-default);
  background-color: var(--color-bg-default-default);
  border: 1px solid var(--color-border-default-default);
  border-radius: var(--border-radius-12);
  outline: none;
  font-family: var(--font-family-base);
  line-height: 1.5;
  resize: vertical;
  min-height: 120px;
  transition:
    border-color 0.2s ease,
    box-shadow 0.2s ease;
}

.hs-form-field textarea::placeholder {
  color: var(--color-text-default-muted);
  opacity: 1;
}

.hs-form-field textarea:focus {
  border-color: var(--color-border-brand-primary-hover);
  box-shadow: 0 0 0 3px rgba(114, 60, 87, 0.1);
}

/* Error State */
.hs-form-field input.invalid,
.hs-form-field input.error {
  border-color: var(--color-border-danger-default);
}

.hs-form-field input.invalid:focus,
.hs-form-field input.error:focus {
  border-color: var(--color-border-danger-default);
  box-shadow: 0 0 0 3px rgba(152, 0, 0, 0.1);
}

/* Error Messages */
.hs-error-msgs {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-4);
  margin: 0;
  padding: 0;
  list-style: none;
  width: 100%;
}

/* Hide error container when empty to prevent extra gap */
.hs-error-msgs:empty {
  display: none;
}

/* Hide error container when it doesn't have role="alert" (means no active errors) */
.hs-error-msgs:not([role='alert']) {
  display: none;
}

.hs-error-msg {
  font-size: var(--typo-body-small);
  color: var(--color-text-danger-default);
  font-weight: var(--font-weight-regular);
  margin: 0;
}

/* General form error message (appears at form level) */
.hs_error_rollup {
  grid-column: 1 / -1 !important;
  width: 100%;
}

/* Collapse error rollup when no active errors */
.hs_error_rollup:not(:has(.hs-error-msg)) {
  display: none;
}

/* Collapse fieldsets that only contain hidden fields */
.hs-form
  fieldset:has(.hs-form-field):not(
    :has(.hs-form-field:not([style*='display: none']):not([style*='display:none']))
  ) {
  display: none !important;
}

/* Collapse empty fieldsets */
.hs-form fieldset:empty {
  display: none !important;
}

/* Collapse legal consent container when empty */
.hs-form .legal-consent-container:empty {
  display: none;
}

.hs_error_rollup .hs-error-msgs {
  width: 100%;
}

.hs_error_rollup .hs-error-msg {
  font-size: var(--typo-body-medium);
  text-align: left;
}

/* Field Description */
.hs-field-desc {
  font-size: var(--typo-body-small);
  color: var(--color-text-default-soft);
  margin-top: var(--spacing-4);
}

/* Submit Button Container */
.hs-submit {
  margin-top: var(--spacing-12);
}

.hs-submit .actions {
  width: 100%;
}

/* Submit Button */
.hs-button.primary {
  width: 100%;
  padding: var(--spacing-16) var(--spacing-40);
  font-size: var(--typo-label-medium);
  font-weight: var(--font-weight-semibold);
  font-family: var(--font-family-base);
  color: var(--btn-primary-text);
  background-color: var(--btn-primary-bg);
  border: none;
  border-radius: 9999px;
  cursor: pointer;
  transition:
    background-color 0.2s ease,
    transform 0.1s ease;
  outline: none;
  line-height: 1.5;
  text-align: center;
}

.hs-button.primary:hover {
  background-color: var(--btn-primary-bg-hover);
}

.hs-button.primary:active {
  background-color: var(--btn-primary-bg-active);
  transform: scale(0.98);
}

.hs-button.primary:focus-visible {
  box-shadow:
    0 0 0 2px var(--btn-primary-focus-inner),
    0 0 0 4px var(--btn-primary-focus-outer);
}

/* Large Button Variant */
.hs-button.large {
  min-height: var(--btn-large-height);
  padding: var(--spacing-16) var(--spacing-40);
  font-size: var(--typo-label-large);
}

/* Hidden Fields */
.hs-form-field[style*='display: none'],
.hs-form-field[style*='display:none'] {
  display: none !important;
}

/* Remove default form margins */
.hs-form fieldset {
  margin: 0;
  padding: 0;
  border: none;
}

/* Utility Classes */
.no-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

/* Fieldset resets — HubSpot wraps fields in fieldsets with their own layout */
.hs-form fieldset {
  max-width: 100% !important;
}

.hs-form fieldset.form-columns-1,
.hs-form fieldset.form-columns-2,
.hs-form fieldset.form-columns-3 {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-12);
}

.hs-form fieldset.form-columns-1 .hs-form-field,
.hs-form fieldset.form-columns-2 .hs-form-field,
.hs-form fieldset.form-columns-3 .hs-form-field {
  width: 100% !important;
}

/* First/last name — keep side by side on larger screens */
@media (min-width: 480px) {
  .hs-form fieldset.form-columns-2:has(.hs_firstname) {
    flex-direction: row;
    gap: var(--spacing-16);
  }

  .hs-form fieldset.form-columns-2:has(.hs_firstname) .hs-form-field {
    flex: 1;
    min-width: 0;
  }
}

/* Responsive Layout - Two columns for first/last name on larger screens */
@media (min-width: 768px) {
  .hs-form {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--spacing-16) var(--spacing-16);
  }

  /* All fieldsets span full width */
  .hs-form fieldset {
    grid-column: 1 / -1;
  }

  /* First Name and Last Name side by side - each field takes full width of its column */
  .hs-firstname,
  .hs-lastname {
    grid-column: span 1;
    display: flex;
    flex-direction: column;
  }

  /* Error messages stay within their column */
  .hs-firstname .hs-error-msgs,
  .hs-lastname .hs-error-msgs {
    width: 100%;
  }

  /* Full width fields */
  .hs-email,
  .hs-company,
  .hs-phone,
  .hs-phone_number_form__c,
  .hs-how_did_you_hear_about_us,
  .hs-submit {
    grid-column: 1 / -1;
  }

  /* Hidden fields stay hidden */
  .hs-form-field[style*='display: none'],
  .hs-form-field[style*='display:none'] {
    grid-column: 1 / -1;
  }
}

/* Mobile - Single Column */
@media (max-width: 767px) {
  .hs-form {
    gap: var(--spacing-12);
  }

  .hs-button.primary {
    font-size: var(--typo-label-medium);
  }
}

/* Privacy Text */
.hs-form .hs-richtext {
  font-size: var(--typo-caption);
  color: var(--color-text-default-soft);
  line-height: 1.5;
  margin-top: var(--spacing-8);
  text-align: center;
}

.hs-form .hs-richtext a {
  color: var(--color-text-link-default);
  text-decoration: underline;
  transition: color 0.2s ease;
}

.hs-form .hs-richtext a:hover {
  color: var(--color-text-link-default-hover);
}

/* Loading State */
.hs-form.hs-form-submitting {
  opacity: 0.6;
  pointer-events: none;
}

/* Success Message */
.submitted-message {
  padding: var(--spacing-24);
  text-align: center;
  font-size: var(--typo-body-large);
  color: var(--color-text-default-default);
  background-color: var(--color-bg-surface-light-surface-1);
  border-radius: var(--border-radius-12);
}

.submitted-message p {
  margin: 0 0 var(--spacing-16);
}

.submitted-message p:last-child {
  margin-bottom: 0;
}

/* Hero Form Compact — stacked inputs, smaller button */
.hero-form .hs-form {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-12);
}

.hero-form .hs-button.primary {
  padding: var(--spacing-12) var(--spacing-40);
  line-height: 1;
}

/* Forms inside html-block (e.g. accessibility pack) — extra space before submit */
.wp-block-interact-html-block .hs-submit {
  margin-top: var(--spacing-16);
}
