/**
 * WP Member Directory - Public Styles
 *
 * DESIGN PHILOSOPHY: Minimal, theme-inheriting CSS.
 * Only provides structural layout - colors, fonts, and spacing inherit from theme.
 * Uses `currentColor` for borders to match theme text color.
 * Uses `opacity` for subtle visual hierarchy without hardcoding colors.
 *
 * ==========================================================================
 * CSS CUSTOM PROPERTIES (THEME OVERRIDE GUIDE)
 * ==========================================================================
 * Themes can override these variables to customize the plugin appearance.
 * Add overrides to your theme's CSS targeting .wp-member-directory:
 *
 * .wp-member-directory {
 *   --md-container-max-width: 1400px;
 *   --md-card-border-radius: 8px;
 * }
 * ==========================================================================
 *
 * ==========================================================================
 * DOCUMENTED EXCEPTIONS TO THEME-INHERITING CSS
 * ==========================================================================
 * The following hardcoded colors are REQUIRED for specific UX/accessibility
 * reasons and cannot inherit from the theme:
 *
 * 1. SEMANTIC ERROR/DANGER COLORS (--md-color-danger)
 *    - Required field asterisks (.required label::after)
 *    - Delete/remove buttons (.remove-spouse, .remove-dependent, .remove-phone)
 *    - Validation error messages (.field-error, .has-error)
 *    - Delete photo button (.delete-photo-button)
 *    Reason: Red is universally understood as "danger/error" across all
 *    cultures and must remain consistent regardless of theme styling.
 *
 * 2. TOOLTIP COLORS (--md-tooltip-bg, --md-tooltip-text)
 *    - Tooltip popups (.tooltiptext, .tooltip-content)
 *    Reason: Tooltips appear as overlays and must have guaranteed contrast.
 *    Theme text/background colors may not provide sufficient contrast.
 *
 * 3. HIGHLIGHTED OPTIONS (--md-highlight-bg)
 *    - Church of Ascription dropdown (.highlighted-option)
 *    Reason: UX requirement to draw attention to the 3 most commonly
 *    selected churches (Roman Catholic, Byzantine, Melkite Greek).
 *
 * 4. SUCCESS/WARNING/INFO MESSAGE COLORS (--md-color-success, etc.)
 *    - Form messages (.member-directory-message, .notice)
 *    Reason: Semantic feedback colors must be consistent for user
 *    understanding regardless of theme styling.
 * ==========================================================================
 */

/* ==========================================================================
   CSS Custom Properties & Layout Structure
   ========================================================================== */
.wp-member-directory {
	/* Typography - Inherit from theme by default */
	--md-font-family: inherit;
	--md-font-size-base: inherit;
	--md-font-size-sm: 0.875em;
	--md-font-size-xs: 0.8em;
	--md-line-height: inherit;
	--md-line-height-tight: 1.4;

	/* Layout */
	--md-container-max-width: 1200px;
	--md-container-padding: 1em;
	--md-grid-gap: 1em;
	--md-section-gap: 2em;
	--md-subsection-gap: 1.5em;

	/* Cards */
	--md-card-padding: 1em;
	--md-card-border-radius: 0.5em;
	--md-card-border-color: currentcolor;
	--md-card-border-width: 1px;

	/* Forms */
	--md-input-padding: 0.5em 0.75em;
	--md-input-border-radius: 0.25em;
	--md-input-border-color: currentcolor;
	--md-label-font-weight: 500;

	/* Semantic Colors */
	--md-color-danger: #dc3232;
	--md-color-danger-dark: #c00;
	--md-color-success-rgb: 70, 180, 80;
	--md-color-error-rgb: 220, 50, 50;
	--md-color-warning-rgb: 255, 185, 0;
	--md-color-info-rgb: 0, 115, 170;

	/* Tooltip */
	--md-tooltip-bg: #333;
	--md-tooltip-text: #fff;

	/* Highlight */
	--md-highlight-bg: #fffacd;

	/* Transitions */
	--md-transition: 0.2s ease;

	/* Layout Structure */
	max-width: var(--md-container-max-width);
	margin: 0 auto;
	padding: 0 var(--md-container-padding);
	box-sizing: border-box;
	overflow-x: hidden;
	font-family: var(--md-font-family);
	font-size: var(--md-font-size-base);
	line-height: var(--md-line-height);
}

.wp-member-directory *,
.wp-member-directory *::before,
.wp-member-directory *::after {
	box-sizing: inherit;
}

/* ==========================================================================
   Directory Listing Grid
   Cards have minimum 400px width to ensure consistent sizing across pages
   ========================================================================== */
.directory-header {
	margin-bottom: var(--md-section-gap);
}

.directory-search {
	display: flex;
	flex-wrap: wrap;
	gap: 0.5em;
	max-width: 400px;
	width: 100%;
}

