/**
 * Virtual Fashion AI - Modal styles
 * Try-On panel, authentication modals, loading and result screens.
 */

.vfai-modal-overlay {
	position: fixed;
	top: 0;
	left: 0;
	right: 0;
	bottom: 0;
	z-index: 100000;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 20px;
	background: rgba(20, 20, 20, 0.32);
	backdrop-filter: blur(6px);
	opacity: 0;
	visibility: hidden;
	transition: opacity 0.35s var(--vfai-ease), visibility 0.35s var(--vfai-ease);
}

.vfai-modal-overlay.is-open {
	opacity: 1;
	visibility: visible;
}

.vfai-modal {
	position: relative;
	width: 100%;
	max-width: 440px;
	max-height: 90vh;
	overflow-y: auto;
	background: var(--vfai-paper);
	color: var(--vfai-ink);
	border-radius: var(--vfai-radius);
	box-shadow: 0 30px 80px rgba(20, 20, 20, 0.18);
	padding: 40px;
	transform: translateY(16px);
	opacity: 0;
	transition: transform 0.35s var(--vfai-ease), opacity 0.35s var(--vfai-ease);
}

.vfai-modal-overlay.is-open .vfai-modal {
	transform: translateY(0);
	opacity: 1;
}

.vfai-auth-modal {
	max-width: 420px;
}

/* Try-On floating card */
#vfai-tryon-modal {
	align-items: flex-end;
	justify-content: flex-end;
	padding: 20px;
}

#vfai-tryon-modal .vfai-modal {
	display: flex;
	flex-direction: column;
	width: 420px;
	max-width: 100%;
	height: 700px;
	max-height: calc(100vh - 40px);
	overflow: hidden;
	border-radius: 20px;
	padding: 0;
	box-shadow: 0 24px 64px rgba(20, 20, 20, 0.22);
	transform: translateY(24px) scale(0.98);
	opacity: 0;
	transition: transform 0.35s var(--vfai-ease), opacity 0.3s var(--vfai-ease);
}

#vfai-tryon-modal.is-open .vfai-modal {
	transform: translateY(0) scale(1);
	opacity: 1;
}

/* Guard against `!important` display rules (e.g. .vfai-btn, .vfai-change-photo-pill)
   leaking through elements that are toggled via the `hidden` attribute. */
#vfai-tryon-modal [hidden] {
	display: none !important;
}

#vfai-tryon-modal .vfai-panel-header {
	position: relative;
	flex: 0 0 auto;
	padding: 20px 24px 16px;
	border-bottom: 1px solid var(--vfai-border);
}

#vfai-tryon-modal .vfai-panel-body {
	flex: 1 1 auto;
	overflow-y: auto;
	padding: 18px 24px 20px;
}

#vfai-tryon-modal .vfai-panel-footer {
	flex: 0 0 auto;
	padding: 14px 24px;
	border-top: 1px solid var(--vfai-border);
	font-size: 11px;
	letter-spacing: 0.03em;
	line-height: 1.6;
	color: var(--vfai-ink-soft);
	text-align: center;
}

/* Panel header top row: title/subtitle + remaining-count badge */
#vfai-tryon-modal .vfai-panel-header-top {
	display: flex;
	align-items: flex-start;
	justify-content: space-between;
	gap: 12px;
	padding-right: 36px;
}

#vfai-tryon-modal .vfai-modal-title {
	margin: 0 0 2px;
	font-size: 18px;
	font-weight: 600;
	letter-spacing: -0.01em;
}

#vfai-tryon-modal .vfai-modal-subtitle {
	margin: 0;
	font-size: 12px;
	line-height: 1.5;
	color: var(--vfai-ink-soft);
}

.vfai-remaining-badge {
	flex: 0 0 auto;
	font-size: 11px;
	font-weight: 600;
	letter-spacing: 0.04em;
	color: var(--vfai-ink-soft);
	background: var(--vfai-surface);
	border: 1px solid var(--vfai-border);
	border-radius: var(--vfai-pill);
	padding: 6px 12px;
	white-space: nowrap;
}

/* Step indicator */
.vfai-step-indicator {
	display: flex;
	align-items: center;
	gap: 8px;
	margin-top: 16px;
}

