/* ======================================================
   GF Hearts — Form inputs, checkboxes, radios, selects
   ====================================================== */

/* --- Base inputs --- */
input[type="text"],
input[type="email"],
input[type="password"],
input[type="search"],
input[type="url"],
input[type="tel"],
input[type="number"],
textarea,
select {
  width: 100%;
  padding: 0.65rem 0.9rem;
  background-color: var(--gfh-surface);
  border: 1.5px solid color-mix(in srgb, var(--gfh-teal) 25%, transparent);
  border-radius: 10px;
  font-family: var(--gfh-font-body);
  font-size: 0.95rem;
  color: var(--gfh-text);
  transition: border-color 0.2s, box-shadow 0.2s;
  appearance: none;
  -webkit-appearance: none;
}

input[type="text"]:focus,
input[type="email"]:focus,
input[type="password"]:focus,
input[type="search"]:focus,
input[type="url"]:focus,
input[type="tel"]:focus,
input[type="number"]:focus,
textarea:focus,
select:focus {
  outline: none;
  border-color: var(--gfh-accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--gfh-accent) 18%, transparent);
}

/* BuddyPress fires input[required]:invalid immediately on page load for empty fields.
   Override to brand color — only show red after user interaction. */
.buddypress-wrap .standard-form input[required]:invalid,
.buddypress-wrap .standard-form select[required]:invalid,
.buddypress-wrap .standard-form textarea[required]:invalid {
  border-color: color-mix(in srgb, var(--gfh-teal) 25%, transparent) !important;
  box-shadow: none !important;
}

/* Show error color only after user has typed and left the field invalid */
.buddypress-wrap .standard-form input[required]:user-invalid,
.buddypress-wrap .standard-form select[required]:user-invalid,
.buddypress-wrap .standard-form textarea[required]:user-invalid {
  border-color: var(--gfh-meter-low) !important;
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--gfh-meter-low) 15%, transparent) !important;
}

/* BuddyPress server-side validation error class */
input.error,
select.error,
textarea.error {
  border-color: var(--gfh-meter-low) !important;
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--gfh-meter-low) 15%, transparent) !important;
}

/* BuddyPress register page layout — padding and container */
#signup-page,
#register-page {
  padding: 1.5rem;
}

#signup-page .register-section,
#register-page .register-section {
  padding: 0 0 1.5rem;
}

/* Remove the red background BuddyPress adds to required field wrappers */
.required-field-missing,
.form-field.required {
  background: none !important;
}

textarea {
  min-height: 100px;
  resize: vertical;
}

label {
  font-family: var(--gfh-font-body);
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--gfh-teal);
  display: block;
  margin-bottom: 0.35rem;
}

/* --- Custom select --- */
select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%231A7076' stroke-width='1.8' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.9rem center;
  padding-right: 2.5rem;
  cursor: pointer;
}

/* --- Custom checkbox --- */
input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  min-width: 18px;
  border: 2px solid color-mix(in srgb, var(--gfh-teal) 40%, transparent);
  border-radius: 4px;
  background-color: var(--gfh-surface);
  cursor: pointer;
  position: relative;
  transition: border-color 0.2s, background-color 0.2s;
  vertical-align: middle;
}

input[type="checkbox"]:checked {
  background-color: var(--gfh-primary);
  border-color: var(--gfh-primary);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 10'%3E%3Cpath d='M1.5 5l2.5 2.5 4.5-4.5' stroke='white' stroke-width='1.5' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: center;
  background-size: 70%;
}

input[type="checkbox"]:focus-visible {
  outline: 2px solid var(--gfh-accent);
  outline-offset: 2px;
}

/* --- Custom radio --- */
input[type="radio"] {
  appearance: none;
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  min-width: 18px;
  border: 2px solid color-mix(in srgb, var(--gfh-teal) 40%, transparent);
  border-radius: 50%;
  background-color: var(--gfh-surface);
  cursor: pointer;
  position: relative;
  transition: border-color 0.2s;
  vertical-align: middle;
}

input[type="radio"]:checked {
  border-color: var(--gfh-primary);
}

input[type="radio"]:checked::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 8px;
  height: 8px;
  background-color: var(--gfh-primary);
  border-radius: 50%;
}

input[type="radio"]:focus-visible {
  outline: 2px solid var(--gfh-accent);
  outline-offset: 2px;
}

