/**
 * Component: forms (fields, choices, errors, submit button).
 *
 * BuddyBoss styles its forms with high-specificity selectors (two IDs). The
 * scope below uses :is(), which takes the specificity of its most specific
 * argument, so these rules win (loaded later) without !important.
 * To style another BuddyBoss form, add its selector to the :is() list.
 */

/* ---------- Layout ---------- */

:is(.bs-bp-container-reg #buddypress #signup-form.standard-form) {
	container-type: inline-size;
}

/*
 * Field sections are grids: one column, two when the form is wide enough.
 * Includes the section IDs to match BuddyBoss's three-ID rules there.
 */
:is(.bs-bp-container-reg #buddypress #signup-form.standard-form) :is(#basic-details-section, #profile-details-section).register-section {
	display: grid;
	grid-template-columns: minmax(0, 1fr);
	gap: var(--cac-space-6);
	align-items: end;
	/* help text sits above inputs; keeps paired inputs aligned */
	margin: 0 0 var(--cac-space-6);
}

.field_type_membertypes ~ .ajax_added {
	align-self: flex-start;
}

@container (min-width: 30rem) {
	:is(.bs-bp-container-reg #buddypress #signup-form.standard-form) :is(#basic-details-section, #profile-details-section).register-section {
		grid-template-columns: repeat(2, minmax(0, 1fr));
	}

	/* Long or choice-list fields, and the profile type that drives the fields below it. */
	:is(.bs-bp-container-reg #buddypress #signup-form.standard-form) :is(#basic-details-section, #profile-details-section).register-section > :is(.field_type_textarea, .field_type_checkbox, .field_type_membertypes) {
		grid-column: 1 / -1;
	}
}

:is(.bs-bp-container-reg #buddypress #signup-form.standard-form) :is(#basic-details-section, #profile-details-section).register-section > :is(.editfield, .bb-signup-field) {
	margin: 0;
}

:is(.bs-bp-container-reg #buddypress #signup-form.standard-form) .cac-signup-consent {
	margin: 0 0 var(--cac-space-5);
}

:is(.bs-bp-container-reg #buddypress #signup-form.standard-form) fieldset {
	margin: 0;
	padding: 0;
	border: 0;
	min-width: 0;
}

/* ---------- Labels ---------- */

:is(.bs-bp-container-reg #buddypress #signup-form.standard-form) :is(label, legend) {
	display: block;
	margin: 0 0 var(--cac-space-2);
	padding: 0;
	font-size: var(--cac-font-size-md);
	font-weight: var(--cac-font-weight-bold);
	line-height: var(--cac-line-height-tight);
	color: var(--cac-color-text-strong);
}

/* Required marker; the requirement is also exposed via aria-required. */
:is(.bs-bp-container-reg #buddypress #signup-form.standard-form) :is(.required-field > fieldset > legend, .signup_email > label, .signup_password > label, .signup_password_confirm > label)::after {
	content: " *";
}

/* Choice labels (checkbox/radio options) are regular weight. */
:is(.bs-bp-container-reg #buddypress #signup-form.standard-form) :is(.checkbox-options, .radio-button-options, .input-options) label {
	font-weight: var(--cac-font-weight-regular);
	font-size: var(--cac-font-size-md);
	line-height: var(--cac-line-height-base);
	color: var(--cac-color-text);
}

/* ---------- Help text ---------- */

:is(.bs-bp-container-reg #buddypress #signup-form.standard-form) :is(p.description, p.cac-form-note) {
	font-size: var(--cac-font-size-sm);
	line-height: var(--cac-line-height-base);
	color: var(--cac-color-text-muted);
}

:is(.bs-bp-container-reg #buddypress #signup-form.standard-form) p.description {
	margin: var(--cac-space-1) 0 0;
}

:is(.bs-bp-container-reg #buddypress #signup-form.standard-form) p.cac-form-note {
	margin: 0 0 var(--cac-space-6);
}

/* ---------- Text controls ---------- */

:is(.bs-bp-container-reg #buddypress #signup-form.standard-form) :is(input[type="text"],
	input[type="email"],
	input[type="password"],
	input[type="url"],
	input[type="tel"],
	input[type="number"],
	input[type="date"],
	select,
	textarea) {
	width: 100%;
	height: var(--cac-control-height);
	margin: 0;
	padding: 0 var(--cac-space-3);
	font-size: var(--cac-font-size-base);
	/* ≥16px avoids zoom on iOS */
	color: var(--cac-color-text-strong);
	background-color: var(--cac-color-bg);
	border: 1px solid var(--cac-color-border-control);
	border-radius: var(--cac-radius-sm);
	box-shadow: none;
}

:is(.bs-bp-container-reg #buddypress #signup-form.standard-form) textarea {
	height: auto;
	min-height: 8rem;
	padding: var(--cac-space-3);
	line-height: var(--cac-line-height-base);
	resize: vertical;
}

