/* ── Light mode ── */
:root {
	--background: #ffffff;
	--foreground: #0a0a0a;
	--card: #ffffff;
	--card-foreground: #0a0a0a;
	--primary: #dd1969;
	--primary-foreground: #000;
	--primary-hover: #cb155d;
	--secondary: #f5f5f5;
	--secondary-foreground: #171717;
	--muted: #f5f5f5;
	--muted-foreground: #737373;
	--accent: #eaf1ff;
	--accent-foreground: #171717;
	--destructive: #e7000b;
	--destructive-foreground: #ffffff;
	--success: #00a268;
	--success-foreground: #ffffff;
	--success-subtle: #ccfce2;
	--destructive-subtle: #ffe8e3;
	--border: #e5e5e5;
	--input: #ffffff;
	--ring: #4c66db;
	--radius: 0.5rem;
}

/* ── Dark mode — classe .dark ou preferência do sistema ── */
.dark {
	--background: #1d1918;
	--foreground: #ecdae1;
	--card: #140f0f;
	--card-foreground: #ecdae1;
	--primary: #dd1969;
	--primary-foreground: #000;
	--primary-hover: #cb155d;
	--secondary: #1d1a19;
	--secondary-foreground: #ecdae1;
	--muted: #1d1a19;
	--muted-foreground: #a09599;
	--accent: hsl(336deg 80% 48% / 20%);
	--accent-foreground: #ecdae1;
	--destructive: #ff6467;
	--destructive-foreground: #fafafa;
	--success: #24c187;
	--success-foreground: #fafafa;
	--success-subtle: #001a0d;
	--destructive-subtle: #250e0e;
	--border: hsl(10, 8%, 32%);
	--input: hsl(10, 13%, 15%);
	--ring: #737373;
}

/* ── Tokens de componente ── */
:root {
	--form-font-family: "Inter", system-ui, sans-serif;
	--form-font-size-base: 16px;
	--form-font-size-label: 14px;
	--form-font-size-small: 12px;
	--form-max-width: 640px;
	--form-border-radius: var(--radius);
	--form-border-radius-lg: calc(var(--radius) + 4px);
	--form-padding: 2rem;
	--form-gap: 2rem;
}

*,
*::before,
*::after {
	box-sizing: border-box;
	margin: 0;
	padding: 0;
}

body {
	font-family: var(--form-font-family);
	font-size: var(--form-font-size-base);
	color: var(--foreground);
	background: var(--background);
	line-height: 1.5;
	-webkit-font-smoothing: antialiased;
}

.form-wrapper {
	max-width: var(--form-max-width);
	margin: 0 auto;
	padding: var(--form-padding);
}

/* Progress bar */
.progress-header {
	margin-bottom: var(--form-gap);
	display: none;
}

.progress-label {
	font-size: var(--form-font-size-label);
	color: var(--muted-foreground);
	margin-bottom: 0.5rem;
	display: flex;
	justify-content: space-between;
}

.progress-bar-track {
	height: 6px;
	background: var(--border);
	border-radius: 99px;
	overflow: hidden;
}

.progress-bar-fill {
	height: 100%;
	background: var(--primary);
	border-radius: 99px;
	transition: width 0.3s ease;
}

/* Sections */
.form-section {
	display: none;
}

.form-section.active {
	display: block;
}

.section-title {
	font-size: 1.25rem;
	font-weight: 600;
	margin-bottom: 0.25rem;
	color: var(--foreground);
}

.section-subtitle {
	font-size: var(--form-font-size-label);
	color: var(--muted-foreground);
	margin-bottom: var(--form-gap);
}

/* Fields */
.field {
	display: flex;
	flex-direction: column;
	gap: 0.375rem;
	margin-bottom: var(--form-gap);
}

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

label {
	font-size: var(--form-font-size-label);
	font-weight: 500;
	color: var(--foreground);
}

label .required {
	color: var(--destructive);
	margin-left: 2px;
}

input[type="text"],
input[type="email"],
input[type="url"],
textarea {
	width: 100%;
	padding: 0.625rem 0.875rem;
	font-size: var(--form-font-size-base);
	font-family: var(--form-font-family);
	color: var(--foreground);
	background: var(--input);
	border: 1.5px solid var(--border);
	border-radius: var(--form-border-radius);
	outline: none;
	transition: border-color 0.15s ease;
}

input[type="text"]:focus,
input[type="email"]:focus,
input[type="url"]:focus,
textarea:focus {
	border-color: var(--primary);
	box-shadow: 0 0 0 3px color-mix(in oklch, var(--ring) 25%, transparent);
}

input.error,
textarea.error {
	border-color: var(--destructive);
}

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