.vfai-step-badge {
	display: flex;
	align-items: center;
	justify-content: center;
	flex: 0 0 auto;
	width: 26px;
	height: 26px;
	border-radius: 50%;
	font-size: 12px;
	font-weight: 700;
	border: 1.5px solid var(--vfai-border);
	color: var(--vfai-ink-soft);
	background: var(--vfai-paper);
	transition: background 0.25s var(--vfai-ease), border-color 0.25s var(--vfai-ease), color 0.25s var(--vfai-ease);
}

.vfai-step-badge.is-active,
.vfai-step-badge.is-complete {
	border-color: var(--vfai-ink);
	background: var(--vfai-ink);
	color: var(--vfai-paper);
}

.vfai-step-line {
	flex: 1 1 auto;
	max-width: 60px;
	height: 1.5px;
	background: var(--vfai-border);
	transition: background 0.3s var(--vfai-ease);
}

.vfai-step-line.is-complete {
	background: var(--vfai-ink);
}

.vfai-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;
}

/* Close button */
.vfai-modal-close {
	position: absolute !important;
	top: 16px !important;
	right: 16px !important;
	left: auto !important;
	bottom: auto !important;
	z-index: 10;
	width: 40px !important;
	height: 40px !important;
	min-width: 0 !important;
	margin: 0 !important;
	display: flex !important;
	align-items: center;
	justify-content: center;
	font-size: 26px;
	font-weight: 300;
	line-height: 1;
	color: var(--vfai-ink) !important;
	background: var(--vfai-paper) !important;
	border: none !important;
	border-radius: 50% !important;
	box-shadow: none !important;
	text-shadow: none !important;
	appearance: none;
	-webkit-appearance: none;
	cursor: pointer;
	transition: opacity 0.2s ease, background 0.2s ease;
}

.vfai-modal-close:hover,
.vfai-modal-close:focus-visible {
	opacity: 0.6;
	outline: none;
}

/* Auth modal header */
.vfai-modal-header {
	text-align: left;
	margin: 0 0 28px;
	padding-right: 36px;
}

.vfai-modal-title {
	margin: 0 0 8px;
	font-size: 22px;
	font-weight: 500;
	letter-spacing: -0.01em;
}

.vfai-modal-subtitle {
	margin: 0;
	font-size: 13px;
	line-height: 1.6;
	color: var(--vfai-ink-soft);
}

.vfai-modal-body {
	position: relative;
}

/* Steps */
.vfai-step {
	display: none;
}

.vfai-step.is-active {
	display: block;
	animation: vfai-fade-in 0.4s var(--vfai-ease);
}

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

/* Stage / image frame */
.vfai-stage {
	position: relative;
	width: 100%;
	overflow: hidden;
	border-radius: var(--vfai-radius-lg);
	background: var(--vfai-surface);
	margin: 0 0 16px;
}

.vfai-stage-upload {
	aspect-ratio: 4 / 3;
}

.vfai-stage-image {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	object-fit: cover;
	display: block;
	opacity: 0;
	transition: opacity 0.6s var(--vfai-ease);
}

.vfai-stage-image.is-visible {
	opacity: 1;
}

/* Empty-state placeholder covering the whole stage */
.vfai-stage-placeholder {
	position: absolute;
	inset: 0;
	z-index: 2;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 10px;
	width: 100%;
	height: 100%;
	padding: 0;
	margin: 0;
	font-size: 12px;
	font-weight: 600;
	letter-spacing: 0.04em;
	color: var(--vfai-ink-soft);
	background: transparent;
	border: none;
	box-shadow: none;
	cursor: pointer;
	font-family: inherit;
	appearance: none;
	-webkit-appearance: none;
	transition: color 0.2s ease;
}

.vfai-stage-placeholder:hover,
.vfai-stage-placeholder:focus-visible {
	color: var(--vfai-ink);
	outline: none;
}

.vfai-stage-placeholder[hidden] {
	display: none;
}

.vfai-stage-placeholder-icon {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 44px;
	height: 44px;
	border-radius: 50%;
	background: var(--vfai-paper);
	border: 1px solid var(--vfai-border);
	color: inherit;
	transition: color 0.2s ease;
}

.vfai-stage-placeholder-icon svg {
	width: 20px;
	height: 20px;
}

