/**
 * WooCommerce Product File Uploads - frontend styles.
 *
 * Everything is scoped under .wpfu-uploader and inherits the theme's font and
 * colours, so the field looks native in block themes, classic themes and page
 * builders. Colours come from custom properties you can override in your theme.
 */

.wpfu-uploader {
	--wpfu-accent: #2f6f4f;
	--wpfu-preview-size: 96px;
	--wpfu-border: rgba( 0, 0, 0, 0.18 );
	--wpfu-surface: rgba( 0, 0, 0, 0.02 );
	--wpfu-muted: rgba( 0, 0, 0, 0.6 );
	--wpfu-danger: #a3231c;
	--wpfu-radius: 6px;
	--wpfu-gap: 12px;

	box-sizing: border-box;
	margin: 0 0 1.5em;
	max-width: 100%;
	font-size: inherit;
	line-height: 1.5;
	color: inherit;
}

.wpfu-uploader *,
.wpfu-uploader *::before,
.wpfu-uploader *::after {
	box-sizing: inherit;
}

/* Header ------------------------------------------------------------------ */

.wpfu-uploader__header {
	margin-bottom: 8px;
}

.wpfu-uploader__label {
	display: block;
	font-weight: 600;
}

.wpfu-uploader__required {
	border: 0;
	color: var( --wpfu-danger );
	text-decoration: none;
}

.wpfu-uploader__description {
	margin: 4px 0 0;
	color: var( --wpfu-muted );
	font-size: 0.9em;
}

/* Drop zone --------------------------------------------------------------- */

.wpfu-dropzone {
	position: relative;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 8px;
	padding: 22px 16px;
	border: 2px dashed var( --wpfu-border );
	border-radius: var( --wpfu-radius );
	background: var( --wpfu-surface );
	text-align: center;
	transition: border-color 0.15s ease, background-color 0.15s ease;
}

.wpfu-uploader--solid .wpfu-dropzone {
	border-style: solid;
	border-width: 1px;
}

.wpfu-uploader--soft .wpfu-dropzone {
	border: 1px solid transparent;
	background: var( --wpfu-surface );
}

.wpfu-dropzone.is-dragging {
	border-color: var( --wpfu-accent );
	background: color-mix( in srgb, var( --wpfu-accent ) 8%, transparent );
}

.wpfu-dropzone:focus-within {
	border-color: var( --wpfu-accent );
	outline: 2px solid var( --wpfu-accent );
	outline-offset: 2px;
}

.wpfu-dropzone__text {
	margin: 0;
	color: var( --wpfu-muted );
	font-size: 0.95em;
}

.wpfu-dropzone__button {
	display: inline-block;
	padding: 8px 18px;
	border: 1px solid var( --wpfu-accent );
	border-radius: var( --wpfu-radius );
	background: var( --wpfu-accent );
	color: #fff;
	cursor: pointer;
	font-size: 0.95em;
	font-weight: 600;
	line-height: 1.4;
}

.wpfu-dropzone__button:hover {
	filter: brightness( 1.08 );
}

/*
 * The file input stays in the accessibility tree and keeps keyboard focus, but
 * is not painted: the label above is the visible control.
 */
.wpfu-dropzone__input {
	position: absolute;
	width: 1px;
	height: 1px;
	margin: -1px;
	padding: 0;
	border: 0;
	clip: rect( 0 0 0 0 );
	clip-path: inset( 50% );
	overflow: hidden;
	white-space: nowrap;
}

.wpfu-dropzone__rules {
	margin: 0;
	color: var( --wpfu-muted );
	font-size: 0.82em;
}

/* File list --------------------------------------------------------------- */

.wpfu-files {
	margin: var( --wpfu-gap ) 0 0;
	padding: 0;
	list-style: none;
	display: grid;
	gap: 8px;
}

.wpfu-files:empty {
	margin: 0;
}

.wpfu-file {
	display: flex;
	align-items: center;
	gap: var( --wpfu-gap );
	margin: 0;
	padding: 8px;
	border: 1px solid var( --wpfu-border );
	border-radius: var( --wpfu-radius );
	background: #fff;
	list-style: none;
}

.wpfu-file.is-failed {
	border-color: var( --wpfu-danger );
}

.wpfu-file__thumb {
	flex: 0 0 auto;
	display: flex;
	align-items: center;
	justify-content: center;
	width: var( --wpfu-preview-size );
	height: var( --wpfu-preview-size );
	border-radius: 4px;
	background: var( --wpfu-surface );
	overflow: hidden;
}

.wpfu-file__thumb img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	display: block;
}