.directory-search input[type="search"] {
	flex: 1 1 200px;
	min-width: 0;
	padding: var(--md-input-padding);
	font-size: 1em;
	border: 1px solid currentcolor;
	border-radius: var(--md-input-border-radius);
	opacity: 0.9;
}

.directory-search input[type="search"]:focus {
	outline: 2px solid currentcolor;
	outline-offset: 1px;
	opacity: 1;
}

.directory-search-submit {
	padding: var(--md-input-padding);
	border: 1px solid currentcolor;
	border-radius: var(--md-input-border-radius);
	background: transparent;
	color: inherit;
	cursor: pointer;
	opacity: 0.9;
	display: flex;
	align-items: center;
	justify-content: center;
}

.directory-search-submit:hover {
	opacity: 1;
}

.directory-search-submit .dashicons {
	font-size: 1.2em;
	width: 1.2em;
	height: 1.2em;
	color: inherit;
}

.directory-grid,
.directory-list {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(min(100%, 320px), 1fr));
	gap: var(--md-grid-gap);
	margin: var(--md-grid-gap) 0;
}

.directory-list {
	list-style: none;
	padding: 0;
}

.directory-entry {
	padding: var(--md-card-padding);
	border: 1px solid currentcolor;
	border-radius: var(--md-input-border-radius);
	opacity: 0.9;
}

.directory-entry:hover {
	opacity: 1;
}

.directory-entry h3 {
	margin: 0 0 0.5em;
}

.directory-entry p {
	margin: 0.25em 0;
}

/* ==========================================================================
   Family Cards (Directory Display & Profile View)
   ========================================================================== */
.family-card {
	display: flex;
	flex-direction: column;
	padding: var(--md-card-padding);
	border: var(--md-card-border-width) solid var(--md-card-border-color);
	border-radius: var(--md-card-border-radius);
	opacity: 0.95;
	height: 100%;
}

.family-card-header {
	display: flex;
	align-items: center;
	gap: var(--md-grid-gap);
	margin-bottom: var(--md-grid-gap);
	padding-bottom: var(--md-grid-gap);
	border-bottom: 1px solid currentcolor;
}

/* Family photo - full width at top of card */
.family-card > .family-photo {
	width: 100%;
	margin-bottom: var(--md-grid-gap);
	border-radius: var(--md-card-border-radius);
	position: relative;
}

.family-card > .family-photo img {
	width: 100%;
	height: auto;
	display: block;
	border-radius: var(--md-card-border-radius);
	position: relative;
}

.family-card > .family-photo .no-photo-placeholder {
	width: 100%;
	aspect-ratio: 4 / 3;
	display: flex;
	align-items: center;
	justify-content: center;
	border: 1px dashed currentcolor;
	border-radius: var(--md-card-border-radius);
	font-size: 0.85em;
	opacity: 0.6;
	text-align: center;
	padding: var(--md-card-padding);
}

/* Family info - below photo */
.family-info {
	flex: 1;
	position: relative;
}

.family-name {
	margin: 0 0 0.5em 0;
	font-size: 1.1em;
}

.family-members {
	margin: 0.5em 0;
}

.family-members p {
	margin: 0;
}

.family-address {
	margin: 0.5em 0;
	line-height: var(--md-line-height-tight);
	font-size: 0.9em;
}

.family-phones,
.family-emails {
	margin: 0.5em 0;
	font-size: 0.9em;
}

.family-phone,
.family-email {
	margin: 0.25em 0;
}

.family-phone a,
.family-email a {
	text-decoration: none;
}

.family-phone a:hover,
.family-email a:hover {
	text-decoration: underline;
}

.phone-type {
	opacity: 0.7;
	font-size: 0.9em;
}

.family-member {
	display: flex;
	align-items: center;
	gap: 0.5em;
	padding: 0.5em 1em;
}

.family-member-photo {
	width: 32px;
	height: 32px;
	border-radius: 50%;
	object-fit: cover;
}

/* ==========================================================================
   Forms - Structure Only
   ========================================================================== */
.registration-form,
.member-profile-form,
.edit-profile-form {
	max-width: 800px;
	margin: 0 auto;
}

.form-section {
	margin-bottom: var(--md-section-gap);
	padding: var(--md-card-padding);
	border: var(--md-card-border-width) solid var(--md-card-border-color);
	border-radius: var(--md-input-border-radius);
	opacity: 0.95;
}

.form-section:last-child {
	margin-bottom: 0;
}

/* ==========================================================================
   Form Fields - Minimal Structure
   ========================================================================== */
.form-field {
	margin-bottom: var(--md-grid-gap);
}

.form-row {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(min(200px, 100%), 1fr));
	gap: var(--md-grid-gap);
	margin-bottom: var(--md-grid-gap);
	align-items: start;
}

/* Ensure consistent alignment when labels have different lengths */
.form-row > .form-field {
	display: flex;
	flex-direction: column;
}

.form-row > .form-field label {
	min-height: 1.5em;
	line-height: var(--md-line-height-tight);
}

