@use "mixins";

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

.endereco-no-scroll {
	overflow: hidden;
}

.endereco-popup-container {
	position: fixed;
	z-index: 9900;
	background-color: rgba(0, 0, 0, 0.3);
	top: 0;
	left: 0;
	width: 100vw;
	height: 100vh;
	display: flex;
	justify-content: center;
	align-items: center;
	padding-top: 80px;
	padding-bottom: 120px;
	overflow-y: auto;

	@include mixins.res(tablet) {
		padding-top: 0;
		padding-bottom: 0;
	}

	&--direction-ltr {
		direction: ltr;
	}

	&--direction-rtl {
		direction: rtl;
	}
}

.endereco-modal {
	width: 95%;
	box-sizing: border-box;
	margin: 0;
	background-color: #fff;
	overflow: hidden;
	border-radius: 4px;
	box-shadow: 1px 1px 4px rgba(0,0,0,0.25), 0 0 12px rgba(0,0,0,0.125);
	animation: fadein 300ms;
	animation-timing-function: ease-in-out;
	max-height: 100vh;
	overflow-y: auto;

	@include mixins.res(tablet) {
		max-width: 480px;
	}

	@include mixins.res(desktop) {
		max-width: 560px;
	}

	a {
		color: #0c517d;
	}

	&--no-prediction {
		&.endereco-invalid-country-code {
			.endereco-country-code {
				display: inline-block;
				background-color: rgba(255, 0, 0, 0.125);
				border-bottom: 1px solid red;
				padding: 0 3px;
				min-width: 20px;
				min-height: 1em;
			}
		}

		&.endereco-invalid-subdivision-code {
			.endereco-subdivision-code {
				display: inline-block;
				background-color: rgba(255, 0, 0, 0.125);
				border-bottom: 1px solid red;
				padding: 0 3px;
				min-width: 20px;
				min-height: 1em;
			}
		}

		&.endereco-invalid-postal-code {
			.endereco-postal-code {
				display: inline-block;
				background-color: rgba(255, 0, 0, 0.125);
				border-bottom: 1px solid red;
				padding: 0 3px;
				min-width: 20px;
				min-height: 1em;
			}
		}

		&.endereco-invalid-locality {
			.endereco-locality {
				display: inline-block;
				background-color: rgba(255, 0, 0, 0.125);
				border-bottom: 1px solid red;
				padding: 0 3px;
				min-width: 20px;
				min-height: 1em;
			}
		}

		&.endereco-invalid-street-name {
			.endereco-street-name {
				display: inline-block;
				background-color: rgba(255, 0, 0, 0.125);
				border-bottom: 1px solid red;
				padding: 0 3px;
				min-width: 20px;
				min-height: 1em;
			}
		}

		&.endereco-invalid-building-number {
			.endereco-building-number,
			.endereco-street-full {
				display: inline-block;
				background-color: rgba(255, 0, 0, 0.125);
				border-bottom: 1px solid red;
				padding: 0 3px;
				min-width: 20px;
				min-height: 1em;
			}
		}

		&.endereco-invalid-postnummer {
			.endereco-additional-info {
				display: inline-block;
				background-color: rgba(255, 0, 0, 0.125);
				border-bottom: 1px solid red;
				padding: 0 3px;
				min-width: 20px;
				min-height: 1em;
			}
		}

		&.endereco-invalid-street-full {
			.endereco-street-full {
				display: inline-block;
				background-color: rgba(255, 0, 0, 0.125);
				border-bottom: 1px solid red;
				padding: 0 3px;
				min-width: 20px;
				min-height: 1em;
			}
		}

		&.endereco-invalid-additional-info-full {
			.endereco-additional-info {
				display: inline-block;
				background-color: rgba(255, 0, 0, 0.125);
				border-bottom: 1px solid red;
				padding: 0 3px;
				min-width: 20px;
				min-height: 1em;
			}
		}

		&.building_number_is_missing,
		&.building_number_not_found {
			.endereco-building-number {
				display: inline-block;
				background-color: rgba(255, 0, 0, 0.125);
				border-bottom: 1px solid red;
				padding: 0 3px;
				min-width: 20px;
				min-height: 1em;
			}

			.endereco-street-full {
				display: inline-block;
				background-color: rgba(255, 0, 0, 0.125);
				border-bottom: 1px solid red;
				padding: 0 3px;
				min-width: 20px;
				min-height: 1em;
			}
		}

		&.street_name_needs_correction {
			.endereco-street-name {
				display: inline-block;
				background-color: rgba(255, 0, 0, 0.125);
				border-bottom: 1px solid red;
				padding: 0 3px;
				min-width: 20px;
				min-height: 1em;
			}

			.endereco-street-full {
				display: inline-block;
				background-color: rgba(255, 0, 0, 0.125);
				border-bottom: 1px solid red;
				padding: 0 3px;
				min-width: 20px;
				min-height: 1em;
			}
		}

		&.postal_code_needs_correction {
			.endereco-postal-code {
				display: inline-block;
				background-color: rgba(255, 0, 0, 0.125);
				border-bottom: 1px solid red;
				padding: 0 3px;
				min-width: 20px;
				min-height: 1em;
			}
		}

		&.locality_needs_correction {
			.endereco-locality {
				display: inline-block;
				background-color: rgba(255, 0, 0, 0.125);
				border-bottom: 1px solid red;
				padding: 0 3px;
				min-width: 20px;
				min-height: 1em;
			}
		}

		&.country_code_needs_correction {
			.endereco-country-code,
			.endereco-country-name {
				display: inline-block;
				background-color: rgba(255, 0, 0, 0.125);
				border-bottom: 1px solid red;
				padding: 0 3px;
				min-width: 20px;
				min-height: 1em;
			}
		}

		&.subdivision_code_needs_correction {
			.endereco-subdivision-code,
			.endereco-subdivision-name {
				display: inline-block;
				background-color: rgba(255, 0, 0, 0.125);
				border-bottom: 1px solid red;
				padding: 0 3px;
				min-width: 20px;
				min-height: 1em;
			}
		}
	}

	&__errors {
		margin: 15px 0;
		background-color: rgba(255,0,0,0.125);
		border-radius: 4px;
		padding: 10px;

		ul {
			padding: 0 0 0 20px;
			margin: 0;
			color: red;

			li {
				margin-bottom: 0.25em;

				&:last-child {
					margin-bottom: 0;
				}
			}
		}
	}

	&__warning {
		padding: 15px;
		background-color: #f6f6f6;
		margin: 15px 0;
		border-radius: 4px;
	}

	&__header {
		color: #333;
		padding: 15px 45px 15px 15px;
		font-family: sans-serif;
		position: relative;

		@include mixins.res(tablet) {
			padding: 30px 65px 15px 30px;
		}

		&-main {
			font-weight: 700;
			text-align: left;
			color: red;
			margin: 0;
			font-size: 24px;
			line-height: 1.25em;

			@include mixins.res(tablet) {
				margin: 0 0 10px;
			}
		}

		&-sub {
			font-weight: 400;
			text-align: left;
			color: #333;
			font-size: 16px;
			margin: 0 0 20px;
			line-height: 1.5;
			display: none;

			@include mixins.res(tablet) {
				display: block;
				margin-bottom: 0;
			}
		}
	}

	&__close {
		margin-left: auto;
		cursor: pointer;
		position: absolute;
		top: 20px;
		right: 20px;

		border: 1px solid gray;
		border-radius: 50%;
		width: 20px;
		height: 20px;
		display: flex;
		justify-content: center;
		align-items: center;
		color: gray;

		@include mixins.res(tablet) {
			top: 33px;
			right: 30px
		}

		&::after {
			content: "\2716";
		}
	}

	&__body {
		padding: 7.5px 15px;
		font-family: sans-serif;
		background-color: #fff;

		@include mixins.res(tablet) {
			padding: 15px 30px;
		}
	}

	&__address-container {
		padding: 20px 20px 20px 23px;
		box-sizing: border-box;
		font-size: 18px;
		font-weight: 400;
		line-height: 22px;
		cursor: pointer;
		border: 1px solid gray;
		border-radius: 4px;
		background-color: #fff;
		box-shadow: 2px 2px 5px rgba(0,0,0,0.125);
		display: block;
		font-family: serif;
		position: relative;
		overflow: hidden;
	}

	&__address-confirmation {
		padding: 0 0 0 15px;
		margin: 15px 0;
		position: relative;
		label {
			font-weight: 600;
			cursor: pointer;
			font-size: 1.125em;
			padding-left: 30px;
			position: relative;
			line-height: 1.8em;
		}

		input[type="checkbox"] {
			width: 20px;
			height: 20px;
			margin-right: 10px;
			position: absolute;
			top: 0;
			left: 0;
		}
	}

	&__secondary-link {
		margin-right: 20px;
	}

	&__footer {
		text-align: right;
		padding: 7.5px 15px 15px;
		font-family: sans-serif;

		@include mixins.res(tablet) {
			padding: 15px 30px 30px;
		}

		button {
			margin-left: 10px;
		}
	}

	&__divider {
		position: relative;

		&:first-child {
			margin-top: 0 !important;
		}

		&:last-child {
			margin-bottom: 0 !important;
		}

		&-innertext {
			display: inline-block;
			padding: 2px 10px;
			background-color: #fff;
			margin-left: 12px;
			position: relative;
			z-index: 1;
		}

		&::after {
			width: 100%;
			height: 2px;
			background-color: rgba(0, 0, 0, 0.125);
			content: " ";
			display: block;
			top: calc(50% - 1px);
			position: absolute;
		}
	}
}

