/* ============================================
   МОДАЛЬНЫЕ ОКНА - ОБНОВЛЕННЫЙ ДИЗАЙН
   ============================================ */

.modal {
	display: none;
	position: fixed;
	inset: 0;
	z-index: 9999;
	width: 100%;
	min-height: 100vh;
	min-height: 100dvh;
	overflow-y: auto;
	-webkit-overflow-scrolling: touch;
	box-sizing: border-box;
	/* Контекст наложения: оверлей не уходит под страницу из-за z-index: -1 */
	isolation: isolate;
}

.modal.show {
	display: flex;
	align-items: flex-start;
	justify-content: center;
	padding: 20px;
	animation: modalFadeIn 0.3s ease-out;
}

.modal__overlay {
	position: absolute;
	inset: 0;
	z-index: 0;
	background: rgba(15, 15, 30, 0.75);
	backdrop-filter: blur(4px);
	-webkit-backdrop-filter: blur(4px);
	pointer-events: auto;
}

.modal__content {
	position: relative;
	z-index: 1;
	display: flex;
	flex-direction: column;
	width: 100%;
	max-width: 500px;
	max-height: calc(100vh - 40px);
	max-height: calc(100dvh - 40px);
	margin: auto;
	background: var(--white-color);
	border-radius: 24px;
	box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
	overflow: hidden;
	animation: modalSlideIn 0.3s ease-out;
	transform-origin: center;
	box-sizing: border-box;
	min-height: 0;
}

.modal.show .modal__content {
	animation: modalSlideIn 0.3s ease-out;
}

/* Размеры модалок */
.modal--small .modal__content {
	max-width: 500px;
}

.modal--medium .modal__content {
	max-width: 800px;
}

.modal--large .modal__content {
	max-width: 1000px;
}

.modal--fullscreen .modal__content {
	max-width: 95%;
	max-height: 95vh;
	border-radius: 16px;
}

/* Кнопка закрытия */
.modal__action-close {
	position: absolute;
	top: 16px;
	right: 16px;
	z-index: 10;
	display: flex;
	align-items: center;
	justify-content: center;
	width: 40px;
	height: 40px;
	padding: 0;
	border: none;
	background: var(--bg-color);
	border-radius: 50%;
	cursor: pointer;
	transition: all 0.2s ease;
	color: var(--gray-color);
}

.modal__action-close:hover {
	color: var(--main-color);
	transform: rotate(90deg);
}

.modal__action-close svg {
	width: 20px;
	height: 20px;
}

/* Заголовок модалки */
.modal__header {
	padding: 24px;
	border-bottom: 1px solid rgba(0, 0, 0, 0.08);
	flex-shrink: 0;
}

.modal__title {
	font-size: clamp(1.5rem, 2vw, 1.75rem);
	font-weight: 500;
	line-height: 1.3;
	color: var(--main-color);
}

.modal__subtitle {
	font-size: 0.9375rem;
	font-weight: 400;
	line-height: 1.5;
	color: var(--gray-color);
	margin: 0;
}

/* Тело модалки */
.modal__body {
	padding: 24px;
	flex: 1 1 auto;
	/* Иначе flex-элемент не сжимается ниже высоты контента — футер уезжает за экран */
	min-height: 0;
	overflow-y: auto;
	-webkit-overflow-scrolling: touch;
}

.modal__body::-webkit-scrollbar {
	width: 6px;
}

.modal__body::-webkit-scrollbar-track {
	background: transparent;
}

.modal__body::-webkit-scrollbar-thumb {
	background: rgba(0, 0, 0, 0.2);
	border-radius: 3px;
}

.modal__body::-webkit-scrollbar-thumb:hover {
	background: rgba(0, 0, 0, 0.3);
}

/* Футер модалки */
.modal__footer {
	padding: 24px;
	border-top: 1px solid rgba(0, 0, 0, 0.08);
	flex-shrink: 0;
	display: flex;
	align-items: center;
	justify-content: flex-end;
	gap: 12px;
}

/* Модификаторы на самом .modal__footer */
.modal__footer.modal__footer--center {
	justify-content: center;
}

.modal__footer.modal__footer--space-between {
	justify-content: space-between;
}

