/* HighwayAds shared front-end form controls. Native control behavior is retained. */
body.ha-modern-forms {
  --ha-field-surface:#fffef9;
  --ha-field-border:#bdc9c0;
  --ha-field-ink:#23251f;
  --ha-field-muted:#697366;
  --ha-field-accent:#246d72;
  --ha-field-ring:rgba(36,109,114,.15);
}

/* :is() also covers fields added later by a form plugin, without reinitializing it. */
body.ha-modern-forms :is(#ha-auth,#ha-account,form,.ur-frontend-form,.user-registration,.wpcf7) :is(
  input:not([type]),input[type=text],input[type=email],input[type=password],
  input[type=tel],input[type=url],input[type=search],input[type=number],
  input[type=date],input[type=time],input[type=datetime-local],input[type=month],
  input[type=week],select,textarea
) {
  box-sizing:border-box !important;
  min-width:0;
  max-width:100% !important;
  min-height:52px !important;
  padding:13px 16px !important;
  border:1px solid var(--ha-field-border) !important;
  border-radius:12px !important;
  background:var(--ha-field-surface) !important;
  color:var(--ha-field-ink) !important;
  font-family:'DM Sans',system-ui,-apple-system,'Segoe UI',sans-serif !important;
  font-size:16px !important;
  font-weight:400 !important;
  line-height:1.5 !important;
  letter-spacing:normal !important;
  text-align:start !important;
  box-shadow:0 1px 2px rgba(35,37,31,.035) !important;
  transition:border-color .16s ease,box-shadow .16s ease,background-color .16s ease !important;
}

body.ha-modern-forms :is(#ha-auth,#ha-account,form,.ur-frontend-form,.user-registration,.wpcf7) :is(input,textarea)::placeholder {
  color:#738073 !important;
  font:inherit !important;
  opacity:1 !important;
}

body.ha-modern-forms :is(#ha-auth,#ha-account,form,.ur-frontend-form,.user-registration,.wpcf7) :is(
  input:not([type]),input[type=text],input[type=email],input[type=password],
  input[type=tel],input[type=url],input[type=search],input[type=number],
  input[type=date],input[type=time],input[type=datetime-local],input[type=month],
  input[type=week],select,textarea
):hover:not(:disabled):not([readonly]) {
  border-color:#8da99b !important;
}

body.ha-modern-forms :is(#ha-auth,#ha-account,form,.ur-frontend-form,.user-registration,.wpcf7) :is(
  input:not([type]),input[type=text],input[type=email],input[type=password],
  input[type=tel],input[type=url],input[type=search],input[type=number],
  input[type=date],input[type=time],input[type=datetime-local],input[type=month],
  input[type=week],select,textarea
):focus {
  border-color:var(--ha-field-accent) !important;
  background:#fff !important;
  box-shadow:0 0 0 4px var(--ha-field-ring) !important;
  outline:2px solid var(--ha-field-accent) !important;
  outline-offset:2px !important;
}

body.ha-modern-forms :is(#ha-auth,#ha-account,form,.ur-frontend-form,.user-registration,.wpcf7) :is(label,legend) {
  color:#34443c !important;
  font-family:'DM Sans',system-ui,-apple-system,'Segoe UI',sans-serif !important;
  font-size:14px !important;
  font-weight:500 !important;
  line-height:1.5 !important;
  letter-spacing:normal !important;
}

body.ha-modern-forms :is(#ha-auth,#ha-account,form,.ur-frontend-form,.user-registration,.wpcf7) textarea {
  min-height:144px !important;
  resize:vertical;
}
body.ha-modern-forms :is(#ha-auth,#ha-account,form,.ur-frontend-form,.user-registration,.wpcf7) select[multiple] {
  min-height:144px !important;
}

/* Do not change appearance, display, or dimensions of plugin checkboxes/switches. */
body.ha-modern-forms :is(#ha-auth,#ha-account,form,.ur-frontend-form,.user-registration,.wpcf7) :is(input[type=checkbox],input[type=radio]) {
  accent-color:var(--ha-field-accent);
}