.endereco-address-predictions {
	list-style: none;
	margin: 15px 0;
	padding: 0;

	max-height: 300px;
	overflow: hidden;
	overflow-y: auto;

	&:last-child {
		margin-bottom: 0 !important;
	}

	&__item {
		margin: 10px 0;
		list-style: none;
		background-color: #fff;

		&:first-child {
			margin-top: 0 !important;
		}

		&:last-child {
			margin-bottom: 0 !important;
		}
	}

	&__radio {
		position: absolute;
		left: -9999px;
		width: 1px;
		height: 1px;
		overflow: hidden;
		clip: rect(0, 0, 0, 0);
		white-space: nowrap;
		border: 0;
		margin: 0;
		padding: 0;
	}

	&__label {
		padding: 2px;
		box-sizing: border-box;
		font-size: 18px;
		font-weight: 400;
		line-height: 22px;
		cursor: pointer;
		border: 1px solid #ccc;
		border-radius: 4px;
		box-shadow: 2px 2px 5px rgba(0,0,0,0.125);
		display: block;
		font-family: serif;
		position: relative;
		overflow: hidden;

		&-inner {
			display: block;
			border: 3px solid transparent;
			padding: 18px 18px 18px 63px;
			border-radius: 2px;
		}

		&::after {
			content: " ";
			position: absolute;
			top: calc(50% - 5px);
			left: 28px;
			font-size: 56px;
			background-color: #4caf50;
			display: none;
			width: 10px;
			height: 10px;
			border-radius: 50%;
			box-sizing: border-box;
		}

		&::before {
			position: absolute;
			top: calc(50% - 26px / 2);
			left: 20px;
			width: 26px;
			height: 26px;
			content: " ";
			background-color: transparent;
			border: 2px solid gray;
			border-radius: 50%;
			box-sizing: border-box;
		}
	}

	&--original {
		.endereco-span--remove {
			display: inline-block;
			background-color: rgba(255, 0, 0, 0.125);
			border-bottom: 1px solid red;
			padding: 0 3px;
		}

		.endereco-span--add {
			display: none !important;
		}
	}

	&--suggestions {

		.endereco-span--add {
			border-bottom: 1px solid rgb(76, 175, 80);
			background-color: rgba(76, 175, 80, 0.125);
			display: inline-block;
			padding: 0 3px;
		}

		.endereco-span--remove {
			display: none;
		}
	}
}