/* "Change Photo" pill overlay shown once a photo has been selected */
.vfai-change-photo-pill {
	position: absolute;
	left: 50%;
	bottom: 14px;
	z-index: 2;
	transform: translateX(-50%);
	display: inline-flex !important;
	align-items: center;
	width: auto !important;
	gap: 6px;
	padding: 10px 18px !important;
	margin: 0 !important;
	font-size: 11px;
	font-weight: 600;
	letter-spacing: 0.08em;
	text-transform: uppercase;
	color: var(--vfai-ink) !important;
	background: var(--vfai-paper) !important;
	border: 1px solid var(--vfai-border) !important;
	border-radius: var(--vfai-pill) !important;
	box-shadow: 0 8px 20px rgba(20, 20, 20, 0.12) !important;
	cursor: pointer;
	font-family: inherit;
	appearance: none;
	-webkit-appearance: none;
	transition: background 0.2s ease, color 0.2s ease;
}

.vfai-change-photo-pill:hover,
.vfai-change-photo-pill:focus-visible {
	background: var(--vfai-ink) !important;
	color: var(--vfai-paper) !important;
	border-color: var(--vfai-ink) !important;
	outline: none;
}

.vfai-change-photo-pill[hidden] {
	display: none !important;
}

.vfai-stage.is-dragover {
	outline: 1px solid var(--vfai-ink);
	outline-offset: -1px;
}

.vfai-stage.is-dragover::after {
	content: "";
	position: absolute;
	inset: 0;
	z-index: 1;
	background: rgba(20, 20, 20, 0.06);
}

.vfai-stage-caption {
	text-align: center;
}

.vfai-stage-hint {
	margin: 10px 0 0;
	font-size: 12px;
	line-height: 1.5;
	color: var(--vfai-ink-soft);
	text-align: center;
}

.vfai-remaining-text {
	margin: 0 0 12px;
	font-size: 12px;
	font-weight: 600;
	letter-spacing: 0.04em;
	color: var(--vfai-ink-soft);
	text-align: center;
}

.vfai-field-error {
	margin: -8px 0 18px;
	padding: 12px 14px;
	font-size: 13px;
	line-height: 1.5;
	color: var(--vfai-danger);
	background: rgba(179, 38, 30, 0.06);
	border-radius: var(--vfai-radius);
}

.vfai-field-hint {
	display: block;
	margin-top: 6px;
	font-size: 12px;
	color: var(--vfai-ink-soft);
}

/* Actions */
.vfai-actions {
	display: flex;
	flex-direction: column;
	align-items: stretch;
	gap: 10px;
	margin-top: 16px;
}

.vfai-result-actions {
	display: flex;
	gap: 10px;
}

.vfai-result-actions .vfai-btn-primary {
	flex: 1 1 auto;
}

/* Buttons */
.vfai-btn {
	display: inline-flex !important;
	align-items: center;
	justify-content: center;
	gap: 10px;
	width: 100%;
	padding: 13px 22px !important;
	margin: 0 !important;
	font-size: 12px !important;
	font-weight: 600 !important;
	letter-spacing: 0.16em !important;
	line-height: 1;
	text-transform: uppercase !important;
	text-decoration: none !important;
	border-radius: var(--vfai-radius) !important;
	border: 1px solid var(--vfai-ink) !important;
	box-shadow: none !important;
	text-shadow: none !important;
	appearance: none;
	-webkit-appearance: none;
	cursor: pointer;
	font-family: inherit !important;
	transition: background 0.25s var(--vfai-ease), color 0.25s var(--vfai-ease), border-color 0.25s var(--vfai-ease), opacity 0.2s ease;
}

.vfai-btn-primary {
	background: var(--vfai-ink) !important;
	color: var(--vfai-paper) !important;
}

.vfai-btn-primary:hover {
	background: #000000 !important;
	color: var(--vfai-paper) !important;
}

.vfai-btn-primary:disabled {
	opacity: 0.35;
	cursor: not-allowed;
}

.vfai-btn-outline {
	background: transparent !important;
	color: var(--vfai-ink) !important;
}

.vfai-btn-outline:hover {
	background: var(--vfai-ink) !important;
	color: var(--vfai-paper) !important;
}

.vfai-btn-pill {
	border-radius: var(--vfai-pill) !important;
}

.vfai-btn-icon-only {
	flex: 0 0 auto !important;
	width: 48px !important;
	padding: 0 !important;
}

.vfai-btn-icon {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 16px;
	height: 16px;
	flex-shrink: 0;
}

.vfai-btn-icon svg {
	display: block;
	width: 100%;
	height: 100%;
}

