/* ============================================================
   3. Dialog Modal Rules (dialog.modal)
   Native HTML dialog with modal styling
   ============================================================ */

dialog.modal {
	position: fixed;
	background: var(--popup-bg);
	color: var(--foreground);
	border: var(--popup-border-width) var(--popup-border-style) var(--popup-border-color);
	border-radius: var(--popup-radius);
	width: calc(100% - 2rem);
	max-width: 420px;
	max-height: calc(100dvh - var(--header-height) - 2rem);
	overflow-y: auto;
	box-shadow: var(--popup-shadow);
	animation: slideFromTop 0.3s ease;
	margin: auto;
	margin-top: calc(var(--header-height) + 1rem);
	padding: 0;
}

dialog.modal::backdrop {
	background: var(--overlay-dark);
	backdrop-filter: blur(4px);
	animation: fadeIn 0.2s ease;
}

/* Size variants */
dialog.modal[data-size="sm"] { max-width: 360px; }
dialog.modal[data-size="md"] { max-width: 420px; }
dialog.modal[data-size="lg"] { max-width: 540px; }
dialog.modal[data-size="xl"] { max-width: 640px; }
dialog.modal[data-size="wide"] { max-width: 760px; }
dialog.modal[data-size="2xl"] { max-width: 960px; }

dialog.modal header {
	position: sticky;
	top: 0;
	z-index: 10;
	padding: var(--space-3) 0;
	border-bottom: 1px solid var(--border);
	background: var(--popup-header-bg);
	backdrop-filter: blur(10px);
	border-radius: var(--popup-radius) var(--popup-radius) 0 0;
}

dialog.modal header h2,
dialog.modal header h3 {
	margin: 0 1rem;
	font-size: var(--text-base);
	font-weight: 400;
	text-align: center;
}

dialog.modal header [data-action="close"],
dialog.modal header .btn-back {
	position: absolute;
	top: var(--space-2);
	background: none;
	border: none;
	color: var(--muted);
	cursor: pointer;
	padding: var(--space-1);
	border-radius: var(--radius-full);
	display: flex;
	align-items: center;
	justify-content: center;
}

dialog.modal header [data-action="close"] { right: var(--space-2); }
dialog.modal header .btn-back { left: var(--space-2); }

dialog.modal header [data-action="close"]:hover,
dialog.modal header .btn-back:hover {
	color: var(--foreground);
}

dialog.modal section {
	padding: var(--space-4) var(--space-4);
	text-align: center;
}

dialog.modal footer {
	padding: var(--space-4) var(--space-4);
	border-top: 1px solid var(--border);
	margin-top: var(--margin-base);
	background: var(--popup-footer-bg);
	display: flex;
	gap: var(--gap-base);
	justify-content: center;
}

/* ============================================================
   3b. Profile Preview (#profile-preview)
   ============================================================ */

#profile-preview {
	overflow: hidden;
}

#profile-preview > header,
#profile-preview > section {
	padding: 0;
	border: none;
	background: none;
}

#profile-preview figure {
	margin: 0;
	aspect-ratio: auto;
}

#profile-preview .info {
	padding: var(--space-4);
}

@media (min-width: 900px) {
	#profile-preview .info {
		padding: var(--space-6);
	}
}

#profile-preview > footer {
	padding: var(--space-4);
	background: none;
	justify-content: stretch;
}

/* Verification inline modal - extends unified modal */
.verification-inline-modal .modal-icon svg {
	color: var(--warning);
}

dialog .modal-actions { padding:var(--padding-base) 0; }
dialog .modal-actions button { margin-right: var(--padding-base);  }

/* ============================================
	 ACTION MODAL (Simple confirm/prompt)
	 Used by ActionModal component in Modal.tsx
	 ============================================ */

.modal-action-content {
	text-align: center;
	padding: var(--space-4) var(--space-4);
	font-size: var(--text-base);
}

.modal-icon {
	font-size: 2.5rem;
	margin-bottom: var(--space-3);
}

.modal-action-title {
	font-size: var(--text-xl);
	font-weight: 600;
	margin: 0 0 0.5rem;
	color: var(--popup-text);
}