/*
 * Text controls use BuddyBoss's own focus style (brand border + ring) for consistency
 * with its other forms. Restated here because the rule above would otherwise reset it.
 * Checkboxes, radios and buttons keep the global focus outline (base.css).
 */
:is(.bs-bp-container-reg #buddypress #signup-form.standard-form) :is(input[type="text"],
	input[type="email"],
	input[type="password"],
	input[type="url"],
	input[type="tel"],
	input[type="number"],
	input[type="date"],
	select,
	textarea):focus {
	outline: none;
	border-color: var(--bb-input-focus-border-color);
	box-shadow: var(--bb-input-focus-shadow);
}

/*
 * Date fields: day / month / year side by side, each label above its select.
 * Markup is label, select, label, select… so the grid flows by column.
 */
:is(.bs-bp-container-reg #buddypress #signup-form.standard-form) .datebox-selects {
	display: grid;
	grid-auto-flow: column;
	grid-template-rows: auto auto;
	grid-template-columns: 1fr 2fr 1.25fr;
	gap: var(--cac-space-1) var(--cac-space-2);
}

:is(.bs-bp-container-reg #buddypress #signup-form.standard-form) .datebox-selects select {
	width: 100%;
	margin: 0;
}

/* BuddyBoss prints the field error inside the grid: give it its own full-width first row. */
:is(.bs-bp-container-reg #buddypress #signup-form.standard-form) .datebox-selects:has(> div.error) {
	grid-template-rows: auto auto auto;
}

:is(.bs-bp-container-reg #buddypress #signup-form.standard-form) .datebox-selects > div.error {
	grid-row: 1;
	grid-column: 1 / -1;
}

/* ---------- Checkboxes and radios ---------- */

:is(.bs-bp-container-reg #buddypress #signup-form.standard-form) :is(.checkbox-options, .radio-button-options, .input-options) :is(.bp-checkbox-wrap, .bp-radio-wrap) {
	display: flex;
	align-items: center;
	min-height: var(--cac-target-min);
}

:is(.bs-bp-container-reg #buddypress #signup-form.standard-form) :is(.checkbox-options, .radio-button-options, .input-options) :is(.bp-checkbox-wrap, .bp-radio-wrap) label {
	margin: 0;
}

/* Date part labels (Dia / Mes / Any): secondary. After the choice-label rule (same specificity). */
:is(.bs-bp-container-reg #buddypress #signup-form.standard-form) .datebox-selects label {
	margin: 0;
	font-size: var(--cac-font-size-sm);
	font-weight: var(--cac-font-weight-regular);
	color: var(--cac-color-text-muted);
}

/* ---------- Choice cards (radio options with title + description) ---------- */

:is(.bs-bp-container-reg #buddypress #signup-form.standard-form) .cac-choice-cards {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(min(100%, 14rem), 1fr));
	gap: var(--cac-space-3);
	margin-top: var(--cac-space-2);
}

:is(.bs-bp-container-reg #buddypress #signup-form.standard-form) .cac-choice-cards + .description {
	margin-top: var(--cac-space-3);
}

:is(.bs-bp-container-reg #buddypress #signup-form.standard-form) .cac-choice-cards .cac-choice-card {
	display: flex;
	align-items: flex-start;
	gap: var(--cac-space-3);
	margin: 0;
	padding: var(--cac-space-4);
	font-weight: var(--cac-font-weight-regular);
	border: 1px solid var(--cac-color-border-control);
	border-radius: var(--cac-radius-sm);
	cursor: pointer;
}

:is(.bs-bp-container-reg #buddypress #signup-form.standard-form) .cac-choice-cards .cac-choice-card:hover {
	border-color: var(--cac-color-text-strong);
}

/* Selected: 2px border look without shifting the layout. */
:is(.bs-bp-container-reg #buddypress #signup-form.standard-form) .cac-choice-cards .cac-choice-card:has(input:checked) {
	border-color: var(--cac-color-text-strong);
	box-shadow: inset 0 0 0 1px var(--cac-color-text-strong);
}

:is(.bs-bp-container-reg #buddypress #signup-form.standard-form) .cac-choice-cards input[type="radio"] {
	flex: none;
	width: 1.25rem;
	height: 1.25rem;
	margin: 0;
	accent-color: var(--cac-color-brand);
}

:is(.bs-bp-container-reg #buddypress #signup-form.standard-form) .cac-choice-cards .cac-choice-card__text {
	display: flex;
	flex-direction: column;
	gap: var(--cac-space-1);
}

:is(.bs-bp-container-reg #buddypress #signup-form.standard-form) .cac-choice-cards .cac-choice-card__title {
	font-size: var(--cac-font-size-md);
	font-weight: var(--cac-font-weight-bold);
	line-height: var(--cac-line-height-tight);
	color: var(--cac-color-text-strong);
}

