/*
 * TableNow ordering module structural styles ONLY (layout, spacing,
 * flex/grid resets). Loaded on top of tablenow-menu.css when the ordering
 * module is enabled. Deliberately free of brand colors/fonts so the active
 * theme's own CSS can fully restyle every BEM class below.
 *
 * Covers the per-dish ordering controls (add toggle, variant picker,
 * quantity), the sticky order sidebar, and the delivery-request modal.
 */

.tablenow-menu__item-toggle {
	flex: 0 0 auto;
	cursor: pointer;
}

.tablenow-menu__item-form {
	display: flex;
	flex-direction: column;
	gap: 0.5rem;
}

.tablenow-menu__item-form[hidden] {
	display: none;
}

.tablenow-menu__variant-group {
	border: 0;
	margin: 0;
	padding: 0;
	display: flex;
	flex-direction: column;
	gap: 0.25rem;
}

.tablenow-menu__variant-group-label {
	padding: 0;
}

.tablenow-menu__variant-option {
	display: flex;
	align-items: center;
	gap: 0.25rem;
	/* Some mobile/WebKit browsers mis-hit-test a bare radio flex child with no
	   intrinsic size, making it feel unclickable even though it's wrapped in
	   this label. Give it explicit dimensions and a min-height tap target. */
	min-height: 1.75rem;
}

.tablenow-menu__variant-option input[type='radio'] {
	flex: 0 0 auto;
	width: 1.125rem;
	height: 1.125rem;
	margin: 0;
}

.tablenow-menu__item-quantity {
	display: flex;
	align-items: center;
	gap: 0.5rem;
}

.tablenow-menu__item-quantity-stepper {
	display: inline-flex;
	align-items: center;
	gap: 0.25rem;
}

.tablenow-menu__item-quantity-input {
	width: 4rem;
	text-align: center;
}

.tablenow-menu__item-quantity-minus,
.tablenow-menu__item-quantity-plus {
	cursor: pointer;
}

.tablenow-order {
	flex: 1 1 280px;
	min-width: 260px;
	position: sticky;
	top: 1rem;
	align-self: flex-start;
	display: flex;
	flex-direction: column;
	gap: 0.75rem;
	/* Cart lines can grow taller than the viewport; without an internal scroll
	   the total and the order button below a long line list become unreachable
	   (sticky only pins the box, it does not clip/scroll its own overflowing
	   content). Themes overriding `top` should override this to match. */
	max-height: calc( 100vh - 2rem );
	overflow-y: auto;
}

.tablenow-order__header {
	display: flex;
	align-items: flex-start;
	justify-content: space-between;
	gap: 0.75rem;
}

.tablenow-order__title {
	margin: 0;
}

/* Only meaningful once the panel becomes a bottom sheet (see the media query
   at the end of this file). */
.tablenow-order__close {
	display: none;
	cursor: pointer;
}

.tablenow-order__empty[hidden],
.tablenow-order__cart[hidden],
.tablenow-order__paused[hidden] {
	display: none;
}

.tablenow-order__empty {
	margin: 0;
}

/* Takes the empty/cart slot's place when both fulfillment types are paused
   (see tablenow-ordering.js renderCart()); its own margin is left to the
   theme skin, only the title/text default <p> margins are reset here. */
.tablenow-order__paused-title,
.tablenow-order__paused-text {
	margin: 0;
}

.tablenow-order__cart {
	display: flex;
	flex-direction: column;
	gap: 0.75rem;
}

.tablenow-order__lines {
	list-style: none;
	margin: 0;
	padding: 0;
	display: flex;
	flex-direction: column;
	gap: 0.5rem;
}

/* Four fixed columns — ellipsized name, quantity stepper, right-aligned
   price, remove button — so controls and prices line up vertically across
   rows no matter how long the dish name is. */
.tablenow-order__line {
	display: grid;
	grid-template-columns: minmax( 0, 1fr ) auto auto auto;
	align-items: center;
	gap: 0.75rem;
}