.modal-action-desc {
	margin: 0;
	line-height: var(--line-height-normal);
	white-space: pre-line;
}

.modal-action-buttons {
	display: flex;
	flex-direction: column;
	gap: var(--space-2);
	padding: var(--space-4) 0 0;
}

.modal-action-buttons BUTTON,
.modal-action-buttons A {
	padding: var(--space-3) var(--space-6);
	border: none;
	border-radius: var(--radius-md);
	font-size: var(--text-base);
	text-decoration: none;
	text-align: center;
	transition: background 0.15s;
}

.modal-btn-primary {
	background: var(--popup-button-primary-bg);
	color: var(--popup-button-primary-text);
}

/* ============================================
	 Wallet (uses unified modal system)
	 ============================================ */

#wallet .col-balance { border-bottom: 1px solid var(--border); padding-bottom: var(--space-4); }
#wallet .col-upgrade { padding-bottom: var(--space-4); padding-top: var(--space-4); }

@media (min-width: 768px) {
	#wallet .col-balance { border-bottom: none; padding-bottom: 0; }
}

/* WalletContent - reusable component */
.wallet h1,
.wallet h2,
.wallet h3,
.wallet h4,
.wallet p {
	text-align: center;
}
.wallet h2,
.wallet h3,
.wallet h4 {
	padding-top: 1rem;
}

.wallet h1 {
	font-size: var(--text-xl);
}

.btn-vip, .btn-coins {
	background: linear-gradient(135deg, var(--vip-gold) 0%, var(--vip-gold-dark) 100%);
	color: var(--vip-button-text);
	padding: var(--space-2) var(--space-3);
	margin: var(--space-1) auto;
	font-size: var(--text-sm);
}

/* Tasks section */
.wallet .tasks {
	display: flex;
	flex-direction: column;
	gap: 0;
	list-style: none;
	margin: 0;
	padding: 0;
}

.wallet .tasks h3 {
	text-align: center;
	font-weight: 400;
	margin: var(--margin-base) 0;
}

.wallet .tasks .verify-discount {
	margin: var(--space-2) 0 0;
}

.wallet .tasks li {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: var(--gap-base);
	padding: var(--space-1) 0;
}

.wallet .tasks li.urgent span:first-child {
	animation: pulse 1s ease-in-out infinite;
}

.wallet .tasks li span:first-child {
	font-size: var(--text-base);
	flex-shrink: 0;
}

