/* Time Picker for WooCommerce checkout styles. Colors and fonts follow the checkout theme. */

/* Block checkout: shared */
.tpfw-block-timepicker {
	--tpfw-accent: var(--tpfw-picker-accent, var(--wp--preset--color--contrast, #1e1e1e));
	--tpfw-accent-text: var(--tpfw-picker-accent-text, var(--wp--preset--color--base, #fff));
	--tpfw-border: color-mix(in srgb, currentColor 28%, transparent);
	margin-top: 16px;
}

.tpfw-block-timepicker .wc-block-components-checkout-step__description {
	margin-bottom: 12px;
}

/* Block checkout: drop-down lists */
.tpfw-dropdown-picker {
	display: grid;
	grid-template-columns: repeat(2, minmax(0, 1fr));
	gap: 12px 16px;
}

.tpfw-dropdown-picker__field {
	min-width: 0;
}

.tpfw-dropdown-picker__note,
.tpfw-dropdown-picker .wc-block-components-validation-error {
	grid-column: 1 / -1;
	margin: 0;
}

.tpfw-dropdown-picker__note {
	opacity: 0.8;
}

@media (max-width: 480px) {
	.tpfw-dropdown-picker {
		grid-template-columns: minmax(0, 1fr);
	}
}

/* Block checkout: date and time chips */
.tpfw-chip-picker {
	display: grid;
	gap: 16px;
	margin-top: 12px;
}

.tpfw-chip-picker__field,
.tpfw-chip-picker__group {
	display: grid;
	gap: 8px;
	min-width: 0;
}

.tpfw-chip-picker__label,
.tpfw-chip-picker__sublabel,
.tpfw-time-field__label {
	font-size: 0.78em;
	font-weight: 700;
	letter-spacing: 0.06em;
	text-transform: uppercase;
	opacity: 0.75;
}

.tpfw-chip-picker__sublabel {
	letter-spacing: 0.04em;
	opacity: 0.65;
}

.tpfw-chip-picker__chips {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
}

.tpfw-block-timepicker .tpfw-chip-picker .tpfw-chip {
	min-height: 40px;
	margin: 0;
	padding: 8px 14px;
	border: 1px solid var(--tpfw-border);
	border-radius: 999px;
	background: transparent;
	color: inherit;
	font: inherit;
	line-height: 1.2;
	text-transform: none;
	letter-spacing: normal;
	cursor: pointer;
}

/* Themes often restyle every button on hover and focus; keep the chip look. */
.tpfw-block-timepicker .tpfw-chip-picker .tpfw-chip:hover,
.tpfw-block-timepicker .tpfw-chip-picker .tpfw-chip:focus {
	background: transparent;
	color: inherit;
}

.tpfw-block-timepicker .tpfw-chip-picker .tpfw-chip:hover:not(:disabled) {
	border-color: currentColor;
}

.tpfw-block-timepicker .tpfw-chip-picker .tpfw-chip.is-active,
.tpfw-block-timepicker .tpfw-chip-picker .tpfw-chip.is-active:hover,
.tpfw-block-timepicker .tpfw-chip-picker .tpfw-chip.is-active:focus {
	border-color: var(--tpfw-accent);
	background: var(--tpfw-accent);
	color: var(--tpfw-accent-text);
}

.tpfw-block-timepicker .tpfw-chip-picker .tpfw-chip:disabled {
	border-color: var(--tpfw-border);
	background: transparent;
	color: inherit;
	cursor: not-allowed;
	opacity: 0.45;
}

.tpfw-chip-picker__note {
	margin: 0;
	opacity: 0.8;
}

/* Block checkout: compact row that opens the chips */
.tpfw-time-field {
	position: relative;
	margin-top: 8px;
}

.tpfw-block-timepicker .tpfw-time-field__button {
	display: flex;
	align-items: center;
	gap: 12px;
	box-sizing: border-box;
	width: 100%;
	min-height: 52px;
	margin: 0;
	padding: 10px 14px;
	border: 1px solid var(--tpfw-border);
	border-radius: 8px;
	background: transparent;
	color: inherit;
	font: inherit;
	text-align: left;
	text-transform: none;
	letter-spacing: normal;
	white-space: normal;
	cursor: pointer;
}

.tpfw-block-timepicker .tpfw-time-field__button:hover,
.tpfw-block-timepicker .tpfw-time-field__button:focus {
	background: transparent;
	color: inherit;
}

.tpfw-block-timepicker .tpfw-time-field__button:hover:not(:disabled) {
	border-color: currentColor;
}

.tpfw-block-timepicker .tpfw-time-field__button:disabled {
	cursor: not-allowed;
	opacity: 0.6;
}

.tpfw-block-timepicker .tpfw-time-field.has-error .tpfw-time-field__button {
	border-color: var(--wc-red, #cc1818);
}

.tpfw-time-field__icon {
	flex: 0 0 auto;
}

.tpfw-time-field__text {
	display: grid;
	flex: 1 1 auto;
	min-width: 0;
	gap: 2px;
}

.tpfw-time-field__value {
	font-weight: 600;
	overflow-wrap: anywhere;
}

.tpfw-time-field__value.is-placeholder {
	font-weight: 400;
	opacity: 0.75;
}

.tpfw-time-field__chevron {
	flex: 0 0 auto;
	transition: transform 0.15s ease;
}

.tpfw-time-field.is-open .tpfw-time-field__chevron {
	transform: rotate(180deg);
}

.tpfw-time-field__backdrop {
	display: none;
}

.tpfw-time-field__panel {
	position: absolute;
	z-index: 1000;
	top: calc(100% + 8px);
	left: 0;
	box-sizing: border-box;
	width: min(480px, 100%);
	max-height: min(70vh, 560px);
	padding: 16px;
	overflow-y: auto;
	border: 1px solid color-mix(in srgb, currentColor 18%, transparent);
	border-radius: 12px;
	background: var(--wp--preset--color--base, #fff);
	box-shadow: 0 12px 32px rgba(0, 0, 0, 0.16);
}

.tpfw-time-field__header {
	display: flex;
	align-items: flex-start;
	justify-content: space-between;
	gap: 12px;
}

.tpfw-time-field__title {
	margin: 0;
	font-size: 1.05em;
}

.tpfw-time-field__copy {
	margin: 4px 0 0;
	font-size: 0.9em;
	opacity: 0.8;
}

.tpfw-block-timepicker .tpfw-time-field__close,
.tpfw-block-timepicker .tpfw-time-field__close:hover,
.tpfw-block-timepicker .tpfw-time-field__close:focus {
	flex: 0 0 auto;
	width: 36px;
	height: 36px;
	margin: 0;
	padding: 0;
	border: 0;
	border-radius: 999px;
	background: transparent;
	color: inherit;
	font-size: 1.5em;
	line-height: 1;
	cursor: pointer;
}

.tpfw-time-field__footer {
	display: flex;
	justify-content: flex-end;
	margin-top: 16px;
}

.tpfw-block-timepicker .tpfw-time-field__done,
.tpfw-block-timepicker .tpfw-time-field__done:hover,
.tpfw-block-timepicker .tpfw-time-field__done:focus {
	min-height: 40px;
	margin: 0;
	padding: 8px 20px;
	border: 1px solid var(--tpfw-accent);
	border-radius: 999px;
	background: var(--tpfw-accent);
	color: var(--tpfw-accent-text);
	font: inherit;
	font-weight: 600;
	text-transform: none;
	cursor: pointer;
}

.tpfw-block-timepicker .tpfw-chip-picker .tpfw-chip:focus-visible,
.tpfw-block-timepicker .tpfw-time-field__button:focus-visible,
.tpfw-block-timepicker .tpfw-time-field__close:focus-visible,
.tpfw-block-timepicker .tpfw-time-field__done:focus-visible {
	outline: 2px solid currentColor;
	outline-offset: 2px;
}

@media (max-width: 600px) {
	.tpfw-time-field.is-open .tpfw-time-field__backdrop {
		display: block;
		position: fixed;
		z-index: 99998;
		inset: 0;
		background: rgba(0, 0, 0, 0.4);
	}

	.tpfw-time-field__panel {
		position: fixed;
		z-index: 99999;
		top: auto;
		right: 0;
		bottom: 0;
		left: 0;
		width: 100%;
		max-height: 85vh;
		border-radius: 16px 16px 0 0;
		padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px));
	}
}

@media (max-width: 480px) {
	.tpfw-block-timepicker .tpfw-chip-picker .tpfw-chip {
		padding: 8px 12px;
	}
}

@media (forced-colors: active) {
	.tpfw-block-timepicker .tpfw-chip-picker .tpfw-chip.is-active {
		border: 2px solid Highlight;
		background: Highlight;
		color: HighlightText;
	}
}

/* Classic checkout */
.tpfw-time-picker:empty {
	display: none;
}

.tpfw-time-picker:not(:empty) {
	box-sizing: border-box;
	margin: 0 0 1.5em;
	padding: 16px 20px;
	border: 1px solid color-mix(in srgb, currentColor 18%, transparent);
	border-radius: 8px;
}

.tpfw-time-picker::after {
	display: table;
	clear: both;
	content: "";
}

.tpfw-time-picker #tpfw-time_checkout_field.shop_table {
	margin: 0;
	border: 0;
}

.tpfw-time-picker .tpfw-checkoutfield-title {
	margin: 0 0 12px;
}

.tpfw-time-picker .form-row {
	margin-bottom: 0;
}

.tpfw-time-picker select#tpfw-date,
.tpfw-time-picker input#tpfw-time {
	box-sizing: border-box;
	width: 100%;
	min-height: 44px;
}

.tpfw-time-picker input#tpfw-time {
	padding-right: 40px;
	background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24' fill='none' stroke='%23757575' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='12' cy='12' r='9'/%3E%3Cpath d='M12 7v5l3 2'/%3E%3C/svg%3E");
	background-position: right 12px center;
	background-repeat: no-repeat;
	cursor: pointer;
}

.woocommerce-checkout .ui-timepicker-wrapper {
	box-sizing: border-box;
	min-width: 180px;
	max-height: 260px;
	margin-top: 4px;
	border: 1px solid rgba(0, 0, 0, 0.12);
	border-radius: 8px;
	box-shadow: 0 12px 32px rgba(0, 0, 0, 0.14);
}

.woocommerce-checkout .ui-timepicker-list li {
	padding: 8px 14px;
	line-height: 1.3;
}

.woocommerce-checkout .ui-timepicker-list li:hover,
.woocommerce-checkout .ui-timepicker-list .ui-timepicker-selected {
	background: #1e1e1e;
	color: #fff;
}

.woocommerce-checkout .ui-timepicker-list li.tpfw-asap {
	font-weight: 600;
}