body.ha-modern-forms :is(#ha-auth,#ha-account,form,.ur-frontend-form,.user-registration,.wpcf7) :is(input,select,textarea):disabled {
  color:#72796f !important;
  border-color:#d4dbd1 !important;
  background:#ecefe8 !important;
  box-shadow:none !important;
  cursor:not-allowed !important;
}
body.ha-modern-forms :is(#ha-auth,#ha-account,form,.ur-frontend-form,.user-registration,.wpcf7) :is(input,textarea)[readonly] {
  background:#f1f3ec !important;
}

/* Show errors only when the form/plugin marks them; untouched required fields stay neutral. */
body.ha-modern-forms :is(#ha-auth,#ha-account,form,.ur-frontend-form,.user-registration,.wpcf7) :is(input,select,textarea)[aria-invalid=true] {
  border-color:#a34337 !important;
}
body.ha-modern-forms :is(#ha-auth,#ha-account,form,.ur-frontend-form,.user-registration,.wpcf7) :is(input,select,textarea)[aria-invalid=true]:focus {
  outline-color:#a34337 !important;
  box-shadow:0 0 0 4px rgba(163,67,55,.13) !important;
}

/* Primary form actions retain their existing width, labels, and enable/disable logic. */
body.ha-modern-forms :is(#ha-auth,#ha-account,form,.ur-frontend-form,.user-registration,.wpcf7) :is(button[type=submit],input[type=submit],.ur-submit-button):not(.hh-btn--danger):not(.pill-btn-reset) {
  min-height:48px !important;
  max-width:100% !important;
  padding:12px 24px !important;
  border:1px solid var(--ha-field-accent) !important;
  border-radius:999px !important;
  background:var(--ha-field-accent) !important;
  color:#fffdf7 !important;
  font:600 14px/1.4 'DM Sans',system-ui,sans-serif !important;
  text-decoration:none !important;
  box-shadow:0 2px 5px rgba(36,109,114,.1) !important;
  transition:background-color .16s ease,box-shadow .16s ease,transform .16s ease !important;
}
body.ha-modern-forms :is(#ha-auth,#ha-account,form,.ur-frontend-form,.user-registration,.wpcf7) :is(button[type=submit],input[type=submit],.ur-submit-button):not(.hh-btn--danger):not(.pill-btn-reset):hover:not(:disabled):not([aria-disabled=true]) {
  background:#1c5a5e !important;
  transform:translateY(-2px) !important;
  box-shadow:0 6px 14px rgba(36,109,114,.17) !important;
}
body.ha-modern-forms :is(#ha-auth,#ha-account,form,.ur-frontend-form,.user-registration,.wpcf7) :is(button,input[type=submit]):disabled,
body.ha-modern-forms :is(#ha-auth,#ha-account,form,.ur-frontend-form,.user-registration,.wpcf7) [aria-disabled=true] {
  opacity:.5 !important;
  cursor:not-allowed !important;
  transform:none !important;
  box-shadow:none !important;
}
body.ha-modern-forms :is(#ha-auth,#ha-account,form,.ur-frontend-form,.user-registration,.wpcf7) :is(button,input[type=submit],input[type=checkbox],input[type=radio]):focus-visible {
  outline:2px solid var(--ha-field-accent) !important;
  outline-offset:3px !important;
}

/* Keep the current password reveal control and its existing event handler. */
body.ha-modern-forms #ha-auth .ha-auth-helper {
  min-height:40px !important;
  padding:8px 14px !important;
  border:1px solid #bdc9c0 !important;
  border-radius:999px !important;
  background:#f0f3ec !important;
  color:#246d72 !important;
  font-size:12px !important;
  box-shadow:none !important;
}

@media(prefers-reduced-motion:reduce) {
  body.ha-modern-forms :is(#ha-auth,#ha-account,form,.ur-frontend-form,.user-registration,.wpcf7) :is(input,select,textarea,button) { transition:none !important; }
  body.ha-modern-forms :is(#ha-auth,#ha-account,form,.ur-frontend-form,.user-registration,.wpcf7) :is(button,input[type=submit]):hover { transform:none !important; }
}
