
:root {
	--melo-otp-bg: var(--melo-surface, #FFFFFF);
	--melo-otp-text-color: var(--melo-ink, #26343B);
	--melo-otp-subtitle-color: var(--melo-muted-ink, #52666F);
	--melo-otp-border-color: var(--melo-border, #DCE7EB);
	--melo-otp-border-focus: var(--melo-accent, #538AA8);
	--melo-otp-btn-bg: var(--melo-disabled-bg, #DCE5E8);
	--melo-otp-btn-text: var(--melo-disabled-ink, #63747B);
	--melo-otp-btn-active-bg: var(--melo-accent, #538AA8);
	--melo-otp-btn-active-text: #FFFFFF;
	--melo-otp-error-color: var(--melo-error-ink, #A8463F);
	--melo-otp-success-color: var(--melo-accent-dark, #3E6D86);
	--melo-otp-font-family: Peyda, Tahoma, sans-serif;
	--melo-otp-radius: 10px;
	--melo-otp-transition: 180ms ease;
}

/* Fullscreen Overlay */
.melo-otp-fullscreen-overlay {
	position: fixed;
	top: 0;
	left: 0;
	right: 0;
	bottom: 0;
	background: linear-gradient(34deg, #BBD9E1 0%, #538AA8 100%);
	z-index: 999999;
	display: flex;
	flex-direction: column;
	justify-content: center;
	align-items: center;
	overflow-y: auto;
	overflow-x: hidden;
	font-family: var(--melo-otp-font-family);
	direction: rtl;
}

/* Background Decoration */
.melo-otp-circle {
	position: absolute;
	inline-size: clamp(18rem, 48vw, 30rem);
	aspect-ratio: 1;
	opacity: 0.20;
	border-radius: 50%;
	border: 3px solid #BBD9E1;
	pointer-events: none;
}
.melo-otp-circle-1 {
	left: -237px;
	top: -263px;
}
.melo-otp-circle-2 {
	right: -150px;
	bottom: -150px;
}

/* Header */
.melo-otp-header {
	position: relative;
	width: 100%;
	display: flex;
	flex-direction: column;
	justify-content: center;
	align-items: center;
	gap: 16px;
	z-index: 10;
	margin-bottom: 24px;
}

/* Logo */
.melo-otp-logo {
	display: flex;
	justify-content: center;
	align-items: center;
}
.melo-otp-site-logo {
	max-inline-size: min(100%, 15rem);
	height: auto;
	max-height: 80px;
	object-fit: contain;
	filter: brightness(0) invert(1);
}
.melo-otp-site-title {
	color: white;
	font-size: 32px;
	font-weight: 700;
}

/* Close Button */
.melo-otp-close-btn {
	background: rgba(255, 255, 255, 0.15);
	border: 1px solid rgba(255, 255, 255, 0.4);
	border-radius: 8px;
	color: white;
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 8px;
	padding: 10px 24px;
	cursor: pointer;
	font-family: var(--melo-otp-font-family);
	font-size: 14px;
	font-weight: 500;
	line-height: 1.5;
	transition: background-color var(--melo-otp-transition), border-color var(--melo-otp-transition), color var(--melo-otp-transition), box-shadow var(--melo-otp-transition), transform var(--melo-otp-transition);
	backdrop-filter: blur(5px);
}
.melo-otp-close-btn:hover {
	background: rgba(255, 255, 255, 0.25);
}
.melo-otp-close-btn svg {
	width: 18px;
	height: 18px;
}

/* Footer Action */
.melo-otp-footer-action {
	margin-top: 24px;
	display: flex;
	justify-content: center;
	width: 100%;
}
.melo-otp-footer-action .melo-otp-close-btn {
	color: #ffffff;
	border: 1px solid #ffffff;
	background: transparent;
}
.melo-otp-footer-action .melo-otp-close-btn:hover {
	color: var(--melo-dark, #1E1E1E);
	background: #ffffff;
}

/* Main Card Container */
.melo-otp-card-container {
	width: 100%;
	max-inline-size: 30rem;
	padding: 0 20px;
	box-sizing: border-box;
	z-index: 10;
}

/* Main Card Wrapper */
.melo-otp-wrapper {
	background: white;
	box-shadow: 0px 10px 40px rgba(0, 0, 0, 0.05);
	border-radius: var(--melo-otp-radius);
	padding: 32px;
	display: flex;
	flex-direction: column;
	gap: 24px;
	width: 100%;
	box-sizing: border-box;
}

/* Headings */
.melo-otp-heading-group {
	display: flex;
	flex-direction: column;
	gap: 8px;
	text-align: right;
}
.melo-otp-title {
	color: var(--melo-dark, #1E1E1E);
	font-size: 24px;
	font-weight: 500;
	margin: 0;
	padding: 0;
	text-align: right;
}
.melo-otp-subtitle, .melo-otp-subtitle-row {
	color: var(--melo-otp-subtitle-color);
	font-size: 14px;
	margin: 0;
	font-weight: 400;
	text-align: right;
}
.melo-otp-subtitle-row {
	display: flex;
	flex-direction: row;
	justify-content: space-between;
	align-items: center;
	gap: 8px;
	flex-wrap: wrap;
}

/* Links */
.melo-otp-edit-link, #melo-otp-resend-link {
	color: var(--wd-primary-color, var(--melo-blue-text, #538AA8));
	font-size: 12px;
	text-decoration: underline;
	transition: color var(--melo-otp-transition);
	white-space: nowrap;
}
.melo-otp-edit-link:hover, #melo-otp-resend-link:hover {
	color: var(--melo-otp-text-color);
}

/* Inputs */
.melo-otp-input-group {
	position: relative;
	display: flex;
	align-items: center;
}
.melo-otp-input {
	width: 100%;
	padding: 14px 45px 14px 16px;
	border: 1px solid var(--melo-otp-border-color);
	border-radius: 8px;
	font-size: 16px;
	color: var(--melo-otp-text-color);
	background: transparent;
	box-shadow: none;
	outline: none;
	transition: border-color var(--melo-otp-transition), box-shadow var(--melo-otp-transition);
	text-align: right;
	direction: ltr;
	box-sizing: border-box;
}
.melo-otp-input.melo-otp-pw-input,
.melo-otp-input[type="password"] {
	padding: 14px 45px 14px 45px;
}
.melo-otp-input::placeholder {
	color: #C0C0C0;
	opacity: 1;
	text-align: right;
}
.melo-otp-input:focus {
	border-color: var(--melo-otp-border-focus);
}
.melo-otp-icon {
	position: absolute;
	right: 16px;
	left: auto;
	top: 50%;
	transform: translateY(-50%);
	color: var(--melo-dark, #1E1E1E);
	display: flex;
	align-items: center;
	pointer-events: none;
}

/* OTP Code Inputs */
.melo-otp-code-inputs {
	display: flex;
	justify-content: space-between;
	align-items: center;
	gap: 12px;
	direction: ltr;
}
.melo-otp-digit {
	width: 56px;
	height: 56px;
	border: 1px solid #D9D9D9;
	border-radius: 8px;
	font-size: 24px;
	font-weight: 500;
	text-align: center;
	color: var(--melo-otp-text-color);
	background: transparent;
	box-shadow: none;
	outline: none;
	padding: 0;
	transition: border-color var(--melo-otp-transition), box-shadow var(--melo-otp-transition);
}
.melo-otp-digit:focus {
	border-color: var(--melo-otp-border-focus);
}

/* Timer */
.melo-otp-timer-wrap {
	text-align: center;
	font-size: 14px;
	color: #444444;
	font-weight: 400;
}
#melo-otp-timer {
	font-weight: 500;
	color: var(--melo-otp-text-color);
}

/* Action Group */
.melo-otp-action-group {
	display: flex;
	flex-direction: column;
	gap: 12px;
	width: 100%;
}

/* Buttons */
.melo-otp-btn {
	width: 100%;
	height: 56px;
	padding: 0;
	border: none;
	border-radius: 8px;
	background: var(--melo-otp-btn-bg);
	color: var(--melo-otp-btn-text);
	font-size: 14px;
	font-weight: 600;
	font-family: var(--melo-otp-font-family);
	cursor: not-allowed;
	transition: background-color var(--melo-otp-transition), border-color var(--melo-otp-transition), color var(--melo-otp-transition), box-shadow var(--melo-otp-transition), transform var(--melo-otp-transition);
	position: relative;
	display: flex;
	justify-content: center;
	align-items: center;
	opacity: 1;
}
.melo-otp-btn:disabled {
	opacity: 1;
}
.melo-otp-btn.active {
	background: var(--melo-otp-btn-active-bg);
	color: var(--melo-otp-btn-active-text);
	cursor: pointer;
	opacity: 1;
}
.melo-otp-btn.loading {
	color: transparent;
	cursor: wait;
}

/* Spinner */
.melo-otp-spinner {
	position: absolute;
	width: 24px;
	height: 24px;
	border: 3px solid rgba(255, 255, 255, 0.3);
	border-radius: 50%;
	border-top-color: #fff;
	animation: melo-otp-spin 1s ease-in-out infinite;
}
@keyframes melo-otp-spin {
	to { transform: rotate(360deg); }
}

/* Messages */
.melo-otp-message {
	font-size: 13px;
	text-align: center;
	display: none;
}
.melo-otp-message.error {
	color: var(--melo-otp-error-color);
	display: block;
}
.melo-otp-message.success {
	color: var(--melo-otp-success-color);
	display: block;
}

/* Shake Animation */
.melo-otp-shake {
	animation: melo-otp-shake-anim 0.5s cubic-bezier(.36,.07,.19,.97) both;
	transform: translate3d(0, 0, 0);
}
@keyframes melo-otp-shake-anim {
	10%, 90% { transform: translate3d(-1px, 0, 0); }
	20%, 80% { transform: translate3d(2px, 0, 0); }
	30%, 50%, 70% { transform: translate3d(-4px, 0, 0); }
	40%, 60% { transform: translate3d(4px, 0, 0); }
}

/* Tab Switcher */
.melo-otp-tabs {
	display: flex;
	position: relative;
	border-bottom: 2px solid #E5E5E5;
	margin-bottom: 16px;
	padding: 0;
	background: transparent;
	width: 100%;
	box-sizing: border-box;
}
.melo-otp-tab {
	flex: 1;
	padding: 14px 0;
	border: none;
	background: transparent;
	cursor: pointer;
	font-family: var(--melo-otp-font-family);
	font-size: 15px;
	font-weight: 500;
	color: #9E9E9E;
	transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
	text-align: center;
	position: relative;
	outline: none;
}
.melo-otp-tab.active {
	color: var(--wd-primary-color, var(--melo-blue-text, #538AA8));
	font-weight: 600;
}
.melo-otp-tab:hover:not(.active) {
	color: var(--wd-primary-color, var(--melo-blue-text, #538AA8));
	opacity: 0.7;
}
.melo-otp-tab::after {
	content: '';
	position: absolute;
	bottom: -2px;
	left: 0;
	width: 100%;
	height: 3px;
	background: var(--wd-primary-color, var(--melo-blue-text, #538AA8));
	border-radius: 4px 4px 0 0;
	transform: scaleX(0);
	transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.3s ease;
	transform-origin: center;
}
.melo-otp-tab.active::after {
	transform: scaleX(1);
}
.melo-otp-tab:hover:not(.active)::after {
	transform: scaleX(0.4);
	opacity: 0.4;
}

/* Tab Content */
.melo-otp-tab-content {
	display: none;
	flex-direction: column;
	gap: 24px;
	width: 100%;
}
.melo-otp-tab-content.active {
	display: flex;
}

/* Password Toggle */
.melo-otp-pw-toggle {
	position: absolute;
	left: 16px;
	right: auto;
	top: 50%;
	transform: translateY(-50%);
	cursor: pointer;
	color: var(--melo-gray-text, #7D7D7D);
	display: flex;
	align-items: center;
	background: none;
	border: none;
	padding: 0;
	pointer-events: auto;
	z-index: 10;
}
.melo-otp-pw-toggle svg {
	transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1), color 0.2s ease;
}
.melo-otp-pw-toggle:hover svg {
	transform: scale(1.15);
	color: var(--wd-primary-color, var(--melo-dark, #1E1E1E));
}
.melo-otp-pw-toggle:active svg {
	transform: scale(0.9);
}

/* Step 3 */
#melo-otp-step-3 .melo-otp-input-group {
	margin-bottom: 0;
}
#melo-otp-step-3 {
	gap: 16px;
}

/* Responsive adjustments */
@media (max-width: 600px) {
	.melo-otp-header {
		margin-bottom: 32px;
	}
	.melo-otp-site-logo {
		width: 100%;
		max-inline-size: min(100%, 15rem);
		padding: 0 24px;
		box-sizing: border-box;
	}
	.melo-otp-footer-action {
		margin-top: 16px;
	}
	.melo-otp-logo-text {
		font-size: 24px;
	}
	.melo-otp-wrapper {
		padding: 20px;
		gap: 20px;
	}
	.melo-otp-title {
		font-size: 20px;
	}
	.melo-otp-code-inputs {
		gap: 8px;
	}
	.melo-otp-digit {
		width: 48px;
		height: 48px;
		font-size: 20px;
	}
	.melo-otp-circle-1 {
		width: 300px;
		height: 300px;
		left: -150px;
		top: -150px;
	}
}

@media (max-width: 375px) {
	.melo-otp-wrapper {
		padding: 16px;
		gap: 16px;
	}
	.melo-otp-title {
		font-size: 18px;
	}
	.melo-otp-subtitle, .melo-otp-subtitle-row {
		font-size: 12px;
	}
	.melo-otp-tab {
		font-size: 13px;
		padding: 10px 0;
	}
	.melo-otp-digit {
		width: 42px;
		height: 42px;
		font-size: 18px;
	}
	.melo-otp-input {
		font-size: 14px;
	}
	.melo-otp-btn {
		font-size: 13px;
		height: 48px;
	}
}
#melo-otp-reg-password {
	padding-left: 75px;
}
/* Shared interaction safeguards */
.melo-otp-fullscreen-overlay :is(button, a, input, select, textarea):focus-visible {
	outline: 2px solid var(--melo-otp-border-focus);
	outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
	.melo-otp-fullscreen-overlay *,
	.melo-otp-fullscreen-overlay *::before,
	.melo-otp-fullscreen-overlay *::after {
		animation-duration: 0.01ms;
		animation-iteration-count: 1;
		transition-duration: 0.01ms;
		scroll-behavior: auto;
	}
}


/* Forgot Password Flow */
.melo-otp-forgot-link-row {
	display: flex;
	justify-content: flex-start;
	align-items: center;
	margin-top: -12px;
	margin-bottom: 4px;
	text-align: right;
	width: 100%;
}
.melo-otp-forgot-link {
	color: var(--wd-primary-color, var(--melo-blue-text, #538AA8));
	font-size: 13px;
	font-weight: 500;
	text-decoration: none;
	transition: color var(--melo-otp-transition), opacity var(--melo-otp-transition);
	cursor: pointer;
	display: inline-block;
}
.melo-otp-forgot-link:hover {
	color: var(--melo-otp-text-color);
	text-decoration: underline;
}

/* Secondary Back Button */
.melo-otp-btn-back {
	width: 100%;
	height: 48px;
	padding: 0;
	border: 1px solid var(--melo-otp-border-color);
	border-radius: 8px;
	background: transparent;
	color: var(--melo-otp-subtitle-color);
	font-size: 13px;
	font-weight: 500;
	font-family: var(--melo-otp-font-family);
	cursor: pointer;
	transition: background-color var(--melo-otp-transition), border-color var(--melo-otp-transition), color var(--melo-otp-transition);
	display: flex;
	justify-content: center;
	align-items: center;
	outline: none;
	box-shadow: none;
}
.melo-otp-btn-back:hover {
	background: rgba(0, 0, 0, 0.03);
	color: var(--melo-otp-text-color);
	border-color: var(--melo-otp-border-focus);
}

/* Forgot Password Form Layouts */
#melo-otp-forgot-step-1,
#melo-otp-forgot-step-2 {
	gap: 20px;
}
#melo-otp-forgot-new-password {
	padding-left: 75px;
}

@media (max-width: 375px) {
	.melo-otp-forgot-link {
		font-size: 12px;
	}
	.melo-otp-btn-back {
		height: 44px;
		font-size: 12px;
	}
}
