/* FORM */
.smart-form {
	display: grid;
	gap: 16px;
	max-width: 640px;
}

.row {
	display: grid;
	grid-template-columns: 1fr;
	gap: 16px;
}

@media ( min-width : 740px) {
	.row.two {
		grid-template-columns: 1fr 1fr;
	}
	.row.three {
		grid-template-columns: 1fr 1fr 1fr;
	}
	.row.four {
		grid-template-columns: 1fr 1fr 1fr 1fr;
	}
	.row.five {
		grid-template-columns: 1fr 1fr 1fr 1fr 1fr;
	}
}

/* Floating-label field wrapper */
.smart-form .field {
	position: relative;
	display: grid;
}

.smart-form .field input::placeholder {
	color: transparent;
}

.smart-form input, .smart-form textarea, .smart-form select {
	width: 100%;
	padding: 18px 12px 10px; /* extra top padding for label */
	border: 1px solid var(--border);
	border-radius: 10px;
	background: var(--bg);
	color: var(--text);
	font-size: 16px;
	outline: none;
}

.smart-form textarea {
	resize: vertical;
	min-height: 120px;
}

/* The label sits inside the field initially */
.smart-form .field>label {
	position: absolute;
	left: 12px;
	top: 14px;
	padding: 0 6px;
	color: var(--muted);
	background: var(--bg); /* creates “cutout” effect over border */
	line-height: 1;
	pointer-events: none;
	transform-origin: left top;
	transform: translateY(0) scale(1);
	transition: transform 160ms ease, color 160ms ease, top 160ms ease;
}

/* Float on focus-within */
.smart-form .field:focus-within>label {
	color: var(--focus);
}

/* Float when focused OR when the field has content (placeholder not shown) */
.smart-form input:focus+label, .smart-form input:not(:placeholder-shown)+label,
	.smart-form textarea:focus+label, .smart-form textarea:not(:placeholder-shown)+label
	{
	top: 6px;
	transform: translateY(-2px) scale(0.85);
}

/* Focus ring */
.smart-form input:focus, .smart-form textarea:focus, .smart-form select:focus
	{
	border-color: var(--focus);
	box-shadow: 0 0 0 3px color-mix(in srgb, var(--focus) 18%, transparent);
}

/* Autofill (Chrome) - keep colors consistent */
.smart-form input:-webkit-autofill {
	-webkit-text-fill-color: var(--text);
	transition: background-color 999999s ease-in-out 0s;
	/* prevents yellow flash */
}

/* SELECT: float label when focused OR when valid (requires modern :has()) */
.smart-form .field-select:focus-within>label {
	top: 6px;
	transform: translateY(-2px) scale(0.85);
	color: var(--focus);
}

.smart-form .field-select:has(select:valid)>label {
	top: 6px;
	transform: translateY(-2px) scale(0.85);
}

/* Checkbox/radio field style (don’t float label; better UX) */
.smart-form .field-check {
	display: flex;
	align-items: center;
	gap: 10px;
	padding: 12px;
	border: 1px solid var(--border);
	border-radius: 10px;
	background: var(--bg);
}

.smart-form .field-check>label {
	position: static;
	padding: 0;
	background: transparent;
	pointer-events: auto;
	transform: none;
	transition: none;
	color: var(--text);
}

.smart-form .field-check input[type="checkbox"], .smart-form .field-check input[type="radio"]
	{
	width: 18px;
	height: 18px;
	margin: 0;
}

/* Optional: highlight checkbox/radio containers when checked */
.smart-form .field-check:has(input:checked) {
	border-color: color-mix(in srgb, var(--focus) 45%, var(--border));
	box-shadow: 0 0 0 3px color-mix(in srgb, var(--focus) 12%, transparent);
}

/* Buttons */
.actions {
	display: flex;
	flex-wrap: wrap;
	gap: 10px;
	margin-top: 4px;
	justify-content: space-between;
}

button {
	appearance: none;
	border: 1px solid #d7dbe7;
	background: #fff;
	padding: 10px 12px;
	border-radius: 10px;
	cursor: pointer;
	font-weight: 600;
}

button.primary {
	border-color: var(--focus);
	background: var(--focus);
	color: #fff;
}

button:active {
	transform: translateY(1px);
}