/**
 * Parts Request Form — front-end styles.
 *
 * Everything is scoped under .prf-wrap and driven by custom properties so a
 * theme can restyle the form by overriding a handful of variables. Values fall
 * back to the theme's own presets where WordPress exposes them.
 *
 * @package PartsRequestForm
 */

.prf-wrap {
	--prf-accent: var(--wp--preset--color--primary, #1d6fd0);
	--prf-accent-hover: var(--wp--preset--color--primary-hover, #175aa8);
	--prf-text: var(--wp--preset--color--foreground, #1f2933);
	--prf-muted: #5c6b7a;
	--prf-border: #d5dce4;
	--prf-border-strong: #aab6c3;
	--prf-surface: var(--wp--preset--color--background, #ffffff);
	--prf-surface-alt: #f6f8fa;
	--prf-success-bg: #e8f6ec;
	--prf-success-border: #1e8e3e;
	--prf-success-text: #14652b;
	--prf-error-bg: #fdecec;
	--prf-error-border: #c62828;
	--prf-error-text: #9b1c1c;
	--prf-warning-bg: #fff8e1;
	--prf-warning-border: #f0a500;
	--prf-warning-text: #7a5200;
	--prf-radius: 8px;
	--prf-gap: 20px;

	box-sizing: border-box;
	color: var(--prf-text);
	max-width: 820px;
	margin-inline: auto;
}

.prf-wrap *,
.prf-wrap *::before,
.prf-wrap *::after {
	box-sizing: inherit;
}

/* -------------------------------------------------------------------------
 * Notices
 * ---------------------------------------------------------------------- */

.prf-notice {
	display: flex;
	align-items: flex-start;
	gap: 12px;
	margin: 0 0 var(--prf-gap);
	padding: 16px 18px;
	border: 1px solid;
	border-left-width: 4px;
	border-radius: var(--prf-radius);
	font-size: 15px;
	line-height: 1.5;
}

.prf-notice p {
	margin: 0;
}

.prf-notice ul {
	margin: 6px 0 0;
	padding-left: 18px;
}

.prf-notice li {
	margin: 2px 0;
}

.prf-notice__icon {
	flex: 0 0 auto;
	width: 20px;
	height: 20px;
	margin-top: 1px;
	fill: currentColor;
}

.prf-notice--success {
	background: var(--prf-success-bg);
	border-color: var(--prf-success-border);
	color: var(--prf-success-text);
	font-weight: 600;
}

.prf-notice--error {
	background: var(--prf-error-bg);
	border-color: var(--prf-error-border);
	color: var(--prf-error-text);
}

.prf-notice--warning {
	background: var(--prf-warning-bg);
	border-color: var(--prf-warning-border);
	color: var(--prf-warning-text);
}

/* -------------------------------------------------------------------------
 * Layout
 * ---------------------------------------------------------------------- */

.prf-form {
	background: var(--prf-surface);
	border: 1px solid var(--prf-border);
	border-radius: calc(var(--prf-radius) + 4px);
	padding: clamp(20px, 4vw, 32px);
}

.prf-form__title {
	margin: 0 0 var(--prf-gap);
	font-size: clamp(20px, 3vw, 26px);
	line-height: 1.25;
}

.prf-grid {
	display: grid;
	grid-template-columns: repeat(2, minmax(0, 1fr));
	gap: var(--prf-gap);
}

.prf-field {
	display: flex;
	flex-direction: column;
	gap: 6px;
	margin: 0;
	min-width: 0;
}

.prf-field--full {
	grid-column: 1 / -1;
}

@media (max-width: 600px) {
	.prf-grid {
		grid-template-columns: minmax(0, 1fr);
	}
}

/* -------------------------------------------------------------------------
 * Fields
 * ---------------------------------------------------------------------- */

.prf-label {
	display: block;
	font-size: 14px;
	font-weight: 600;
	line-height: 1.4;
}

.prf-required {
	color: var(--prf-error-border);
	margin-left: 2px;
}

.prf-optional {
	margin-left: 4px;
	font-weight: 400;
	font-size: 13px;
	color: var(--prf-muted);
}

.prf-wrap .prf-input {
	width: 100%;
	max-width: 100%;
	padding: 11px 13px;
	border: 1px solid var(--prf-border-strong);
	border-radius: var(--prf-radius);
	background: var(--prf-surface);
	color: inherit;
	font-family: inherit;
	font-size: 16px; /* 16px keeps iOS Safari from zooming on focus. */
	line-height: 1.4;
	transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.prf-wrap .prf-input:focus {
	border-color: var(--prf-accent);
	box-shadow: 0 0 0 3px color-mix(in srgb, var(--prf-accent) 25%, transparent);
	outline: 2px solid transparent; /* Keeps a visible ring in forced-colors mode. */
	outline-offset: 2px;
}

.prf-wrap .prf-input[aria-invalid="true"] {
	border-color: var(--prf-error-border);
}

.prf-textarea {
	min-height: 110px;
	resize: vertical;
}

.prf-help {
	font-size: 13px;
	line-height: 1.45;
	color: var(--prf-muted);
}

.prf-field-error {
	margin: 0;
	font-size: 13px;
	font-weight: 600;
	color: var(--prf-error-text);
}

/* -------------------------------------------------------------------------
 * Honeypot: hidden from people, reachable for bots. Never display:none —
 * some bots skip those fields on purpose.
 * ---------------------------------------------------------------------- */

.prf-hp {
	position: absolute !important;
	left: -9999px !important;
	top: auto;
	width: 1px;
	height: 1px;
	overflow: hidden;
}

/* -------------------------------------------------------------------------
 * Upload
 * ---------------------------------------------------------------------- */

.prf-upload {
	position: relative;
}

.prf-upload__input {
	position: absolute;
	width: 1px;
	height: 1px;
	padding: 0;
	margin: -1px;
	overflow: hidden;
	clip: rect(0 0 0 0);
	clip-path: inset(50%);
	white-space: nowrap;
	border: 0;
}

.prf-upload__label {
	display: flex;
	align-items: center;
	gap: 14px;
	padding: 18px;
	border: 2px dashed var(--prf-border-strong);
	border-radius: var(--prf-radius);
	background: var(--prf-surface-alt);
	cursor: pointer;
	transition: border-color 0.15s ease, background 0.15s ease;
}

.prf-upload__label:hover,
.prf-upload__input:focus-visible + .prf-upload__label,
.prf-upload.is-dragover .prf-upload__label {
	border-color: var(--prf-accent);
	background: color-mix(in srgb, var(--prf-accent) 6%, var(--prf-surface-alt));
}

.prf-upload__icon {
	flex: 0 0 auto;
	width: 28px;
	height: 28px;
	fill: var(--prf-accent);
}

.prf-upload__text {
	display: flex;
	flex-direction: column;
	gap: 2px;
	min-width: 0;
}

.prf-file-list {
	list-style: none;
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
	gap: 12px;
	margin: 12px 0 0;
	padding: 0;
}

.prf-file-list:empty {
	display: none;
}

.prf-file {
	position: relative;
	border: 1px solid var(--prf-border);
	border-radius: var(--prf-radius);
	overflow: hidden;
	background: var(--prf-surface-alt);
}

.prf-file__thumb {
	display: block;
	width: 100%;
	aspect-ratio: 4 / 3;
	object-fit: cover;
	background: var(--prf-surface-alt);
}

.prf-file__meta {
	display: flex;
	flex-direction: column;
	padding: 7px 9px;
	font-size: 12px;
	line-height: 1.35;
	min-width: 0;
}

.prf-file__name {
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.prf-file__size {
	color: var(--prf-muted);
}

.prf-file__remove {
	position: absolute;
	top: 6px;
	right: 6px;
	display: flex;
	align-items: center;
	justify-content: center;
	width: 26px;
	height: 26px;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: rgba(15, 23, 32, 0.72);
	color: #fff;
	font-size: 16px;
	line-height: 1;
	cursor: pointer;
}

.prf-file__remove:hover,
.prf-file__remove:focus-visible {
	background: var(--prf-error-border);
}

/* -------------------------------------------------------------------------
 * Submit
 * ---------------------------------------------------------------------- */

.prf-submit {
	display: flex;
	align-items: center;
	justify-content: space-between;
	flex-wrap: wrap;
	gap: 12px;
	margin: var(--prf-gap) 0 0;
	padding-top: var(--prf-gap);
	border-top: 1px solid var(--prf-border);
}

.prf-wrap .prf-button {
	appearance: none;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-height: 48px;
	padding: 12px 28px;
	border: 0;
	border-radius: var(--prf-radius);
	background: var(--prf-accent);
	color: #fff;
	font-family: inherit;
	font-size: 16px;
	font-weight: 600;
	line-height: 1.2;
	cursor: pointer;
	transition: background 0.15s ease, transform 0.05s ease;
}

.prf-wrap .prf-button:hover {
	background: var(--prf-accent-hover);
}

.prf-wrap .prf-button:active {
	transform: translateY(1px);
}

.prf-wrap .prf-button:focus-visible {
	outline: 3px solid color-mix(in srgb, var(--prf-accent) 45%, transparent);
	outline-offset: 2px;
}

.prf-wrap .prf-button[disabled] {
	opacity: 0.65;
	cursor: progress;
}

.prf-required-note {
	font-size: 13px;
	color: var(--prf-muted);
}

@media (prefers-reduced-motion: reduce) {
	.prf-wrap * {
		transition: none !important;
	}
}
