/**
 * OTP Modal Styles - Deutschfuns LMS
 *
 * States:
 * - .de-otp-state-loading
 * - .de-otp-state-input
 * - .de-otp-state-verifying
 * - .de-otp-state-success
 * - .de-otp-state-error
 *
 * @package    Deutschfuns_LMS
 * @subpackage OTP_Module
 * @since      3.0.0
 */

/* ===== CSS Variables ===== */
:root {
	--de-otp-primary: #1976d2;
	--de-otp-primary-dark: #1565c0;
	--de-otp-primary-light: #e3f2fd;
	--de-otp-success: #4caf50;
	--de-otp-success-light: #e8f5e9;
	--de-otp-error: #d32f2f;
	--de-otp-error-light: #ffebee;
	--de-otp-warning: #f57c00;
	--de-otp-text: #212121;
	--de-otp-text-secondary: #757575;
	--de-otp-border: #e0e0e0;
	--de-otp-bg: #ffffff;
	--de-otp-bg-input: #fafafa;
	--de-otp-overlay: rgba(0, 0, 0, 0.6);
	--de-otp-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
	--de-otp-radius: 16px;
	--de-otp-radius-sm: 8px;
	--de-otp-radius-input: 12px;
	--de-otp-transition: 0.3s ease;
	--de-otp-font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
		"Helvetica Neue", Arial, sans-serif;
}

/* ===== Modal Overlay ===== */
.de-otp-modal {
	position: fixed;
	top: 0;
	left: 0;
	width: 100%;
	height: 100%;
	z-index: 999999;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 20px;
	opacity: 0;
	visibility: hidden;
	transition: opacity var(--de-otp-transition),
		visibility var(--de-otp-transition);
	font-family: var(--de-otp-font);
	box-sizing: border-box;
}

.de-otp-modal.is-visible {
	opacity: 1;
	visibility: visible;
}

.de-otp-modal * {
	box-sizing: border-box;
}

.de-otp-modal-overlay {
	position: absolute;
	top: 0;
	left: 0;
	width: 100%;
	height: 100%;
	background: var(--de-otp-overlay);
	backdrop-filter: blur(4px);
	-webkit-backdrop-filter: blur(4px);
}

/* ===== Modal Container ===== */
.de-otp-modal-container {
	position: relative;
	background: var(--de-otp-bg);
	border-radius: var(--de-otp-radius);
	box-shadow: var(--de-otp-shadow);
	max-width: 480px;
	width: 100%;
	padding: 40px 32px;
	transform: scale(0.9) translateY(20px);
	transition: transform var(--de-otp-transition);
}

.de-otp-modal.is-visible .de-otp-modal-container {
	transform: scale(1) translateY(0);
}

/* ===== Close Button ===== */
.de-otp-modal-close {
	position: absolute;
	top: 16px;
	right: 16px;
	width: 36px;
	height: 36px;
	border: none;
	background: transparent;
	color: var(--de-otp-text-secondary);
	cursor: pointer;
	border-radius: 50%;
	display: flex;
	align-items: center;
	justify-content: center;
	transition: all 0.2s ease;
	padding: 0;
}

.de-otp-modal-close:hover {
	background: #f5f5f5;
	color: var(--de-otp-text);
}

.de-otp-modal-close:focus {
	outline: 2px solid var(--de-otp-primary);
	outline-offset: 2px;
}

.de-otp-modal-close:active {
	transform: scale(0.95);
}

/* ===== Common State Styles ===== */
.de-otp-state {
	text-align: center;
}

.de-otp-modal-content {
	min-height: 280px;
	display: flex;
	align-items: center;
	justify-content: center;
}

.de-otp-title {
	font-size: 24px;
	font-weight: 600;
	color: var(--de-otp-text);
	margin: 16px 0 8px;
	line-height: 1.3;
}

.de-otp-description {
	font-size: 14px;
	color: var(--de-otp-text-secondary);
	margin: 0 0 24px;
	line-height: 1.6;
}

.de-otp-description strong {
	color: var(--de-otp-text);
	font-weight: 600;
}

/* ===== Spinner Animation ===== */
.de-otp-spinner {
	display: inline-block;
	animation: de-otp-pulse 1.5s ease-in-out infinite;
}

@keyframes de-otp-pulse {
	0%,
	100% {
		opacity: 1;
		transform: scale(1);
	}
	50% {
		opacity: 0.8;
		transform: scale(0.95);
	}
}

/* ===== Icons ===== */
.de-otp-icon {
	display: inline-block;
	margin-bottom: 16px;
}

.de-otp-icon svg {
	display: block;
}