.form-field label,
.form-row label {
	display: block;
	margin-bottom: 0.25em;
	font-weight: var(--md-label-font-weight);
}

/* EXCEPTION: Red for required field indicators.
   Red asterisks are a universal convention for required fields. */
.form-field.required label::after {
	content: " *";
	color: var(--md-color-danger);
}

.form-field label .required,
.form-row label .required {
	color: var(--md-color-danger-dark);
}

/* Grid layout for side-by-side fields */
.form-row-group {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(min(200px, 100%), 1fr));
	gap: var(--md-grid-gap);
}

/* ==========================================================================
   Inputs - Width Control Only
   Theme handles all other styling
   ========================================================================== */
.wp-member-directory input[type="text"],
.wp-member-directory input[type="email"],
.wp-member-directory input[type="tel"],
.wp-member-directory input[type="password"],
.wp-member-directory input[type="url"],
.wp-member-directory input[type="number"],
.wp-member-directory input[type="date"],
.wp-member-directory select,
.wp-member-directory textarea {
	display: block;
	width: 100%;
	max-width: 100%;
	padding: var(--md-input-padding);
	font-family: var(--md-font-family);
	font-size: 1em;
	line-height: var(--md-line-height-tight);
	border: 1px solid var(--md-input-border-color);
	border-radius: var(--md-input-border-radius);
	box-sizing: border-box;
	opacity: 0.8;
}

.wp-member-directory input[type="text"]:focus,
.wp-member-directory input[type="email"]:focus,
.wp-member-directory input[type="tel"]:focus,
.wp-member-directory input[type="password"]:focus,
.wp-member-directory input[type="url"]:focus,
.wp-member-directory input[type="number"]:focus,
.wp-member-directory input[type="date"]:focus,
.wp-member-directory select:focus,
.wp-member-directory textarea:focus {
	outline: 2px solid currentcolor;
	outline-offset: 1px;
	opacity: 1;
}

.wp-member-directory textarea {
	min-height: 100px;
	resize: vertical;
}

/* ==========================================================================
   Select Dropdown - Highlighted Options
   NOTE: Yellow background (#fffacd) used for top churches in Church of
   Ascription dropdown. This is a UX requirement to draw attention to the
   most commonly selected options.
   ========================================================================== */
.church-select option.highlighted-option {
	background-color: var(--md-highlight-bg);
	font-weight: 600;
}

/* ==========================================================================
   Checkboxes and Radio Buttons
   ========================================================================== */
.checkbox-field,
.radio-field {
	display: flex;
	align-items: center;
	margin-bottom: 0.5em;
}

.checkbox-field label,
.radio-field label {
	display: inline;
	margin-bottom: 0;
	margin-left: 0.5em;
	cursor: pointer;
}

.checkbox-group,
.radio-group {
	display: flex;
	flex-direction: column;
	gap: 0.5em;
	margin-top: 0.25em;
}

.checkbox-group.inline,
.radio-group.inline {
	flex-direction: row;
	flex-wrap: wrap;
	gap: 1em;
}

/* ==========================================================================
   Phone Number Fields
   ========================================================================== */
.phone-numbers-container {
	margin-bottom: 0.5em;
}

.phone-item {
	padding: var(--md-card-padding);
	margin-bottom: var(--md-grid-gap);
	border: var(--md-card-border-width) solid var(--md-card-border-color);
	border-radius: var(--md-input-border-radius);
	opacity: 0.9;
}

.phone-header {
	margin: 0 0 1em 0;
	display: flex;
	justify-content: space-between;
	align-items: center;
	font-size: 1em;
	font-weight: 600;
	padding-bottom: 0.5em;
	border-bottom: 1px solid currentcolor;
	opacity: 0.7;
}

.phone-row {
	align-items: end;
}

.phone-item .form-field {
	margin-bottom: 0;
}

.phone-actions {
	display: flex;
	gap: 0.25em;
	padding-bottom: 2px;
}

.add-phone {
	margin-top: 0.5em;
}

/* ==========================================================================
   Member Sections
   ========================================================================== */
.member-section,
.additional-member {
	padding: var(--md-card-padding);
	margin-bottom: var(--md-grid-gap);
	border: var(--md-card-border-width) solid var(--md-card-border-color);
	border-radius: var(--md-input-border-radius);
	opacity: 0.95;
}

/* Spouse section container - ensures spacing before dependents section */
#spouse-section-container {
	margin-bottom: var(--md-section-gap);
}

/* Spouse and Dependents sections - match form-section spacing */
.spouse-section,
.dependents-section {
	margin-bottom: var(--md-section-gap);
	padding: var(--md-card-padding);
	border: var(--md-card-border-width) solid var(--md-card-border-color);
	border-radius: var(--md-input-border-radius);
	opacity: 0.95;
}

/* Remove bottom margin when section is last child within its container */
.spouse-section:last-child,
.dependents-section:last-child {
	margin-bottom: 0;
}

