/**
 * Drag & drop file uploader (classic checkout, my-account and Checkout block).
 */

.thwcfe-upload {
	--thwcfe-upload-border: #c3c4c7;
	--thwcfe-upload-border-active: #2271b1;
	--thwcfe-upload-bg: #fff;
	--thwcfe-upload-bg-active: rgba(34, 113, 177, 0.06);
	--thwcfe-upload-text: inherit;
	--thwcfe-upload-muted: #646970;
	--thwcfe-upload-error: #cc1818;
	--thwcfe-upload-radius: 6px;

	display: block;
	width: 100%;
	box-sizing: border-box;
	font-size: 0.9em;
	line-height: 1.4;
}

.thwcfe-upload *,
.thwcfe-upload *::before,
.thwcfe-upload *::after {
	box-sizing: border-box;
}

/* Drop zone */

.thwcfe-upload__dropzone {
	position: relative;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 4px;
	padding: 22px 16px;
	border: 2px dashed var(--thwcfe-upload-border);
	border-radius: var(--thwcfe-upload-radius);
	background: var(--thwcfe-upload-bg);
	color: var(--thwcfe-upload-text);
	text-align: center;
	cursor: pointer;
	transition: border-color 0.15s ease, background-color 0.15s ease;
}

.thwcfe-upload__dropzone:hover,
.thwcfe-upload__dropzone:focus-visible,
.thwcfe-upload.is-dragover .thwcfe-upload__dropzone {
	border-color: var(--thwcfe-upload-border-active);
	background: var(--thwcfe-upload-bg-active);
	outline: none;
}

.thwcfe-upload__dropzone:focus-visible {
	box-shadow: 0 0 0 2px var(--thwcfe-upload-border-active);
}

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

.thwcfe-upload__icon {
	display: block;
	margin-bottom: 4px;
	color: var(--thwcfe-upload-border-active);
}

.thwcfe-upload__text {
	display: block;
}

.thwcfe-upload__text strong {
	color: var(--thwcfe-upload-border-active);
	font-weight: 600;
}

.thwcfe-upload__hint {
	display: block;
	font-size: 0.85em;
	color: var(--thwcfe-upload-muted);
}

/* A single-file field hides the drop zone once a file is attached. */
.thwcfe-upload.has-files:not(.thwcfe-upload--multiple) .thwcfe-upload__dropzone {
	display: none;
}

.thwcfe-upload--multiple.has-files .thwcfe-upload__dropzone {
	padding: 12px 16px;
	flex-direction: row;
	gap: 10px;
}

.thwcfe-upload--multiple.has-files .thwcfe-upload__icon {
	width: 20px;
	height: 20px;
	margin: 0;
}

.thwcfe-upload--multiple.has-files .thwcfe-upload__hint {
	display: none;
}

/* Status */

.thwcfe-upload__status {
	display: block;
	min-height: 0;
}

.thwcfe-upload__progress,
.thwcfe-upload__message {
	display: none;
	margin-top: 8px;
	font-size: 0.9em;
}

.thwcfe-upload.is-uploading .thwcfe-upload__progress {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	color: var(--thwcfe-upload-muted);
}

.thwcfe-upload.has-error .thwcfe-upload__message {
	display: block;
	color: var(--thwcfe-upload-error);
}

.thwcfe-upload__spinner {
	width: 14px;
	height: 14px;
	border: 2px solid var(--thwcfe-upload-border);
	border-top-color: var(--thwcfe-upload-border-active);
	border-radius: 50%;
	animation: thwcfe-upload-spin 0.8s linear infinite;
}

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

/* File list */

.thwcfe-upload__list {
	list-style: none;
	margin: 0;
	padding: 0;
}

.thwcfe-upload.has-files .thwcfe-upload__list {
	margin-top: 8px;
}

.thwcfe-upload__item {
	display: flex;
	align-items: center;
	gap: 12px;
	margin: 0 0 8px;
	padding: 8px 10px;
	border: 1px solid var(--thwcfe-upload-border);
	border-radius: var(--thwcfe-upload-radius);
	background: var(--thwcfe-upload-bg);
}

.thwcfe-upload__item:last-child {
	margin-bottom: 0;
}

.thwcfe-upload__thumb {
	display: flex;
	align-items: center;
	justify-content: center;
	flex: 0 0 40px;
	width: 40px;
	height: 40px;
	border-radius: 4px;
	background: rgba(0, 0, 0, 0.04);
	color: var(--thwcfe-upload-muted);
	overflow: hidden;
}

.thwcfe-upload__thumb img {
	display: block;
	width: 100%;
	height: 100%;
	object-fit: cover;
	margin: 0;
	border-radius: 0;
}

.thwcfe-upload__meta {
	display: flex;
	flex-direction: column;
	flex: 1 1 auto;
	min-width: 0;
}

.thwcfe-upload__name {
	display: block;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
	font-weight: 500;
	text-decoration: none;
}

.thwcfe-upload__size {
	font-size: 0.85em;
	color: var(--thwcfe-upload-muted);
}

.thwcfe-upload__remove {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	flex: 0 0 auto;
	width: 28px;
	height: 28px;
	margin: 0;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: transparent;
	color: var(--thwcfe-upload-muted);
	line-height: 1;
	cursor: pointer;
	box-shadow: none;
}

.thwcfe-upload__remove:hover,
.thwcfe-upload__remove:focus-visible {
	background: rgba(204, 24, 24, 0.08);
	color: var(--thwcfe-upload-error);
	outline: none;
}

/* Checkout block integration */

.thwcfe-block-checkout__file .thwcfe-upload {
	font-size: 0.875em;
}

.thwcfe-block-checkout__file__label {
	display: block;
	margin-bottom: 8px;
	font-weight: 600;
}

.thwcfe-block-checkout__file.has-error .thwcfe-upload__dropzone {
	border-color: var(--thwcfe-upload-error);
}

/* Image choice (classic and block checkout): radio options shown as image cards. */
.thwcfe-image-choice {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
	gap: 12px;
	margin-top: 6px;
}

.thwcfe-image-choice__option {
	position: relative;
	min-width: 0;
}

.thwcfe-image-choice__input {
	position: absolute;
	top: 10px;
	left: 10px;
	width: 1px;
	height: 1px;
	margin: 0;
	opacity: 0;
}

.thwcfe-image-choice .thwcfe-image-choice__label {
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 6px;
	height: 100%;
	margin: 0;
	padding: 8px;
	border: 2px solid #dcdcde;
	border-radius: 6px;
	background: #fff;
	color: inherit;
	text-align: center;
	line-height: 1.3;
	cursor: pointer;
	box-sizing: border-box;
	transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.thwcfe-image-choice__label:hover {
	border-color: #8c8f94;
}

.thwcfe-image-choice__input:checked + .thwcfe-image-choice__label {
	border-color: #1e1e1e;
	box-shadow: 0 0 0 1px #1e1e1e;
}

.thwcfe-image-choice__input:focus-visible + .thwcfe-image-choice__label {
	outline: 2px solid #2271b1;
	outline-offset: 2px;
}

.thwcfe-image-choice__input:disabled + .thwcfe-image-choice__label {
	opacity: 0.6;
	cursor: default;
}

.thwcfe-image-choice__image {
	display: block;
	width: 100%;
	height: auto;
	aspect-ratio: 1 / 1;
	object-fit: cover;
	border-radius: 4px;
}

.thwcfe-image-choice__text {
	font-size: 0.9em;
	word-break: break-word;
}

@media (max-width: 480px) {
	.thwcfe-image-choice {
		grid-template-columns: repeat(2, minmax(0, 1fr));
	}
}
