/* Shared modal styling */
.modal-overlay {
	position: fixed;
	inset: 0;
	display: none;
	align-items: center;
	justify-content: center;
	padding: 1.5rem;
	background: rgba(15, 23, 42, 0.55);
	backdrop-filter: blur(6px);
	z-index: 15000 !important; /* Must be higher than immunization form overlay (9999) */
}

.modal-overlay.is-visible {
	display: flex;
}

.modal-card {
	width: min(420px, 95%);
	background: var(--background-white, #fff);
	border-radius: 20px;
	padding: 2.4rem 2.2rem 2rem;
	box-shadow: 0 30px 70px rgba(15, 23, 42, 0.18);
	text-align: center;
	font-family: "Poppins", system-ui, sans-serif;
	border: 1px solid rgba(148, 163, 184, 0.25);
	position: relative;
	overflow: hidden;
}

.modal-card::after {
	content: "";
	position: absolute;
	inset: -40% 10% auto;
	height: 220px;
	background: radial-gradient(
		circle at center,
		rgba(37, 99, 235, 0.15),
		transparent 60%
	);
	z-index: 0;
}

.modal-card > * {
	position: relative;
	z-index: 1;
}

.modal-card .modal-icon {
	width: 64px;
	height: 64px;
	border-radius: 50%;
	display: flex;
	align-items: center;
	justify-content: center;
	margin: 0 auto 1.2rem;
	background: linear-gradient(135deg, #22c55e, #16a34a);
	color: #fff;
	box-shadow: 0 12px 30px rgba(34, 197, 94, 0.4);
}

/* Modal icon variants */
.modal-icon.success {
	background: linear-gradient(135deg, #22c55e, #16a34a);
	box-shadow: 0 12px 30px rgba(34, 197, 94, 0.4);
}

.modal-icon.error {
	background: linear-gradient(135deg, #dc2626, #b91c1c);
	box-shadow: 0 12px 30px rgba(220, 38, 38, 0.4);
}

.modal-icon.warning {
	background: linear-gradient(135deg, #f59e0b, #d97706);
	box-shadow: 0 12px 30px rgba(245, 158, 11, 0.4);
}

.modal-icon.info {
	background: linear-gradient(135deg, #3b82f6, #2563eb);
	box-shadow: 0 12px 30px rgba(59, 130, 246, 0.4);
}

.modal-card h3 {
	font-size: 1.8rem;
	margin-bottom: 0.4rem;
	color: #111827;
}

.modal-card p {
	color: #475569;
	font-size: 1.3rem;
	margin-bottom: 1.2rem;
}

.modal-summary {
	background: rgba(241, 245, 249, 0.85);
	border-radius: 14px;
	padding: 1.4rem;
	margin-bottom: 1.4rem;
	font-size: 1.3rem;
	color: #1f2937;
	border: 1px solid rgba(148, 163, 184, 0.25);
}

.modal-summary.centered {
	text-align: center;
	background: rgba(241, 245, 249, 0.9);
	box-shadow: none;
}

.modal-summary .family-code-label {
	font-size: 1.3rem;
	letter-spacing: 0.08em;
	text-transform: uppercase;
	color: #64748b;
	margin-bottom: 0.4rem;
}

.modal-summary .family-code-value {
	font-size: clamp(2.4rem, 4vw, 2.8rem);
	font-weight: 700;
	color: #0f172a;
	letter-spacing: 0.08em;
	margin: 0;
	background: linear-gradient(120deg, #1d4ed8, #22d3ee);
	background-clip: text;
	-webkit-background-clip: text;
	color: transparent;
}

.modal-summary strong {
	color: #0f172a;
}

.modal-summary .share-link {
	display: block;
	margin-top: 0.3rem;
	word-break: break-all;
	font-weight: 600;
	color: #0f172a;
}

.modal-field-group {
	margin-bottom: 1rem;
	text-align: left;
}

.modal-field-group label {
	display: block;
	font-size: 1.2rem;
	color: #475569;
	margin-bottom: 0.4rem;
}

.modal-input {
	width: 100%;
	padding: 0.9rem 1rem;
	border-radius: 10px;
	border: 1px solid rgba(148, 163, 184, 0.6);
	font-size: 1.4rem;
	font-family: inherit;
}

.modal-input:focus {
	outline: 2px solid var(--primary-color, #2563eb);
	border-color: transparent;
}

.modal-hint {
	font-size: 1.2rem;
	color: #475569;
	margin: 0.5rem 0 0;
}

.modal-hint.is-error {
	color: #dc2626;
}

.modal-otp-input {
	width: 100%;
	text-align: center;
	letter-spacing: 0.3rem;
	font-size: 2rem;
	padding: 1rem;
	border-radius: 12px;
	border: 1px solid rgba(148, 163, 184, 0.6);
	font-family: inherit;
}

.modal-otp-helper {
	margin-top: 0.6rem;
	font-size: 1.2rem;
	color: #475569;
}

.modal-otp-helper.is-error {
	color: #dc2626;
}

.modal-otp-timer {
	margin-top: 0.8rem;
	font-size: 1.2rem;
	color: #475569;
}

.modal-actions {
	display: flex;
	gap: 1rem;
	flex-wrap: wrap;
	justify-content: center;
}

.modal-actions.align-end {
	justify-content: flex-end;
}

.modal-btn {
	display: flex;
	justify-content: center;
	flex: 1;
	min-width: 150px;
	padding: 0.95rem 1.6rem;
	border-radius: 999px;
	border: none;
	font-size: 1.4rem;
	font-weight: 600;
	cursor: pointer;
	transition: transform 120ms ease, box-shadow 160ms ease;
}

.modal-btn.primary {
	background: var(--primary-color, #2563eb);
	color: #fff;
	box-shadow: 0 15px 30px rgba(37, 99, 235, 0.4);
}

.modal-btn.secondary {
	background: #e0e7ff;
	color: #1d4ed8;
}

.modal-btn.small {
	flex: 0;
	min-width: 140px;
	padding-inline: 1.4rem;
}

.modal-btn:active {
	transform: scale(0.98);
}

.modal-close {
	position: absolute;
	top: 16px;
	right: 16px;
	background: none;
	border: none;
	color: #9ca3af;
	cursor: pointer;
	padding: 6px;
	border-radius: 999px;
	transition: background 120ms ease;
}

.modal-close:hover {
	background: rgba(148, 163, 184, 0.15);
	color: #475569;
}

/* --- Slide-in modal variant --- */
.modal-overlay.slide-in {
	justify-content: flex-end;
	align-items: flex-start;
	padding: 2rem;
}

.modal-card.slide-panel {
	width: min(380px, 100%);
	text-align: left;
	transform: translateX(16px);
	opacity: 0;
	transition: transform 220ms ease, opacity 220ms ease;
}

.modal-overlay.slide-in.is-visible .modal-card.slide-panel {
	transform: translateX(0);
	opacity: 1;
}

.modal-card.slide-panel .modal-icon {
	margin-left: 0;
	margin-right: 0;
}

.modal-card.slide-panel .modal-summary.centered {
	text-align: left;
}

/* Toast notifications */
.toast-container {
	position: fixed;
	bottom: 24px;
	right: 24px;
	display: flex;
	flex-direction: column;
	gap: 12px;
	z-index: 11000; /* Higher than modals to appear on top of everything */
}

.toast {
	width: 400px;
	background: var(--background-white, #fff);
	color: #0f172a;
	border-radius: 18px;
	padding: 1.8rem 1.8rem;
	box-shadow: 0 18px 40px rgba(15, 23, 42, 0.18);
	transform: translateX(24px);
	opacity: 0;
	transition: transform 220ms ease, opacity 220ms ease;
	border: 1px solid rgba(148, 163, 184, 0.35);
}

.toast.is-visible {
	transform: translateX(0);
	opacity: 1;
}

.toast-header {
	display: flex;
	align-items: center;
	gap: 0.8rem;
	margin-bottom: 0.4rem;
	justify-content: space-between;
}

.toast-title-row {
	display: flex;
	align-items: center;
	gap: 0.6rem;
}

.toast-header .material-symbols-rounded {
	font-size: 1.6rem;
	color: var(--primary-color, #2563eb);
}

.toast-title {
	font-size: 1.35rem;
	font-weight: 600;
	margin: 0;
	flex: 1;
}

.toast-body {
	font-size: 1.25rem;
	margin: 0;
	color: #475569;
}

.toast-close {
	background: none;
	border: none;
	color: #94a3b8;
	cursor: pointer;
	padding: 4px;
	border-radius: 999px;
	transition: background 120ms ease, color 120ms ease;
}

.toast-close:hover {
	background: rgba(148, 163, 184, 0.2);
	color: #475569;
}

.toast.toast-success .toast-header .material-symbols-rounded {
	color: #16a34a;
}
.toast.toast-error .toast-header .material-symbols-rounded {
	color: #dc2626;
}
.toast.toast-warning .toast-header .material-symbols-rounded {
	color: #d97706;
}

.modal-card.modal-loading .modal-title,
.modal-card.modal-loading .modal-message {
	margin-bottom: 1rem;
}

.modal-spinner {
	width: 48px;
	height: 48px;
	border-radius: 50%;
	border: 4px solid rgba(148, 163, 184, 0.3);
	border-top-color: var(--primary-color, #2563eb);
	margin: 0 auto;
	animation: modal-spin 0.8s linear infinite;
}

@keyframes modal-spin {
	to {
		transform: rotate(360deg);
	}
}

/* =========================
   Responsive Styles
   ========================= */

/* =========================
   Mobile (≤ 30rem / 480px)
   ========================= */
@media (max-width: 30rem) {
	/* =========================
	   Modal Overlay
	   ========================= */
	.modal-overlay {
		padding: 0;
		align-items: flex-end;
		justify-content: center;
	}

	.modal-overlay.is-visible {
		display: flex;
	}

	/* =========================
	   Modal Card
	   ========================= */
	.modal-card {
		width: 100%;
		max-width: 100%;
		border-radius: 20px 20px 0 0;
		padding: 1.8rem 1.5rem 1.5rem;
		margin: 0;
		max-height: 90vh;
		overflow-y: auto;
		transform: translateY(100%);
		animation: modalSlideUpMobile 0.25s ease forwards;
	}

	@keyframes modalSlideUpMobile {
		0% {
			opacity: 0;
			transform: translateY(100%);
		}
		100% {
			opacity: 1;
			transform: translateY(0);
		}
	}

	.modal-overlay.is-visible .modal-card {
		transform: translateY(0);
	}

	.modal-card h3 {
		font-size: 1.5rem;
		margin-bottom: 0.3rem;
	}

	.modal-card p {
		font-size: 1.2rem;
		margin-bottom: 1rem;
	}

	/* =========================
	   Modal Icon
	   ========================= */
	.modal-card .modal-icon {
		width: 56px;
		height: 56px;
		margin: 0 auto 1rem;
	}

	.modal-card .modal-icon .material-symbols-rounded {
		font-size: 2.4rem;
	}

	/* =========================
	   Modal Summary
	   ========================= */
	.modal-summary {
		padding: 1.2rem;
		margin-bottom: 1.2rem;
		font-size: 1.2rem;
		border-radius: 12px;
	}

	.modal-summary .family-code-label {
		font-size: 1.1rem;
		margin-bottom: 0.3rem;
	}

	.modal-summary .family-code-value {
		font-size: clamp(1.8rem, 5vw, 2.2rem);
	}

	.modal-summary .share-link {
		font-size: 1.1rem;
		word-break: break-all;
	}

	/* =========================
	   Modal Inputs
	   ========================= */
	.modal-field-group {
		margin-bottom: 1.2rem;
	}

	.modal-field-group label {
		font-size: 1.1rem;
		margin-bottom: 0.4rem;
	}

	.modal-input {
		padding: 0.8rem;
		font-size: 1.3rem;
		border-radius: 8px;
	}

	.modal-otp-input {
		font-size: 1.6rem;
		padding: 0.9rem;
		letter-spacing: 0.2rem;
	}

	.modal-hint,
	.modal-otp-helper,
	.modal-otp-timer {
		font-size: 1.1rem;
	}

	/* =========================
	   Modal Actions
	   ========================= */
	.modal-actions {
		flex-direction: column;
		gap: 0.8rem;
		width: 100%;
		margin-top: 0.5rem;
	}

	.modal-actions.align-end {
		justify-content: stretch;
	}

	.modal-btn {
		width: 100%;
		min-width: 100%;
		padding: 1rem 1.4rem;
		font-size: 1.3rem;
		border-radius: 12px;
		min-height: 48px;
		display: flex;
		align-items: center;
		justify-content: center;
		font-weight: 600;
	}

	.modal-btn.small {
		width: 100%;
		min-width: 100%;
	}

	/* Ensure logout modal buttons are touch-friendly */
	.modal-btn.primary,
	.modal-btn.secondary,
	.modal-btn.danger {
		min-height: 48px;
	}

	/* =========================
	   Modal Close Button
	   ========================= */
	.modal-close {
		top: 12px;
		right: 12px;
		padding: 8px;
		width: 36px;
		height: 36px;
		display: flex;
		align-items: center;
		justify-content: center;
	}

	.modal-close .material-symbols-rounded {
		font-size: 2rem;
	}

	/* =========================
	   Slide-in Modal
	   ========================= */
	.modal-overlay.slide-in {
		padding: 0;
		align-items: flex-end;
	}

	.modal-card.slide-panel {
		width: 100%;
		max-width: 100%;
		border-radius: 20px 20px 0 0;
	}

	/* =========================
	   Toast Container
	   ========================= */
	.toast-container {
		bottom: 16px;
		right: 16px;
		left: 16px;
		gap: 10px;
		flex-direction: column;
		align-items: stretch;
	}

	/* =========================
	   Toast
	   ========================= */
	.toast {
		width: 100%;
		max-width: 100%;
		padding: 1.4rem 1.4rem;
		border-radius: 14px;
		transform: translateY(20px);
		box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
		min-height: auto;
	}

	.toast.is-visible {
		transform: translateY(0);
		animation: toastSlideUp 0.3s ease forwards;
	}

	@keyframes toastSlideUp {
		0% {
			opacity: 0;
			transform: translateY(20px);
		}
		100% {
			opacity: 1;
			transform: translateY(0);
		}
	}

	.toast-header {
		gap: 0.6rem;
		margin-bottom: 0.3rem;
		flex-wrap: wrap;
	}

	.toast-title-row {
		flex: 1;
		min-width: 0;
	}

	.toast-header .material-symbols-rounded {
		font-size: 1.6rem;
		width: 24px;
		height: 24px;
		flex-shrink: 0;
	}

	.toast-title {
		font-size: 1.2rem;
		font-weight: 600;
		word-break: break-word;
	}

	.toast-body {
		font-size: 1.15rem;
		line-height: 1.5;
		word-break: break-word;
	}

	.toast-close {
		padding: 8px;
		min-width: 36px;
		min-height: 36px;
		display: flex;
		align-items: center;
		justify-content: center;
		flex-shrink: 0;
	}

	.toast-close .material-symbols-rounded {
		font-size: 1.8rem;
	}

	/* Toast icon sizing */
	.toast-header .material-symbols-rounded {
		font-size: 1.6rem;
		width: 24px;
		height: 24px;
		flex-shrink: 0;
	}

	/* =========================
	   Modal Spinner
	   ========================= */
	.modal-spinner {
		width: 40px;
		height: 40px;
		border-width: 3px;
	}
}

/* =========================
   Tablet (30.0625rem - 48rem / 481px - 768px)
   ========================= */
@media (min-width: 30.0625rem) and (max-width: 48rem) {
	/* =========================
	   Modal Overlay
	   ========================= */
	.modal-overlay {
		padding: 1.2rem;
	}

	/* =========================
	   Modal Card
	   ========================= */
	.modal-card {
		width: min(380px, 90%);
		padding: 2rem 1.8rem 1.8rem;
	}

	.modal-card h3 {
		font-size: 1.65rem;
	}

	.modal-card p {
		font-size: 1.25rem;
	}

	/* =========================
	   Modal Icon
	   ========================= */
	.modal-card .modal-icon {
		width: 60px;
		height: 60px;
	}

	/* =========================
	   Modal Summary
	   ========================= */
	.modal-summary {
		padding: 1.3rem;
		font-size: 1.25rem;
	}

	.modal-summary .family-code-value {
		font-size: clamp(2.2rem, 4vw, 2.6rem);
	}

	/* =========================
	   Modal Inputs
	   ========================= */
	.modal-input {
		font-size: 1.35rem;
		padding: 0.85rem 0.95rem;
	}

	.modal-otp-input {
		font-size: 1.8rem;
	}

	/* =========================
	   Modal Actions
	   ========================= */
	.modal-actions {
		gap: 0.9rem;
	}

	.modal-btn {
		padding: 0.9rem 1.5rem;
		font-size: 1.35rem;
		min-width: 140px;
	}

	/* =========================
	   Toast Container
	   ========================= */
	.toast-container {
		bottom: 20px;
		right: 20px;
		left: auto;
		gap: 12px;
		flex-direction: column;
		align-items: flex-end;
		max-width: 400px;
	}

	/* =========================
	   Toast
	   ========================= */
	.toast {
		width: 360px;
		max-width: calc(100vw - 40px);
		padding: 1.6rem 1.6rem;
	}

	.toast-title {
		font-size: 1.3rem;
	}

	.toast-body {
		font-size: 1.2rem;
	}

	.toast-header .material-symbols-rounded {
		font-size: 1.5rem;
	}
}

/* =========================
   Desktop (≥ 48.0625rem / 769px)
   ========================= */
@media (min-width: 48.0625rem) {
	/* Desktop styles are already defined above */
	/* This media query ensures proper scaling */
}
