/**
 * Front end styles for rental products.
 *
 * Colours are derived from the theme rather than hard-coded: neutral greys are
 * expressed as translucent black/white so the block reads correctly on light and
 * dark themes alike, and accents inherit `currentColor`. Layout is owned here,
 * not borrowed from the theme's form classes, so the two date fields stay on one
 * line whatever the active theme does to `.form-row`.
 *
 * @package WooCommerce_Rental_Booking
 */

.wcrb-rental-fields {
	--wcrb-gap: 0.875rem;
	--wcrb-radius: 10px;
	--wcrb-border: rgba( 128, 128, 128, 0.32 );
	--wcrb-border-strong: rgba( 128, 128, 128, 0.55 );
	--wcrb-surface: rgba( 128, 128, 128, 0.06 );
	--wcrb-muted: rgba( 128, 128, 128, 0.85 );

	margin: 0 0 1.5em;

	/*
	 * Many themes lay out `form.cart` as a flex or grid row (quantity, button).
	 * Claim a whole row so the dates never have to share it with the add to cart
	 * button. Both declarations are inert in a plain block level form.
	 */
	flex: 1 0 100%;
	grid-column: 1 / -1;
	width: 100%;
}

/*
|--------------------------------------------------------------------------
| The two date fields, side by side
|--------------------------------------------------------------------------
*/

.wcrb-rental-fields .wcrb-rental-dates {
	align-items: end;
	display: grid;
	gap: var( --wcrb-gap );
	grid-template-columns: 1fr auto 1fr;
	margin: 0 0 0.85em;
}

.wcrb-rental-fields .wcrb-field {
	display: flex;
	flex-direction: column;
	margin: 0;
	min-width: 0;
	padding: 0;
}

.wcrb-rental-fields .wcrb-field__label {
	display: flex;
	align-items: baseline;
	gap: 0.25em;
	font-size: 0.8125em;
	font-weight: 600;
	letter-spacing: 0.02em;
	line-height: 1.3;
	margin: 0 0 0.4em;
	opacity: 0.9;
	text-transform: uppercase;
}

.wcrb-rental-fields .wcrb-required {
	border: 0;
	color: inherit;
	opacity: 0.55;
	text-decoration: none;
}

/* The arrow that reads "from this date to that date". */
.wcrb-rental-fields .wcrb-dates-arrow {
	align-self: end;
	display: block;
	height: 2.75rem;
	opacity: 0.45;
	position: relative;
	width: 1em;
}

.wcrb-rental-fields .wcrb-dates-arrow::before {
	border-right: 2px solid currentColor;
	border-top: 2px solid currentColor;
	content: "";
	height: 0.5em;
	left: 50%;
	position: absolute;
	top: 50%;
	transform: translate( -50%, -50% ) rotate( 45deg );
	width: 0.5em;
}

/*
|--------------------------------------------------------------------------
| The date inputs
|--------------------------------------------------------------------------
*/

.wcrb-rental-fields input.wcrb-date-input {
	-webkit-appearance: none;
	appearance: none;
	background-color: transparent;
	border: 1px solid var( --wcrb-border );
	border-radius: var( --wcrb-radius );
	box-shadow: none;
	box-sizing: border-box;
	color: inherit;
	display: block;
	font: inherit;
	font-size: 1em;
	line-height: 1.4;
	margin: 0;
	max-width: 100%;
	min-height: 2.75rem;
	padding: 0.625em 0.75em;
	transition: border-color 0.15s ease, box-shadow 0.15s ease;
	width: 100%;
}

.wcrb-rental-fields input.wcrb-date-input:hover {
	border-color: var( --wcrb-border-strong );
}

.wcrb-rental-fields input.wcrb-date-input:focus,
.wcrb-rental-fields input.wcrb-date-input:focus-visible {
	border-color: currentColor;
	box-shadow: 0 0 0 3px rgba( 128, 128, 128, 0.18 );
	outline: none;
}

/* Keep the native calendar button aligned and on-theme. */
.wcrb-rental-fields input.wcrb-date-input::-webkit-calendar-picker-indicator {
	cursor: pointer;
	opacity: 0.55;
}

.wcrb-rental-fields input.wcrb-date-input:hover::-webkit-calendar-picker-indicator {
	opacity: 0.85;
}

/* Safari and iOS give date inputs an intrinsic width; override it. */
.wcrb-rental-fields input.wcrb-date-input::-webkit-date-and-time-value {
	text-align: left;
}

/*
|--------------------------------------------------------------------------
| Hints and messages
|--------------------------------------------------------------------------
*/

.wcrb-rental-fields .wcrb-duration-hint,
.wcrb-rental-fields .wcrb-unavailable-dates {
	font-size: 0.8125em;
	line-height: 1.5;
	margin: 0 0 0.75em;
	opacity: 0.75;
}

