/**
 * PixTry — Frontend Styles
 *
 * All classes are prefixed with .wvto- to avoid theme/plugin collisions.
 * Mobile-first responsive design. Modal-based UI.
 */

/* ================================================================
   CSS Variables (scoped to modal)
   ================================================================ */
.wvto-modal-overlay {
	--wvto-primary: #1a1a2e;
	--wvto-accent: #6c63ff;
	--wvto-accent-hover: #5a52d5;
	--wvto-bg: #ffffff;
	--wvto-bg-subtle: #f8f9fb;
	--wvto-border: #e8eaed;
	--wvto-text: #1a1a2e;
	--wvto-text-muted: #6b7280;
	--wvto-radius: 16px;
	--wvto-radius-sm: 8px;
	--wvto-shadow-lg: 0 16px 48px rgba(0, 0, 0, 0.18);
	--wvto-transition: 0.2s ease;
	--wvto-font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
}

/* ================================================================
   Utility
   ================================================================ */
.wvto-hidden {
	display: none !important;
}

.wvto-sr-only {
	position: absolute;
	width: 1px;
	height: 1px;
	padding: 0;
	margin: -1px;
	overflow: hidden;
	clip: rect(0, 0, 0, 0);
	white-space: nowrap;
	border: 0;
}

/* ================================================================
   Trigger Button (inline on product page)
   ================================================================ */
.wvto-trigger-wrap {
	margin: 12px 0;
}

.wvto-trigger-btn {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	padding: 12px 24px;
	font-size: 14px;
	font-weight: 600;
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
	color: #6c63ff;
	background: #f5f3ff;
	border: 1.5px solid #ddd6fe;
	border-radius: 8px;
	cursor: pointer;
	transition: all 0.2s ease;
	line-height: 1;
	text-decoration: none;
}

.wvto-trigger-btn:hover {
	background: #ede9fe;
	border-color: #c4b5fd;
	color: #5a52d5;
	transform: translateY(-1px);
	box-shadow: 0 2px 8px rgba(108, 99, 255, 0.15);
}

.wvto-trigger-btn:focus-visible {
	outline: 2px solid #6c63ff;
	outline-offset: 2px;
}

.wvto-trigger-btn:active {
	transform: translateY(0);
}

.wvto-trigger-icon {
	flex-shrink: 0;
}

/* ================================================================
   Modal Overlay
   ================================================================ */
.wvto-modal-overlay {
	position: fixed;
	inset: 0;
	z-index: 999999;
	display: flex;
	align-items: center;
	justify-content: center;
	background: rgba(0, 0, 0, 0.5);
	backdrop-filter: blur(4px);
	-webkit-backdrop-filter: blur(4px);
	padding: 16px;
	opacity: 0;
	visibility: hidden;
	pointer-events: none;
	transition: opacity 0.25s ease, visibility 0.25s ease;
}

.wvto-modal-overlay.wvto-modal--open {
	opacity: 1;
	visibility: visible;
	pointer-events: auto;
}

/* ================================================================
   Modal Container
   ================================================================ */
.wvto-modal {
	position: relative;
	width: 100%;
	max-width: 560px;
	max-height: calc(100vh - 32px);
	background: var(--wvto-bg);
	border-radius: var(--wvto-radius);
	box-shadow: var(--wvto-shadow-lg);
	display: flex;
	flex-direction: column;
	overflow: hidden;
	font-family: var(--wvto-font);
	color: var(--wvto-text);
	font-size: 15px;
	line-height: 1.5;
	transform: translateY(12px) scale(0.98);
	transition: transform 0.25s ease;
}

.wvto-modal-overlay.wvto-modal--open .wvto-modal {
	transform: translateY(0) scale(1);
}

/* ================================================================
   Modal Header
   ================================================================ */
.wvto-modal__header {
	display: flex;
	align-items: flex-start;
	justify-content: space-between;
	gap: 12px;
	padding: 20px 24px 16px;
	border-bottom: 1px solid var(--wvto-border);
	flex-shrink: 0;
}

.wvto-heading {
	font-size: 18px;
	font-weight: 700;
	color: var(--wvto-text);
	margin: 0 0 2px;
	letter-spacing: -0.01em;
}

.wvto-subtitle {
	font-size: 13px;
	color: var(--wvto-text-muted);
	margin: 0;
}

.wvto-credits-badge {
	display: inline-block;
	margin-top: 6px;
	padding: 2px 10px;
	background: #f0eeff;
	color: var(--wvto-accent);
	border-radius: 10px;
	font-size: 11px;
	font-weight: 600;
}

.wvto-modal__close {
	flex-shrink: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	width: 36px;
	height: 36px;
	background: var(--wvto-bg-subtle);
	border: none;
	border-radius: 50%;
	cursor: pointer;
	color: var(--wvto-text-muted);
	transition: background var(--wvto-transition), color var(--wvto-transition);
}