.dependent-item {
	padding: var(--md-card-padding);
	margin-bottom: var(--md-grid-gap);
	border: var(--md-card-border-width) solid var(--md-card-border-color);
	border-radius: var(--md-input-border-radius);
	position: relative;
	opacity: 0.9;
}

.dependent-item h4 {
	margin: 0 0 1em 0;
	display: flex;
	justify-content: space-between;
	align-items: center;
	font-size: 1.1em;
	font-weight: 600;
}

/* Member section headers with remove buttons */
.spouse-section h3,
.form-section h3 {
	display: flex;
	justify-content: space-between;
	align-items: center;
	margin: 0 0 1em 0;
	padding-bottom: 0.5em;
	border-bottom: 1px solid currentcolor;
	font-size: 1.2em;
	font-weight: 600;
	opacity: 0.8;
}

.member-section-header,
.additional-member-header {
	display: flex;
	justify-content: space-between;
	align-items: center;
	margin-bottom: 1em;
	padding-bottom: 0.5em;
	border-bottom: 1px solid currentcolor;
	opacity: 0.8;
}

.member-section-header h4,
.additional-member-header h4 {
	margin: 0;
}

/* ==========================================================================
   Remove/Delete Buttons
   EXCEPTION: Hardcoded red (#dc3232) used for danger/destructive actions.
   Red is universally understood as "danger" and must remain consistent
   regardless of theme styling for user safety.
   ========================================================================== */
.remove-spouse,
.remove-dependent,
.remove-phone,
.button-link-delete {
	color: var(--md-color-danger);
	background-color: transparent;
	border: 1px solid var(--md-color-danger);
	padding: 0.35em 0.75em;
	font-size: var(--md-font-size-sm);
	font-weight: var(--md-label-font-weight);
	text-decoration: none;
	cursor: pointer;
	border-radius: var(--md-input-border-radius);
	transition: all var(--md-transition);
	line-height: var(--md-line-height-tight);
	white-space: nowrap;
}

.remove-spouse:hover,
.remove-dependent:hover,
.remove-phone:hover,
.button-link-delete:hover {
	background-color: var(--md-color-danger);
	color: #fff;
	border-color: var(--md-color-danger);
	text-decoration: none;
}

.under-18-fields,
.over-18-fields {
	margin-top: var(--md-grid-gap);
}

#add-dependent,
#add-spouse,
.add-phone {
	margin-top: var(--md-grid-gap);
	font-size: 1em;
}

/* ==========================================================================
   Photo Upload
   NOTE: Hardcoded colors used for .current-photo border and .description text
   to ensure visibility regardless of theme. Photo dimensions are explicit
   to prevent overflow.
   ========================================================================== */
.photo-upload-field {
	margin-bottom: 1em;
}

.photo-preview {
	display: flex;
	align-items: center;
	gap: 1em;
	margin-bottom: 1em;
}

.photo-preview img {
	width: 100px;
	height: 100px;
	object-fit: cover;
	border-radius: 50%;
}

/* Current photo display - contains uploaded images */
.current-photo {
	display: flex;
	flex-direction: column;
	align-items: flex-start;
	gap: 0.5em;
	margin-bottom: var(--md-grid-gap);
	padding: var(--md-card-padding);
	border: 1px solid currentcolor;
	border-radius: var(--md-input-border-radius);
	max-width: 100%;
	overflow: hidden;
}

/* Constrain uploaded images to prevent overflow */
.current-photo img {
	max-width: 200px;
	max-height: 200px;
	width: auto;
	height: auto;
	object-fit: contain;
	border-radius: var(--md-input-border-radius);
}

.current-photo p {
	margin: 0;
	font-size: 0.9em;
	opacity: 0.8;
}

/* Delete photo button */
.delete-photo-button {
	color: var(--md-color-danger);
	background-color: transparent;
	border: 1px solid var(--md-color-danger);
	padding: 0.35em 0.75em;
	font-size: var(--md-font-size-sm);
	cursor: pointer;
	border-radius: var(--md-input-border-radius);
	transition: all var(--md-transition);
}

.delete-photo-button:hover {
	background-color: var(--md-color-danger);
	color: #fff;
}

/* Photo upload description/help text */
.form-field .description {
	display: block;
	margin-top: 0.5em;
	font-size: 0.85em;
	font-style: italic;
	opacity: 0.7;
}

/* ==========================================================================
   Form Actions
   ========================================================================== */
.form-actions {
	display: flex;
	gap: var(--md-grid-gap);
	margin-top: var(--md-section-gap);
	padding-top: var(--md-card-padding);
	border-top: 1px solid currentcolor;
}

.form-actions button[type="submit"],
.form-actions .button-primary {
	padding: 0.625em 1.5em;
	font-size: 1em;
	font-weight: 500;
}

/* ==========================================================================
   Messages - Semantic Status Colors
   EXCEPTION: Hardcoded rgba() colors for success/error/warning/info states.
   These semantic colors must be consistent for user understanding:
   - Green (70, 180, 80): Success/confirmation
   - Red (220, 50, 50): Error/failure
   - Yellow (255, 185, 0): Warning/caution
   - Blue (0, 115, 170): Information
   ========================================================================== */