.wcrb-rental-fields .wcrb-discount-note {
	display: flex;
	align-items: center;
	gap: 0.75em;
	margin: 0.875em 0;
	padding: 0.75em 1em;
	border: 1px solid rgba( 73, 151, 109, 0.35 );
	border-inline-start: 4px solid #49976d;
	border-radius: var( --wcrb-radius );
	background: linear-gradient( 135deg, rgba( 73, 151, 109, 0.14 ), rgba( 73, 151, 109, 0.04 ) );
	color: #24533a;
	font-size: 0.9375em;
	font-weight: 500;
	line-height: 1.5;
}

.wcrb-rental-fields .wcrb-discount-note__icon {
	display: inline-flex;
	flex-shrink: 0;
	align-items: center;
	justify-content: center;
	width: 2.25em;
	height: 2.25em;
	border-radius: 50%;
	background: #49976d;
	color: #fff;
	font-size: 0.9375em;
	font-weight: 700;
	line-height: 1;
	box-shadow: 0 2px 6px rgba( 73, 151, 109, 0.35 );
}

/* Marker pen highlight on the key phrase. */
.wcrb-rental-fields .wcrb-discount-note mark {
	/* Negative margin lets the highlight bleed past the letters without adding space before the comma. */
	margin: 0 -0.15em;
	padding: 0 0.15em;
	background: linear-gradient( transparent 55%, rgba( 255, 205, 40, 0.7 ) 55% );
	color: inherit;
	font-weight: 700;
	text-decoration: none;
	-webkit-box-decoration-break: clone;
	box-decoration-break: clone;
}

.wcrb-rental-fields .wcrb-discount-note strong {
	color: #1d7a4a;
	font-weight: 700;
}

.wcrb-rental-fields .wcrb-unavailable-label {
	display: inline-block;
	font-weight: 600;
	margin-right: 0.35em;
	opacity: 0.9;
}

/*
|--------------------------------------------------------------------------
| Price summary
|--------------------------------------------------------------------------
*/

.wcrb-rental-fields .wcrb-rental-summary {
	background: var( --wcrb-surface );
	border: 1px solid var( --wcrb-border );
	border-radius: var( --wcrb-radius );
	margin: 0 0 1.25em;
	padding: 0.85em 1em;
}

.wcrb-rental-fields .wcrb-summary-status:not(:empty) {
	display: block;
	font-size: 0.8125em;
	margin-bottom: 0.5em;
	opacity: 0.7;
}

.wcrb-rental-fields table.wcrb-summary-table {
	border: 0;
	border-collapse: collapse;
	margin: 0;
	table-layout: auto;
	width: 100%;
}

.wcrb-rental-fields table.wcrb-summary-table tr {
	background: transparent;
	border: 0;
}

.wcrb-rental-fields table.wcrb-summary-table th,
.wcrb-rental-fields table.wcrb-summary-table td {
	background: transparent;
	border: 0;
	border-bottom: 1px solid var( --wcrb-border );
	font-size: 0.9375em;
	font-weight: 400;
	line-height: 1.45;
	padding: 0.5em 0;
	vertical-align: baseline;
}

.wcrb-rental-fields table.wcrb-summary-table th {
	opacity: 0.8;
	padding-right: 1em;
	text-align: left;
	white-space: nowrap;
}

.wcrb-rental-fields table.wcrb-summary-table td {
	font-variant-numeric: tabular-nums;
	text-align: right;
	white-space: nowrap;
}

/* The rental total is the number that matters. */
.wcrb-rental-fields table.wcrb-summary-table tr:last-child th,
.wcrb-rental-fields table.wcrb-summary-table tr:last-child td {
	border-bottom: 0;
	font-size: 1.0625em;
	font-weight: 700;
	opacity: 1;
	padding-bottom: 0;
	padding-top: 0.65em;
}

.wcrb-rental-fields .wcrb-summary-error {
	font-size: 0.875em;
	font-weight: 600;
	line-height: 1.5;
	margin: 0 0 0.5em;
}

.wcrb-rental-fields .wcrb-summary-placeholder {
	font-size: 0.875em;
	line-height: 1.5;
	margin: 0;
	opacity: 0.8;
}

.wcrb-hidden {
	display: none !important;
}

/*
|--------------------------------------------------------------------------
| Cart and mini cart
|--------------------------------------------------------------------------
*/

.wcrb-mini-cart-rental {
	display: block;
	font-size: 0.85em;
	opacity: 0.85;
}

.wcrb-mini-cart-duration::before {
	content: " \00b7 ";
}

/*
|--------------------------------------------------------------------------
| Narrow screens
|--------------------------------------------------------------------------
*/

@media screen and ( max-width: 480px ) {
	.wcrb-rental-fields .wcrb-rental-dates {
		gap: 0.75rem;
		grid-template-columns: 1fr;
	}

	/* The arrow only makes sense when the fields sit side by side. */
	.wcrb-rental-fields .wcrb-dates-arrow {
		display: none;
	}

	.wcrb-rental-fields table.wcrb-summary-table th {
		white-space: normal;
	}
}

/*
|--------------------------------------------------------------------------
| Respect reduced motion
|--------------------------------------------------------------------------
*/

@media ( prefers-reduced-motion: reduce ) {
	.wcrb-rental-fields input.wcrb-date-input {
		transition: none;
	}
}