.wpfu-file__ext {
	font-size: 0.78em;
	font-weight: 700;
	letter-spacing: 0.04em;
	color: var( --wpfu-muted );
}

.wpfu-file__body {
	flex: 1 1 auto;
	min-width: 0;
	display: flex;
	flex-direction: column;
	gap: 2px;
}

.wpfu-file__name {
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
	font-weight: 600;
}

.wpfu-file__meta,
.wpfu-file__state {
	color: var( --wpfu-muted );
	font-size: 0.82em;
}

.wpfu-file.is-done .wpfu-file__state {
	color: var( --wpfu-accent );
}

.wpfu-file.is-failed .wpfu-file__state {
	color: var( --wpfu-danger );
}

.wpfu-file__progress {
	display: block;
	height: 4px;
	margin-top: 4px;
	border-radius: 999px;
	background: var( --wpfu-border );
	overflow: hidden;
}

.wpfu-file__bar {
	display: block;
	width: 0;
	height: 100%;
	background: var( --wpfu-accent );
	transition: width 0.2s ease;
}

.wpfu-file__remove {
	flex: 0 0 auto;
	width: 32px;
	height: 32px;
	padding: 0;
	border: 1px solid var( --wpfu-border );
	border-radius: 50%;
	background: transparent;
	color: inherit;
	cursor: pointer;
	font-size: 18px;
	line-height: 1;
}

.wpfu-file__remove:hover,
.wpfu-file__remove:focus-visible {
	border-color: var( --wpfu-danger );
	color: var( --wpfu-danger );
}

.wpfu-file__remove:focus-visible {
	outline: 2px solid var( --wpfu-accent );
	outline-offset: 2px;
}

/* Messages ---------------------------------------------------------------- */

.wpfu-status,
.wpfu-error {
	margin: 8px 0 0;
	font-size: 0.88em;
}

.wpfu-status:empty,
.wpfu-error:empty {
	margin: 0;
}

.wpfu-status {
	color: var( --wpfu-muted );
}

.wpfu-error {
	color: var( --wpfu-danger );
	font-weight: 600;
}

/* Instructions ------------------------------------------------------------ */

.wpfu-instructions {
	margin: var( --wpfu-gap ) 0 0;
}

.wpfu-instructions__label {
	display: block;
	margin-bottom: 4px;
	font-weight: 600;
}

.wpfu-instructions__field {
	width: 100%;
	padding: 8px;
	border: 1px solid var( --wpfu-border );
	border-radius: var( --wpfu-radius );
	font: inherit;
	resize: vertical;
}

.wpfu-instructions__field:focus-visible {
	outline: 2px solid var( --wpfu-accent );
	outline-offset: 1px;
}

/* States ------------------------------------------------------------------ */

.wpfu-uploader.is-busy .wpfu-dropzone {
	opacity: 0.7;
}

.wpfu-uploader.has-error .wpfu-dropzone {
	border-color: var( --wpfu-danger );
}

.wpfu-disabled,
button.wpfu-disabled[aria-disabled="true"] {
	opacity: 0.55;
	cursor: progress;
	pointer-events: none;
}

/* Screen reader helper, in case the theme does not ship one. */
.wpfu-uploader .screen-reader-text {
	position: absolute !important;
	width: 1px;
	height: 1px;
	margin: -1px;
	padding: 0;
	border: 0;
	clip: rect( 0 0 0 0 );
	clip-path: inset( 50% );
	overflow: hidden;
	white-space: nowrap;
}

/* Cart and order pages ---------------------------------------------------- */

.wpfu-customer-files {
	margin-top: 6px;
	font-size: 0.9em;
}

.wpfu-customer-files__title {
	margin: 0 0 2px;
}

.wpfu-customer-files__list {
	margin: 0;
	padding-left: 1.1em;
}

.wpfu-customer-files__list span {
	opacity: 0.7;
}

/* Small screens ----------------------------------------------------------- */

@media ( max-width: 480px ) {
	.wpfu-uploader {
		--wpfu-preview-size: 64px;
	}

	.wpfu-dropzone {
		padding: 18px 12px;
	}

	.wpfu-file {
		gap: 8px;
	}
}

@media ( prefers-reduced-motion: reduce ) {
	.wpfu-dropzone,
	.wpfu-file__bar {
		transition: none;
	}
}

@media ( prefers-color-scheme: dark ) {
	.wpfu-uploader {
		--wpfu-border: rgba( 255, 255, 255, 0.24 );
		--wpfu-surface: rgba( 255, 255, 255, 0.04 );
		--wpfu-muted: rgba( 255, 255, 255, 0.68 );
	}

	.wpfu-file {
		background: transparent;
	}
}