.wallet .tasks li span:last-of-type {
	font-size: var(--text-sm);
	color: var(--foreground);
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.wallet .tasks li em {
	font-size: var(--text-base);
	font-style: normal;
	color: var(--vip-gold-dark);
	font-variant-numeric: tabular-nums;
	flex-shrink: 0;
	min-width: 4rem;
	text-align: right;
}

.wallet .col-upgrade .subtitle {
	font-size: var(--text-base);
	color: var(--muted);
	margin: var(--space-5) 0;
}

.wallet fieldset {
	padding: var(--space-3) 0;
	border: none;
	border-bottom: 1px solid var(--border);
	text-align: center;
	display: grid;
	grid-template-columns: 1fr;
	align-items: center;
	margin: 0;
}

.wallet fieldset .hint {
	color: var(--muted);
	font-size: var(--text-sm);
}

.wallet fieldset label {
	display: flex;
	align-items: center;
	gap: var(--space-2);
	font-size: var(--text-base);
	cursor: pointer;
	margin: 0 auto;
}

.wallet fieldset input[type="checkbox"] {
	width: 1.5rem;
	height: 1.5rem;
	accent-color: var(--primary);
	cursor: pointer;
}

.profile-section .wallet {
	padding: var(--space-2);
}

.wallet h1 {
	align-items: center;
	justify-content: space-between;
	gap: var(--space-2);
}

.wallet footer {
	text-align: center;
	margin-top: var(--space-4);
}

/* VIP Wallet - simplified view */
.wallet.vip {
	text-align: left;
	padding: var(--space-6);
}

.wallet.vip h1 {
	margin-bottom: var(--space-4);
}

.wallet .vip-info h4 {
	margin: 0; padding: 0; font-weight: normal; color: var(--vip-gold-dark); font-size: var(--text-lg);
}

.wallet .vip-info p {
	font-size: var(--text-sm);
	color: var(--muted);
}

/* Desktop 2-column layout */
@media (min-width: 768px) {
	.wallet {
		display: grid;
		grid-template-columns: 1fr 1fr;
		align-items: baseline;
		gap: 0 var(--space-6);
	}

	.wallet.vip {
		display: grid;
		grid-template-columns: 1fr 2fr;
		gap: 0 var(--space-6);
		align-items: center;
	}

	.wallet h1 { font-size: var(--text-2xl); }
	#wallet .col-upgrade { padding-top: 0; }
	.wallet .tasks li { padding: var(--space-2\.5) 0; }

	.wallet .col-upgrade {
		border-left: 1px solid var(--border);
		padding-left: var(--space-6);
		display: flex;
		flex-direction: column;
		justify-content: center;
		text-align: center;
	}

	.wallet .verify-discount {
		grid-column: 1 / -1;
		max-width: none;
	}
}



/* ============================================
	 Popup Form Content Styles
	 ============================================ */

/* Scrollable content area for popup forms */
.popup-content {
	flex: 1;
	overflow: auto;
	padding: 0 1.5rem 1.5rem;
}

/* Modal with Background Image */
.popup-modal--has-bg {
	background-size: cover;
	background-position: center;
	background-repeat: no-repeat;
	position: relative;
}

.popup-modal--has-bg::before {
	content: '';
	position: absolute;
	top: 0;
	left: 0;
	right: 0;
	bottom: 0;
	background: var(--overlay-light);
	border-radius: var(--radius-xl);
	pointer-events: none;
}

.popup-modal--has-bg > * {
	position: relative;
	z-index: 1;
}

.popup-modal--has-bg .popup-title,
.popup-modal--has-bg .popup-subtitle {
	text-shadow: var(--text-shadow-md);
}

.popup-icon {
	text-align: center;
	margin-bottom: var(--space-3);
	font-size: var(--text-3xl);
}

.popup-image {
	margin: 0 -1.5rem 1rem;
}

.popup-image img {
	width: 100%;
	height: auto;
	display: block;
}

.popup-title {
	font-size: var(--text-xl);
	font-weight: 600;
	margin-top: var(--space-2);
	margin-bottom: var(--space-1);
	text-align: center;
}

.popup-subtitle {
	font-size: var(--text-base);
	color: var(--popup-text-muted);
	text-align: center;
	margin-bottom: var(--space-5);
}

.popup-fields {
	margin-bottom: var(--space-5);
}

.popup-fields--center {
	text-align: center;
}

/* Popup Body - HTML content, centered by default */
.popup-body {
	text-align: center;
}

/* Primary Button */
.popup-btn-primary {
	padding: var(--space-3) var(--space-6);
	background: var(--popup-button-primary-bg);
	color: var(--popup-button-primary-text);
	border: none;
	border-radius: var(--radius-md);
	font-size: var(--text-base);
	font-weight: 600;
	cursor: pointer;
	transition: opacity 0.15s;
}

.popup-btn-primary:disabled {
	cursor: wait;
	opacity: 0.5;
}

/* Secondary Button */
.popup-btn-secondary {
	padding: var(--space-2) var(--space-4);
	background: var(--popup-button-secondary-bg);
	color: var(--popup-button-secondary-text);
	border: none;
	font-size: var(--text-sm);
	cursor: pointer;
}

/* Tertiary Button */
.popup-btn-tertiary {
	padding: var(--space-1\.5) var(--space-4);
	background: transparent;
	color: var(--popup-text-muted);
	border: none;
	font-size: var(--text-xs);
	cursor: pointer;
}

/* Reward Toast */
.popup-reward-toast {
	position: fixed;
	bottom: var(--space-8);
	left: 50%;
	transform: translateX(-50%);
	background: linear-gradient(135deg, var(--success) 0%, var(--success-dark, var(--success)) 100%);
	color: var(--popup-button-primary-text);
	padding: var(--space-3) var(--space-6);
	border-radius: var(--radius-md);
	font-size: var(--text-base);
	font-weight: 600;
	z-index: 10000;
	box-shadow: var(--shadow-md);
}

/* == Popup Form Fields == */

.popup-field {
	margin-bottom: var(--space-4);
}

.popup-field:last-child {
	margin-bottom: 0;
}

.popup-field-label {
	display: block;
	font-size: var(--text-sm);
	font-weight: 500;
	margin-bottom: var(--space-2);
	color: var(--popup-text);
}

.popup-field-required {
	color: var(--error);
	margin-left: var(--space-1);
}

input.popup-field-input,
textarea.popup-field-textarea,
select.popup-field-select {
	width: 100%;
	box-sizing: border-box;
	padding: var(--space-3) var(--space-4);
	font-size: var(--text-base);
	background: var(--popup-input-bg);
	color: var(--popup-input-text);
	border: 1px solid var(--popup-input-border);
	border-radius: var(--radius-md);
	outline: none;
	transition: border-color 0.15s;
}

input.popup-field-input:focus,
textarea.popup-field-textarea:focus,
select.popup-field-select:focus {
	border-color: var(--popup-button-primary-bg);
}

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

.popup-field-char-count {
	font-size: var(--text-xs);
	color: var(--popup-text-muted);
	text-align: right;
	margin-top: var(--space-1);
}

.popup-field-error {
	color: var(--error);
	font-size: var(--text-xs);
	margin-top: var(--space-1);
}

/* Radio/Checkbox Options Container */
.popup-field-options {
	display: flex;
	gap: var(--gap-base);
	flex-wrap: wrap;
}

.popup-field-options--center {
	justify-content: center;
}

/* Radio/Checkbox Option Label */
.popup-field-option {
	display: flex;
	align-items: center;
	gap: var(--space-2);
	padding: var(--space-2) var(--space-4);
	background: var(--popup-input-bg);
	color: var(--popup-text);
	border: 1px solid var(--popup-input-border);
	border-radius: var(--radius-md);
	cursor: pointer;
	font-size: var(--text-sm);
	transition: all 0.15s ease;
}

.popup-field-option--selected {
	background: var(--popup-button-primary-bg);
	color: var(--popup-button-primary-text);
	border-color: var(--popup-button-primary-bg);
}

.popup-field-option input[type="radio"],
.popup-field-option input[type="checkbox"] {
	display: none;
}

/* == Popup Confirmation View == */

.popup-confirmation-view {
	text-align: center;
	padding: var(--space-4) 0;
}

.popup-confirmation-grid {
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: var(--gap-base);
	text-align: left;
}

.popup-confirmation-item {
	background: var(--popup-input-bg);
	padding: var(--space-3);
	border-radius: var(--radius-md);
	border: 1px solid var(--popup-input-border);
}

.popup-confirmation-item-label {
	font-size: var(--text-xs);
	color: var(--popup-text-muted);
	margin-bottom: var(--space-1);
}

.popup-confirmation-item-value {
	font-size: var(--text-sm);
	color: var(--popup-text);
	font-weight: 500;
}

.popup-confirmation-item-value--large {
	font-size: var(--text-lg);
}

.popup-confirmation-item--full {
	margin-bottom: var(--space-4);
}

/* == Profile Preview Popup == */

#profile-preview section {
	display: flex;
	flex-direction: column;
}