.tablenow-order__line-qty {
	display: inline-flex;
	align-items: center;
	gap: 0.25rem;
}

.tablenow-order__line-qty-minus,
.tablenow-order__line-qty-plus {
	cursor: pointer;
}

.tablenow-order__line-qty-value {
	min-width: 1.5rem;
	text-align: center;
}

.tablenow-order__line-label {
	min-width: 0;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.tablenow-order__line-subtotal {
	text-align: right;
}

/* Per-line note: its own full-width row under the four line columns. */
.tablenow-order__line-note {
	grid-column: 1 / -1;
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 0.5rem;
}

.tablenow-order__line-note-toggle {
	cursor: pointer;
	font-size: 0.85em;
}

.tablenow-order__line-note-input {
	flex: 1 1 12rem;
	min-width: 0;
	box-sizing: border-box;
}

.tablenow-order__line-note-input[hidden] {
	display: none;
}

.tablenow-order__total {
	display: flex;
	justify-content: space-between;
	margin: 0;
}

/* The delivery total row toggles via [hidden]; display:flex would win. */
.tablenow-order__total[hidden] {
	display: none;
}

.tablenow-order__place {
	cursor: pointer;
}

.tablenow-order__message:empty {
	display: none;
}

/*
 * Delivery-request modal. Appended to <body>, so these selectors are
 * intentionally un-nested and must not rely on `.tablenow-app` scope.
 */

.tablenow-order-modal {
	position: fixed;
	inset: 0;
	z-index: 1000;
	display: flex;
}

/* `display: flex` above would otherwise defeat the `hidden` attribute. */
.tablenow-order-modal[hidden] {
	display: none;
}

/* Stops the page behind the dialog from scrolling with it. */
body.tablenow-order-modal-open {
	overflow: hidden;
}

/* The dialog fills the overlay edge to edge and never scrolls as a whole: its
   body is the only scroll container. Height tracks the fixed overlay rather
   than `100vh`, which on mobile would run under the browser chrome. */
.tablenow-order-modal__dialog {
	position: relative;
	width: 100%;
	height: 100%;
	box-sizing: border-box;
	display: flex;
	flex-direction: column;
	gap: 1rem;
	overflow: hidden;
}

/* Full-bleed applies to the surface, not the form: left unbounded on a wide
   monitor, the two-column grid would stretch its inputs past readability. The
   header shares the cap so the close button tracks the content edge. */
.tablenow-order-modal__header,
.tablenow-order-modal__body {
	width: 100%;
	max-width: 68rem;
	margin-inline: auto;
}

.tablenow-order-modal__header {
	position: relative;
	flex: 0 0 auto;
}

.tablenow-order-modal__title {
	margin: 0;
}

/* Eyebrow above the title. The gap lives here because this rule set loads after
   the theme skin, so a margin declared there would never win. */
.tablenow-order-modal__subtitle {
	margin: 0 0 2px;
}

.tablenow-order-modal__close {
	position: absolute;
	top: 0;
	right: 0;
	cursor: pointer;
}

.tablenow-order-modal__body {
	flex: 1 1 auto;
	/* `min-height: 0` lets this flex child shrink below its content height,
	   which is what makes the scrollbar land here and not on the dialog. */
	min-height: 0;
	overflow-y: auto;
}

.tablenow-order-modal__body[hidden] {
	display: none;
}

.tablenow-order-modal__intro {
	margin: 0 0 0.5rem;
}

.tablenow-order-modal__columns {
	display: grid;
	grid-template-columns: minmax( 0, 1.15fr ) minmax( 0, 0.85fr );
	gap: 1.5rem;
	align-items: start;
}

.tablenow-order-modal__col {
	display: flex;
	flex-direction: column;
	gap: 0.85rem;
	min-width: 0;
}

/* Pairs of short fields (phone/email, postal code/extra) share a line. Bottom
   alignment keeps the two inputs on one baseline when only one of the labels
   wraps to a second line. */
.tablenow-order-modal__row {
	display: grid;
	grid-template-columns: repeat( 2, minmax( 0, 1fr ) );
	gap: 0.75rem;
	align-items: end;
}

/* One column below the two-column threshold: a stacked form is still readable,
   a squeezed one is not. */
@media ( max-width: 860px ) {
	.tablenow-order-modal__columns,
	.tablenow-order-modal__row {
		grid-template-columns: minmax( 0, 1fr );
	}
}

.tablenow-order-modal__fieldset {
	border: 0;
	margin: 0;
	padding: 0;
	display: flex;
	flex-direction: column;
	gap: 0.4rem;
}

/* `display: flex` above would otherwise beat the user-agent [hidden] rule, so
   the pickup path could not hide the delivery-address fieldset. */
.tablenow-order-modal__fieldset[hidden] {
	display: none;
}

.tablenow-order-modal__legend {
	padding: 0;
}

/* Bestellart: legend and both modes share one row. Stacking them would cost the
   ~30px of height that keeps the delivery form inside a laptop viewport without
   scrolling; on a narrow sheet they wrap instead of overflowing. */
.tablenow-order-modal__fieldset--order-type {
	flex-direction: row;
	flex-wrap: wrap;
	align-items: baseline;
	column-gap: 1.25rem;
}

.tablenow-order-modal__order-type {
	display: flex;
	flex-wrap: wrap;
	gap: 0.25rem 1.25rem;
}

.tablenow-order-modal__order-type-choice {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 0.5rem;
}

.tablenow-order-modal__order-type-input {
	flex: 0 0 auto;
	cursor: pointer;
}

.tablenow-order-modal__order-type-input:disabled {
	cursor: not-allowed;
}

.tablenow-order-modal__order-type-label {
	cursor: pointer;
}

/* flex-basis: 100% forces this onto its own line under input+label within
   the wrapping flex row above, regardless of viewport width. */
.tablenow-order-modal__order-type-notice[hidden] {
	display: none;
}

.tablenow-order-modal__order-type-notice {
	flex-basis: 100%;
	margin: 0;
}

.tablenow-order-modal__upcoming-notice[hidden] {
	display: none;
}

.tablenow-order-modal__upcoming-notice {
	margin: 0.35rem 0 0;
}

/* Wunschzeit: "as soon as possible" / "pick a time" + its HH:MM picker. */
.tablenow-order-modal__time-option {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 0.5rem;
}

.tablenow-order-modal__time-mode-input,
.tablenow-order-modal__time-mode-label {
	cursor: pointer;
}

.tablenow-order-modal__time-mode-input {
	flex: 0 0 auto;
}

.tablenow-order-modal__input.tablenow-order-modal__time-input {
	width: auto;
	min-width: 8rem;
}

.tablenow-order-modal__input.tablenow-order-modal__time-input:disabled {
	opacity: 0.5;
	cursor: not-allowed;
}

/* Vorbestellung: day + time selects, and the "closed, but you can pre-order" notes. */
.tablenow-order-modal__slot-pickers {
	display: flex;
	flex-wrap: wrap;
	gap: 0.5rem;
	flex: 1 1 100%;
}

.tablenow-order-modal__slot-pickers[hidden],
.tablenow-order-modal__preorder-note[hidden],
.tablenow-order-modal__scheduled[hidden],
.tablenow-order__preorder-note[hidden],
.tablenow-order-modal__time-option[hidden] {
	display: none;
}

.tablenow-order-modal__input.tablenow-order-modal__slot-select {
	flex: 1 1 9rem;
	width: auto;
	min-width: 0;
}

.tablenow-order-modal__preorder-note,
.tablenow-order__preorder-note {
	margin: 0.35rem 0 0;
}

/* A line's note, under its label in the read-only summary. */
.tablenow-order-modal__summary-note {
	display: block;
	font-size: 0.85em;
}

.tablenow-order-modal__field {
	display: flex;
	flex-direction: column;
	gap: 0.25rem;
}

.tablenow-order-modal__input {
	width: 100%;
	box-sizing: border-box;
}

.tablenow-order-modal__summary-panel,
.tablenow-order-modal__summary {
	display: flex;
	flex-direction: column;
	gap: 0.5rem;
}

.tablenow-order-modal__summary-title {
	margin: 0;
}

.tablenow-order-modal__summary-lines {
	list-style: none;
	margin: 0;
	padding: 0;
	display: flex;
	flex-direction: column;
	gap: 0.25rem;
}

/* Expanding a long cart gives the list its own scroll area, so revealing the
   hidden lines can never push the dialog past the viewport. */
.tablenow-order-modal__summary-lines--expanded {
	max-height: 11rem;
	overflow-y: auto;
}

.tablenow-order-modal__summary-line[hidden] {
	display: none;
}

.tablenow-order-modal__summary-toggle {
	align-self: flex-start;
	cursor: pointer;
}

.tablenow-order-modal__summary-line,
.tablenow-order-modal__summary-total {
	display: flex;
	justify-content: space-between;
	gap: 0.75rem;
	margin: 0;
}

.tablenow-order-modal__summary-subtotal {
	white-space: nowrap;
}

.tablenow-order-modal__consent-heading {
	margin: 0;
}

.tablenow-order-modal__consent {
	display: flex;
	align-items: flex-start;
	gap: 0.5rem;
}

.tablenow-order-modal__consent-input {
	flex: 0 0 auto;
	margin-top: 0.25rem;
}

.tablenow-order-modal__submit,
.tablenow-order-modal__done {
	cursor: pointer;
}

.tablenow-order-modal__message:empty {
	display: none;
}

.tablenow-order-modal__reference {
	display: flex;
	gap: 0.5rem;
}

/*
 * Floating cart button + bottom-sheet order panel.
 *
 * On a wide viewport the panel is a sticky sidebar next to the menu and the
 * button is not rendered at all. Below the breakpoint the menu takes the full
 * width, which would strand the panel below hundreds of dishes — so the panel
 * becomes a dismissable sheet and this button summons it.
 *
 * The button lives on <body>, outside `.tablenow-app`, so its selectors are
 * intentionally un-nested. The breakpoint below must stay in step with the
 * theme's own `.tablenow-app` stacking breakpoint.
 */

.tablenow-order-fab {
	display: none;
	position: fixed;
	right: 1rem;
	bottom: 1rem;
	z-index: 900;
	align-items: center;
	justify-content: center;
	cursor: pointer;
}

.tablenow-order-fab__icon {
	width: 1.5rem;
	height: 1.5rem;
	pointer-events: none;
}

.tablenow-order-fab__count {
	position: absolute;
	top: -0.25rem;
	right: -0.25rem;
	display: flex;
	align-items: center;
	justify-content: center;
	pointer-events: none;
}

.tablenow-order-fab__count[hidden] {
	display: none;
}

/* The dialog already owns the screen; a cart button floating over it would
   only compete with its own summary. Un-nested, so it beats the media query
   below on specificity regardless of source order. */
body.tablenow-order-modal-open .tablenow-order-fab {
	display: none;
}

@media ( max-width: 900px ) {
	.tablenow-order-fab {
		display: inline-flex;
	}

	.tablenow-order__close {
		display: inline-flex;
	}

	.tablenow-order {
		position: fixed;
		left: 1rem;
		right: 1rem;
		bottom: 5.25rem;
		top: auto;
		z-index: 899;
		max-height: min( 70vh, 32rem );
		overflow-y: auto;
		box-sizing: border-box;

		/* Closed: removed from the tab order and from hit-testing, but still
		   laid out so the open transition has something to animate. */
		visibility: hidden;
		opacity: 0;
		transform: translateY( 0.75rem );
		transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s;
	}

	.tablenow-order--open {
		visibility: visible;
		opacity: 1;
		transform: none;
	}
}

@media ( prefers-reduced-motion: reduce ) {
	.tablenow-order {
		transition: none;
	}
}
