/* ─────────────── MODAL ─────────────── */

#ac-modal-root {
	position: fixed;
	inset: 0;
	z-index: 1000;
	pointer-events: none;
}

.ac-modal {
	position: absolute;
	inset: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	pointer-events: auto;
	padding: var(--space-4);
}

/* ── Backdrop ── */
.ac-modal__backdrop {
	position: absolute;
	inset: 0;
	background: rgba(0, 0, 0, 0);
	backdrop-filter: blur(0);
	transition:
		background 0.2s ease,
		backdrop-filter 0.2s ease;
}

.ac-modal.is-open .ac-modal__backdrop {
	background: rgba(0, 0, 0, 0.4);
	backdrop-filter: blur(2px);
}

.ac-modal.is-closing .ac-modal__backdrop {
	background: rgba(0, 0, 0, 0);
	backdrop-filter: blur(0);
}

/* ── Dialog ── */
.ac-modal__dialog {
	position: relative;
	background: var(--ac-white);
	border-radius: var(--radius-lg);
	z-index: 1;
	width: 100%;
	max-height: calc(100vh - var(--space-8));
	display: flex;
	flex-direction: column;
	box-shadow:
		0 20px 25px -5px rgba(0, 0, 0, 0.1),
		0 8px 10px -6px rgba(0, 0, 0, 0.1);

	/* Entry animation */
	opacity: 0;
	transform: translateY(8px) scale(0.98);
	transition:
		opacity 0.2s ease,
		transform 0.2s ease;
	padding: var(--space-6);

	/* Size presets */
	&--sm {
		max-width: 380px;
	}
	&--md {
		max-width: 480px;
	}
	&--lg {
		max-width: 640px;
	}
	&--xl {
		max-width: 800px;
	}
	&--full {
		max-width: calc(100vw - var(--space-8));
		max-height: calc(100vh - var(--space-8));
	}
}

.ac-modal.is-open .ac-modal__dialog {
	opacity: 1;
	transform: translateY(0) scale(1);
}

.ac-modal.is-closing .ac-modal__dialog {
	opacity: 0;
	transform: translateY(4px) scale(0.98);
	transition:
		opacity 0.15s ease,
		transform 0.15s ease;
}

/* ── Header ── */
.ac-modal__header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	flex-shrink: 0;
	margin-bottom: 1.1em;
}

.ac-modal__title {
	font-size: 15px;
	font-weight: var(--weight-medium);
	color: var(--ac-text);
	margin: 0;
	line-height: 1.3;
}

.ac-modal__close {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 28px;
	height: 28px;
	border: none;
	background: none;
	border-radius: var(--radius-md);
	color: var(--ac-text-hint);
	cursor: pointer;
	flex-shrink: 0;
	transition:
		background 0.12s,
		color 0.12s;

	&:hover {
		background: var(--ac-bg);
		color: var(--ac-text);
	}
}

/* ── Body ── */
.ac-modal__body {
	overflow-y: auto;
	flex: 1;
	overscroll-behavior: contain;

	* {
		box-sizing: border-box;
	}
}

/* ── Responsive ── */
@media (max-width: 520px) {
	.ac-modal {
		align-items: flex-end;
		padding: 0;
	}

	.ac-modal__dialog {
		max-width: 100%;
		border-radius: var(--radius-lg) var(--radius-lg) 0 0;
		max-height: 90vh;
		transform: translateY(100%);
	}

	.ac-modal.is-open .ac-modal__dialog {
		transform: translateY(0);
	}

	.ac-modal.is-closing .ac-modal__dialog {
		transform: translateY(100%);
	}
}
