/**
 * Toast Notifications Component Styles
 *
 * Styles for toast notification system.
 *
 * @package MphbGuestServices
 * @since 2.0.0
 */

/* ========================================
 * Toast Container
 * ======================================== */

.gs-toast-container {
	position: fixed;
	bottom: calc(var(--gs-space-2xl) + 72px);
	left: 50%;
	transform: translateX(-50%);
	z-index: var(--gs-z-index-toast);
	display: flex;
	flex-direction: column;
	gap: var(--gs-space-md);
	max-width: 500px;
	width: auto;
	pointer-events: none;
}

/* ========================================
 * Toast Base
 * ======================================== */

.gs-toast {
	display: flex;
	align-items: flex-start;
	gap: var(--gs-space-md);
	padding: var(--gs-space-lg) var(--gs-space-xl);
	border-radius: var(--gs-radius-md);
	font-family: var(--gs-font-family);
	pointer-events: auto;
	opacity: 0;
	transform: translateY(100%);
	transition: all var(--gs-duration-base) var(--gs-ease-out);
	min-width: 320px;
	justify-content: center;
}

.gs-toast--show {
	opacity: 1;
	transform: translateY(0);
}

.gs-toast--hide {
	opacity: 0;
	transform: translateY(100%);
}

/* ========================================
 * Toast Icon
 * ======================================== */

.gs-toast__icon {
	flex-shrink: 0;
	width: 20px;
	height: 20px;
	display: flex;
	align-items: center;
	justify-content: center;
}

.gs-toast__icon svg {
	display: block;
	width: 100%;
	height: 100%;
}

/* ========================================
 * Toast Message
 * ======================================== */

.gs-toast__message {
	flex: 1;
	font: var(--gs-font-weight-normal) var(--gs-font-size-base)/var(--gs-line-height-normal);
}

/* ========================================
 * Toast Close Button
 * ======================================== */

.gs-toast__close {
	flex-shrink: 0;
	width: 24px;
	height: 24px;
	padding: 0;
	margin: -4px -4px 0 0;
	display: flex;
	align-items: center;
	justify-content: center;
	background: transparent;
	border: none;
	border-radius: var(--gs-radius-xs);
	cursor: pointer;
	transition: all var(--gs-transition-fast);
}

.gs-toast__close:focus {
	outline: none;
}

.gs-toast__close svg {
	display: block;
	width: 16px;
	height: 16px;
}

/* ========================================
 * Toast Types
 * ======================================== */

/* Success Toast */
.gs-toast--success {
	border-left: 4px solid var(--gs-color-success);
}

.gs-toast--success .gs-toast__icon {
	color: var(--gs-color-success);
}

/* Error Toast */
.gs-toast--error {
	border-left: 4px solid var(--gs-color-error);
}

.gs-toast--error .gs-toast__icon {
	color: var(--gs-color-error);
}

/* Warning Toast */
.gs-toast--warning {
	border-left: 4px solid var(--gs-color-warning-text);
}

.gs-toast--warning .gs-toast__icon {
	color: var(--gs-color-warning-text);
}

/* Info Toast */
.gs-toast--info {
	border-left: 4px solid var(--gs-color-info);
}

.gs-toast--info .gs-toast__icon {
	color: var(--gs-color-info);
}

/* ========================================
 * Responsive
 * ======================================== */

@media (max-width: 768px) {
	.gs-toast-container {
		left: 50%;
	}
}

@media (max-width: 640px) {
	.gs-toast-container {
		bottom: var(--gs-space-lg);
		left: var(--gs-space-lg);
		right: var(--gs-space-lg);
		transform: none;
		max-width: none;
		width: auto;
	}

	.gs-toast {
		padding: var(--gs-space-md) var(--gs-space-lg);
		min-width: 0;
	}
}

/* ========================================
 * Dark Mode Variables
 * ======================================== */

/* --- Toast dark mode variables --- */
/* The container sits outside .mphb-gs-shell, so the shell's dark text token never reaches it. */
@media (prefers-color-scheme: dark) {
	.gs-toast-container[data-theme="auto"] {
		--gs-toast-bg: #20242c;
		--gs-color-warning-text: var(--gs-color-warning);
		--gs-toast-shadow: 0 12px 30px rgba(0, 0, 0, 0.6);
		--gs-toast-msg-color: #e5e7eb;
		--gs-toast-close-color: #9ca3af;
		--gs-toast-close-hover-bg: #292d36;
		--gs-toast-close-hover-color: #e5e7eb;
		--gs-toast-close-focus-shadow: 0 0 0 3px rgba(59, 130, 246, 0.4);
	}
}
.gs-toast-container[data-theme="dark"] {
	--gs-toast-bg: #20242c;
	--gs-color-warning-text: var(--gs-color-warning);
	--gs-toast-shadow: 0 12px 30px rgba(0, 0, 0, 0.6);
	--gs-toast-msg-color: #e5e7eb;
	--gs-toast-close-color: #9ca3af;
	--gs-toast-close-hover-bg: #292d36;
	--gs-toast-close-hover-color: #e5e7eb;
	--gs-toast-close-focus-shadow: 0 0 0 3px rgba(59, 130, 246, 0.4);
}

