/*
 * Styled dropdowns (see assets/js/custom-select.js).
 *
 * body:not(#gg) lifts the specificity above theme and WooCommerce form rules.
 */

body:not(#gg) .gg-select {
	--gs-ink: #121212;
	--gs-ink-soft: #1b1c1a;
	--gs-muted: #6e6a64;
	--gs-gold: #b3924c;
	--gs-sand: #f5f3ef;
	--gs-line: #e6e2da;

	position: relative;
	display: block;
	width: 100%;
	max-width: 100%;
	margin: 0;
	padding: 0;
	font-family: Manrope, system-ui, -apple-system, 'Segoe UI', sans-serif;
	letter-spacing: normal;
	text-align: left;
	text-transform: none;

	/* The real select stays for forms and scripts, but out of sight. */
	> select.gg-select__native {
		position: absolute !important;
		top: 0;
		left: 0;
		width: 100% !important;
		height: 100% !important;
		min-width: 0 !important;
		margin: 0 !important;
		padding: 0 !important;
		border: 0 !important;
		opacity: 0 !important;
		pointer-events: none !important;
		appearance: none;
		-webkit-appearance: none;
	}

	.gg-select__btn {
		position: relative;
		display: flex;
		align-items: center;
		justify-content: space-between;
		gap: 10px;
		width: 100%;
		min-height: 44px;
		margin: 0;
		padding: 0.7rem 0.9rem;
		border: 1px solid rgb(183, 183, 183);
		border-radius: 8px;
		background: #fff;
		box-shadow: none;
		color: var(--gs-ink-soft);
		font: inherit;
		font-size: 14px;
		font-weight: 400;
		line-height: 20px;
		letter-spacing: normal;
		text-align: left;
		text-transform: none;
		cursor: pointer;
		transition: background-color 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;

		&:hover {
			border-color: #8f8a82;
			background: #fff;
			color: var(--gs-ink-soft);
		}

		&:focus {
			outline: 0;
		}

		&:focus-visible {
			outline: 2px solid var(--gs-ink);
			outline-offset: 2px;
		}

		&:disabled {
			cursor: not-allowed;
			opacity: 0.55;
		}
	}

	.gg-select__value {
		flex: 1 1 auto;
		min-width: 0;
		overflow: hidden;
		text-overflow: ellipsis;
		white-space: nowrap;
	}

	&.is-placeholder .gg-select__value {
		color: var(--gs-muted);
	}

	.gg-select__chev {
		flex: none;
		width: 14px;
		height: 14px;
		color: var(--gs-ink-soft);
		transition: transform 0.18s ease;
	}

	&.is-open .gg-select__chev {
		transform: rotate(180deg);
	}

	.gg-select__list {
		position: absolute;
		top: calc(100% + 6px);
		left: 0;
		z-index: 60;
		box-sizing: border-box;
		min-width: 100%;
		width: max-content;
		max-width: min(340px, calc(100vw - 24px));
		max-height: 280px;
		margin: 0;
		padding: 6px;
		overflow-y: auto;
		overscroll-behavior: contain;
		border: 1px solid var(--gs-line);
		border-radius: 8px;
		background: #fff;
		box-shadow: 0 12px 32px rgba(18, 18, 18, 0.12), 0 2px 6px rgba(18, 18, 18, 0.06);
		list-style: none;
		outline: 0;
		transform-origin: top center;
		animation: gg-select-in 0.14s ease-out;

		&[hidden] {
			display: none;
		}
	}

	&.is-up .gg-select__list {
		top: auto;
		bottom: calc(100% + 6px);
		transform-origin: bottom center;
	}

	&.is-end .gg-select__list {
		right: 0;
		left: auto;
	}

	.gg-select__copy {
		flex: 1 1 auto;
		min-width: 0;
		overflow: hidden;
		text-overflow: ellipsis;
	}

	.gg-select__option {
		display: flex;
		align-items: center;
		justify-content: space-between;
		gap: 16px;
		margin: 0;
		padding: 9px 12px;
		border-radius: 4px;
		color: var(--gs-ink-soft);
		font-size: 13px;
		font-weight: 400;
		line-height: 20px;
		list-style: none;
		white-space: nowrap;
		cursor: pointer;

		&::before,
		&::marker {
			content: none;
		}

		svg {
			flex: none;
			color: var(--gs-gold);
			opacity: 0;
		}

		&.is-active {
			background: var(--gs-sand);
		}

		&.is-selected {
			font-weight: 700;

			svg {
				opacity: 1;
			}
		}

		&.is-disabled {
			color: #a8a49c;
			cursor: not-allowed;
		}
	}

	.gg-select__group {
		margin: 0;
		padding: 10px 12px 4px;
		color: var(--gs-muted);
		font-size: 10px;
		font-weight: 700;
		line-height: 14px;
		letter-spacing: 0.5px;
		list-style: none;
		text-transform: uppercase;
	}
}

