/*
 * JB Tickets: seat selection. Neutral base styles, the theme restyles them through the custom
 * properties below. Zone color comes in --jb-zone on each seat (SchemeRenderer).
 * The background shema4.svg draws the seats itself (dark squares with white numbers), so a free
 * seat has no fill (as in movie-booking), states are tinted and the numbers stay readable. State
 * colors come from the settings (Admin\SettingsPage) as inline --jb-selected, --jb-held, --jb-sold.
 * Zone tint of free seats: only with .jb-seat-selection--zones (a hall with several zones).
 */

.jb-seat-selection {
	--jb-accent: #bd905b;
	--jb-accent-text: #fff;
	--jb-text: #1f1f1f;
	--jb-muted: #737373;
	--jb-border: #d9d9d9;
	--jb-surface: #fff;
	--jb-selected: #8bc34a;
	--jb-held: #ff9800;
	--jb-sold: #f44336;
	--jb-focus: #1d5fbf;
	/* Seat squares in the background scheme: legend swatches blend with it to match the map. */
	--jb-seat-bg: #565656;

	color: var(--jb-text);
}

.jb-seat-selection__head {
	margin-bottom: 12px;
}

.jb-seat-selection__title {
	margin: 0 0 4px;
}

.jb-seat-selection__badge {
	display: inline-block;
	margin-left: 8px;
	padding: 2px 8px;
	border-radius: 4px;
	background: var(--jb-accent);
	color: var(--jb-accent-text);
	font-size: 0.6em;
	vertical-align: middle;
}

.jb-seat-selection__meta {
	margin: 0;
	color: var(--jb-muted);
}

.jb-seat-selection__notice {
	margin: 0 0 12px;
	padding: 10px 14px;
	border-left: 4px solid var(--jb-accent);
	background: color-mix(in srgb, var(--jb-accent) 12%, var(--jb-surface));
}

.jb-seat-legend {
	display: flex;
	flex-wrap: wrap;
	gap: 6px 18px;
	margin: 0 0 12px;
	padding: 0;
	list-style: none;
	font-size: 0.9em;
}

.jb-seat-legend li {
	display: flex;
	align-items: center;
	gap: 6px;
	margin: 0;
}

.jb-seat-legend__swatch {
	width: 16px;
	height: 16px;
	border: 1px solid rgba(0, 0, 0, 0.3);
	border-radius: 3px;
	/* Same as a free seat on the map: the bare seat square of the background. */
	background: var(--jb-seat-bg);
}

/* Same mix as a free seat in a hall with zones: zone color at fill-opacity 0.45 over the square. */
.jb-seat-selection--zones .jb-seat-legend__swatch {
	background: color-mix(in srgb, var(--jb-zone, var(--jb-accent)) 45%, var(--jb-seat-bg));
}

.jb-seat-selection .jb-seat-legend__swatch--selected {
	background: color-mix(in srgb, var(--jb-selected) 90%, var(--jb-seat-bg));
	border: 2px solid var(--jb-text);
}

.jb-seat-selection .jb-seat-legend__swatch--held {
	background: color-mix(in srgb, var(--jb-held) 80%, var(--jb-seat-bg));
}

.jb-seat-selection .jb-seat-legend__swatch--sold {
	background: color-mix(in srgb, var(--jb-sold) 85%, var(--jb-seat-bg));
}

.jb-seat-selection__body {
	display: grid;
	gap: 20px;
}

@media (min-width: 1025px) {
	.jb-seat-selection__body {
		grid-template-columns: minmax(0, 1fr) 300px;
		align-items: start;
	}

	/* Below the theme's sticky header (the theme sets --jb-sticky-top) and the admin bar (staff). */
	.jb-seat-selection__summary {
		position: sticky;
		top: calc(var(--jb-sticky-top, 20px) + var(--wp-admin--admin-bar--height, 0px));
	}
}

.jb-seat-selection__map {
	min-width: 0;
}

/* Above the scheme, not over it: the background has its own title «Схема зала». */
.jb-seat-selection__zoom {
	display: flex;
	justify-content: flex-end;
	gap: 4px;
	margin-bottom: 6px;
}

.jb-seat-selection .jb-seat-selection__zoom-btn {
	width: 36px;
	height: 36px;
	padding: 0;
	border: 1px solid var(--jb-border);
	border-radius: 4px;
	background: var(--jb-surface);
	color: var(--jb-text);
	font-size: 20px;
	line-height: 1;
	cursor: pointer;
}

.jb-seat-selection .jb-seat-selection__zoom-btn:disabled {
	opacity: 0.4;
	cursor: default;
}

.jb-seat-selection__scheme {
	overflow: auto;
	border: 1px solid var(--jb-border);
	background: var(--jb-surface);
	-webkit-overflow-scrolling: touch;
}

.jb-seat-selection__scheme .jb-hall-scheme {
	display: block;
	width: 100%;
	height: auto;
	user-select: none;
	touch-action: manipulation;
}