@media (min-width: 900px) {
	#profile-preview section {
		flex-direction: row;
	}

	#profile-preview figure {
		width: 600px;
		flex-shrink: 0;
	}

	#profile-preview .info {
		flex: 1;
		overflow-y: auto;
		max-height: 600px;
		display: flex;
		flex-direction: column;
	}
}

#profile-preview figure {
	position: relative;
}

#profile-preview .photo {
	position: relative;
	width: 100%;
	aspect-ratio: 1;
	background: var(--accent);
}

#profile-preview .photo img {
	object-fit: cover;
}

#profile-preview .online {
	position: absolute;
	bottom: var(--space-4);
	left: var(--space-4);
	width: var(--icon-xs);
	height: var(--icon-xs);
	background: var(--success);
	border: 2px solid var(--background-color);
	border-radius: var(--radius-full);
}

#profile-preview .count {
	position: absolute;
	bottom: var(--space-3);
	right: var(--space-3);
	background: var(--overlay-medium);
	color: white;
	padding: var(--space-1) var(--space-2);
	border-radius: var(--radius-xl);
	font-size: var(--text-xs);
	font-weight: 600;
	display: flex;
	align-items: center;
	gap: var(--space-1);
}

#profile-preview h3 {
	font-size: var(--text-xl);
	font-weight: 700;
	margin: 0 0 var(--space-2);
}