:is(.bs-bp-container-reg #buddypress #signup-form.standard-form) .cac-choice-cards .cac-choice-card__description {
	font-size: var(--cac-font-size-sm);
	line-height: var(--cac-line-height-base);
	color: var(--cac-color-text-muted);
}

:is(.bs-bp-container-reg #buddypress #signup-form.standard-form) .editfield:has(div.error) .cac-choice-card {
	border-color: var(--cac-color-error);
}

/* ---------- Errors ---------- */

:is(.bs-bp-container-reg #buddypress #signup-form.standard-form) div.error {
	display: flex;
	gap: var(--cac-space-2);
	width: auto;
	margin: 0 0 var(--cac-space-2);
	padding: 0;
	border-radius: 0;
	font-size: var(--cac-font-size-sm);
	font-weight: var(--cac-font-weight-regular);
	line-height: var(--cac-line-height-base);
	color: var(--cac-color-error);
	background: none;
	border: 0;
}

:is(.bs-bp-container-reg #buddypress #signup-form.standard-form) div.error::before {
	content: "!";
	font-weight: var(--cac-font-weight-bold);
}

/* BuddyBoss nests div.error inside div.error for profile fields. */
:is(.bs-bp-container-reg #buddypress #signup-form.standard-form) div.error div.error {
	margin: 0;
}

:is(.bs-bp-container-reg #buddypress #signup-form.standard-form) div.error div.error::before {
	content: none;
}

:is(.bs-bp-container-reg #buddypress #signup-form.standard-form) :is(.editfield, .bb-signup-field):has(div.error) :is(input:not([type="checkbox"], [type="radio"]), select, textarea) {
	border: 2px solid var(--cac-color-error);
}

/* ---------- Submit button ---------- */

:is(.bs-bp-container-reg #buddypress #signup-form.standard-form) .submit input[type="submit"] {
	min-height: var(--cac-control-height);
	padding: 0 var(--cac-space-8);
	font-size: var(--cac-font-size-lg);
	font-weight: var(--cac-font-weight-bold);
	color: var(--cac-color-on-brand);
	background-color: var(--cac-color-brand);
	border: 0;
	border-radius: var(--cac-radius-sm);
	cursor: pointer;
}

:is(.bs-bp-container-reg #buddypress #signup-form.standard-form) .submit input[type="submit"]:hover {
	background-color: var(--cac-color-brand-hover);
}

/* ---------- Password strength (shown on the label's line, so the grid doesn't move) ---------- */

:is(.bs-bp-container-reg #buddypress #signup-form.standard-form) .signup_password {
	position: relative;
}

:is(.bs-bp-container-reg #buddypress #signup-form.standard-form) #pass-strength-result {
	position: absolute;
	top: 0;
	right: 0;
	margin: 0;
	padding: 0;
	font-size: var(--cac-font-size-sm);
	font-weight: var(--cac-font-weight-bold) !important;
	/* BuddyBoss sets 400 !important on .strong. */
	line-height: inherit;
	color: var(--cac-color-text-muted);
	background: none;
	border: 0;
}

:is(.bs-bp-container-reg #buddypress #signup-form.standard-form) #pass-strength-result::before {
	content: none;
}

:is(.bs-bp-container-reg #buddypress #signup-form.standard-form) #pass-strength-result:is(.short, .bad) {
	color: var(--cac-color-error);
}

:is(.bs-bp-container-reg #buddypress #signup-form.standard-form) #pass-strength-result.good {
	color: var(--cac-color-warning);
}

:is(.bs-bp-container-reg #buddypress #signup-form.standard-form) #pass-strength-result.strong {
	color: var(--cac-color-success);
}

/* ---------- Live email check (same look as other field errors) ---------- */

:is(.bs-bp-container-reg #buddypress #signup-form.standard-form) .signup_email {
	position: relative;
}

:is(.bs-bp-container-reg #buddypress #signup-form.standard-form) #email-strength-result {
	gap: var(--cac-space-2);
	margin: 0.125rem 0 0;
	padding: 0;
	font-size: var(--cac-font-size-sm);
	font-weight: var(--cac-font-weight-regular);
	line-height: var(--cac-line-height-tight);
	color: var(--cac-color-error);
	text-align: left;
	background: none;
	border: 0;
	border-radius: 0;
}

:is(.bs-bp-container-reg #buddypress #signup-form.standard-form) #email-strength-result.show {
	display: flex;
}

:is(.bs-bp-container-reg #buddypress #signup-form.standard-form) #email-strength-result.show::before {
	content: "!";
	font-weight: var(--cac-font-weight-bold);
}

/* Two columns: sit in the row gap so the paired field doesn't move. */
@container (min-width: 30rem) {
	:is(.bs-bp-container-reg #buddypress #signup-form.standard-form) #email-strength-result {
		position: absolute;
		top: 100%;
		right: 0;
		left: 0;
	}
}