/* --- Error modal dark mode variables --- */
@media (prefers-color-scheme: dark) {
	.gs-toast-backdrop[data-theme="auto"] {
		--gs-modal-backdrop-bg: rgba(0, 0, 0, 0.7);
		--gs-modal-bg: #1a1d23;
		--gs-modal-shadow: 0 20px 40px rgba(0, 0, 0, 0.8);
		--gs-modal-msg-color: #e5e7eb;
	}
}
.gs-toast-backdrop[data-theme="dark"] {
	--gs-modal-backdrop-bg: rgba(0, 0, 0, 0.7);
	--gs-modal-bg: #1a1d23;
	--gs-modal-shadow: 0 20px 40px rgba(0, 0, 0, 0.8);
	--gs-modal-msg-color: #e5e7eb;
}

/* --- Toast dark mode applied rules (written once) --- */
.gs-toast-container .gs-toast {
	background: var(--gs-toast-bg, var(--gs-color-surface));
	box-shadow: var(--gs-toast-shadow, var(--gs-shadow-lg));
}

.gs-toast-container .gs-toast__message {
	color: var(--gs-toast-msg-color, var(--gs-color-text));
}

.gs-toast-container .gs-toast__close {
	color: var(--gs-toast-close-color, var(--gs-color-text-muted));
}

.gs-toast-container .gs-toast__close:hover {
	background: var(--gs-toast-close-hover-bg, var(--gs-color-surface-hover));
	color: var(--gs-toast-close-hover-color, var(--gs-color-text));
}

.gs-toast-container .gs-toast__close:focus {
	box-shadow: var(--gs-toast-close-focus-shadow, var(--gs-shadow-focus));
}

/* ========================================
 * Error Modal (Centered with backdrop)
 * ======================================== */

.gs-toast-backdrop {
	position: fixed;
	inset: 0;
	z-index: calc(var(--gs-z-index-toast) + 10);
	display: flex;
	align-items: center;
	justify-content: center;
	background: rgba(0, 0, 0, 0);
	backdrop-filter: blur(0);
	transition: background 0.3s ease, backdrop-filter 0.3s ease;
	padding: var(--gs-space-lg);
}

.gs-toast-backdrop--show {
	backdrop-filter: blur(4px);
}

.gs-toast-modal {
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: var(--gs-space-lg);
	padding: var(--gs-space-2xl) var(--gs-space-3xl);
	border-radius: var(--gs-radius-lg);
	max-width: 400px;
	width: 100%;
	text-align: center;
	opacity: 0;
	transform: scale(0.9) translateY(-20px);
	transition: all 0.3s var(--gs-ease-out);
}

.gs-toast-modal--show {
	opacity: 1;
	transform: scale(1) translateY(0);
}

.gs-toast-modal__icon {
	width: 48px;
	height: 48px;
	display: flex;
	align-items: center;
	justify-content: center;
	color: var(--gs-color-error);
}

.gs-toast-modal__icon svg {
	width: 100%;
	height: 100%;
}

.gs-toast-modal__content {
	display: flex;
	flex-direction: column;
	gap: var(--gs-space-sm);
}

.gs-toast-modal__title {
	font-size: var(--gs-font-size-xl);
	font-weight: var(--gs-font-weight-bold);
	color: var(--gs-color-error);
}

.gs-toast-modal__message {
	font-size: var(--gs-font-size-base);
	line-height: var(--gs-line-height-relaxed);
}

.gs-toast-modal__dismiss {
	margin-top: var(--gs-space-md);
	padding: var(--gs-space-md) var(--gs-space-3xl);
	font-size: var(--gs-font-size-base);
	font-weight: var(--gs-font-weight-medium);
	color: #fff;
	background: var(--gs-color-error);
	border: none;
	border-radius: var(--gs-radius-sm);
	cursor: pointer;
	transition: background 0.15s ease, transform 0.15s ease;
}

.gs-toast-modal__dismiss:hover {
	background: #dc2626;
}

.gs-toast-modal__dismiss:focus {
	outline: none;
	box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.3);
}

.gs-toast-modal__dismiss:active {
	transform: scale(0.98);
}

/* Theme override protection – prevent CozyStay from overriding button styles */
.gs-toast-backdrop .gs-toast-modal__dismiss,
.gs-toast-modal__dismiss {
	color: #fff !important;
	background: var(--gs-color-error) !important;
	border: none !important;
	padding: var(--gs-space-md) var(--gs-space-3xl) !important;
}

.gs-toast__close {
	background: transparent !important;
	border: none !important;
}

/* Error modal responsive */
@media (max-width: 480px) {
	.gs-toast-modal {
		padding: var(--gs-space-xl) var(--gs-space-2xl);
	}

	.gs-toast-modal__icon {
		width: 40px;
		height: 40px;
	}

	.gs-toast-modal__title {
		font-size: var(--gs-font-size-lg);
	}
}

/* --- Error modal dark mode applied rules (written once) --- */
.gs-toast-backdrop--show {
	background: var(--gs-modal-backdrop-bg, rgba(0, 0, 0, 0.5));
}

.gs-toast-backdrop .gs-toast-modal {
	background: var(--gs-modal-bg, var(--gs-color-surface));
	box-shadow: var(--gs-modal-shadow, var(--gs-shadow-xl));
}

.gs-toast-backdrop .gs-toast-modal__message {
	color: var(--gs-modal-msg-color, var(--gs-color-text));
}