.member-directory-message,
.form-message,
.notice {
	padding: var(--md-card-padding);
	margin-bottom: var(--md-grid-gap);
	border-radius: var(--md-input-border-radius);
	border-width: 1px;
	border-style: solid;
}

.member-directory-message.success,
.form-message.success,
.notice-success {
	background-color: rgba(var(--md-color-success-rgb), 0.1);
	border-color: rgba(var(--md-color-success-rgb), 0.5);
}

.member-directory-message.error,
.form-message.error,
.notice-error {
	background-color: rgba(var(--md-color-error-rgb), 0.1);
	border-color: rgba(var(--md-color-error-rgb), 0.5);
}

.member-directory-message.warning,
.form-message.warning,
.notice-warning {
	background-color: rgba(var(--md-color-warning-rgb), 0.1);
	border-color: rgba(var(--md-color-warning-rgb), 0.5);
}

.member-directory-message.info,
.form-message.info,
.notice-info {
	background-color: rgba(var(--md-color-info-rgb), 0.1);
	border-color: rgba(var(--md-color-info-rgb), 0.5);
}

/* EXCEPTION: Red for validation errors - must be visible regardless of theme */
.form-field.has-error input,
.form-field.has-error select,
.form-field.has-error textarea {
	border-color: var(--md-color-danger-dark);
}

.form-field .field-error,
.field-error-message {
	display: block;
	margin-top: 0.25em;
	color: var(--md-color-danger-dark);
}

/* Age Display - shown next to birth date fields */
.age-display {
	display: inline-block;
	margin-left: 0.5em;
	font-size: 0.9em;
	color: inherit;
	opacity: 0.7;
}

.age-display.age-warning {
	color: rgb(var(--md-color-warning-rgb));
	opacity: 1;
	font-weight: 500;
}

/* ==========================================================================
   Profile View Page
   ========================================================================== */
.profile-view {
	max-width: 500px;
	margin: 0;
}

.profile-view h1 {
	margin: 0 0 0.5em 0;
}

.profile-view > .description {
	margin-bottom: var(--md-subsection-gap);
	opacity: 0.8;
}

.profile-view .directory-grid {
	display: grid;
	grid-template-columns: 1fr;
	margin: var(--md-subsection-gap) 0;
}

/* Profile view shows single card - remove height constraint */
.profile-view .family-card {
	height: auto;
}

.profile-actions {
	margin-top: var(--md-subsection-gap);
	padding-top: var(--md-subsection-gap);
	border-top: 1px solid currentcolor;
}

/* Profile View - Read-only Fields */
.profile-field,
.read-only-field {
	margin-bottom: 1em;
	padding: 1em;
}

.profile-field-label,
.read-only-field label {
	display: block;
	margin-bottom: 0.25em;
	opacity: 0.7;
}

.profile-section {
	margin-bottom: var(--md-section-gap);
}

.profile-section h3 {
	margin: 0 0 1em;
	padding-bottom: 0.5em;
	border-bottom: 1px solid currentcolor;
}

.profile-grid {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
	gap: var(--md-grid-gap);
}

/* ==========================================================================
   Dashboard
   ========================================================================== */
.member-dashboard {
	max-width: 1000px;
	margin: 0 auto;
}

.dashboard-section {
	padding: var(--md-card-padding);
	margin-bottom: var(--md-grid-gap);
	border: 1px solid currentcolor;
	border-radius: var(--md-input-border-radius);
}

.dashboard-section h2 {
	margin: 0 0 var(--md-grid-gap);
}

.dashboard-actions {
	display: flex;
	gap: var(--md-grid-gap);
	flex-wrap: wrap;
}

/* ==========================================================================
   Tooltips
   NOTE: Hardcoded background (#333) and text (#fff) colors are REQUIRED
   for tooltips to be readable regardless of theme. Without explicit colors,
   tooltip text may be invisible against theme backgrounds.
   NOTE: All selectors MUST be scoped to .wp-member-directory to prevent
   conflicts with theme tooltip systems (e.g., Bootstrap, Genesis themes).
   ========================================================================== */
.wp-member-directory .tooltip,
.wp-member-directory .church-tooltip,
.wp-member-directory .sacramental-tooltip,
.wp-member-directory .lastname-tooltip,
.wp-member-directory .ecclesiastical-tooltip {
	position: relative;
	display: inline-block;
	margin-left: 0.25em;
	cursor: help;
}

.wp-member-directory .tooltip-icon {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 1em;
	height: 1em;
	border-radius: 50%;
	border: 1px solid currentcolor;
}

