/* css/ui.css */
/* Design tokens */
:root {
	--ui-radius: 12px;
	--ui-gap: 10px;
	--ui-z: 999999999;
	--ui-bg: #222;
	--ui-fg: #fff;
	--ui-shadow: 0 12px 32px rgba(0, 0, 0, 0.28);
	--ui-success: #2e7d32;
	--ui-error: #b00020;
	--ui-info: #333;
	--ui-warning: #b26a00;
	--ui-border: rgba(255, 255, 255, 0.08);
}

/* Toasts */
#toast-root {
	position: fixed;
	right: 20px;
	bottom: 20px;
	z-index: var(--ui-z);
	display: flex;
	flex-direction: column;
	gap: var(--ui-gap);
	pointer-events: none;
}

/* Responsive toasts for smaller screens */
@media (max-width: 550px) {
	#toast-root {
		left: 50%;
		right: auto;
		bottom: 15px;
		transform: translateX(-50%);
		width: calc(100vw - 24px);
		max-width: 420px;
		align-items: center;
	}
}

.ui-toast {
	pointer-events: auto;
	color: var(--ui-fg);
	background: var(--ui-bg);
	border-radius: var(--ui-radius);
	padding: 18px 22px;
	box-shadow: var(--ui-shadow);
	max-width: 480px;
	min-width: 360px;
	font: 16px/1.5 system-ui, -apple-system, Segoe UI, Roboto, Arial;
	display: flex;
	align-items: center;
	gap: 16px;
	border: 1px solid var(--ui-border);
	animation: ui-toast-enter 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
	transform-origin: bottom right;
	-webkit-backdrop-filter: blur(8px);
	backdrop-filter: blur(8px);
}

/* Responsive toast-adjustments */
@media (max-width: 550px) {
	.ui-toast {
		max-width: 100%;
		min-width: auto;
		width: 100%;
		padding: 14px 18px;
		font-size: 15px;
		gap: 14px;
		transform-origin: bottom center;
		animation: ui-toast-enter-mobile 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
	}

	.ui-toast.ui-toast--removing {
		animation: ui-toast-exit-mobile 0.4s cubic-bezier(0.4, 0, 0.2, 1) forwards;
	}
}