.vfai-btn-text {
	display: inline-flex !important;
	align-items: center;
	width: auto !important;
	align-self: center;
	padding: 6px 0 !important;
	margin: 0 !important;
	font-size: 13px;
	font-weight: 500;
	letter-spacing: 0.02em;
	text-transform: none !important;
	color: var(--vfai-ink-soft) !important;
	background: none !important;
	border: none !important;
	box-shadow: none !important;
	text-decoration: underline !important;
	text-underline-offset: 3px;
	cursor: pointer;
	font-family: inherit;
	appearance: none;
	-webkit-appearance: none;
	transition: color 0.2s ease;
}

.vfai-btn-text:hover {
	color: var(--vfai-ink);
}

.vfai-btn.is-loading {
	pointer-events: none;
	opacity: 0.6;
}

.vfai-btn .vfai-btn-label::after {
	content: none;
}

.vfai-btn.is-loading .vfai-btn-label::after {
	content: "";
	display: inline-block;
	width: 13px;
	height: 13px;
	margin-left: 10px;
	border: 1.5px solid currentColor;
	border-right-color: transparent;
	border-radius: 50%;
	vertical-align: -2px;
	animation: vfai-spin 0.8s linear infinite;
}

.vfai-btn-text.is-loading {
	pointer-events: none;
	opacity: 0.6;
}

.vfai-btn-text.is-loading::after {
	content: "";
	display: inline-block;
	width: 11px;
	height: 11px;
	margin-left: 8px;
	border: 1.5px solid currentColor;
	border-right-color: transparent;
	border-radius: 50%;
	vertical-align: -1px;
	animation: vfai-spin 0.8s linear infinite;
}

/* Loading screen */
.vfai-loading-thumbs {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 12px;
	margin: 4px auto 20px;
}

.vfai-loading-thumb {
	flex: 0 0 auto;
	width: 100px;
	height: 100px;
	border-radius: var(--vfai-radius-lg);
	overflow: hidden;
	background: var(--vfai-paper);
	border: 1px solid var(--vfai-border);
}

.vfai-loading-thumb img {
	display: block;
	width: 100%;
	height: 100%;
	object-fit: cover;
}

.vfai-loading-swap {
	display: flex;
	align-items: center;
	justify-content: center;
	flex: 0 0 auto;
	width: 32px;
	height: 32px;
	border-radius: 50%;
	background: var(--vfai-surface);
	border: 1px solid var(--vfai-border);
	color: var(--vfai-ink-soft);
	animation: vfai-swap-pulse 2.4s ease-in-out infinite;
}

.vfai-loading-swap svg {
	width: 16px;
	height: 16px;
}

@keyframes vfai-swap-pulse {
	0%, 100% { transform: scale(1); }
	50% { transform: scale(1.12); }
}

.vfai-loading-message {
	margin: 0 0 14px;
	font-size: 15px;
	font-weight: 500;
	letter-spacing: 0.01em;
	color: var(--vfai-ink);
	min-height: 20px;
	text-align: center;
	transition: opacity 0.3s ease;
}

.vfai-loader {
	width: 48px;
	aspect-ratio: 1;
	margin: 0 auto 16px;
	--vfai-loader-bar: no-repeat linear-gradient(var(--vfai-ink-soft) 0 0);
	background: var(--vfai-loader-bar), var(--vfai-loader-bar), var(--vfai-loader-bar);
	animation:
		vfai-loader-size 1s infinite ease-in-out,
		vfai-loader-pos 1s infinite ease-in-out;
}

@keyframes vfai-loader-size {
	0%, 100% { background-size: 20% 100%; }
	33%, 66% { background-size: 20% 25%; }
}

@keyframes vfai-loader-pos {
	0%, 33% {
		background-position: 0 0, 50% 50%, 100% 100%;
	}

	66%, 100% {
		background-position: 100% 0, 50% 50%, 0 100%;
	}
}

.vfai-estimated-time {
	margin: 10px 0 0;
	font-size: 12px;
	color: var(--vfai-ink-soft);
	text-align: center;
}

.vfai-tip-box {
	margin: 16px 0 0;
	padding: 12px 14px;
	border-radius: var(--vfai-radius-md);
	background: var(--vfai-surface);
	font-size: 12px;
	line-height: 1.6;
	color: var(--vfai-ink-soft);
	text-align: left;
}

.vfai-tip-box strong {
	color: var(--vfai-ink);
}