.char-counter {
	font-size: var(--form-font-size-small);
	color: var(--muted-foreground);
	text-align: right;
	margin-top: 0.125rem;
}

.char-counter.near-limit {
	color: var(--destructive);
}

.field-hint {
	font-size: var(--form-font-size-small);
	color: var(--muted-foreground);
}

/* ── Input com prefixo ── */
.input-prefix-group {
	display: flex;
	align-items: stretch;
}

.input-prefix {
	display: flex;
	align-items: center;
	padding: 0.625rem 0.75rem;
	font-size: var(--form-font-size-base);
	color: var(--muted-foreground);
	background: var(--muted);
	border: 1.5px solid var(--border);
	border-right: none;
	border-radius: var(--form-border-radius) 0 0 var(--form-border-radius);
	white-space: nowrap;
	user-select: none;
	transition: border-color 0.15s ease;
}

.input-prefix-group input {
	border-radius: 0 var(--form-border-radius) var(--form-border-radius) 0;
	min-width: 0;
}

.input-prefix-group:focus-within .input-prefix {
	border-color: var(--primary);
}

.input-prefix-group input.error + .input-prefix,
.input-prefix-group:has(input.error) .input-prefix {
	border-color: var(--destructive);
}

/* ── Quiz deck ── */
.quiz-deck-wrapper {
	margin-bottom: 1rem;
}

.quiz-deck {
	position: relative;
}

.quiz-card {
	position: absolute;
	left: 0;
	right: 0;
	top: 0;
	overflow: hidden;
	background: var(--card);
	border: 1.5px solid var(--border);
	border-radius: var(--form-border-radius-lg);
	padding: 1.5rem;
	-webkit-backface-visibility: hidden;
	backface-visibility: hidden;
}

.quiz-card[data-state="active"] {
	transform: translate3d(0, 0, 0) scale(1);
	opacity: 1;
	z-index: 10;
	pointer-events: auto;
	box-shadow: 0 4px 20px color-mix(in oklch, var(--foreground) 10%, transparent);
}

.quiz-card[data-state="behind-1"] {
	transform: translate3d(0, 10px, 0) scale(0.965);
	opacity: 1;
	z-index: 9;
	pointer-events: none;
	overflow: hidden;
}

.quiz-card[data-state="behind-2"] {
	transform: translate3d(0, 20px, 0) scale(0.93);
	opacity: 0.6;
	z-index: 8;
	pointer-events: none;
	overflow: hidden;
}

.quiz-card[data-state="hidden"] {
	transform: translate3d(0, 28px, 0) scale(0.895);
	opacity: 0;
	z-index: 1;
	pointer-events: none;
}

.quiz-step {
	font-size: 11px;
	font-weight: 600;
	color: var(--muted-foreground);
	text-transform: uppercase;
	letter-spacing: 0.06em;
	margin-bottom: 0.625rem;
}

.quiz-question {
	font-size: 1rem;
	font-weight: 700;
	color: var(--foreground);
	margin-bottom: 1.125rem;
	line-height: 1.4;
}

.btn-quiz-back {
	display: inline-flex;
	align-items: center;
	gap: 0.2rem;
	font-family: var(--form-font-family);
	font-size: 11px;
	font-weight: 500;
	line-height: 1;
	color: var(--muted-foreground);
	background: transparent;
	border: 1px solid var(--border);
	border-radius: calc(var(--radius) - 2px);
	padding: 0.2rem 0.5rem;
	cursor: pointer;
	margin-bottom: 0.875rem;
	touch-action: manipulation;
	transition:
		color 0.15s ease,
		border-color 0.15s ease;
}

.btn-quiz-back:hover {
	color: var(--foreground);
	border-color: var(--muted-foreground);
}

/* Fields — label direto filho do .field */
.field > label {
	font-size: 16px;
	font-weight: 700;
}

/* Radio options */
.radio-group {
	display: flex;
	flex-direction: column;
	gap: 0.5rem;
}

#group-genero,
#group-busca_conexao,
#group-faixa_etaria {
	display: grid;
	grid-template-columns: repeat(3, 1fr);
}

.radio-option {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 0.5rem;
	padding: 0.625rem 0.875rem;
	border: 1.5px solid var(--border);
	border-radius: var(--form-border-radius);
	cursor: pointer;
	transition:
		border-color 0.15s ease,
		background 0.15s ease;
	user-select: none;
}

.radio-option:hover {
	border-color: var(--primary);
	background: var(--accent);
}

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

.radio-option.selected {
	border-color: var(--primary);
	background: var(--accent);
}

.radio-option span {
	font-size: var(--form-font-size-base);
}