/* Tooltip popup - uses .tooltiptext class from HTML */
.wp-member-directory .tooltip-content,
.wp-member-directory .tooltip .tooltiptext,
.wp-member-directory .church-tooltip .tooltiptext,
.wp-member-directory .sacramental-tooltip .tooltiptext,
.wp-member-directory .lastname-tooltip .tooltiptext,
.wp-member-directory .ecclesiastical-tooltip .tooltiptext {
	visibility: hidden;
	opacity: 0;
	position: absolute;
	z-index: 1000;
	bottom: 125%;
	left: 50%;
	transform: translateX(-50%);
	min-width: 200px;
	max-width: 300px;
	padding: 0.75em 1em;
	text-align: left;
	font-size: 0.85em;
	font-weight: normal;
	line-height: var(--md-line-height-tight);

	/* EXCEPTION: Hardcoded colors required for tooltip visibility */
	background-color: var(--md-tooltip-bg);
	color: var(--md-tooltip-text);
	border-radius: var(--md-input-border-radius);
	box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
	transition: opacity var(--md-transition), visibility var(--md-transition);
}

/* Tooltip arrow */
.wp-member-directory .tooltip-content::after,
.wp-member-directory .tooltip .tooltiptext::after,
.wp-member-directory .church-tooltip .tooltiptext::after,
.wp-member-directory .sacramental-tooltip .tooltiptext::after,
.wp-member-directory .lastname-tooltip .tooltiptext::after,
.wp-member-directory .ecclesiastical-tooltip .tooltiptext::after {
	content: "";
	position: absolute;
	top: 100%;
	left: 50%;
	transform: translateX(-50%);
	border-width: 6px;
	border-style: solid;
	border-color: var(--md-tooltip-bg) transparent transparent transparent;
}

.wp-member-directory .tooltip:hover .tooltip-content,
.wp-member-directory .tooltip:hover .tooltiptext,
.wp-member-directory .church-tooltip:hover .tooltiptext,
.wp-member-directory .sacramental-tooltip:hover .tooltiptext,
.wp-member-directory .lastname-tooltip:hover .tooltiptext,
.wp-member-directory .ecclesiastical-tooltip:hover .tooltiptext {
	visibility: visible;
	opacity: 1;
}

/* Different last names toggle styling */
.wp-member-directory .different-lastnames-toggle {
	margin-top: 0.5em;
	margin-bottom: 1em;
}

/* Override tooltip positioning for lastname tooltip - appear below to avoid clipping by form-section border */
.wp-member-directory .different-lastnames-toggle .lastname-tooltip .tooltiptext {
	bottom: auto;
	top: 125%;
}

.wp-member-directory .different-lastnames-toggle .lastname-tooltip .tooltiptext::after {
	top: auto;
	bottom: 100%;
	border-color: transparent transparent var(--md-tooltip-bg) transparent;
}

/* Ecclesiastical address toggle styling */
.wp-member-directory .ecclesiastical-address-toggle {
	margin-top: 0.5em;
	margin-bottom: 0.5em;
}

/* Override tooltip positioning for ecclesiastical tooltip - appear below to avoid clipping */
.wp-member-directory .ecclesiastical-address-toggle .ecclesiastical-tooltip .tooltiptext {
	bottom: auto;
	top: 125%;
}

.wp-member-directory .ecclesiastical-address-toggle .ecclesiastical-tooltip .tooltiptext::after {
	top: auto;
	bottom: 100%;
	border-color: transparent transparent var(--md-tooltip-bg) transparent;
}

/* ==========================================================================
   Responsive Design - Bootstrap 5.3 Breakpoints

   xs: <576px    (extra small - portrait phones)
   sm: ≥576px   (small - landscape phones)
   md: ≥768px   (medium - tablets)
   lg: ≥992px   (large - desktops)
   xl: ≥1200px  (extra large - large desktops)
   xxl: ≥1400px (extra extra large)
   ========================================================================== */