/* Result */
.vfai-stage-result {
	aspect-ratio: 6 / 5;
}

.vfai-result-badge {
	position: absolute;
	left: 12px;
	bottom: 12px;
	z-index: 2;
	width: 56px;
	height: 56px;
	border-radius: var(--vfai-radius-md);
	overflow: hidden;
	background: var(--vfai-surface);
	border: 2px solid var(--vfai-paper);
	box-shadow: 0 6px 16px rgba(20, 20, 20, 0.18);
}

.vfai-result-badge img {
	display: block;
	width: 100%;
	height: 100%;
	object-fit: cover;
}

.vfai-result-info {
	margin: 0 0 16px;
	text-align: left;
}

.vfai-result-product {
	margin: 0;
	font-size: 15px;
	font-weight: 600;
	letter-spacing: 0.01em;
	color: var(--vfai-ink);
}

/* Result error state */
.vfai-result-error {
	text-align: center;
	padding: 24px 0;
}

.vfai-error-message {
	margin: 0 0 8px;
	font-size: 14px;
	line-height: 1.6;
	color: var(--vfai-ink-soft);
}

/* Toast */
.vfai-toast {
	position: absolute;
	left: 50%;
	bottom: 24px;
	transform: translate(-50%, 12px);
	padding: 12px 22px;
	font-size: 11px;
	font-weight: 600;
	letter-spacing: 0.1em;
	text-transform: uppercase;
	white-space: nowrap;
	color: var(--vfai-paper);
	background: var(--vfai-ink);
	border-radius: var(--vfai-radius);
	opacity: 0;
	pointer-events: none;
	z-index: 5;
	transition: opacity 0.25s ease, transform 0.25s ease;
}

.vfai-toast.is-visible {
	opacity: 1;
	transform: translate(-50%, 0);
}

/* Auth forms */
.vfai-auth-form {
	display: flex;
	flex-direction: column;
	gap: 18px;
}

.vfai-form-group {
	display: flex;
	flex-direction: column;
	gap: 8px;
}

.vfai-form-group label {
	font-size: 11px;
	font-weight: 600;
	letter-spacing: 0.14em;
	text-transform: uppercase;
	color: var(--vfai-ink-soft);
}

.vfai-form-group input {
	display: block !important;
	width: 100% !important;
	padding: 14px 16px !important;
	margin: 0 !important;
	font-size: 14px;
	border: 1px solid var(--vfai-border) !important;
	border-radius: var(--vfai-radius) !important;
	background: var(--vfai-paper) !important;
	color: var(--vfai-ink) !important;
	box-shadow: none !important;
	appearance: none;
	-webkit-appearance: none;
	font-family: inherit;
	transition: border-color 0.2s ease;
}

.vfai-form-group input:focus {
	outline: none;
	border-color: var(--vfai-ink) !important;
	box-shadow: none !important;
}

.vfai-auth-switch {
	text-align: center;
	margin: 24px 0 0;
	font-size: 13px;
	color: var(--vfai-ink-soft);
}

.vfai-link-button {
	display: inline !important;
	width: auto !important;
	background: none !important;
	border: none !important;
	box-shadow: none !important;
	padding: 0 !important;
	margin: 0 !important;
	color: var(--vfai-ink) !important;
	font-weight: 600;
	cursor: pointer;
	text-decoration: underline !important;
	text-underline-offset: 3px;
	font-size: 13px;
	font-family: inherit;
	appearance: none;
	-webkit-appearance: none;
}

/* Body scroll lock when modal open */
html.vfai-modal-open,
body.vfai-modal-open {
	overflow: hidden;
	height: 100%;
}

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

	.vfai-modal {
		max-width: 100%;
		max-height: 92vh;
		width: 100%;
		border-radius: 2px 2px 0 0;
		padding: 28px 24px;
	}

	#vfai-tryon-modal {
		align-items: flex-end;
		justify-content: center;
		padding: 10px;
	}

	#vfai-tryon-modal .vfai-modal {
		width: 100%;
		max-width: 100%;
		max-height: calc(100vh - 20px);
		border-radius: 18px;
	}

	#vfai-tryon-modal .vfai-panel-body,
	#vfai-tryon-modal .vfai-panel-header,
	#vfai-tryon-modal .vfai-panel-footer {
		padding-left: 18px;
		padding-right: 18px;
	}
}