.ui-toast.ui-toast--removing {
	animation: ui-toast-exit 0.4s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

.ui-toast__icon {
	line-height: 1;
	opacity: 0.95;
	display: flex;
	align-items: center;
	justify-content: center;
	font-size: 18px;
	flex-shrink: 0;
	animation: ui-icon-bounce 0.6s cubic-bezier(0.68, -0.55, 0.265, 1.55) 0.1s both;
}

@media (max-width: 550px) {
	.ui-toast__icon {
		font-size: 16px;
	}
}

.ui-toast__msg {
	flex: 1;
	line-height: 1.5;
	font-weight: 500;
}

.ui-toast__close {
	border: 0;
	background: transparent;
	color: #fff;
	opacity: 0.7;
	cursor: pointer;
	font-size: 20px;
	padding: 4px 6px;
	display: flex;
	align-items: center;
	justify-content: center;
	flex-shrink: 0;
	border-radius: 6px;
	transition: all 0.2s ease;
}

@media (max-width: 550px) {
	.ui-toast__close {
		font-size: 18px;
		padding: 3px 5px;
	}
}

.ui-toast__close:hover {
	opacity: 1;
	background: rgba(255, 255, 255, 0.1);
	transform: scale(1.1);
}

.ui-toast--success {
	background: var(--ui-success);
	border-left: 4px solid #4caf50;
}

.ui-toast--error {
	background: var(--ui-error);
	border-left: 4px solid #f44336;
}

.ui-toast--info {
	background: var(--ui-info);
	border-left: 4px solid #2196f3;
}

.ui-toast--warning {
	background: var(--ui-warning);
	border-left: 4px solid #ff9800;
}

/* Toast animations */
@keyframes ui-toast-enter {
	0% {
		opacity: 0;
		transform: translateX(100%) scale(0.8);
	}

	60% {
		transform: translateX(-8px) scale(1.02);
	}

	100% {
		opacity: 1;
		transform: translateX(0) scale(1);
	}
}

@keyframes ui-toast-exit {
	0% {
		opacity: 1;
		transform: translateX(0) scale(1);
		max-height: 100px;
		margin-bottom: var(--ui-gap);
	}

	30% {
		opacity: 0.8;
		transform: translateX(8px) scale(0.98);
	}

	70% {
		opacity: 0.3;
		transform: translateX(50px) scale(0.9);
		max-height: 80px;
	}

	100% {
		opacity: 0;
		transform: translateX(100%) scale(0.8);
		max-height: 0;
		margin-bottom: 0;
		padding-top: 0;
		padding-bottom: 0;
	}
}

@keyframes ui-icon-bounce {
	0% {
		transform: scale(0.3) rotate(-10deg);
		opacity: 0;
	}

	50% {
		transform: scale(1.1) rotate(5deg);
	}

	100% {
		transform: scale(1) rotate(0deg);
		opacity: 0.95;
	}
}

/* Confirm modal */
.ui-modal-overlay {
	position: fixed;
	inset: 0;
	background: rgba(0, 0, 0, 0.35);
	display: flex;
	align-items: center;
	justify-content: center;
	z-index: var(--ui-z);
	z-index: 2147483648;
}

.ui-modal {
	background: #fff;
	color: #111;
	width: min(520px, calc(100vw - 32px));
	border-radius: var(--ui-radius);
	box-shadow: var(--ui-shadow);
	border: 1px solid #e7e7e7;
	padding: 18px;
}

.ui-modal__title {
	margin: 0 0 6px;
	font: 600 18px/1.3 system-ui, -apple-system;
}

.ui-modal__body {
	font: 14px/1.5 system-ui, -apple-system;
	color: #333;
}

.ui-modal__footer {
	display: flex;
	gap: 10px;
	justify-content: flex-end;
	margin-top: 16px;
}

/* Buttons */
.ui-btn {
	border: 1px solid #d0d0d0;
	background: #fff;
	color: #111;
	padding: 8px 12px;
	border-radius: 10px;
	cursor: pointer;
	font: 14px system-ui, -apple-system;
}

.ui-btn:hover {
	background: #eaeaea;
	color: var(--black);
}

.ui-btn--primary {
	background: var(--CBlue);
	color: #fff;
	border: 1px solid var(--CBlue);
}

.ui-btn--danger {
	background: #d32f2f;
	border-color: #d32f2f;
	color: #fff;
}

.ui-btn--danger:hover {
	background: #ff5c5c;
	border-color: #b71c1c;
}

.ui-btn[disabled] {
	opacity: 0.65;
	cursor: not-allowed;
}

.ui-btn__loading {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 0.5rem;
	white-space: nowrap;
	max-width: 100%;
}

.ui-btn__loading>span:last-child {
	overflow: hidden;
	text-overflow: ellipsis;
}

.ui-spinner {
	display: block;
	flex: 0 0 auto;
	animation: ui-spin 0.8s linear infinite;
	transform-origin: center;
	will-change: transform;
}

@keyframes ui-spin {
	from {
		transform: rotate(0deg);
	}

	to {
		transform: rotate(360deg);
	}
}

.btn.ui-btn--success-flash,
a.btn.ui-btn--success-flash {
	background: #2e7d32 !important;
	color: #fff !important;
	box-shadow: 0 0 0 0 rgba(46, 125, 50, 0.35);
	animation: ui-btn-success-pop 0.45s ease;
	transform: none;
}

.btn.ui-btn--success-flash:hover,
a.btn.ui-btn--success-flash:hover {
	background: #2e7d32 !important;
	color: #fff !important;
	box-shadow: 0 0 0 0 rgba(46, 125, 50, 0.35);
	transform: none;
}

@keyframes ui-btn-success-pop {
	0% {
		transform: scale(1);
		box-shadow: 0 0 0 0 rgba(46, 125, 50, 0.35);
	}

	40% {
		transform: scale(1.03);
		box-shadow: 0 0 0 8px rgba(46, 125, 50, 0.12);
	}

	100% {
		transform: scale(1);
		box-shadow: 0 0 0 0 rgba(46, 125, 50, 0);
	}
}

/* Print: visa inte overlays/toasts */
@media print {

	.ui-modal-overlay,
	#toast-root {
		display: none !important;
	}
}

