/**
 * Delivery Slots for WooCommerce — storefront styles.
 */

/* Checkout date / time-slot picker. */
.dslots-form-row .dslots-select,
.dslots-review-row .dslots-select {
	width: 100%;
	max-width: 100%;
	min-width: 190px;
	box-sizing: border-box;
	margin: 0;
	padding: 10px 36px 10px 14px;
	border: 1px solid #cbd5e1;
	border-radius: 8px;
	background-color: #fff;
	/* Custom caret so the native arrow never overlaps the text. */
	background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
	background-repeat: no-repeat;
	background-position: right 12px center;
	-webkit-appearance: none;
	-moz-appearance: none;
	appearance: none;
	font-size: 14px;
	line-height: 1.4;
	color: #1f2937;
	height: auto;
	cursor: pointer;
}

.dslots-form-row .dslots-select:focus,
.dslots-review-row .dslots-select:focus {
	outline: none;
	border-color: #2563eb;
	box-shadow: 0 0 0 3px rgba( 37, 99, 235, 0.15 );
}

/* Give the order-review row room so the full date / slot text is readable. */
.dslots-review-row th,
.dslots-review-row td {
	padding-top: 12px;
	padding-bottom: 12px;
	vertical-align: middle;
}

.dslots-review-row td {
	min-width: 210px;
}

/* Required marker — drop the browser's dotted underline on the <abbr> so the
   asterisk doesn't read as "*.." */
.dslots-field abbr.required,
.dslots-review-row abbr.required,
.dslots-form-row abbr.required {
	border: 0;
	text-decoration: none;
	cursor: default;
	color: #dc2626;
	margin-inline-start: 2px;
}

.dslots-field {
	clear: both;
}

.dslots-empty {
	display: block;
	margin-top: 6px;
	color: #6b7280;
	font-style: italic;
	font-size: 0.9em;
}

/* Order detail box (Thank You + My Account). */
.dslots-order-detail {
	display: flex;
	align-items: center;
	gap: 6px;
	margin: 14px 0;
	padding: 10px 14px;
	background: rgb(236, 247, 239);
	border-radius: 8px;
	color: #166534;
	font-size: 14px;
}

.dslots-order-detail__icon {
	flex: 0 0 auto;
	display: inline-flex;
	align-items: center;
	color: #16a34a;
}

.dslots-order-detail__icon svg {
	width: 16px;
	height: 16px;
	display: block;
}

.dslots-order-detail__date {
	font-weight: 600;
}

/* ============================================================
   Custom single-select dropdown (progressive enhancement over the
   native .dslots-select). JS builds this markup; the real <select>
   stays in the DOM (visually hidden) as the submit/validate source.
   Un-scoped (checkout is not a .zui-scope page); palette matches the
   styled .dslots-select control above.
   ============================================================ */
.dslots-visually-hidden {
	position: absolute !important;
	width: 1px;
	height: 1px;
	padding: 0;
	margin: -1px;
	overflow: hidden;
	clip: rect( 0, 0, 0, 0 );
	white-space: nowrap;
	border: 0;
}

.dslots-ui {
	position: relative;
	display: block;
	width: 100%;
	max-width: 100%;
	min-width: 190px;
	box-sizing: border-box;
}

.dslots-ui__control {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 8px;
	width: 100%;
	box-sizing: border-box;
	margin: 0;
	padding: 10px 12px 10px 14px;
	border: 1px solid #cbd5e1;
	border-radius: 8px;
	background: #fff;
	font-size: 14px;
	line-height: 1.4;
	color: #1f2937;
	text-align: left;
	cursor: pointer;
	appearance: none;
	-webkit-appearance: none;
}

/* Keep a plain white control on every state — themes (e.g. Storefront) tint
   <button> backgrounds on hover/focus/active, which we don't want here. */
.dslots-ui__control,
.dslots-ui__control:hover,
.dslots-ui__control:focus,
.dslots-ui__control:active,
.dslots-ui.is-open .dslots-ui__control {
	background: #fff !important;
	color: #1f2937;
}

.dslots-ui__control:focus,
.dslots-ui.is-open .dslots-ui__control {
	outline: none;
	border-color: #2563eb;
	box-shadow: 0 0 0 3px rgba( 37, 99, 235, 0.15 );
}