/* Pickup points: name and address on two lines, list as wide as the field. */

body:not(#gg) .gg-proteria-pickup .gg-select {
	.gg-select__btn {
		min-height: 52px;
		border-color: var(--gs-line);
		border-radius: 8px;
		background: #fbf9f5;
	}

	.gg-select__value {
		display: flex;
		flex-direction: column;
		gap: 2px;
		white-space: normal;
	}

	.gg-select__list {
		width: 100%;
		max-width: none;
	}

	.gg-select__option {
		align-items: flex-start;
		white-space: normal;
	}

	.gg-select__copy {
		display: flex;
		flex-direction: column;
		gap: 2px;
		overflow: visible;
		text-overflow: unset;
		white-space: normal;
	}

	.gg-select__label {
		font-weight: 600;
		line-height: 18px;
	}

	.gg-select__detail {
		color: var(--gs-muted);
		font-size: 12px;
		font-weight: 400;
		line-height: 16px;
	}

	&.is-open {
		z-index: 5;
	}
}

@keyframes gg-select-in {
	from {
		opacity: 0;
		transform: translateY(-4px);
	}

	to {
		opacity: 1;
		transform: none;
	}
}

@media (prefers-reduced-motion: reduce) {
	body:not(#gg) .gg-select .gg-select__list {
		animation: none;
	}
}

/* Shop toolbar sort */

body:not(#gg) .gg-sort__field > .gg-select {
	width: auto;
	min-width: 151px;

	.gg-select__btn {
		min-height: 36px;
		padding: 8px 12px 8px 18px;
		border: 0;
		border-radius: 4px;
		background: #f5f3ef;
		font-size: 13px;

		&:hover {
			background: #efeeea;
		}
	}

	.gg-select__list {
		right: 0;
		left: auto;
		min-width: 190px;
	}
}

body:not(#gg) .gg-sort__field > svg {
	display: none;
}

@media (max-width: 760px) {
	body:not(#gg) .gg-sort__field > .gg-select {
		width: 100%;
		min-width: 0;
	}
}

/* Checkout and account forms */

body:not(#gg) .gg-co .form-row .gg-select .gg-select__btn,
body:not(#gg) .woocommerce-address-fields .form-row .gg-select .gg-select__btn {
	height: 48px;
	padding: 12px 16px;
	border: 0;
	border-radius: 4px;
	background: #fbf9f5;
	box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.05);
	font-size: 15px;
	line-height: 24px;

	&:hover {
		background: #fbf9f5;
	}

	&:focus-visible {
		outline: 0;
		background: #fff;
		box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.05), 0 0 0 2px rgba(212, 175, 55, 0.55);
	}
}

body:not(#gg) .gg-co .form-row.woocommerce-invalid .gg-select .gg-select__btn {
	box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.05), 0 0 0 1px #ba1a1a;
}
