/* JIG SMS OTP Login — Premium mobile-first UI */

.jig-otp-root {
	--jig-otp-primary: #2563eb;
	--jig-otp-accent: #0ea5e9;
	--jig-otp-radius: 16px;
	--jig-otp-bg: #f8fafc;
	--jig-otp-card: #ffffff;
	--jig-otp-text: #0f172a;
	--jig-otp-muted: #64748b;
	--jig-otp-border: #e2e8f0;
	--jig-otp-error: #dc2626;
	--jig-otp-success: #16a34a;
	--jig-otp-shadow: 0 25px 50px -12px rgba(15, 23, 42, 0.15);
	font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
	min-height: min(100dvh, 100vh);
	display: flex;
	align-items: center;
	justify-content: center;
	padding: max(16px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) max(16px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
	background:
		radial-gradient(ellipse 80% 60% at 50% -10%, color-mix(in srgb, var(--jig-otp-primary) 18%, transparent), transparent),
		var(--jig-otp-bg);
	color: var(--jig-otp-text);
	box-sizing: border-box;
}

.jig-otp-root *,
.jig-otp-root *::before,
.jig-otp-root *::after {
	box-sizing: border-box;
}

/* Dark mode */
@media (prefers-color-scheme: dark) {
	.jig-otp-root[data-dark="auto"] {
		--jig-otp-bg: #0b1120;
		--jig-otp-card: #111827;
		--jig-otp-text: #f1f5f9;
		--jig-otp-muted: #94a3b8;
		--jig-otp-border: #1e293b;
		--jig-otp-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
	}
}

.jig-otp-root[data-dark="dark"] {
	--jig-otp-bg: #0b1120;
	--jig-otp-card: #111827;
	--jig-otp-text: #f1f5f9;
	--jig-otp-muted: #94a3b8;
	--jig-otp-border: #1e293b;
	--jig-otp-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
}

.jig-otp-card {
	width: 100%;
	max-width: 420px;
	background: var(--jig-otp-card);
	border-radius: calc(var(--jig-otp-radius) + 4px);
	box-shadow: var(--jig-otp-shadow);
	border: 1px solid var(--jig-otp-border);
	padding: 32px 28px 24px;
	animation: jigOtpFadeIn 0.45s ease-out;
}

@keyframes jigOtpFadeIn {
	from { opacity: 0; transform: translateY(12px); }
	to { opacity: 1; transform: translateY(0); }
}

.jig-otp-header {
	text-align: center;
	margin-bottom: 28px;
}

.jig-otp-logo {
	color: var(--jig-otp-primary);
	width: 56px;
	height: 56px;
	margin: 0 auto 16px;
}

.jig-otp-logo svg {
	width: 100%;
	height: 100%;
}

.jig-otp-title {
	font-size: 1.5rem;
	font-weight: 700;
	margin: 0 0 8px;
	letter-spacing: -0.02em;
}

.jig-otp-subtitle {
	font-size: 0.9375rem;
	color: var(--jig-otp-muted);
	margin: 0;
	line-height: 1.5;
}

.jig-otp-label {
	display: block;
	font-size: 0.8125rem;
	font-weight: 600;
	margin-bottom: 8px;
	color: var(--jig-otp-muted);
	text-transform: uppercase;
	letter-spacing: 0.04em;
}

.jig-otp-phone-wrap {
	display: flex;
	align-items: stretch;
	border: 2px solid var(--jig-otp-border);
	border-radius: var(--jig-otp-radius);
	overflow: hidden;
	transition: border-color 0.2s, box-shadow 0.2s;
	background: var(--jig-otp-bg);
	direction: ltr;
}

.jig-otp-phone-wrap:focus-within {
	border-color: var(--jig-otp-primary);
	box-shadow: 0 0 0 4px color-mix(in srgb, var(--jig-otp-primary) 20%, transparent);
}

.jig-otp-prefix {
	display: flex;
	align-items: center;
	padding: 0 14px;
	font-weight: 600;
	color: var(--jig-otp-muted);
	background: color-mix(in srgb, var(--jig-otp-border) 40%, transparent);
	border-right: 1px solid var(--jig-otp-border);
	font-size: 1rem;
	user-select: none;
}

.jig-otp-input {
	flex: 1;
	border: none;
	background: transparent;
	padding: 14px 16px;
	font-size: 1.125rem;
	color: var(--jig-otp-text);
	outline: none;
	min-height: 52px;
	-webkit-tap-highlight-color: transparent;
}

.jig-otp-input::placeholder {
	color: color-mix(in srgb, var(--jig-otp-muted) 60%, transparent);
}

.jig-otp-hint {
	font-size: 0.8125rem;
	color: var(--jig-otp-muted);
	margin: 8px 0 20px;
}

/* OTP digit inputs */
.jig-otp-digits {
	display: flex;
	gap: clamp(6px, 2vw, 10px);
	justify-content: center;
	margin: 16px 0 12px;
	direction: ltr;
}

.jig-otp-digit {
	width: clamp(40px, 11vw, 52px);
	height: clamp(48px, 13vw, 58px);
	text-align: center;
	font-size: clamp(1.25rem, 4vw, 1.5rem);
	font-weight: 700;
	border: 2px solid var(--jig-otp-border);
	border-radius: calc(var(--jig-otp-radius) - 4px);
	background: var(--jig-otp-bg);
	color: var(--jig-otp-text);
	outline: none;
	transition: border-color 0.15s, transform 0.1s, box-shadow 0.15s;
	caret-color: transparent;
	-webkit-tap-highlight-color: transparent;
}

.jig-otp-digit:focus {
	border-color: var(--jig-otp-primary);
	box-shadow: 0 0 0 3px color-mix(in srgb, var(--jig-otp-primary) 18%, transparent);
	transform: scale(1.04);
}

.jig-otp-digit.filled {
	border-color: color-mix(in srgb, var(--jig-otp-primary) 50%, var(--jig-otp-border));
	background: color-mix(in srgb, var(--jig-otp-primary) 6%, var(--jig-otp-bg));
}

.jig-otp-digit.error {
	border-color: var(--jig-otp-error);
	animation: jigOtpShake 0.4s ease;
}

@keyframes jigOtpShake {
	0%, 100% { transform: translateX(0); }
	20% { transform: translateX(-6px); }
	40% { transform: translateX(6px); }
	60% { transform: translateX(-4px); }
	80% { transform: translateX(4px); }
}

.jig-otp-webotp-hint {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 6px;
	font-size: 0.75rem;
	color: var(--jig-otp-muted);
	margin: 0 0 16px;
}

/* Timer */
.jig-otp-timer-wrap {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 8px;
	margin-bottom: 20px;
}

.jig-otp-timer-ring {
	width: 28px;
	height: 28px;
	transform: rotate(-90deg);
}

.jig-otp-timer-bg {
	stroke: var(--jig-otp-border);
}

.jig-otp-timer-fg {
	stroke: var(--jig-otp-primary);
	stroke-linecap: round;
	transition: stroke-dashoffset 1s linear;
}

.jig-otp-timer-text {
	font-size: 0.875rem;
	color: var(--jig-otp-muted);
	font-variant-numeric: tabular-nums;
	min-width: 4ch;
}

/* Buttons */
.jig-otp-btn {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 8px;
	width: 100%;
	min-height: 52px;
	padding: 14px 24px;
	border: none;
	border-radius: var(--jig-otp-radius);
	font-size: 1rem;
	font-weight: 600;
	cursor: pointer;
	transition: transform 0.15s, opacity 0.15s, background 0.2s;
	-webkit-tap-highlight-color: transparent;
	touch-action: manipulation;
}

.jig-otp-btn:active:not(:disabled) {
	transform: scale(0.98);
}

.jig-otp-btn-primary {
	background: linear-gradient(135deg, var(--jig-otp-primary), var(--jig-otp-accent));
	color: #fff;
	box-shadow: 0 4px 14px color-mix(in srgb, var(--jig-otp-primary) 35%, transparent);
}

.jig-otp-btn-primary:hover:not(:disabled) {
	filter: brightness(1.05);
}

.jig-otp-btn:disabled {
	opacity: 0.45;
	cursor: not-allowed;
}

.jig-otp-spinner {
	width: 20px;
	height: 20px;
	border: 2px solid rgba(255, 255, 255, 0.3);
	border-top-color: #fff;
	border-radius: 50%;
	animation: jigOtpSpin 0.7s linear infinite;
}

@keyframes jigOtpSpin {
	to { transform: rotate(360deg); }
}

.jig-otp-actions {
	display: flex;
	justify-content: space-between;
	align-items: center;
	margin-top: 16px;
	gap: 12px;
	flex-wrap: wrap;
}

.jig-otp-link {
	background: none;
	border: none;
	color: var(--jig-otp-primary);
	font-size: 0.875rem;
	font-weight: 500;
	cursor: pointer;
	padding: 8px 4px;
	min-height: 44px;
	-webkit-tap-highlight-color: transparent;
}

.jig-otp-link:disabled {
	color: var(--jig-otp-muted);
	cursor: not-allowed;
}

.jig-otp-link:not(:disabled):hover {
	text-decoration: underline;
}

/* Alert */
.jig-otp-alert {
	margin-top: 16px;
	padding: 12px 14px;
	border-radius: calc(var(--jig-otp-radius) - 4px);
	font-size: 0.875rem;
	line-height: 1.45;
}

.jig-otp-alert[data-type="error"] {
	background: color-mix(in srgb, var(--jig-otp-error) 12%, transparent);
	color: var(--jig-otp-error);
	border: 1px solid color-mix(in srgb, var(--jig-otp-error) 25%, transparent);
}

.jig-otp-alert[data-type="success"] {
	background: color-mix(in srgb, var(--jig-otp-success) 12%, transparent);
	color: var(--jig-otp-success);
	border: 1px solid color-mix(in srgb, var(--jig-otp-success) 25%, transparent);
}

.jig-otp-footer {
	text-align: center;
	margin-top: 24px;
	padding-top: 16px;
	border-top: 1px solid var(--jig-otp-border);
	font-size: 0.75rem;
	color: var(--jig-otp-muted);
}

/* Step transitions */
.jig-otp-step[hidden] {
	display: none !important;
}

.jig-otp-step-code:not([hidden]) {
	animation: jigOtpSlideIn 0.35s ease-out;
}

@keyframes jigOtpSlideIn {
	from { opacity: 0; transform: translateX(16px); }
	to { opacity: 1; transform: translateX(0); }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
	.jig-otp-card,
	.jig-otp-step-code,
	.jig-otp-digit.error {
		animation: none;
	}
	.jig-otp-spinner {
		animation-duration: 1.5s;
	}
}

/* RTL support for Persian sites */
[dir="rtl"] .jig-otp-root {
	direction: rtl;
}

[dir="rtl"] .jig-otp-digits,
[dir="rtl"] .jig-otp-phone-wrap {
	direction: ltr;
}