.dslots-ui__value {
	flex: 1 1 auto;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.dslots-ui__value.is-placeholder {
	color: #9aa4b2;
}

.dslots-ui__chevron {
	flex: 0 0 auto;
	display: inline-flex;
	color: #6b7280;
	transition: transform 0.15s ease;
}

.dslots-ui.is-open .dslots-ui__chevron {
	transform: rotate( 180deg );
}

.dslots-ui__chevron svg {
	width: 16px;
	height: 16px;
	display: block;
}

.dslots-ui__panel {
	position: absolute;
	left: 0;
	right: 0;
	top: calc( 100% + 4px );
	margin: 0;
	padding: 4px 0;
	list-style: none;
	background: #fff;
	border: 1px solid #e2e8f0;
	border-radius: 10px;
	box-shadow: 0 20px 25px -5px rgba( 15, 23, 42, 0.12 ), 0 8px 10px -6px rgba( 15, 23, 42, 0.1 );
	max-height: 260px;
	overflow-y: auto;
	z-index: 40;
}

.dslots-ui__panel[hidden] {
	display: none;
}

.dslots-ui__option {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 8px;
	padding: 10px 14px;
	font-size: 14px;
	line-height: 1.3;
	color: #334155;
	cursor: pointer;
}

.dslots-ui__panel .dslots-ui__option:hover {
	background: transparent;
	color: #1d4ed8;
}

.dslots-ui__panel .dslots-ui__option.is-active {
	background: transparent;
	color: #1d4ed8;
}

.dslots-ui__option.is-selected {
	background: rgba( 37, 99, 235, 0.08 );
	color: #1d4ed8;
	font-weight: 600;
}

.dslots-ui__option.is-placeholder {
	color: #9aa4b2;
}

.dslots-ui__check {
	flex: 0 0 auto;
	display: inline-flex;
	color: #2563eb;
	visibility: hidden;
}

.dslots-ui__option.is-selected .dslots-ui__check {
	visibility: visible;
}

.dslots-ui__check svg {
	width: 16px;
	height: 16px;
	display: block;
}

/* ============================================================
   WooCommerce Checkout Block — style the delivery date / time-slot
   fields to match the classic plugin look. WooCommerce owns the block
   field component, so we theme the control (rounded, soft border, blue
   focus); the native option list stays as WooCommerce renders it.
   Scoped to our two fields via their select ids (dslots-delivery-*).
   ============================================================ */
.wc-block-components-select:has( select[id^="dslots-delivery"] ) .wc-block-components-select__select,
select.wc-block-components-select__select[id^="dslots-delivery"] {
	border: 1px solid #cbd5e1;
	border-radius: 8px;
	background-color: #fff;
	color: #1f2937;
	font-size: 14px;
}

.wc-block-components-select:has( select[id^="dslots-delivery"] ) .wc-block-components-select__select:focus,
select.wc-block-components-select__select[id^="dslots-delivery"]:focus {
	border-color: #2563eb;
	box-shadow: 0 0 0 2px rgba( 37, 99, 235, 0.18 );
	outline: none;
}

/* Soften the active/filled border WooCommerce draws around the field. */
.wc-block-components-select:has( select[id^="dslots-delivery"] ) {
	border-radius: 8px;
}

/* Highlight the Delivery date / Delivery time slot rows in the order totals
   table with the same soft green as the EDD "Estimated Delivery" row. The totals
   <tr> has no class, so match the row by the marker span in its value via :has(). */
.woocommerce-table tr:has( .dslots-order-total ) > th,
.woocommerce-table tr:has( .dslots-order-total ) > td,
.woocommerce-table--order-details tr:has( .dslots-order-total ) > th,
.woocommerce-table--order-details tr:has( .dslots-order-total ) > td,
table.order_details tr:has( .dslots-order-total ) > th,
table.order_details tr:has( .dslots-order-total ) > td {
	background: rgb( 236, 247, 239 ) !important;
}

/* Value text in the same green as the EDD "Estimated Delivery" date. */
.dslots-order-total,
.dslots-order-total strong {
	color: #166534 !important;
	font-weight: 600;
}
