/**
 * Nelsons Dashboard - Profile CSS Refinements
 *
 * Enhanced styles for frontend profile templates with improved:
 * - Responsive grid behavior
 * - Typography and spacing
 * - Button consistency
 * - Avatar display
 * - Mobile-friendly adjustments
 *
 * File: assets/css/profile-refinements.css
 *
 * @package NELSONS_Membership
 * @since 2.1.0
 */

/* ==========================================================================
   CSS CUSTOM PROPERTIES (Variables)
   ========================================================================== */

:root {
	/* Profile-specific spacing */
	--nd-profile-gap: 2rem;
	--nd-profile-section-gap: 2.5rem;
	--nd-profile-field-gap: 1.25rem;

	/* Profile colors */
	--nd-profile-bg: #ffffff;
	--nd-profile-section-bg: #f8f9fa;
	--nd-profile-border: #e5e7eb;
	--nd-profile-border-focus: #2271b1;
	--nd-profile-label: #374151;
	--nd-profile-text: #1f2937;
	--nd-profile-muted: #6b7280;
	--nd-profile-success: #059669;
	--nd-profile-error: #dc2626;

	/* Typography */
	--nd-profile-font-base: 15px;
	--nd-profile-font-sm: 13px;
	--nd-profile-font-xs: 11px;
	--nd-profile-line-height: 1.6;

	/* Shadows */
	--nd-profile-shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
	--nd-profile-shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
	--nd-profile-shadow-focus: 0 0 0 3px rgba(34, 113, 177, 0.15);
}

/* ==========================================================================
   PROFILE CONTAINER & LAYOUT
   ========================================================================== */

.nd-profile-section,
.nd-manage-profile {
	max-width: 1000px;
	margin: 0 auto;
	padding: var(--nd-profile-gap);
}

/* Two-column grid for profile form */
.nd-form-grid,
.nd-profile-grid {
	display: grid;
	grid-template-columns: repeat(2, 1fr);
	gap: var(--nd-profile-gap);
	margin-bottom: var(--nd-profile-section-gap);
}

/* Column styling */
.nd-col {
	display: flex;
	flex-direction: column;
	gap: var(--nd-profile-field-gap);
}

/* Full-width sections */
.nd-col--full,
.nd-form-section--full {
	grid-column: 1 / -1;
}

/* ==========================================================================
   SECTION HEADINGS
   ========================================================================== */