.wvto-modal__close:hover {
	background: #eee;
	color: var(--wvto-text);
}

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

/* ================================================================
   Modal Body (scrollable)
   ================================================================ */
.wvto-modal__body {
	padding: 20px 24px 24px;
	overflow-y: auto;
	-webkit-overflow-scrolling: touch;
	flex: 1 1 auto;
}

.wvto-modal__body *,
.wvto-modal__body *::before,
.wvto-modal__body *::after {
	box-sizing: border-box;
}

/* ================================================================
   Grid: side-by-side on wider modals, stacked on small
   ================================================================ */
.wvto-grid {
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: 14px;
	margin-bottom: 14px;
}

@media (max-width: 520px) {
	.wvto-grid {
		grid-template-columns: 1fr;
	}
}

/* ================================================================
   Panel
   ================================================================ */
.wvto-panel {
	display: flex;
	flex-direction: column;
	gap: 6px;
}

.wvto-panel__label {
	font-size: 11px;
	font-weight: 600;
	text-transform: uppercase;
	letter-spacing: 0.05em;
	color: var(--wvto-text-muted);
}

/* ================================================================
   Upload Area
   ================================================================ */
.wvto-upload-area {
	position: relative;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	min-height: 180px;
	border: 2px dashed var(--wvto-border);
	border-radius: var(--wvto-radius-sm);
	background: var(--wvto-bg-subtle);
	cursor: pointer;
	transition: border-color var(--wvto-transition), background var(--wvto-transition);
	overflow: hidden;
}

.wvto-upload-area:hover,
.wvto-upload-area:focus-visible {
	border-color: var(--wvto-accent);
	background: #f0eeff;
	outline: none;
}

.wvto-upload-area.wvto-dragover {
	border-color: var(--wvto-accent);
	background: #ede9ff;
}

.wvto-upload-area.wvto-has-image {
	border-style: solid;
	border-color: var(--wvto-border);
	background: var(--wvto-bg);
}

.wvto-upload-placeholder {
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 6px;
	padding: 20px 12px;
	text-align: center;
}

.wvto-upload-icon {
	color: var(--wvto-accent);
	opacity: 0.8;
}

.wvto-upload-text {
	font-size: 14px;
	font-weight: 600;
	color: var(--wvto-text);
}

.wvto-upload-hint {
	font-size: 11px;
	color: var(--wvto-text-muted);
}

/* ================================================================
   Image Previews (compact in modal)
   ================================================================ */
.wvto-preview-img {
	width: 100%;
	height: 100%;
	min-height: 160px;
	max-height: 220px;
	object-fit: contain;
	border-radius: var(--wvto-radius-sm);
	background: var(--wvto-bg-subtle);
}

.wvto-garment-area {
	min-height: 160px;
	max-height: 220px;
	display: flex;
	align-items: center;
	justify-content: center;
	border: 1px solid var(--wvto-border);
	border-radius: var(--wvto-radius-sm);
	background: var(--wvto-bg-subtle);
	overflow: hidden;
}

.wvto-garment-area .wvto-preview-img {
	border-radius: 0;
}

.wvto-no-image {
	display: flex;
	align-items: center;
	justify-content: center;
	min-height: 160px;
	width: 100%;
	color: var(--wvto-text-muted);
	font-size: 13px;
}

/* Change photo button overlay */
.wvto-change-btn {
	position: absolute;
	bottom: 8px;
	right: 8px;
	background: rgba(0, 0, 0, 0.6);
	color: #fff;
	border: none;
	border-radius: 6px;
	padding: 5px 12px;
	font-size: 11px;
	font-weight: 600;
	cursor: pointer;
	backdrop-filter: blur(4px);
	transition: background var(--wvto-transition);
}

.wvto-change-btn:hover {
	background: rgba(0, 0, 0, 0.8);
}

/* ================================================================
   Tip
   ================================================================ */
.wvto-tip {
	display: flex;
	align-items: flex-start;
	gap: 8px;
	padding: 8px 12px;
	background: var(--wvto-bg-subtle);
	border: 1px solid var(--wvto-border);
	border-radius: var(--wvto-radius-sm);
	margin-bottom: 14px;
	font-size: 12px;
	color: var(--wvto-text-muted);
	line-height: 1.4;
}

.wvto-tip svg {
	flex-shrink: 0;
	margin-top: 1px;
	color: var(--wvto-accent);
}

/* ================================================================
   Buttons
   ================================================================ */
.wvto-btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 8px;
	padding: 12px 24px;
	font-size: 14px;
	font-weight: 600;
	font-family: var(--wvto-font);
	border-radius: var(--wvto-radius-sm);
	border: none;
	cursor: pointer;
	transition: all var(--wvto-transition);
	text-decoration: none;
	line-height: 1;
}

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

.wvto-btn--primary {
	width: 100%;
	background: var(--wvto-accent);
	color: #fff;
	box-shadow: 0 2px 8px rgba(108, 99, 255, 0.25);
}