/* BP Profile Search's own template (bps-form-default.php) inlines
   ".bps-form input { display: inline; }" at the same specificity as our
   input[type="checkbox"]/[type="radio"] rules above, and wins the cascade
   tie by appearing later in the document. That forces our appearance:none
   boxes to display:inline, which drops the explicit width/height and
   collapses them to a sliver. Re-assert inline-block with matching
   specificity so the custom box renders on the members search filters. */
.bps-form input[type="checkbox"],
.bps-form input[type="radio"] {
  display: inline-block;
}

/* --- Checkbox/radio label alignment --- */
.checkbox-wrap,
.radio-wrap {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
}

/* BuddyPress field groups */
.editfield {
  margin-bottom: 1.25rem;
}

.editfield label {
  margin-bottom: 0.35rem;
}

/* BuddyPress radio field inline labels */
#profile-edit-form input[type="radio"],
.register-section input[type="radio"],
#signup_profile_fields input[type="radio"] {
  margin-right: 0.35rem;
}

/* GF Meter is locked from further edits after registration (see the
   bp_xprofile_set_field_data_pre_save filter in inc/gf-meter.php). The note +
   request-a-change link are injected by nav.js (initGfMeterLockNote) rather than
   here, since a pseudo-element ::after can't contain a real, clickable <a>. */
.gfh-gf-meter-locked-note {
  display: block;
  margin-top: 0.35rem;
  font-size: 0.8rem;
  font-weight: 400;
  color: var(--gfh-text-muted);
}

.gfh-gf-meter-locked-note a {
  color: var(--gfh-teal) !important;
}

/* The options themselves are disabled (see initGfMeterLockNote in gf-meter.js)
   so the registered value is visible but can't be reselected. */
#profile-edit-form .field_gf-meter input[type="radio"]:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

#profile-edit-form .field_gf-meter label.option-label:has(input:disabled) {
  cursor: not-allowed;
  color: var(--gfh-text-muted);
}

/* --- Password strength meter --- */
#pass-strength-result {
  border-radius: var(--gfh-radius-pill);
  font-family: var(--gfh-font-body);
  font-size: 0.8rem;
  font-weight: 700;
  text-align: center;
  padding: 0.35rem 0.75rem;
  margin-top: 0.5rem;
  border: none !important;
  display: inline-block;
}

#pass-strength-result.strong,
#pass-strength-result.short { background-color: var(--gfh-primary) !important; color: #fff !important; }
#pass-strength-result.bad   { background-color: var(--gfh-meter-low) !important; color: #fff !important; }
#pass-strength-result.good  { background-color: var(--gfh-accent) !important; color: #fff !important; }

/* --- BuddyPress page padding --- */
#buddypress {
  padding: 1.5rem 0;
}

#buddypress .padder {
  padding: 0 1rem;
}

/* Members / activity / groups directory padding */
.bp-dir-hdr,
#subnav,
#members-dir-list,
#activity-dir-list,
#groups-dir-list {
  padding-left: 0;
}

/* Content area general padding for BP pages */
body.activity-page .entry-content,
body.members-page .entry-content,
body.groups-page .entry-content,
body[class*="bp-"] .entry-content {
  padding: 1.5rem;
}

/* --- BuddyPress register page — centered, no card container --- */
body.registration .buddypress-wrap,
body.register .buddypress-wrap {
  max-width: 520px;
  margin: 2rem auto;
}

/* BP uses .layout-wrap with display:flex, splitting sections into columns.
   Override to block so sections stack vertically in the card. */
body.registration .layout-wrap,
body.register .layout-wrap {
  display: block !important;
}

/* Stack the two register sections into a single column */
body.registration #basic-details-section,
body.registration #profile-details-section,
body.register #basic-details-section,
body.register #profile-details-section {
  float: none !important;
  width: 100% !important;
  margin-left: 0 !important;
  padding: 0 !important;
  flex-basis: auto !important;
}

body.registration .register-section,
body.register .register-section {
  margin-bottom: 1.5rem;
}

body.registration .register-section h2,
body.register .register-section h2 {
  font-size: 1rem;
  font-family: var(--gfh-font-body);
  font-weight: 700;
  color: var(--gfh-teal);
  border-bottom: 1px solid color-mix(in srgb, var(--gfh-teal) 12%, transparent);
  padding-bottom: 0.5rem;
  margin-bottom: 1.25rem;
}