/* ===== OTP Input Boxes ===== */
.de-otp-input-container {
	display: flex;
	gap: 12px;
	justify-content: center;
	margin: 24px 0;
}

.de-otp-input {
	width: 52px;
	height: 60px;
	font-size: 24px;
	font-weight: 600;
	text-align: center;
	border: 2px solid var(--de-otp-border);
	border-radius: var(--de-otp-radius-input);
	outline: none;
	transition: all 0.2s ease;
	background: var(--de-otp-bg-input);
	color: var(--de-otp-text);
	-webkit-appearance: none;
	-moz-appearance: textfield;
}

.de-otp-input::-webkit-outer-spin-button,
.de-otp-input::-webkit-inner-spin-button {
	-webkit-appearance: none;
	margin: 0;
}

.de-otp-input:focus {
	border-color: var(--de-otp-primary);
	background: var(--de-otp-bg);
	box-shadow: 0 0 0 4px rgba(25, 118, 210, 0.1);
}

.de-otp-input.is-filled {
	border-color: var(--de-otp-primary);
	background: var(--de-otp-primary-light);
}

.de-otp-input.is-error {
	border-color: var(--de-otp-error);
	background: var(--de-otp-error-light);
	animation: de-otp-shake 0.4s ease;
}

.de-otp-input:disabled {
	background: #f5f5f5;
	cursor: not-allowed;
	opacity: 0.7;
}

@keyframes de-otp-shake {
	0%,
	100% {
		transform: translateX(0);
	}
	25% {
		transform: translateX(-8px);
	}
	75% {
		transform: translateX(8px);
	}
}

/* ===== Error Message ===== */
.de-otp-error {
	padding: 12px 16px;
	background: var(--de-otp-error-light);
	border: 1px solid #ef5350;
	border-radius: var(--de-otp-radius-sm);
	color: #c62828;
	font-size: 14px;
	margin-bottom: 16px;
	text-align: left;
	display: flex;
	align-items: flex-start;
	gap: 10px;
}

.de-otp-error-icon {
	flex-shrink: 0;
	width: 20px;
	height: 20px;
}

.de-otp-error-content {
	flex: 1;
}

.de-otp-error-action {
	background: none;
	border: none;
	color: var(--de-otp-primary);
	cursor: pointer;
	padding: 0;
	font-size: 14px;
	text-decoration: underline;
	margin-top: 4px;
}

.de-otp-error-action:hover {
	color: var(--de-otp-primary-dark);
}

/* ===== Timer ===== */
.de-otp-timer {
	font-size: 14px;
	color: var(--de-otp-text-secondary);
	margin-bottom: 24px;
}

#de-otp-countdown {
	font-weight: 600;
	color: var(--de-otp-primary);
	font-variant-numeric: tabular-nums;
}

#de-otp-countdown.is-warning {
	color: var(--de-otp-warning);
}

#de-otp-countdown.is-danger {
	color: var(--de-otp-error);
}

/* ===== Action Buttons ===== */
.de-otp-actions {
	display: flex;
	flex-direction: column;
	gap: 12px;
}

.de-otp-btn {
	width: 100%;
	padding: 14px 24px;
	font-size: 16px;
	font-weight: 600;
	border: none;
	border-radius: var(--de-otp-radius-sm);
	cursor: pointer;
	transition: all 0.2s ease;
	font-family: inherit;
}

.de-otp-btn:focus {
	outline: 2px solid var(--de-otp-primary);
	outline-offset: 2px;
}

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

.de-otp-btn-primary {
	background: var(--de-otp-primary);
	color: #ffffff;
}

.de-otp-btn-primary:hover:not(:disabled) {
	background: var(--de-otp-primary-dark);
	transform: translateY(-2px);
	box-shadow: 0 4px 12px rgba(25, 118, 210, 0.3);
}

.de-otp-btn-primary:disabled {
	background: var(--de-otp-border);
	color: #9e9e9e;
	cursor: not-allowed;
	transform: none;
	box-shadow: none;
}

.de-otp-btn-secondary {
	background: transparent;
	color: var(--de-otp-primary);
	border: 2px solid var(--de-otp-primary);
}

.de-otp-btn-secondary:hover:not(:disabled) {
	background: var(--de-otp-primary-light);
}

.de-otp-btn-secondary:disabled {
	border-color: var(--de-otp-border);
	color: #9e9e9e;
	cursor: not-allowed;
}

/* ===== Help Text ===== */
.de-otp-help {
	margin-top: 16px;
	font-size: 13px;
	color: var(--de-otp-text-secondary);
}

.de-otp-help a {
	color: var(--de-otp-primary);
	text-decoration: none;
}

.de-otp-help a:hover {
	text-decoration: underline;
}

