/**
 * Divi Modal & Gravity Forms Popup - Frontend Styles
 */

/* Prevent scroll when modal is active */
body.divi-modal-open {
	overflow: hidden !important;
}

/* Modal Wrapper */
.divi-modal-wrapper {
	position: fixed;
	top: 0;
	left: 0;
	width: 100%;
	height: 100%;
	z-index: 9999999;
	display: none;
	opacity: 0;
	transition: opacity 0.25s ease;
}

.divi-modal-wrapper.is-visible {
	display: block !important;
	opacity: 1;
}

/* Backdrop / Overlay */
.divi-modal-backdrop {
	position: absolute;
	top: 0;
	left: 0;
	width: 100%;
	height: 100%;
	background: var(--dm-overlay, rgba(0, 0, 0, 0.65));
	backdrop-filter: blur(2px);
	-webkit-backdrop-filter: blur(2px);
	cursor: pointer;
}

/* Container for Centering & Scrolling */
.divi-modal-container {
	position: absolute;
	top: 0;
	left: 0;
	width: 100%;
	height: 100%;
	overflow-y: auto;
	-webkit-overflow-scrolling: touch;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 20px;
	box-sizing: border-box;
	pointer-events: none; /* Allows click through to backdrop */
}

/* Modal Dialog Box */
.divi-modal-dialog {
	position: relative;
	width: 100%;
	max-width: var(--dm-max-width, 650px);
	background-color: var(--dm-bg, #ffffff);
	color: var(--dm-color, #333333);
	border-radius: var(--dm-radius, 12px);
	padding: var(--dm-padding, 35px);
	box-sizing: border-box;
	box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.35);
	margin: auto;
	pointer-events: auto; /* Re-enable pointer events for dialog content */
	max-height: calc(100vh - 40px);
	overflow-y: auto;
}

/* Close Button ("X") */
.divi-modal-close {
	position: absolute;
	top: 14px;
	right: 14px;
	width: 36px;
	height: 36px;
	background: transparent;
	border: none;
	border-radius: 50%;
	font-size: 30px;
	line-height: 1;
	color: var(--dm-close-color, #666666);
	cursor: pointer;
	padding: 0;
	margin: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	transition: background-color 0.2s ease, transform 0.2s ease, color 0.2s ease;
	z-index: 20;
}

.divi-modal-close:hover,
.divi-modal-close:focus {
	background-color: rgba(0, 0, 0, 0.06);
	color: #000000;
	transform: scale(1.08);
	outline: none;
}

/* Modal Body Content */
.divi-modal-body {
	font-size: 16px;
	line-height: 1.6;
}

.divi-modal-body > *:first-child {
	margin-top: 0;
}

.divi-modal-body > *:last-child {
	margin-bottom: 0;
}

/* Animations */
.divi-modal-wrapper[data-animation="zoom"] .divi-modal-dialog {
	animation: dmZoomIn 0.28s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}
.divi-modal-wrapper[data-animation="fade"] .divi-modal-dialog {
	animation: dmFadeIn 0.25s ease-out forwards;
}
.divi-modal-wrapper[data-animation="slide-down"] .divi-modal-dialog {
	animation: dmSlideDownIn 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}
.divi-modal-wrapper[data-animation="slide-up"] .divi-modal-dialog {
	animation: dmSlideUpIn 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes dmZoomIn {
	from {
		opacity: 0;
		transform: scale(0.92);
	}
	to {
		opacity: 1;
		transform: scale(1);
	}
}

@keyframes dmFadeIn {
	from {
		opacity: 0;
	}
	to {
		opacity: 1;
	}
}

@keyframes dmSlideDownIn {
	from {
		opacity: 0;
		transform: translateY(-30px);
	}
	to {
		opacity: 1;
		transform: translateY(0);
	}
}

@keyframes dmSlideUpIn {
	from {
		opacity: 0;
		transform: translateY(30px);
	}
	to {
		opacity: 1;
		transform: translateY(0);
	}
}

/* ==========================================================================
   Gravity Forms Optimierungen im Modal
   ========================================================================== */
.divi-modal-body .gform_wrapper {
	width: 100% !important;
	max-width: 100% !important;
	margin: 0 !important;
}

.divi-modal-body .gform_wrapper form {
	margin: 0 !important;
	padding: 0 !important;
}

.divi-modal-body .gform_wrapper fieldset.gfield,
.divi-modal-body .gform_wrapper fieldset {
	border: none !important;
	padding: 0 !important;
	margin: 0 !important;
	width: 100% !important;
	max-width: 100% !important;
	box-sizing: border-box !important;
}

.divi-modal-body .gform_wrapper .ginput_container_checkbox,
.divi-modal-body .gform_wrapper .gfield_checkbox {
	width: 100% !important;
	box-sizing: border-box !important;
}

.divi-modal-body .gform_confirmation_message {
	padding: 20px;
	border-radius: 8px;
	background-color: #eafaf1;
	color: #27ae60;
	border: 1px solid #a9dfbf;
	font-size: 17px;
	text-align: center;
	line-height: 1.5;
}

.divi-modal-body .gform_validation_errors {
	margin-bottom: 20px !important;
}

/* Datepicker Fix: Ensure Gravity Forms Datepicker is on top of modal */
.ui-datepicker {
	z-index: 99999999 !important;
}

/* Responsive Handling for Small Devices */
@media screen and (max-width: 600px) {
	.divi-modal-container {
		padding: 10px;
	}
	.divi-modal-dialog {
		padding: 24px 18px !important;
		border-radius: 8px !important;
	}
	.divi-modal-close {
		top: 10px;
		right: 10px;
		width: 32px;
		height: 32px;
		font-size: 26px;
	}
}
