/**
 * Open Hours Booking (VX) widget styles.
 *
 * Theme-first: every colour, border and surface is pulled from Voxel's design
 * tokens (--ts-shade-1…7 = text→light bg; --ts-accent-1 = the theme accent) via a
 * small "bridge" of local vars, each with a safe fallback so nothing breaks if a
 * token is missing. Typography is inherited from the theme (no font-family here).
 * Interactive controls reuse Voxel's own classes (.ts-btn, .ts-filter,
 * .ts-stepper-input, .ts-icon-btn) so they already match the theme — this file only
 * adds the calendar grid + layout the theme has no equivalent for.
 *
 * @package VxBookings
 */

.vxb-ohb {
	/* Theme bridge — map Voxel tokens to semantic names (fallbacks keep it safe). */
	--vxb-text: var(--ts-shade-1, #313135);
	--vxb-muted: var(--ts-shade-2, #797a88);
	--vxb-border: var(--ts-shade-4, #dadfe4);
	--vxb-bg-soft: var(--ts-shade-5, #f3f3f3);
	--vxb-bg: var(--ts-shade-7, #fff);
	--vxb-accent: var(--ts-accent-1, #4f46e5);
	--vxb-on-accent: #fff;
	--vxb-radius: 8px;

	display: flex;
	flex-direction: column;
	gap: 20px;
	max-width: 420px;
	color: inherit;
}

.vxb-ohb[v-cloak] {
	display: none;
}

/* Flatten the browser's default 3D button bevel. A native <button> gets a UA
   `border: 2px outset`; Voxel never resets it because it styles <a class="ts-btn">,
   while we use <button> for real actions (correct keyboard/screen-reader semantics).
   Wrapped in :where() so this carries ZERO specificity — any button that sets its own
   border (our nav/stepper buttons, or an Elementor "Buttons" border control) wins. */
:where( .vxb-ohb button ) {
	border: 0;
}

/* --- Date/time popup ---
   The popup box is teleported to <body>, outside our widget. We re-declare the SAME theme
   bridge vars here as on .vxb-ohb so the calendar + dropdowns read the theme EXACTLY like
   the inline version (shade-1 ↔ shade-7 always contrast, so the dropdowns can't go
   white-on-white). We add ONLY popup layout (padding, compact sizing, heading, back
   button); all COLOURS come from the base .vxb-ohb-* rules + the Elementor "Calendar" and
   "Date & time popup" controls — which reach the popup because Voxel stamps
   .elementor-element-{id} (our {{WRAPPER}}) on the popup root. */
.vxb-ohb-pop {
	--vxb-text: var(--ts-shade-1, #313135);
	--vxb-muted: var(--ts-shade-2, #797a88);
	--vxb-border: var(--ts-shade-4, #dadfe4);
	--vxb-bg-soft: var(--ts-shade-5, #f3f3f3);
	--vxb-bg: var(--ts-shade-7, #fff);
	--vxb-accent: var(--ts-accent-1, #4f46e5);
	--vxb-on-accent: #fff;
	--vxb-radius: 8px;

	color: var(--vxb-text);
	padding: 16px;
	box-sizing: border-box;
}

.vxb-ohb-pop *,
.vxb-ohb-pop *::before,
.vxb-ohb-pop *::after {
	box-sizing: border-box;
}

/* Step heading (our own class — NOT Voxel's .datepicker-head, which forces its own
   font-size + icon colour and would fight the Elementor controls). */
.vxb-ohb-phead {
	position: relative;
	margin: 0 0 14px;
	padding: 0;
}

.vxb-ohb-phead h3 {
	display: flex;
	align-items: center;
	gap: 8px;
	margin: 0;
	font-size: 1.05em;
	font-weight: 700;
	color: var(--vxb-text);
}

.vxb-ohb-phead h3 svg {
	color: var(--vxb-accent);
	flex: 0 0 auto;
}

.vxb-ohb-phead p {
	margin: 4px 0 0;
	font-size: 0.85em;
	color: var(--vxb-muted);
}

/* Back-to-calendar button (top-right of the time step). Our own class — Voxel's
   .ts-icon-btn is hidden/sized by theme rules in some contexts. */
.vxb-ohb-back {
	position: absolute;
	top: -4px;
	right: 0;
	width: 34px;
	height: 34px;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	border: 1px solid var(--vxb-border);
	border-radius: 8px;
	color: var(--vxb-text);
	background: var(--vxb-bg-soft);
	cursor: pointer;
	transition: border-color 0.15s ease, color 0.15s ease;
}

.vxb-ohb-back:hover {
	border-color: var(--vxb-accent);
	color: var(--vxb-accent);
}

/* Compact calendar — no inner card (the popup IS the card) + smaller cells so it fits
   without a scrollbar. Layout only; colours come from the Calendar controls. */
.vxb-ohb-pop .vxb-ohb-cal {
	border: 0;
	padding: 0;
}

.vxb-ohb-pop .vxb-ohb-day {
	aspect-ratio: auto;
	height: 36px;
	font-size: 13px;
}

/* Space between the heading and the calendar/time body. */
.vxb-ohb-pop .vxb-ohb-cal,
.vxb-ohb-pop .vxb-ohb-time-grid {
	margin-top: 0;
}

/* Start + end time shown side by side (popup and inline). */
.vxb-ohb-time-grid {
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: 12px;
}

.vxb-ohb-time-col {
	display: flex;
	flex-direction: column;
	gap: 6px;
	min-width: 0;
}

.vxb-ohb-heading {
	font-size: 1.15em;
	font-weight: 700;
	line-height: 1.3;
}

.vxb-ohb-section {
	display: flex;
	flex-direction: column;
	gap: 10px;
}

.vxb-ohb-label {
	font-weight: 600;
	font-size: 0.95em;
}

.vxb-ohb-muted {
	color: var(--vxb-muted);
	font-size: 0.9em;
}

/* --- Calendar --- */
.vxb-ohb-cal {
	border: 1px solid var(--vxb-border);
	border-radius: calc(var(--vxb-radius) + 2px);
	padding: 12px;
}

.vxb-ohb-cal-head {
	display: flex;
	align-items: center;
	justify-content: space-between;
	margin-bottom: 10px;
}

.vxb-ohb-cal-title {
	font-weight: 600;
}

/* Month + year jump dropdowns in the calendar header (inline AND popup) — small
   select-buttons so far-future dates don't need a dozen arrow clicks. */
.vxb-ohb-cal-selects {
	display: flex;
	gap: 6px;
}

.vxb-ohb-cal-sel {
	position: relative;
	display: inline-flex;
}

.vxb-ohb-cal-sel select {
	appearance: none;
	-webkit-appearance: none;
	-moz-appearance: none;
	font: inherit;
	font-size: 0.95em;
	line-height: 1.2;
	color: var(--vxb-text);
	background-color: var(--vxb-bg-soft);
	border: 1px solid var(--vxb-border);
	border-radius: 6px;
	padding: 5px 24px 5px 9px;
	cursor: pointer;
	transition: border-color 0.15s ease;
}

.vxb-ohb-cal-sel select:focus {
	outline: none;
	border-color: var(--vxb-accent);
}

.vxb-ohb-cal-sel select option {
	/* Open list: own controllable pair (--vxb-dd-*) with hard literal fallbacks, so a
	   theme that maps the shade tokens oddly can never produce white-on-white items. */
	color: var(--vxb-dd-text, #1f2430);
	background: var(--vxb-dd-bg, #fff);
}

.vxb-ohb-cal-sel .vxb-ohb-chevron {
	right: 9px;
	width: 6px;
	height: 6px;
	margin-top: -4px;
}

.vxb-ohb-nav {
	width: 34px;
	height: 34px;
	min-width: 34px;
	border: 1px solid var(--vxb-border);
	border-radius: 50%;
	background: var(--vxb-bg-soft);
	color: inherit;
	cursor: pointer;
	line-height: 0;
	padding: 0;
	display: inline-flex;
	align-items: center;
	justify-content: center;
}

.vxb-ohb-nav svg {
	display: block;
}

.vxb-ohb-nav:hover {
	border-color: var(--vxb-accent);
	color: var(--vxb-accent);
}

.vxb-ohb-nav:disabled {
	opacity: 0.35;
	cursor: default;
}

.vxb-ohb-weekdays,
.vxb-ohb-grid {
	display: grid;
	grid-template-columns: repeat(7, 1fr);
	gap: 4px;
}

.vxb-ohb-weekdays {
	margin-bottom: 4px;
}

.vxb-ohb-weekdays span {
	text-align: center;
	font-size: 0.72em;
	text-transform: uppercase;
	letter-spacing: 0.03em;
	color: var(--vxb-muted);
	padding: 4px 0;
}

.vxb-ohb-day {
	aspect-ratio: 1 / 1;
	display: flex;
	align-items: center;
	justify-content: center;
	border: 1px solid transparent;
	border-radius: var(--vxb-radius);
	background: transparent;
	color: inherit;
	font: inherit;
	font-size: 0.9em;
	cursor: pointer;
	padding: 0;
}

.vxb-ohb-day.is-empty {
	visibility: hidden;
}

.vxb-ohb-day.is-available {
	background: var(--vxb-bg-soft);
}

.vxb-ohb-day.is-available:hover {
	border-color: var(--vxb-accent);
}

.vxb-ohb-day.is-disabled {
	/* Unavailable: blocked, outside the booking window, closed, or fully booked. Stays
	   visible (a muted, struck-through number) instead of fading to nothing — opacity:0.35
	   made these vanish on some backgrounds. Both colours are overridable in the Style tab. */
	cursor: not-allowed;
	color: var(--vxb-muted);
	background: transparent;
	text-decoration: line-through;
	text-decoration-thickness: 1px;
}

.vxb-ohb-day.is-selected {
	background: var(--vxb-accent);
	border-color: var(--vxb-accent);
	color: var(--vxb-on-accent);
	font-weight: 700;
}

/* --- Start stepper: inherits Voxel's native .ts-stepper-input / .ts-icon-btn look.
   We only keep the value box from jumping width as the time changes. --- */
.vxb-ohb-step-val {
	min-width: 84px;
	text-align: center;
	display: inline-flex;
	align-items: center;
	justify-content: center;
}

.vxb-ohb-step:disabled {
	opacity: 0.4;
	cursor: default;
}

/* --- Time dropdowns (Start / End — popup AND inline) ---
   A fully self-styled native <select>. We deliberately do NOT use Voxel's .ts-filter
   wrapper: .ts-filter forces the inner <select> to position:absolute + background:
   transparent (Voxel's custom-dropdown overlay pattern), which made our native selects
   unreadable (white-on-white) and impossible to recolour. Owning the markup + styling
   means our CSS — and the Elementor controls — win cleanly. */
.vxb-ohb-select {
	position: relative;
}

.vxb-ohb-select select {
	width: 100%;
	margin: 0;
	appearance: none;
	-webkit-appearance: none;
	-moz-appearance: none;
	padding: 10px 34px 10px 12px;
	border: 1px solid var(--vxb-border);
	border-radius: var(--vxb-radius);
	background-color: var(--vxb-bg);
	color: var(--vxb-text);
	font: inherit;
	line-height: 1.3;
	cursor: pointer;
	transition: border-color 0.15s ease;
}

.vxb-ohb-select select:focus {
	outline: none;
	border-color: var(--vxb-accent);
}

.vxb-ohb-select select option {
	color: var(--vxb-dd-text, #1f2430);
	background: var(--vxb-dd-bg, #fff);
}

/* Custom chevron (we dropped Voxel's .ts-down-icon, which needs the .ts-filter context). */
.vxb-ohb-chevron {
	position: absolute;
	top: 50%;
	right: 13px;
	width: 8px;
	height: 8px;
	margin-top: -6px;
	border-right: 2px solid var(--vxb-muted);
	border-bottom: 2px solid var(--vxb-muted);
	transform: rotate(45deg);
	pointer-events: none;
}

/* Native <select> otherwise inherits the page text colour (often light on a dark
   theme) while rendering on a light system field → white-on-white. Pin the closed
   field AND the popup option list to the theme's contrasting text/bg token PAIR
   (shade-1 ↔ shade-7 are opposite ends of one scale, so they always contrast — on a
   light theme OR a dark one). Covers our end-time select and the addon ".ts-filter"
   dropdowns alike. */
.vxb-ohb select {
	color: var(--vxb-text);
	background-color: var(--vxb-bg);
}

.vxb-ohb select option {
	color: var(--vxb-dd-text, #1f2430);
	background: var(--vxb-dd-bg, #fff);
}

/* --- Footer: price + button --- */
.vxb-ohb-footer {
	display: flex;
	flex-direction: column;
	gap: 12px;
}

.vxb-ohb-price {
	display: flex;
	align-items: baseline;
	gap: 8px;
	flex-wrap: wrap;
}

.vxb-ohb-price-label {
	font-weight: 600;
}

.vxb-ohb-price-amount {
	font-size: 1.3em;
	font-weight: 700;
}

.vxb-ohb-duration {
	color: var(--vxb-muted);
	font-size: 0.85em;
}

.vxb-ohb-error {
	color: var(--ts-error, #d33);
	font-size: 0.9em;
}

.vxb-ohb-book {
	width: 100%;
	justify-content: center;
	text-align: center;
}

.vxb-ohb-book:disabled {
	opacity: 0.5;
	cursor: default;
}

.vxb-ohb-login {
	display: flex;
}

/* --- Extra options (addons) ---
   The markup mirrors Voxel's product form, so the look comes from vx:forms.css +
   vx:product-form.css (.ts-form-group, .onoffswitch toggle, .ts-addition-list choice
   lists, .vx-addon-price, steppers). We only set the section rhythm + the "required"
   tag; we deliberately add NO card/box/shadow of our own. --- */
.vxb-ohb-addons {
	display: flex;
	flex-direction: column;
	gap: 14px;
}

.vxb-ohb-addons-heading {
	font-weight: 600;
}

/* Use our section spacing between addon groups instead of Voxel's default margin
   (avoids double spacing) — keeps the whole widget's rhythm consistent. */
.vxb-ohb-addons .ts-form-group {
	margin: 0;
}

.vxb-ohb-req {
	font-style: normal;
	font-size: 0.72em;
	text-transform: uppercase;
	letter-spacing: 0.03em;
	color: var(--vxb-accent);
	margin-left: 6px;
}

/* --- Responsive --- */
@media (max-width: 480px) {
	.vxb-ohb {
		max-width: 100%;
	}

	.vxb-ohb-times {
		grid-template-columns: repeat(auto-fill, minmax(64px, 1fr));
	}
}