/*
 * The scheme starts at the width of the box, so the whole hall fits a phone screen (as in
 * movie-booking); the zoom buttons enlarge it and the box scrolls.
 */

.jb-hall-scheme image {
	pointer-events: none;
}

/* fill-opacity 0, not fill: none: a seat without fill still takes clicks. */
.jb-hall-scheme .jb-seat {
	fill: var(--jb-seat-bg);
	fill-opacity: 0;
	stroke: transparent;
	stroke-width: 2;
	outline: none;
}

.jb-seat-selection--zones .jb-hall-scheme .jb-seat--free {
	fill: var(--jb-zone, var(--jb-accent));
	fill-opacity: 0.45;
}

.jb-hall-scheme .jb-seat--free,
.jb-hall-scheme .jb-seat--mine {
	cursor: pointer;
}

/*
 * Hover tint only for a real pointer. On a touch screen :hover sticks to the tapped seat until
 * the next tap elsewhere, so a seat just unselected stayed green. Touch gets the tint while the
 * finger is down (:active; iOS needs the touchstart listener in seats.js for it).
 */
@media (hover: hover) {
	.jb-seat-selection .jb-hall-scheme .jb-seat--free:hover {
		fill: var(--jb-selected);
		fill-opacity: 0.4;
		stroke: var(--jb-selected);
	}
}

.jb-seat-selection .jb-hall-scheme .jb-seat--free:active {
	fill: var(--jb-selected);
	fill-opacity: 0.4;
	stroke: var(--jb-selected);
}

.jb-hall-scheme .jb-seat.is-selected,
.jb-hall-scheme .jb-seat--mine.is-selected {
	fill: var(--jb-selected);
	fill-opacity: 0.85;
	stroke: var(--jb-text);
	stroke-width: 3;
}

/* Seats of the buyer's hold that were unselected before «Обновить бронь». */
.jb-hall-scheme .jb-seat--mine:not(.is-selected) {
	fill: var(--jb-selected);
	fill-opacity: 0.3;
	stroke: var(--jb-selected);
	stroke-dasharray: 4 3;
}

.jb-hall-scheme .jb-seat--held {
	fill: var(--jb-held);
	fill-opacity: 0.8;
}

.jb-hall-scheme .jb-seat--sold {
	fill: var(--jb-sold);
	fill-opacity: 0.85;
}

.jb-hall-scheme .jb-seat--off {
	fill: var(--jb-surface);
	fill-opacity: 0.7;
}

.jb-hall-scheme .jb-seat:focus-visible {
	stroke: var(--jb-focus);
	stroke-width: 4;
}

.jb-seat-selection__summary {
	padding: 16px;
	border: 1px solid var(--jb-border);
	background: var(--jb-surface);
}

.jb-seat-selection__summary-title {
	margin: 0 0 10px;
	font-size: 1.1em;
}

.jb-seat-selection__hold {
	margin: 0 0 12px;
	padding: 10px;
	background: color-mix(in srgb, var(--jb-accent) 12%, var(--jb-surface));
}

.jb-seat-selection__hold p {
	margin: 0 0 8px;
}

.jb-seat-selection__timer {
	font-variant-numeric: tabular-nums;
}

.jb-seat-selection .jb-seat-selection__checkout {
	display: inline-block;
	padding: 8px 14px;
	border-radius: 4px;
	background: var(--jb-accent);
	color: var(--jb-accent-text);
	text-decoration: none;
}

.jb-seat-selection__empty {
	margin: 0 0 10px;
	color: var(--jb-muted);
}

.jb-seat-selection__list {
	margin: 0 0 10px;
	padding: 0;
	list-style: none;
}

.jb-seat-selection__item {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 8px;
	padding: 4px 0;
	border-bottom: 1px solid var(--jb-border);
}

.jb-seat-selection .jb-seat-selection__remove,
.jb-seat-selection .jb-seat-selection__release {
	padding: 2px 8px;
	border: 1px solid var(--jb-border);
	border-radius: 4px;
	background: transparent;
	color: var(--jb-text);
	cursor: pointer;
}

.jb-seat-selection__total {
	margin: 0 0 12px;
	font-size: 1.1em;
}

.jb-seat-selection .jb-seat-selection__submit {
	width: 100%;
	padding: 12px 16px;
	border: 0;
	border-radius: 4px;
	background: var(--jb-accent);
	color: var(--jb-accent-text);
	font-size: 1em;
	cursor: pointer;
}

.jb-seat-selection .jb-seat-selection__submit:disabled {
	opacity: 0.5;
	cursor: default;
}

.jb-seat-selection.is-busy .jb-seat-selection__scheme {
	opacity: 0.7;
}

.jb-seat-selection button:focus-visible {
	outline: 2px solid var(--jb-focus);
	outline-offset: 2px;
}