#profile-preview .badges {
	display: flex;
	align-items: stretch;
	gap: var(--space-2);
	margin-bottom: var(--space-3);
}

#profile-preview .badges > span {
	flex: 1;
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: var(--space-1);
	padding: var(--space-2) var(--space-3);
	background: var(--accent);
	border: 1px solid var(--border);
	border-radius: var(--radius-md);
	font-size: var(--text-xs);
	color: var(--muted);
	max-width: 80px;
}

#profile-preview address {
	display: flex;
	align-items: center;
	gap: var(--space-2);
	font-size: var(--text-sm);
	font-style: normal;
	color: var(--muted);
	margin-bottom: var(--space-3);
}

#profile-preview .tagline {
	font-size: var(--text-sm);
	font-style: italic;
	color: var(--foreground);
	margin: 0 0 var(--space-2) 0;
}

#profile-preview .about {
	font-size: var(--text-sm);
	color: var(--muted);
	line-height: var(--line-height-tight);
	margin: 0;
}

#profile-preview .info footer {
	display: flex;
	align-items: center;
	gap: var(--space-2);
	margin-top: auto;
	padding-top: var(--space-4);
}

#profile-preview > footer {
	display: flex;
	gap: var(--gap-base);
	padding: var(--space-4);
	border-top: 1px solid var(--border);
}

/* Additional photos thumbnails (blurred) */
#profile-preview .thumbs {
	display: flex;
	gap: var(--space-2);
	padding: var(--space-3);
	background: var(--accent);
}

#profile-preview .thumb {
	position: relative;
	width: var(--icon-3xl);
	height: var(--icon-3xl);
	border-radius: var(--radius-md);
	overflow: hidden;
}

#profile-preview .thumb img {
	object-fit: cover;
}

#profile-preview .blur {
	position: absolute;
	inset: 0;
	backdrop-filter: blur(8px);
	background: rgba(0, 0, 0, 0.2);
}

#profile-preview .thumb.more {
	width: var(--icon-3xl);
	height: var(--icon-3xl);
	border-radius: var(--radius-md);
	background: var(--border);
	font-size: var(--text-xs);
	font-weight: 600;
	color: var(--muted);
}

/* Interests tags */
#profile-preview .interests {
	display: flex;
	flex-wrap: wrap;
	gap: var(--space-2);
	margin-top: var(--space-3);
}

#profile-preview .interests span {
	background: var(--accent);
	border: 1px solid var(--border);
	border-radius: var(--radius-xl);
	padding: var(--space-1) var(--space-2);
	font-size: var(--text-xs);
	color: var(--foreground);
}

#profile-preview .interests em {
	font-size: var(--text-xs);
	font-style: normal;
	color: var(--muted);
	padding: var(--space-1) var(--space-2);
}

/* ============================================================
   Animations (referenced by dialogs)
   ============================================================ */

@keyframes fadeIn {
	from { opacity: 0; }
	to { opacity: 1; }
}

@keyframes slideFromTop {
	from {
		opacity: 0;
		transform: translateY(-40px);
	}
	to {
		opacity: 1;
		transform: translateY(0);
	}
}

@keyframes slideUp {
	from {
		opacity: 0;
		transform: translateY(20px);
	}
	to {
		opacity: 1;
		transform: translateY(0);
	}
}