.endereco-address-predictions--original .endereco-address-predictions__label {
	border-color: red;
}

.endereco-address-predictions__radio:checked ~ .endereco-address-predictions__label,
.endereco-address-predictions__item.active .endereco-address-predictions__label {
	border-color: #4caf50;
}

.endereco-address-predictions__radio:checked ~ .endereco-address-predictions__label::after,
.endereco-address-predictions__item.active .endereco-address-predictions__label::after {
	display: block;
}
.endereco-address-predictions__radio:checked ~ .endereco-address-predictions__label::before,
.endereco-address-predictions__item.active .endereco-address-predictions__label::before {
	border-color: #4caf50;
}

// Focus indicators for keyboard navigation
.endereco-address-predictions__radio:focus ~ .endereco-address-predictions__label .endereco-address-predictions__label-inner,
.endereco-address-predictions__radio:focus-visible ~ .endereco-address-predictions__label .endereco-address-predictions__label-inner {
	border-color: #0c517d;
	box-shadow: 0 0 4px rgba(12, 81, 125, 0.5);
}

.endereco-modal {
	// Focus indicator for buttons
	button:focus,
	button:focus-visible {
		outline: 3px solid #0c517d;
		outline-offset: 2px;
		box-shadow: 0 0 0 3px rgba(12, 81, 125, 0.25);
	}

	// Focus indicator for links
	a:focus,
	a:focus-visible {
		outline: 3px solid #0c517d;
		outline-offset: 2px;
		background-color: rgba(12, 81, 125, 0.1);
		text-decoration: underline;
	}

	// Focus indicator for checkbox
	input[type="checkbox"]:focus,
	input[type="checkbox"]:focus-visible {
		outline: 3px solid #0c517d;
		outline-offset: 2px;
		box-shadow: 0 0 0 3px rgba(12, 81, 125, 0.25);
	}

	// Focus indicator for close button
	&__close:focus,
	&__close:focus-visible {
		outline: 3px solid #0c517d;
		outline-offset: 2px;
		box-shadow: 0 0 0 3px rgba(12, 81, 125, 0.25);
	}
}