/* ===== Success State ===== */
.de-otp-title-success {
	color: var(--de-otp-success);
}

.de-otp-icon-success {
	animation: de-otp-successPop 0.6s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

@keyframes de-otp-successPop {
	0% {
		transform: scale(0);
		opacity: 0;
	}
	50% {
		transform: scale(1.1);
	}
	100% {
		transform: scale(1);
		opacity: 1;
	}
}

/* Redirect Progress Bar */
.de-otp-redirect-progress {
	width: 200px;
	height: 4px;
	background: #e0e0e0;
	border-radius: 2px;
	margin: 24px auto 0;
	overflow: hidden;
}

.de-otp-redirect-bar {
	height: 100%;
	background: var(--de-otp-success);
	width: 0%;
	animation: de-otp-progress 2s linear forwards;
}

@keyframes de-otp-progress {
	to {
		width: 100%;
	}
}

/* ===== Error State ===== */
.de-otp-title-error {
	color: var(--de-otp-error);
}

.de-otp-icon-error {
	animation: de-otp-errorShake 0.5s ease;
}

@keyframes de-otp-errorShake {
	0%,
	100% {
		transform: translateX(0);
	}
	20%,
	60% {
		transform: translateX(-10px);
	}
	40%,
	80% {
		transform: translateX(10px);
	}
}

/* ===== Responsive Design ===== */
@media (max-width: 640px) {
	.de-otp-modal {
		padding: 16px;
	}

	.de-otp-modal-container {
		padding: 32px 24px;
	}

	.de-otp-input-container {
		gap: 8px;
	}

	.de-otp-input {
		width: 46px;
		height: 54px;
		font-size: 20px;
	}

	.de-otp-title {
		font-size: 20px;
	}

	.de-otp-description {
		font-size: 13px;
	}

	.de-otp-btn {
		padding: 12px 20px;
		font-size: 15px;
	}
}

@media (max-width: 400px) {
	.de-otp-modal-container {
		padding: 28px 20px;
	}

	.de-otp-input-container {
		gap: 6px;
	}

	.de-otp-input {
		width: 40px;
		height: 48px;
		font-size: 18px;
		border-radius: 8px;
	}

	.de-otp-title {
		font-size: 18px;
	}
}

/* ===== Print Styles ===== */
@media print {
	.de-otp-modal {
		display: none !important;
	}
}

/* ===== High Contrast Mode ===== */
@media (prefers-contrast: high) {
	.de-otp-modal-overlay {
		background: rgba(0, 0, 0, 0.9);
	}

	.de-otp-input {
		border-width: 3px;
	}

	.de-otp-btn {
		border-width: 3px;
	}
}

/* ===== Reduced Motion ===== */
@media (prefers-reduced-motion: reduce) {
	.de-otp-modal,
	.de-otp-modal-container,
	.de-otp-input,
	.de-otp-btn,
	.de-otp-spinner,
	.de-otp-icon-success,
	.de-otp-icon-error,
	.de-otp-redirect-bar {
		animation: none !important;
		transition: none !important;
	}
}

/* ===== Dark Mode Support (optional) ===== */
@media (prefers-color-scheme: dark) {
	.de-otp-modal[data-theme="auto"] {
		--de-otp-bg: #1e1e1e;
		--de-otp-text: #ffffff;
		--de-otp-text-secondary: #b0b0b0;
		--de-otp-border: #424242;
		--de-otp-bg-input: #2d2d2d;
		--de-otp-overlay: rgba(0, 0, 0, 0.8);
	}
}

/* ===== Focus Visible (Keyboard Navigation) ===== */
.de-otp-modal :focus:not(:focus-visible) {
	outline: none;
}

.de-otp-modal :focus-visible {
	outline: 2px solid var(--de-otp-primary);
	outline-offset: 2px;
}

/* ===== Loading State Overlay for Buttons ===== */
.de-otp-btn.is-loading {
	position: relative;
	color: transparent !important;
	pointer-events: none;
}

.de-otp-btn.is-loading::after {
	content: "";
	position: absolute;
	top: 50%;
	left: 50%;
	width: 20px;
	height: 20px;
	margin: -10px 0 0 -10px;
	border: 2px solid transparent;
	border-top-color: currentColor;
	border-radius: 50%;
	animation: de-otp-btn-spin 0.8s linear infinite;
}

.de-otp-btn-primary.is-loading::after {
	border-top-color: #ffffff;
}

.de-otp-btn-secondary.is-loading::after {
	border-top-color: var(--de-otp-primary);
}

@keyframes de-otp-btn-spin {
	to {
		transform: rotate(360deg);
	}
}