.wvto-btn--primary:hover:not(:disabled) {
	background: var(--wvto-accent-hover);
	box-shadow: 0 4px 14px rgba(108, 99, 255, 0.35);
	transform: translateY(-1px);
}

.wvto-btn--primary:disabled {
	opacity: 0.5;
	cursor: not-allowed;
	transform: none;
	box-shadow: none;
}

.wvto-btn--primary.wvto-loading {
	pointer-events: none;
	opacity: 0.8;
}

.wvto-btn--secondary {
	background: var(--wvto-bg);
	color: var(--wvto-text);
	border: 1px solid var(--wvto-border);
	padding: 10px 18px;
	font-size: 13px;
}

.wvto-btn--secondary:hover {
	background: var(--wvto-bg-subtle);
	border-color: #d1d5db;
}

/* ================================================================
   Spinner
   ================================================================ */
@keyframes wvto-spin {
	to { transform: rotate(360deg); }
}

.wvto-spinner {
	animation: wvto-spin 1s linear infinite;
}

/* ================================================================
   Status Message
   ================================================================ */
.wvto-status {
	text-align: center;
	padding: 10px 14px;
	margin: 14px 0;
	border-radius: var(--wvto-radius-sm);
	font-size: 13px;
	font-weight: 500;
}

.wvto-status--processing {
	background: #eef2ff;
	color: #4338ca;
	border: 1px solid #c7d2fe;
}

.wvto-status--success {
	background: #ecfdf5;
	color: #065f46;
	border: 1px solid #a7f3d0;
}

.wvto-status--error {
	background: #fef2f2;
	color: #991b1b;
	border: 1px solid #fecaca;
}

/* ================================================================
   Progress Bar
   ================================================================ */
.wvto-progress {
	width: 100%;
	height: 3px;
	background: #e0e7ff;
	border-radius: 2px;
	margin-top: 6px;
	overflow: hidden;
}

.wvto-progress__bar {
	height: 100%;
	background: var(--wvto-accent);
	border-radius: 2px;
	width: 0%;
	transition: width 0.5s ease;
}

@keyframes wvto-indeterminate {
	0% { transform: translateX(-100%); }
	100% { transform: translateX(400%); }
}

.wvto-progress__bar--indeterminate {
	width: 30%;
	animation: wvto-indeterminate 1.5s ease-in-out infinite;
}

/* ================================================================
   Result Section (compact)
   ================================================================ */
.wvto-result {
	margin-top: 16px;
	animation: wvto-fade-in 0.4s ease;
}

@keyframes wvto-fade-in {
	from { opacity: 0; transform: translateY(6px); }
	to   { opacity: 1; transform: translateY(0); }
}

.wvto-result__image-wrap {
	border: 1px solid var(--wvto-border);
	border-radius: var(--wvto-radius-sm);
	overflow: hidden;
	margin: 8px 0 14px;
	background: var(--wvto-bg-subtle);
	text-align: center;
	max-width: 320px;
	margin-left: auto;
	margin-right: auto;
}

.wvto-result__img {
	max-width: 100%;
	max-height: 340px;
	width: auto;
	height: auto;
	display: block;
	margin: 0 auto;
	object-fit: contain;
}

.wvto-result__actions {
	display: flex;
	gap: 10px;
	flex-wrap: wrap;
	justify-content: center;
}

/* ================================================================
   Mobile Optimizations
   ================================================================ */
@media (max-width: 520px) {
	.wvto-modal-overlay {
		padding: 0;
		align-items: flex-end;
	}

	.wvto-modal {
		max-width: 100%;
		max-height: 92vh;
		border-radius: var(--wvto-radius) var(--wvto-radius) 0 0;
	}

	.wvto-modal-overlay.wvto-modal--open .wvto-modal {
		transform: translateY(0);
	}

	.wvto-modal__header {
		padding: 16px 16px 12px;
	}

	.wvto-modal__body {
		padding: 16px;
	}

	.wvto-heading {
		font-size: 16px;
	}

	.wvto-preview-img {
		min-height: 140px;
		max-height: 180px;
	}

	.wvto-garment-area {
		min-height: 140px;
		max-height: 180px;
	}

	.wvto-result__image-wrap {
		max-width: 100%;
	}

	.wvto-result__img {
		max-height: 280px;
	}

	.wvto-result__actions {
		flex-direction: column;
	}

	.wvto-result__actions .wvto-btn {
		width: 100%;
	}

	.wvto-trigger-btn {
		width: 100%;
		justify-content: center;
		padding: 14px 24px;
		font-size: 15px;
	}
}

/* Large touch targets on mobile */
@media (pointer: coarse) {
	.wvto-upload-area {
		min-height: 160px;
	}

	.wvto-btn {
		min-height: 44px;
	}

	.wvto-trigger-btn {
		min-height: 48px;
	}
}

/* Body scroll lock when modal is open */
body.wvto-body-locked {
	overflow: hidden !important;
}