/* Группа кнопок во футере (часто вне <form>, класс .form-actions) */
.modal__footer .form-actions {
	display: flex;
	flex-direction: row;
	align-items: center;
	justify-content: flex-end;
	flex-wrap: wrap;
	gap: 12px;
	width: 100%;
}

/*
 * Обёртка с центрированием (например modal-create-task: кнопка внутри .modal__footer--center).
 * Раньше у класса был только justify-content без display — внутри .modal__footer не работало.
 */
.modal__footer > .modal__footer--center {
	display: flex;
	width: 100%;
	justify-content: center;
	align-items: center;
	flex-wrap: wrap;
	gap: 12px;
}

/* Формы в модалках */
.modal__header-inputs {
	display: flex;
	flex-direction: column;
	gap: 24px;
	width: 100%;
}

.modal__inputs {
	display: flex;
	flex-direction: column;
	gap: 24px;
	width: 100%;
}

.modal__inputs-item {
	display: flex;
	flex-direction: column;
	gap: 8px;
	width: 100%;
}

.modal__input-title {
	font-size: 0.9375rem;
	font-weight: 500;
	color: var(--main-color);
}

.modal__inputs-item input:not([type="file"]),
.modal__inputs-item textarea,
.modal__inputs-item select {
	width: 100%;
	max-width: 100%;
	min-width: 0;
	padding: 14px 20px;
	box-sizing: border-box;
	border-radius: 12px;
	border: 1.5px solid var(--border-color);
	outline: none;
	font-size: 1rem;
	font-weight: 400;
	font-family: inherit;
	color: var(--main-color);
	background: var(--white-color);
	transition: all 0.2s ease;
}

.modal__inputs-item input:not([type="file"]):focus,
.modal__inputs-item textarea:focus,
.modal__inputs-item select:focus {
	border-color: var(--accent-color);
	box-shadow: 0 0 0 3px rgba(104, 85, 248, 0.1);
}

.modal__inputs-item input:not([type="file"]):hover,
.modal__inputs-item textarea:hover,
.modal__inputs-item select:hover {
	border-color: var(--accent-color);
}

.modal__inputs-item input:not([type="file"])::placeholder,
.modal__inputs-item textarea::placeholder {
	color: var(--gray-color);
	opacity: 0.6;
}

.modal__label-file {
	display: flex;
	flex-direction: column;
	justify-content: center;
	align-items: center;
	gap: 16px;
	width: 100%;
	min-height: 180px;
	padding: 32px;
	box-sizing: border-box;
	border-radius: 16px;
	border: 2px dashed var(--border-color);
	background: var(--bg-color);
	transition: all 0.2s ease;
	cursor: pointer;
	color: var(--gray-color);
	text-align: center;
}

.modal__label-file:hover {
	border-color: var(--accent-color);
	background: rgba(104, 85, 248, 0.05);
}

.modal__label-file.drag-over {
	border-color: var(--accent-color);
	background: rgba(104, 85, 248, 0.1);
	transform: scale(1.02);
}

.modal__label-file .fa-solid {
	font-size: 48px;
	color: var(--accent-color);
}

/* Кнопки */
.modal__action-button {
	display: flex;
	justify-content: center;
	align-items: center;
	gap: 8px;
	padding: 14px 32px;
	box-sizing: border-box;
	border-radius: 100px;
	border: none;
	font-size: 1rem;
	font-weight: 500;
	font-family: inherit;
	cursor: pointer;
	transition: all 0.2s ease;
	background: var(--accent-color);
	color: var(--white-color);
	min-height: 48px;
}

.modal__action-button:hover {
	opacity: 0.9;
	transform: translateY(-1px);
	box-shadow: 0 4px 12px rgba(104, 85, 248, 0.3);
}

.modal__action-button:active {
	transform: translateY(0);
}

.modal__action-button:disabled {
	opacity: 0.5;
	cursor: not-allowed;
	transform: none;
}

.modal__action-button--secondary {
	background: var(--bg-color);
	color: var(--main-color);
	border: 1.5px solid var(--border-color);
}