/* Protocol status celebration animation */
.status--celebrating {
	animation: celebrate 1.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
	transform-origin: center;
}

.status--celebrating .badge {
	animation: badge-pulse-enhanced 2.2s ease-in-out;
	transform-origin: center;
}

@keyframes celebrate {
	0% {
		transform: scale(1) translateY(0);
	}

	15% {
		transform: scale(1.08) translateY(-4px);
	}

	30% {
		transform: scale(1.02) translateY(-2px);
	}

	45% {
		transform: scale(1.05) translateY(-3px);
	}

	60% {
		transform: scale(1.01) translateY(-1px);
	}

	75% {
		transform: scale(1.03) translateY(-2px);
	}

	90% {
		transform: scale(1.005) translateY(-0.5px);
	}

	100% {
		transform: scale(1) translateY(0);
	}
}

@keyframes badge-pulse-enhanced {

	0%,
	100% {
		box-shadow: 0 0 0 0 rgba(76, 175, 80, 0.5), 0 0 0 0 rgba(76, 175, 80, 0.3);
		transform: scale(1);
	}

	25% {
		box-shadow: 0 0 0 6px rgba(76, 175, 80, 0.2), 0 0 0 12px rgba(76, 175, 80, 0.1);
		transform: scale(1.02);
	}

	50% {
		box-shadow: 0 0 0 10px rgba(76, 175, 80, 0), 0 0 0 20px rgba(76, 175, 80, 0);
		transform: scale(1.04);
	}

	75% {
		box-shadow: 0 0 0 6px rgba(76, 175, 80, 0.1), 0 0 0 12px rgba(76, 175, 80, 0.05);
		transform: scale(1.01);
	}
}

/* Smooth scroll behavior */
html {
	scroll-behavior: smooth;
}

/* Entity picker */
.entity-picker {
	display: flex;
	flex-direction: column;
	gap: 0.75rem;
}

.entity-picker__status {
	font-size: 0.9rem;
	color: #666;
}

.entity-picker__selected {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 0.5rem;
	padding: 0.75rem;
	border: 1px solid #e5e7eb;
	border-radius: 12px;
	background: #fafafa;
	min-height: 56px;
}

.entity-picker__results {
	display: flex;
	flex-direction: column;
	gap: 0.35rem;
	max-height: 220px;
	overflow: auto;
}

.entity-picker__result {
	display: flex;
	align-items: center;
	justify-content: space-between;
	width: 100%;
	padding: 0.75rem 0.9rem;
	border: 1px solid #e5e7eb;
	border-radius: 10px;
	background: #fff;
	cursor: pointer;
	text-align: left;
	transition: background 0.15s ease, border-color 0.15s ease;
}

.entity-picker__result:hover {
	background: #f7f9fc;
	border-color: #cfd8e3;
}

.entity-picker__chip {
	display: inline-flex;
	align-items: center;
	gap: 0.5rem;
	padding: 0.5rem 0.75rem;
	border-radius: 999px;
	background: #eaf2ff;
	border: 1px solid #c9dcff;
	max-width: 100%;
}

.entity-picker__chip-label {
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
	font-size: 0.777rem;
}

.entity-picker__chip-remove {
	border: 0;
	background: transparent;
	cursor: pointer;
	font-size: 0.777rem;
	line-height: 1;
	padding: 0;
}

.entity-picker__empty {
	font-size: 0.87rem;
	color: #666;
}

.entity-picker__result-label {
	font-size: 0.877rem;
}

.input-help-text {
	margin-top: 0.35rem;
	font-size: 0.87rem;
	color: #666;
}