.nd-col h3,
.nd-form-section h3,
.nd-form-section-title {
	margin: 0 0 var(--nd-profile-field-gap) 0;
	padding: 0 0 0.75rem 0;
	font-size: 1.125rem;
	font-weight: 600;
	color: var(--nd-profile-text);
	border-bottom: 2px solid var(--nd-primary, #2271b1);
	line-height: 1.3;
}

.nd-col h3:not(:first-child) {
	margin-top: 1rem;
}

/* ==========================================================================
   FORM GROUPS & FIELDS
   ========================================================================== */

.nd-form-group {
	margin-bottom: var(--nd-profile-field-gap);
}

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

/* Labels */
.nd-form-group > label,
.nd-form-group .nd-label {
	display: block;
	margin-bottom: 0.5rem;
	font-size: var(--nd-profile-font-base);
	font-weight: 600;
	color: var(--nd-profile-label);
	line-height: var(--nd-profile-line-height);
}

.nd-form-group > label .required,
.nd-form-group .nd-label .required {
	color: var(--nd-profile-error);
	margin-left: 2px;
}

/* Input fields */
.nd-form-group input[type="text"],
.nd-form-group input[type="email"],
.nd-form-group input[type="password"],
.nd-form-group input[type="url"],
.nd-form-group input[type="tel"],
.nd-form-group input[type="number"],
.nd-form-group input[type="date"],
.nd-form-group select,
.nd-form-group textarea {
	width: 100%;
	padding: 0.75rem 1rem;
	font-size: var(--nd-profile-font-base);
	line-height: var(--nd-profile-line-height);
	color: var(--nd-profile-text);
	background-color: var(--nd-profile-bg);
	border: 1px solid var(--nd-profile-border);
	border-radius: 6px;
	transition: border-color 0.2s ease, box-shadow 0.2s ease;
	-webkit-appearance: none;
	appearance: none;
}

.nd-form-group input:focus,
.nd-form-group select:focus,
.nd-form-group textarea:focus {
	outline: none;
	border-color: var(--nd-profile-border-focus);
	box-shadow: var(--nd-profile-shadow-focus);
}

.nd-form-group input::placeholder,
.nd-form-group textarea::placeholder {
	color: var(--nd-profile-muted);
	opacity: 0.7;
}

/* Textarea specific */
.nd-form-group textarea {
	min-height: 100px;
	resize: vertical;
}

/* Select dropdown styling */
.nd-form-group select {
	background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%236b7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3e%3c/svg%3e");
	background-position: right 0.75rem center;
	background-repeat: no-repeat;
	background-size: 1.25em 1.25em;
	padding-right: 2.5rem;
	cursor: pointer;
}

/* Field descriptions */
.nd-field-description {
	margin: 0.5rem 0 0 0;
	font-size: var(--nd-profile-font-sm);
	color: var(--nd-profile-muted);
	line-height: 1.5;
}

/* ==========================================================================
   CHECKBOX & RADIO BUTTONS
   ========================================================================== */

.nd-form-group input[type="checkbox"],
.nd-form-group input[type="radio"] {
	width: 18px;
	height: 18px;
	margin: 0;
	margin-right: 0.5rem;
	vertical-align: middle;
	cursor: pointer;
	accent-color: var(--nd-primary, #2271b1);
}

/* Checkbox/radio label styling */
.nd-form-group label:has(input[type="checkbox"]),
.nd-form-group label:has(input[type="radio"]) {
	display: flex;
	align-items: flex-start;
	gap: 0.5rem;
	font-weight: 400;
	cursor: pointer;
	padding: 0.25rem 0;
}

.nd-form-group label:has(input[type="checkbox"]) input,
.nd-form-group label:has(input[type="radio"]) input {
	flex-shrink: 0;
	margin-top: 2px;
}

/* Radio group styling */
.nd-radio-group,
.nd-checkbox-group {
	display: flex;
	flex-direction: column;
	gap: 0.5rem;
	margin-top: 0.5rem;
}

/* ==========================================================================
   AVATAR SECTION
   ========================================================================== */

.nd-avatar {
	display: flex;
	flex-direction: column;
	align-items: flex-start;
	gap: 1rem;
}

.nd-avatar-img {
	width: 120px;
	height: 120px;
	border-radius: 50%;
	object-fit: cover;
	border: 3px solid var(--nd-profile-border);
	box-shadow: var(--nd-profile-shadow-md);
	transition: border-color 0.2s ease;
}

.nd-avatar-img:hover {
	border-color: var(--nd-primary, #2271b1);
}

.nd-avatar-actions {
	display: flex;
	flex-wrap: wrap;
	gap: 0.5rem;
}

/* Avatar placeholder when no image */
.nd-avatar-placeholder {
	width: 120px;
	height: 120px;
	border-radius: 50%;
	background: linear-gradient(135deg, #e5e7eb 0%, #d1d5db 100%);
	display: flex;
	align-items: center;
	justify-content: center;
	border: 3px dashed var(--nd-profile-border);
}

.nd-avatar-placeholder .dashicons {
	font-size: 48px;
	width: 48px;
	height: 48px;
	color: var(--nd-profile-muted);
}

/* ==========================================================================
   BUTTONS
   ========================================================================== */

.nd-button {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 0.5rem;
	padding: 0.75rem 1.5rem;
	font-size: var(--nd-profile-font-base);
	font-weight: 500;
	line-height: 1;
	text-decoration: none;
	border-radius: 6px;
	border: 2px solid transparent;
	cursor: pointer;
	transition: all 0.2s ease;
	white-space: nowrap;
}

/* Primary button */
.nd-button--primary,
.nd-button.nd-button--primary {
	background-color: var(--nd-primary, #2271b1);
	border-color: var(--nd-primary, #2271b1);
	color: #ffffff;
}

.nd-button--primary:hover,
.nd-button--primary:focus {
	background-color: var(--nd-primary-hover, #135e96);
	border-color: var(--nd-primary-hover, #135e96);
	color: #ffffff;
	transform: translateY(-1px);
	box-shadow: var(--nd-profile-shadow-md);
}

/* Secondary button */
.nd-button--secondary,
.nd-button.nd-button--secondary {
	background-color: transparent;
	border-color: var(--nd-profile-border);
	color: var(--nd-profile-text);
}

.nd-button--secondary:hover,
.nd-button--secondary:focus {
	background-color: var(--nd-profile-section-bg);
	border-color: var(--nd-profile-text);
	color: var(--nd-profile-text);
}

/* Danger button */
.nd-button--danger {
	background-color: var(--nd-profile-error);
	border-color: var(--nd-profile-error);
	color: #ffffff;
}

.nd-button--danger:hover,
.nd-button--danger:focus {
	background-color: #b91c1c;
	border-color: #b91c1c;
}

/* Small button */
.nd-button--small {
	padding: 0.5rem 1rem;
	font-size: var(--nd-profile-font-sm);
}

/* Button with icon */
.nd-button .dashicons {
	font-size: 18px;
	width: 18px;
	height: 18px;
}

/* Disabled state */
.nd-button:disabled,
.nd-button[disabled] {
	opacity: 0.6;
	cursor: not-allowed;
	transform: none !important;
}

/* ==========================================================================
   FORM ACTIONS (Submit Area)
   ========================================================================== */

.nd-form-actions {
	display: flex;
	flex-wrap: wrap;
	gap: 1rem;
	padding-top: 1.5rem;
	margin-top: 1.5rem;
	border-top: 1px solid var(--nd-profile-border);
}

.nd-form-actions--right {
	justify-content: flex-end;
}

.nd-form-actions--center {
	justify-content: center;
}

.nd-form-actions--between {
	justify-content: space-between;
}

/* ==========================================================================
   SPECIAL SECTIONS (Privacy, Settings, etc.)
   ========================================================================== */

.nd-settings-section,
.nd-privacy-section {
	grid-column: 1 / -1;
	margin-top: 1rem;
	padding: 1.5rem;
	background: var(--nd-profile-section-bg);
	border: 1px solid var(--nd-profile-border);
	border-radius: 8px;
}

.nd-settings-section h3,
.nd-privacy-section h3 {
	margin-top: 0;
}

/* ==========================================================================
   CUSTOM FIELDS GRID
   ========================================================================== */

.nd-custom-fields-grid {
	display: grid;
	grid-template-columns: repeat(2, 1fr);
	gap: var(--nd-profile-field-gap) var(--nd-profile-gap);
}

.nd-custom-fields-grid .nd-form-group {
	margin-bottom: 0;
}

/* Full-width custom fields (textarea, etc.) */
.nd-custom-fields-grid .nd-custom-field[data-field-type="textarea"],
.nd-custom-fields-grid .nd-custom-field--full {
	grid-column: 1 / -1;
}

/* Visibility control styling */
.nd-cf-visibility-control {
	margin-top: 0.75rem;
	padding: 0.75rem;
	background: #f0f4f8;
	border-radius: 6px;
	font-size: var(--nd-profile-font-sm);
}

.nd-cf-visibility-label {
	display: flex;
	align-items: center;
	gap: 0.5rem;
	color: var(--nd-profile-muted);
	font-weight: 500;
}

.nd-cf-visibility-label .dashicons {
	font-size: 16px;
	width: 16px;
	height: 16px;
}

.nd-cf-visibility-control select {
	margin-left: auto;
	padding: 0.375rem 0.75rem;
	font-size: var(--nd-profile-font-sm);
	border-radius: 4px;
}

/* ==========================================================================
   ALERTS & MESSAGES
   ========================================================================== */

.nd-alert,
.nd-message {
	padding: 1rem 1.25rem;
	border-radius: 6px;
	margin-bottom: 1.5rem;
	display: flex;
	align-items: flex-start;
	gap: 0.75rem;
}

.nd-alert--success,
.nd-message--success {
	background-color: #ecfdf5;
	border: 1px solid #a7f3d0;
	color: #065f46;
}

.nd-alert--error,
.nd-message--error {
	background-color: #fef2f2;
	border: 1px solid #fecaca;
	color: #991b1b;
}

.nd-alert--warning,
.nd-message--warning {
	background-color: #fffbeb;
	border: 1px solid #fde68a;
	color: #92400e;
}

.nd-alert--info,
.nd-message--info {
	background-color: #eff6ff;
	border: 1px solid #bfdbfe;
	color: #1e40af;
}

.nd-alert .dashicons,
.nd-message .dashicons {
	flex-shrink: 0;
	margin-top: 2px;
}

/* ==========================================================================
   PUBLIC PROFILE DISPLAY
   ========================================================================== */

.nd-profile-about-me {
	margin-top: 2rem;
	padding: 1.5rem;
	background: var(--nd-profile-bg);
	border: 1px solid var(--nd-profile-border);
	border-radius: 8px;
	box-shadow: var(--nd-profile-shadow-sm);
}

.nd-profile-section-title {
	margin: 0 0 1.25rem 0;
	padding-bottom: 0.75rem;
	border-bottom: 2px solid var(--nd-primary, #2271b1);
	font-size: 1.25rem;
	font-weight: 600;
	color: var(--nd-profile-text);
}

.nd-profile-fields-grid {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
	gap: 1rem;
}

.nd-profile-field {
	padding: 1rem;
	background: var(--nd-profile-section-bg);
	border-radius: 6px;
	border-left: 3px solid var(--nd-primary, #2271b1);
	transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.nd-profile-field:hover {
	transform: translateY(-2px);
	box-shadow: var(--nd-profile-shadow-md);
}

.nd-profile-field-label {
	font-size: var(--nd-profile-font-xs);
	font-weight: 700;
	text-transform: uppercase;
	letter-spacing: 0.5px;
	color: var(--nd-profile-muted);
	margin-bottom: 0.5rem;
}

.nd-profile-field-value {
	font-size: var(--nd-profile-font-base);
	color: var(--nd-profile-text);
	line-height: var(--nd-profile-line-height);
	word-wrap: break-word;
}

.nd-profile-field-value a {
	color: var(--nd-primary, #2271b1);
	text-decoration: none;
	border-bottom: 1px solid transparent;
	transition: border-color 0.2s ease;
}

.nd-profile-field-value a:hover {
	border-bottom-color: currentColor;
}

/* ==========================================================================
   RESPONSIVE DESIGN
   ========================================================================== */

/* Tablet (768px and below) */
@media screen and (max-width: 768px) {
	:root {
		--nd-profile-gap: 1.5rem;
		--nd-profile-section-gap: 2rem;
		--nd-profile-field-gap: 1rem;
	}

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

	.nd-custom-fields-grid {
		grid-template-columns: 1fr;
	}

	.nd-col h3 {
		font-size: 1rem;
	}

	/* Stack avatar and info on tablet */
	.nd-avatar {
		align-items: center;
		text-align: center;
	}

	.nd-avatar-actions {
		justify-content: center;
	}

	/* Full-width buttons on tablet */
	.nd-form-actions {
		flex-direction: column;
	}

	.nd-form-actions .nd-button {
		width: 100%;
	}

	/* Adjust public profile grid */
	.nd-profile-fields-grid {
		grid-template-columns: 1fr;
	}
}

/* Mobile (480px and below) */
@media screen and (max-width: 480px) {
	:root {
		--nd-profile-gap: 1rem;
		--nd-profile-font-base: 14px;
	}

	.nd-profile-section,
	.nd-manage-profile {
		padding: 1rem;
	}

	/* Smaller avatar on mobile */
	.nd-avatar-img,
	.nd-avatar-placeholder {
		width: 100px;
		height: 100px;
	}

	.nd-avatar-placeholder .dashicons {
		font-size: 40px;
		width: 40px;
		height: 40px;
	}

	/* Adjust input padding */
	.nd-form-group input[type="text"],
	.nd-form-group input[type="email"],
	.nd-form-group input[type="password"],
	.nd-form-group select,
	.nd-form-group textarea {
		padding: 0.625rem 0.875rem;
	}

	/* Smaller buttons on mobile */
	.nd-button {
		padding: 0.625rem 1.25rem;
		font-size: var(--nd-profile-font-sm);
	}

	/* Settings sections */
	.nd-settings-section,
	.nd-privacy-section {
		padding: 1rem;
	}

	/* Visibility control stacked */
	.nd-cf-visibility-control {
		flex-direction: column;
		align-items: stretch;
	}

	.nd-cf-visibility-control select {
		margin-left: 0;
		margin-top: 0.5rem;
		width: 100%;
	}
}

/* ==========================================================================
   DARK MODE SUPPORT (Optional)
   ========================================================================== */

@media (prefers-color-scheme: dark) {
	.nd-profile-section,
	.nd-manage-profile {
		/* Dark mode variables can be added here if needed */
	}
}

/* ==========================================================================
   PRINT STYLES
   ========================================================================== */

@media print {
	.nd-avatar-actions,
	.nd-form-actions,
	.nd-button {
		display: none !important;
	}

	.nd-form-grid,
	.nd-profile-grid,
	.nd-custom-fields-grid {
		display: block;
	}

	.nd-col {
		margin-bottom: 1rem;
	}
}

/* ==========================================================================
   ACCESSIBILITY ENHANCEMENTS
   ========================================================================== */

/* Focus visible for keyboard navigation */
.nd-button:focus-visible,
.nd-form-group input:focus-visible,
.nd-form-group select:focus-visible,
.nd-form-group textarea:focus-visible {
	outline: 2px solid var(--nd-primary, #2271b1);
	outline-offset: 2px;
}

/* Reduced motion preference */
@media (prefers-reduced-motion: reduce) {
	.nd-button,
	.nd-form-group input,
	.nd-form-group select,
	.nd-form-group textarea,
	.nd-profile-field,
	.nd-avatar-img {
		transition: none;
	}
}

/* Skip to content link styling */
.nd-skip-link {
	position: absolute;
	left: -9999px;
	top: auto;
	width: 1px;
	height: 1px;
	overflow: hidden;
}

.nd-skip-link:focus {
	position: static;
	width: auto;
	height: auto;
	padding: 0.5rem 1rem;
	background: var(--nd-primary, #2271b1);
	color: #fff;
	z-index: 100000;
}

/* ==========================================================================
   UTILITY CLASSES
   ========================================================================== */

/* Spacing utilities */
.nd-mb-0 { margin-bottom: 0 !important; }
.nd-mb-1 { margin-bottom: 0.5rem !important; }
.nd-mb-2 { margin-bottom: 1rem !important; }
.nd-mb-3 { margin-bottom: 1.5rem !important; }
.nd-mb-4 { margin-bottom: 2rem !important; }

.nd-mt-0 { margin-top: 0 !important; }
.nd-mt-1 { margin-top: 0.5rem !important; }
.nd-mt-2 { margin-top: 1rem !important; }
.nd-mt-3 { margin-top: 1.5rem !important; }
.nd-mt-4 { margin-top: 2rem !important; }

/* Text utilities */
.nd-text-center { text-align: center !important; }
.nd-text-right { text-align: right !important; }
.nd-text-muted { color: var(--nd-profile-muted) !important; }
.nd-text-small { font-size: var(--nd-profile-font-sm) !important; }

/* Display utilities */
.nd-hidden { display: none !important; }
.nd-sr-only {
	position: absolute;
	width: 1px;
	height: 1px;
	padding: 0;
	margin: -1px;
	overflow: hidden;
	clip: rect(0, 0, 0, 0);
	white-space: nowrap;
	border: 0;
}

/* Flex utilities */
.nd-flex { display: flex !important; }
.nd-flex-wrap { flex-wrap: wrap !important; }
.nd-items-center { align-items: center !important; }
.nd-justify-between { justify-content: space-between !important; }
.nd-gap-1 { gap: 0.5rem !important; }
.nd-gap-2 { gap: 1rem !important; }