.radio-option::after {
	content: "";
	width: 18px;
	height: 18px;
	flex-shrink: 0;
	background-color: var(--primary);
	-webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none'%3E%3Cpath d='M5 13L9 17L19 7' stroke='black' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
	-webkit-mask-size: contain;
	-webkit-mask-repeat: no-repeat;
	-webkit-mask-position: center;
	mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none'%3E%3Cpath d='M5 13L9 17L19 7' stroke='black' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
	mask-size: contain;
	mask-repeat: no-repeat;
	mask-position: center;
	opacity: 0;
	transform: scale(0.5);
	transition:
		opacity 0.15s ease,
		transform 0.15s ease;
}

.radio-option.selected::after {
	opacity: 1;
	transform: scale(1);
}

/* Checkbox */
.checkbox-option {
	display: flex;
	align-items: center;
	gap: 0.75rem;
	padding: 0.875rem;
	border: 1.5px solid var(--border);
	border-radius: var(--form-border-radius);
	cursor: pointer;
	transition:
		border-color 0.15s ease,
		background 0.15s ease;
	user-select: none;
}

.checkbox-option:hover {
	border-color: var(--primary);
	background: var(--accent);
}

.checkbox-option input[type="checkbox"] {
	accent-color: var(--primary);
	width: 18px;
	height: 18px;
	flex-shrink: 0;
	margin-top: 2px;
}

.checkbox-option.checked {
	border-color: var(--primary);
	background: var(--accent);
}

.checkbox-option .checkbox-text {
	font-size: var(--form-font-size-label);
	color: var(--foreground);
	line-height: 1.5;
	font-weight: 400;
}

/* Error messages */
.field-error {
	font-size: var(--form-font-size-small);
	color: var(--destructive);
	display: none;
}

.field-error.visible {
	display: block;
}

/* Buttons */
.form-actions {
	display: flex;
	gap: 0.75rem;
	margin-top: calc(var(--form-gap) * 1.5);
	flex-wrap: wrap;
}

.btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	padding: 1rem 2rem;
	font-size: var(--form-font-size-base);
	font-family: var(--form-font-family);
	font-weight: 600;
	border-radius: var(--form-border-radius);
	border: none;
	cursor: pointer;
	transition:
		opacity 0.15s ease,
		transform 0.1s ease,
		background 0.15s ease;
	text-decoration: none;
	line-height: 1;
}

.btn:active {
	transform: scale(0.98);
}

.btn-primary {
	background: var(--primary);
	color: var(--primary-foreground);
	flex: 1;
}

.btn-primary:hover:not(:disabled) {
	background: var(--primary-hover);
}

.btn-primary:disabled {
	opacity: 0.6;
	cursor: not-allowed;
}

.btn-secondary {
	background: transparent;
	color: var(--muted-foreground);
	border: 1.5px solid var(--border);
}

.btn-secondary:hover {
	border-color: var(--primary);
	color: var(--primary);
}

/* Success / Error screens */
.screen-success,
.screen-error {
	display: none;
	text-align: center;
	padding: calc(var(--form-padding) * 1.5) var(--form-padding);
}

.screen-success.active,
.screen-error.active {
	display: block;
}

.screen-icon {
	width: 64px;
	height: 64px;
	border-radius: 50%;
	display: flex;
	align-items: center;
	justify-content: center;
	margin: 0 auto 1.25rem;
	font-size: 1.75rem;
}

.screen-icon.success {
	background: var(--success-subtle);
	color: var(--success);
}

.screen-icon.error {
	background: var(--destructive-subtle);
	color: var(--destructive);
}

.screen-title {
	font-size: 1.375rem;
	font-weight: 700;
	margin-bottom: 0.625rem;
	color: var(--foreground);
}

.screen-body {
	font-size: var(--form-font-size-base);
	color: var(--muted-foreground);
	margin-bottom: 1.5rem;
	line-height: 1.6;
}

/* Loading spinner */
.btn-loading {
	display: inline-block;
	width: 18px;
	height: 18px;
	border: 2px solid color-mix(in oklch, var(--primary-foreground) 40%, transparent);
	border-top-color: var(--primary-foreground);
	border-radius: 50%;
	animation: spin 0.7s linear infinite;
	margin-right: 0.5rem;
	vertical-align: middle;
}

@keyframes spin {
	to {
		transform: rotate(360deg);
	}
}

/* Divider */
.section-divider {
	height: 1px;
	background: var(--border);
	margin: var(--form-gap) 0;
}

/* Mobile */
@media (max-width: 480px) {
	.form-wrapper {
		padding: 1.25rem;
	}

	#group-genero,
	#group-busca_conexao,
	#group-faixa_etaria {
		display: grid;
		grid-template-columns: repeat(2, 1fr);
	}

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

	.btn-secondary {
		width: 100%;
	}
}