.modal__action-button--secondary:hover {
	background: var(--white-color);
	border-color: var(--accent-color);
	box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.modal__action-button--danger {
	background: #e74c3c;
	color: var(--white-color);
}

.modal__action-button--danger:hover {
	background: #c0392b;
}

/* Блок действий */
.modal__actions-block {
	display: flex;
	flex-direction: column;
	gap: 16px;
	width: 100%;
	margin-top: 24px;
	padding-top: 24px;
	border-top: 1px solid rgba(0, 0, 0, 0.08);
}

.modal__actions-text {
	font-size: 0.9375rem;
	font-weight: 400;
	color: var(--gray-color);
	text-align: center;
	margin: 0;
}

.modal__actions {
	display: flex;
	gap: 12px;
	width: 100%;
}

.modal__action-link {
	display: flex;
	justify-content: center;
	align-items: center;
	gap: 8px;
	flex: 1;
	padding: 12px 20px;
	box-sizing: border-box;
	border-radius: 100px;
	background: var(--bg-color);
	border: 1.5px solid var(--border-color);
	cursor: pointer;
	transition: all 0.2s ease;
	color: var(--main-color);
	font-size: 0.9375rem;
	font-weight: 500;
	text-decoration: none;
}

.modal__action-link:hover {
	background: var(--white-color);
	border-color: var(--accent-color);
	transform: translateY(-1px);
	box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.modal__action-icon {
	width: 20px;
	height: 20px;
	object-fit: contain;
}

/* Сообщения и ошибки */
.modal__form-info {
	font-size: 0.875rem;
	font-weight: 400;
	line-height: 1.4;
	color: var(--accent-color);
	margin-top: 4px;
	display: none;
}

.modal__form-info:not(:empty) {
	display: block;
}

.modal__form-info.error {
	color: #e74c3c;
}

.modal__form-info.success {
	color: #27ae60;
}

.modal__form-description {
	font-size: 0.875rem;
	font-weight: 400;
	line-height: 1.4;
	color: var(--gray-color);
	margin-top: 4px;
}

/* Капча */
.g-recaptcha {
	width: 100%;
	display: flex;
	justify-content: center;
}

/* Анимации */
@keyframes modalFadeIn {
	from {
		opacity: 0;
	}
	to {
		opacity: 1;
	}
}

@keyframes modalSlideIn {
	from {
		opacity: 0;
		transform: translateY(-20px) scale(0.95);
	}
	to {
		opacity: 1;
		transform: translateY(0) scale(1);
	}
}

/* Блокировка прокрутки body при открытой модалке */
body.modal-open {
	overflow: hidden;
	padding-right: 0;
}

/* Адаптивность */
@media screen and (max-width: 768px) {
	.modal.show {
		padding: 0;
		padding-bottom: env(safe-area-inset-bottom, 0px);
		align-items: flex-end;
	}

	.modal__content {
		max-width: 100%;
		max-height: 92vh;
		max-height: 92dvh;
		border-radius: 24px 24px 0 0;
		margin: 0;
		animation: modalSlideUp 0.3s ease-out;
	}

	/* Планшет: отступы модалки 20px */
	.modal__header,
	.modal__body,
	.modal__footer {
		padding: 20px;
	}

	.modal__footer {
		flex-direction: column;
		align-items: stretch;
		padding-bottom: max(20px, env(safe-area-inset-bottom, 0px));
	}

	.modal__footer .form-actions {
		flex-direction: column;
		align-items: stretch;
	}

	.modal__footer > .modal__footer--center {
		flex-direction: column;
		align-items: stretch;
	}

	.modal__footer .modal__action-button {
		width: 100%;
	}

	.modal__actions {
		flex-direction: column;
	}

	.modal__action-link {
		width: 100%;
	}
}

@keyframes modalSlideUp {
	from {
		opacity: 0;
		transform: translateY(100%);
	}
	to {
		opacity: 1;
		transform: translateY(0);
	}
}

@media screen and (max-width: 480px) {
	/* Мобилка: отступы модалки 16px */
	.modal__header,
	.modal__body {
		padding: 16px;
	}

	.modal__footer {
		padding: 16px;
		padding-bottom: max(16px, env(safe-area-inset-bottom, 0px));
	}

	.modal__title {
		font-size: 1.25rem;
	}
}