/* Extra small devices (portrait phones, less than 576px) */
@media screen and (max-width: 575.98px) {

	.wp-member-directory {
		padding: 0 0.5em;
	}

	/* ===== DIRECTORY GRID ===== */
	.directory-grid,
	.directory-list {
		grid-template-columns: 1fr;
		gap: 0.75em;
	}

	.family-card {
		padding: 0.75em;
	}

	.family-name {
		font-size: 1em;
	}

	.family-address,
	.family-phones,
	.family-emails {
		font-size: 0.85em;
	}

	.directory-search {
		max-width: 100%;
	}

	.directory-search input[type="search"] {
		flex: 1 1 100%;
		font-size: 16px; /* Prevents iOS zoom on focus */
	}

	/* ===== REGISTRATION FORM ===== */
	.registration-form,
	.member-profile-form,
	.edit-profile-form {
		padding: 0;
	}

	.form-section {
		padding: 1em;
		margin-bottom: 1em;
	}

	.form-section h3 {
		font-size: 1.1em;
		flex-wrap: wrap;
		gap: 0.5em;
	}

	/* Force all form rows to single column */
	.form-row {
		grid-template-columns: 1fr;
		gap: 0.75em;
	}

	.form-row-group {
		grid-template-columns: 1fr;
		gap: 0.75em;
	}

	/* Form fields */
	.form-field {
		margin-bottom: 0.75em;
	}

	.form-field label {
		font-size: 0.95em;
		margin-bottom: 0.35em;
	}

	/* Inputs - 16px prevents iOS zoom on focus */
	.wp-member-directory input[type="text"],
	.wp-member-directory input[type="email"],
	.wp-member-directory input[type="tel"],
	.wp-member-directory input[type="password"],
	.wp-member-directory input[type="url"],
	.wp-member-directory input[type="number"],
	.wp-member-directory input[type="date"],
	.wp-member-directory select,
	.wp-member-directory textarea {
		font-size: 16px;
		padding: 0.6em 0.75em;
		width: 100%;
	}

	/* Age display - stack below date input on small screens */
	.age-display {
		display: block;
		margin-left: 0;
		margin-top: 0.35em;
	}

	/* Phone fields */
	.phone-item {
		padding: 0.75em;
	}

	.phone-header {
		font-size: 0.95em;
		flex-wrap: wrap;
		gap: 0.5em;
	}

	.phone-row {
		grid-template-columns: 1fr;
		gap: 0.5em;
	}

	.phone-actions {
		justify-content: flex-start;
		margin-top: 0.5em;
	}

	/* Member sections */
	.member-section,
	.additional-member {
		padding: 1em;
		margin-bottom: 1em;
	}

	.dependent-item {
		padding: 0.75em;
	}

	.dependent-item h4 {
		font-size: 1em;
		flex-wrap: wrap;
		gap: 0.5em;
	}

	/* Buttons - full width for touch targets */
	#add-dependent,
	#add-spouse,
	.add-phone {
		width: 100%;
		text-align: center;
		padding: 0.75em 1em;
	}

	.form-actions {
		flex-direction: column;
	}

	.form-actions button,
	.form-actions .button {
		width: 100%;
		padding: 0.75em 1em;
	}

	.remove-spouse,
	.remove-dependent,
	.remove-phone {
		padding: 0.5em 0.75em;
		font-size: 0.85em;
	}

	/* Photo upload */
	.current-photo img {
		max-width: 150px;
		max-height: 150px;
	}

	/* Checkboxes */
	.form-field-checkbox label {
		font-size: 0.9em;
		display: flex;
		align-items: flex-start;
		gap: 0.5em;
	}

	.form-field-checkbox input[type="checkbox"] {
		margin-top: 0.2em;
		flex-shrink: 0;
	}

	/* Tooltips - reposition for small screens */
	.wp-member-directory .tooltip-content,
	.wp-member-directory .tooltip .tooltiptext,
	.wp-member-directory .church-tooltip .tooltiptext,
	.wp-member-directory .sacramental-tooltip .tooltiptext,
	.wp-member-directory .lastname-tooltip .tooltiptext,
	.wp-member-directory .ecclesiastical-tooltip .tooltiptext {
		left: 0;
		transform: translateX(0);
		min-width: 250px;
		max-width: calc(100vw - 2em);
	}

	.wp-member-directory .tooltip-content::after,
	.wp-member-directory .tooltip .tooltiptext::after,
	.wp-member-directory .church-tooltip .tooltiptext::after,
	.wp-member-directory .sacramental-tooltip .tooltiptext::after,
	.wp-member-directory .lastname-tooltip .tooltiptext::after,
	.wp-member-directory .ecclesiastical-tooltip .tooltiptext::after {
		left: 1em;
		transform: translateX(0);
	}

	/* Keep lastname toggle tooltip below on small screens */
	.wp-member-directory .different-lastnames-toggle .lastname-tooltip .tooltiptext {
		bottom: auto;
		top: 125%;
	}

	.wp-member-directory .different-lastnames-toggle .lastname-tooltip .tooltiptext::after {
		top: auto;
		bottom: 100%;
		border-color: transparent transparent var(--md-tooltip-bg) transparent;
	}

	/* Keep ecclesiastical toggle tooltip below on small screens */
	.wp-member-directory .ecclesiastical-address-toggle .ecclesiastical-tooltip .tooltiptext {
		bottom: auto;
		top: 125%;
	}

	.wp-member-directory .ecclesiastical-address-toggle .ecclesiastical-tooltip .tooltiptext::after {
		top: auto;
		bottom: 100%;
		border-color: transparent transparent var(--md-tooltip-bg) transparent;
	}

	.form-field .description {
		font-size: 0.8em;
	}
}