/* Register submit button */
body.registration #signup_submit,
body.register #signup_submit {
  background-color: var(--gfh-primary) !important;
  color: #fff !important;
  border: none !important;
  border-radius: var(--gfh-radius-pill) !important;
  font-family: var(--gfh-font-body) !important;
  font-weight: 700 !important;
  font-size: 0.875rem !important;
  padding: 0.45rem 1.5rem !important;
  cursor: pointer;
  transition: opacity 0.2s;
  width: auto;
}

body.registration #signup_submit:hover,
body.register #signup_submit:hover {
  opacity: 0.88;
}

/* --- GF Hearts inline login prompt (community restricted page) --- */
.gfh-login-prompt {
  max-width: 420px;
  margin: 2rem auto;
}

.gfh-login-prompt__message {
  color: var(--gfh-text-muted);
  font-size: 0.95rem;
  margin-bottom: 1.25rem;
}

.gfh-login-prompt .login-username,
.gfh-login-prompt .login-password {
  margin-bottom: 1rem;
}

.gfh-login-prompt .login-submit {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 1rem;
}

.gfh-login-prompt #wp-submit {
  background-color: var(--gfh-primary);
  color: #fff;
  border: none;
  border-radius: var(--gfh-radius-pill);
  padding: 0.4rem 1.25rem;
  font-family: var(--gfh-font-body);
  font-weight: 700;
  font-size: 0.875rem;
  cursor: pointer;
  transition: opacity 0.2s;
  width: auto;
}

.gfh-login-prompt #wp-submit:hover { opacity: 0.88; }

.gfh-login-prompt .login-remember {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.85rem;
  color: var(--gfh-text-muted);
}

.gfh-login-prompt__register {
  margin-top: 1rem;
  font-size: 0.875rem;
  color: var(--gfh-text-muted);
  border-top: 1px solid color-mix(in srgb, var(--gfh-teal) 10%, transparent);
  padding-top: 0.875rem;
}

.gfh-login-prompt__register a {
  color: var(--gfh-primary);
  font-weight: 700;
  text-decoration: none;
}

/* --- Notification notices --- */
.gfh-notice {
  padding: 0.875rem 1rem;
  border-radius: 8px;
  margin-bottom: 1.5rem;
  font-size: 0.9rem;
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
}

.gfh-notice--error {
  background: color-mix(in srgb, var(--gfh-meter-low) 10%, transparent);
  color: var(--gfh-meter-low);
  border: 1px solid color-mix(in srgb, var(--gfh-meter-low) 25%, transparent);
}

/* Dark mode forms — gated on BuddyX's own data-bx-mode="dark" state, not
   prefers-color-scheme, so it stays in sync with the rest of the page. */
:root[data-bx-mode="dark"] {
  input[type="text"],
  input[type="email"],
  input[type="password"],
  input[type="search"],
  textarea,
  select {
    background-color: var(--gfh-surface);
    border-color: rgba(255, 255, 255, 0.15);
    color: var(--gfh-text);
  }

  input[type="checkbox"],
  input[type="radio"] {
    background-color: var(--gfh-surface);
    border-color: rgba(255, 255, 255, 0.2);
  }

  select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%232AB8CC' stroke-width='1.8' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  }

  .gfh-login-wall {
    background-color: var(--gfh-surface);
    box-shadow: 0 4px 24px rgba(0,0,0,0.3);
  }
}

@media (prefers-color-scheme: dark) {
  :root[data-bx-mode="auto"] {
    input[type="text"],
    input[type="email"],
    input[type="password"],
    input[type="search"],
    textarea,
    select {
      background-color: var(--gfh-surface);
      border-color: rgba(255, 255, 255, 0.15);
      color: var(--gfh-text);
    }

    input[type="checkbox"],
    input[type="radio"] {
      background-color: var(--gfh-surface);
      border-color: rgba(255, 255, 255, 0.2);
    }

    select {
      background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%232AB8CC' stroke-width='1.8' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    }

    .gfh-login-wall {
      background-color: var(--gfh-surface);
      box-shadow: 0 4px 24px rgba(0,0,0,0.3);
    }
  }
}