/* Small devices (landscape phones, less than 768px) */
@media screen and (max-width: 767.98px) {

	.form-row-group {
		grid-template-columns: 1fr;
	}

	.phone-item {
		grid-template-columns: 1fr;
		gap: 0.5em;
	}

	.form-actions {
		flex-direction: column;
	}

	/* Family card adjustments */
	.family-card {
		text-align: center;
	}

	.family-card-header {
		flex-direction: column;
		text-align: center;
	}

	.member-section-header,
	.additional-member-header {
		flex-direction: column;
		gap: 0.5em;
		text-align: center;
	}

	.dashboard-actions {
		flex-direction: column;
	}

	.profile-grid {
		grid-template-columns: 1fr;
	}

	.form-section h3 {
		flex-wrap: wrap;
		gap: 0.5em;
	}

	.dependent-item h4 {
		flex-wrap: wrap;
		gap: 0.5em;
	}
}

/* ==========================================================================
   Print Styles
   ========================================================================== */
@media print {

	.form-actions,
	.add-member-btn,
	.remove-member-btn,
	.remove-phone-btn,
	.delete-photo-btn {
		display: none !important;
	}

	.directory-entry,
	.family-card,
	.member-section,
	.form-section {
		break-inside: avoid;
		page-break-inside: avoid;
	}
}

/* ==========================================================================
   Accessibility
   ========================================================================== */
@media (prefers-reduced-motion: reduce) {

	*,
	*::before,
	*::after {
		animation-duration: 0.01ms !important;
		animation-iteration-count: 1 !important;
		transition-duration: 0.01ms !important;
	}
}

/* Screen reader only content */
.sr-only,
.screen-reader-text {
	position: absolute;
	width: 1px;
	height: 1px;
	padding: 0;
	margin: -1px;
	overflow: hidden;
	clip: rect(0, 0, 0, 0);
	white-space: nowrap;
	border: 0;
}

/* ==========================================================================
   Photo Lightbox
   ========================================================================== */

/* Make clickable photos show pointer cursor */
.wp-member-directory .family-photo img[data-full-src] {
	cursor: zoom-in;
}

/* Lightbox overlay */
.md-lightbox-overlay {
	position: fixed;
	inset: 0;
	z-index: 999999;
	display: flex;
	align-items: center;
	justify-content: center;
	background: rgb(0 0 0 / 90%);
	opacity: 0;
	visibility: hidden;
	transition: opacity 0.3s ease, visibility 0.3s ease;
	cursor: zoom-out;
}

.md-lightbox-overlay.active {
	opacity: 1;
	visibility: visible;
}

/* Lightbox image container */
.md-lightbox-content {
	position: relative;
	max-width: 90vw;
	max-height: 90vh;
	transform: scale(0.9);
	transition: transform 0.3s ease;
}

.md-lightbox-overlay.active .md-lightbox-content {
	transform: scale(1);
}

/* Lightbox image */
.md-lightbox-content img {
	display: block;
	max-width: 90vw;
	max-height: 90vh;
	width: auto;
	height: auto;
	object-fit: contain;
	border-radius: 4px;
	box-shadow: 0 4px 20px rgb(0 0 0 / 50%);
}

/* Close button */
.md-lightbox-close {
	position: absolute;
	top: -40px;
	right: 0;
	padding: 8px 16px;
	font-family: inherit;
	font-size: 14px;
	font-weight: 500;
	color: #fff;
	cursor: pointer;
	background: transparent;
	border: 1px solid rgb(255 255 255 / 30%);
	border-radius: 4px;
	transition: background 0.2s ease, border-color 0.2s ease;
}

.md-lightbox-close:hover,
.md-lightbox-close:focus {
	background: rgb(255 255 255 / 10%);
	border-color: rgb(255 255 255 / 50%);
	outline: none;
}

/* Loading spinner */
.md-lightbox-loading {
	position: absolute;
	top: 50%;
	left: 50%;
	width: 40px;
	height: 40px;
	margin: -20px 0 0 -20px;
	border: 3px solid rgb(255 255 255 / 20%);
	border-top-color: #fff;
	border-radius: 50%;
	animation: md-spin 0.8s linear infinite;
}

@keyframes md-spin {

	to {
		transform: rotate(360deg);
	}
}

/* Hide loading spinner once image is loaded */
.md-lightbox-content.loaded .md-lightbox-loading {
	display: none;
}

/* Accessibility: respect reduced motion */
@media (prefers-reduced-motion: reduce) {

	.md-lightbox-overlay,
	.md-lightbox-content {
		transition: none;
	}

	.md-lightbox-loading {
		animation: none;
	}
}

/* ==========================================================================
   Private Profile Notice
   ========================================================================== */

.wp-member-directory.private-profile-notice {
	max-width: 600px;
	margin: 2em auto;
	padding: 1.5em 2em;
	background: #fff8e5;
	border: 1px solid #f0c36d;
	border-left: 4px solid #f0c36d;
	border-radius: 4px;
}

.wp-member-directory.private-profile-notice p {
	margin: 0 0 1em;
}

.wp-member-directory.private-profile-notice p:last-child {
	margin-bottom: 0;
}

.wp-member-directory.private-profile-notice a {
	color: #0073aa;
	text-decoration: underline;
}

.wp-member-directory.private-profile-notice a:hover {
	color: #005177;
}
