/* Wisprof Ticket: staff scanner. Designed for phones held at a door. */

.wes-scanner {
	--wes-s-bg: #0b1020;
	--wes-s-panel: #151b2e;
	--wes-s-text: #f3f4f6;
	--wes-s-muted: #9ca3af;
	--wes-s-ok: #16a34a;
	--wes-s-ok-dark: #15803d;
	--wes-s-bad: #dc2626;

	position: relative;
	display: flex;
	flex-direction: column;
	max-width: 560px;
	margin: 0 auto;
	min-height: 560px;
	background: var(--wes-s-bg);
	color: var(--wes-s-text);
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
	font-size: 16px;
	line-height: 1.4;
	border-radius: 16px;
	overflow: hidden;
	box-sizing: border-box;
}

.wes-scanner *,
.wes-scanner *::before,
.wes-scanner *::after {
	box-sizing: inherit;
}

/* Take over the viewport, below the admin bar if shown. */
.wes-scanner--fullscreen {
	position: fixed;
	inset: var(--wp-admin--admin-bar--height, 0px) 0 0 0;
	z-index: 99990;
	max-width: none;
	min-height: 0;
	border-radius: 0;
}

.wes-scanner__bar {
	display: flex;
	flex-direction: column;
	gap: 10px;
	padding: 10px 14px;
	padding-top: max(10px, env(safe-area-inset-top));
	background: var(--wes-s-panel);
	font-size: 0.95rem;
}

.wes-scanner__bar-row {
	display: flex;
	justify-content: space-between;
	align-items: center;
	gap: 10px;
}

.wes-scanner__tools {
	display: flex;
	align-items: center;
	gap: 8px;
	flex-wrap: wrap;
}

/* Connection pill */
.wes-net {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	padding: 3px 10px;
	border-radius: 999px;
	background: rgba(22, 163, 74, 0.18);
	color: #86efac;
	font-size: 0.8rem;
	font-weight: 700;
	white-space: nowrap;
}

.wes-net__dot {
	width: 8px;
	height: 8px;
	border-radius: 50%;
	background: currentColor;
}

.wes-net.is-offline {
	background: rgba(245, 158, 11, 0.2);
	color: #fcd34d;
}

.wes-net.is-offline .wes-net__dot {
	animation: wes-blink 1s steps(2, start) infinite;
}

.wes-net__queue {
	padding-left: 6px;
	border-left: 1px solid currentColor;
}

@keyframes wes-blink {
	to {
		visibility: hidden;
	}
}

/* Instant Check-In switch */
.wes-switch {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	margin-right: auto;
	cursor: pointer;
	font-weight: 700;
	font-size: 0.9rem;
	-webkit-tap-highlight-color: transparent;
}

.wes-switch input {
	position: absolute;
	opacity: 0;
	width: 1px;
	height: 1px;
}

.wes-switch__track {
	position: relative;
	width: 46px;
	height: 28px;
	border-radius: 999px;
	background: #374151;
	transition: background 0.15s;
	flex: none;
}

.wes-switch__thumb {
	position: absolute;
	top: 3px;
	left: 3px;
	width: 22px;
	height: 22px;
	border-radius: 50%;
	background: #fff;
	transition: transform 0.15s;
}

.wes-switch input:checked + .wes-switch__track {
	background: var(--wes-s-ok);
}

.wes-switch input:checked + .wes-switch__track .wes-switch__thumb {
	transform: translateX(18px);
}

.wes-switch input:focus-visible + .wes-switch__track {
	outline: 3px solid #93c5fd;
	outline-offset: 2px;
}

.wes-tool {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	min-height: 40px;
	padding: 6px 12px;
	border: 1px solid #374151;
	border-radius: 10px;
	background: transparent;
	color: var(--wes-s-text);
	font-size: 0.9rem;
	font-weight: 600;
	cursor: pointer;
}

.wes-tool[hidden] {
	display: none;
}

.wes-tool.is-on {
	background: #fde047;
	border-color: #fde047;
	color: #111827;
}

/* Visual cue that scans are admitted automatically. */
.wes-scanner.is-auto .wes-scanner__reader {
	box-shadow: 0 0 0 4px var(--wes-s-ok);
}

.wes-scanner__cache {
	margin: 0;
	font-size: 0.8rem;
	color: #6b7280;
	text-align: center;
}

.wes-scanner__camera {
	flex: 1;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 14px;
	padding: 16px;
	padding-bottom: max(16px, env(safe-area-inset-bottom));
	overflow-y: auto;
}

.wes-scanner__reader {
	width: 100%;
	max-width: 420px;
	margin: 0 auto;
	aspect-ratio: 1;
	border-radius: 16px;
	overflow: hidden;
	background: #000;
}

.wes-scanner__reader video {
	width: 100% !important;
	height: 100% !important;
	object-fit: cover;
}

/* html5-qrcode adds its own shaded region; keep it subtle. */
.wes-scanner__reader #qr-shaded-region {
	border-color: rgba(0, 0, 0, 0.45) !important;
}

.wes-scanner__hint {
	margin: 0;
	text-align: center;
	color: var(--wes-s-muted);
}

.wes-scanner__hint.is-error {
	color: #fca5a5;
}

.wes-scanner__manual {
	display: flex;
	gap: 8px;
	width: 100%;
	max-width: 420px;
}

.wes-scanner__manual input {
	flex: 1;
	min-width: 0;
	min-height: 48px;
	padding: 10px 12px;
	border: 1px solid #374151;
	border-radius: 10px;
	background: var(--wes-s-panel);
	color: var(--wes-s-text);
	font-size: 16px;
	font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
	letter-spacing: 0.05em;
	text-transform: uppercase;
}

.wes-scanner__manual input::placeholder {
	text-transform: none;
	letter-spacing: 0;
	font-family: inherit;
	color: #6b7280;
}

/* Buttons ---------------------------------------------------------------- */
.wes-scan-btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-height: 48px;
	padding: 10px 18px;
	border: 0;
	border-radius: 10px;
	background: #374151;
	color: #fff;
	font-size: 1rem;
	font-weight: 700;
	cursor: pointer;
	text-decoration: none;
	-webkit-tap-highlight-color: transparent;
}

.wes-scan-btn:active {
	transform: translateY(1px);
}

.wes-scan-btn:disabled {
	opacity: 0.7;
	cursor: progress;
}

.wes-scan-btn--primary {
	background: #4f46e5;
}

.wes-scan-btn--ghost {
	background: transparent;
	border: 2px solid rgba(255, 255, 255, 0.35);
}

.wes-scan-btn--mark {
	width: 100%;
	min-height: 84px;
	margin-top: 8px;
	background: #fff;
	color: var(--wes-s-ok-dark);
	font-size: 1.5rem;
	font-weight: 900;
	letter-spacing: 0.04em;
	border-radius: 16px;
	box-shadow: 0 6px 0 rgba(0, 0, 0, 0.2);
}

.wes-scan-btn--mark:active {
	transform: translateY(4px);
	box-shadow: 0 2px 0 rgba(0, 0, 0, 0.2);
}

.wes-scan-btn--next {
	width: 100%;
	min-height: 64px;
	margin-top: 8px;
	background: rgba(0, 0, 0, 0.25);
	font-size: 1.2rem;
	border-radius: 14px;
}

.wes-result .wes-scan-btn--ghost {
	width: 100%;
	margin-top: 4px;
}

/* Result panel ----------------------------------------------------------- */
.wes-result {
	position: absolute;
	inset: 0;
	z-index: 5;
	display: flex;
	flex-direction: column;
	justify-content: center;
	gap: 14px;
	padding: 24px 20px;
	padding-bottom: max(24px, env(safe-area-inset-bottom));
	overflow-y: auto;
	animation: wes-pop 0.18s ease-out;
}

.wes-result[hidden] {
	display: none;
}

@keyframes wes-pop {
	from {
		opacity: 0;
		transform: scale(0.98);
	}
	to {
		opacity: 1;
		transform: none;
	}
}

.wes-result--checking {
	background: var(--wes-s-bg);
	align-items: center;
}

.wes-result--ok {
	background: var(--wes-s-ok);
}

.wes-result--bad {
	background: var(--wes-s-bad);
}

.wes-result__title {
	margin: 0;
	color: #fff;
	font-size: 2rem;
	font-weight: 900;
	line-height: 1.15;
	text-align: center;
	letter-spacing: 0.02em;
}

.wes-result__details {
	background: rgba(0, 0, 0, 0.18);
	border-radius: 14px;
	padding: 6px 16px;
}

.wes-result__row {
	display: flex;
	flex-direction: column;
	padding: 10px 0;
	border-bottom: 1px solid rgba(255, 255, 255, 0.18);
}

.wes-result__row:last-child {
	border-bottom: 0;
}

.wes-result__label {
	font-size: 0.8rem;
	text-transform: uppercase;
	letter-spacing: 0.08em;
	opacity: 0.85;
}

.wes-result__value {
	font-size: 1.35rem;
	font-weight: 700;
	word-break: break-word;
}

.wes-result__row--mono .wes-result__value {
	font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
	letter-spacing: 0.06em;
}

.wes-result__row--strong .wes-result__value {
	font-size: 1.8rem;
	font-weight: 900;
	letter-spacing: 0.1em;
}

.wes-result__payment {
	text-align: center;
	font-size: 1.3rem;
	font-weight: 900;
	letter-spacing: 0.06em;
	background: rgba(255, 255, 255, 0.95);
	color: var(--wes-s-ok-dark);
	border-radius: 10px;
	padding: 10px;
}

.wes-result__recorded {
	text-align: center;
	font-size: 1.25rem;
	font-weight: 800;
	background: rgba(0, 0, 0, 0.25);
	border-radius: 10px;
	padding: 14px 10px;
}

.wes-result__note {
	margin: 0;
	text-align: center;
	font-size: 1rem;
	opacity: 0.95;
}

.wes-result__checking {
	text-align: center;
	color: var(--wes-s-muted);
}

.wes-result__spinner {
	width: 48px;
	height: 48px;
	margin: 0 auto 12px;
	border: 5px solid #374151;
	border-top-color: #fff;
	border-radius: 50%;
	animation: wes-s-spin 0.7s linear infinite;
}

@keyframes wes-s-spin {
	to {
		transform: rotate(360deg);
	}
}

.wes-result__group {
	align-self: center;
	padding: 6px 14px;
	border-radius: 999px;
	background: rgba(255, 255, 255, 0.95);
	color: #111827;
	font-weight: 800;
	font-size: 1rem;
}

.wes-result__offline {
	padding: 8px 12px;
	border-radius: 10px;
	background: #fcd34d;
	color: #111827;
	font-weight: 700;
	font-size: 0.85rem;
	text-align: center;
}

.wes-result__row--list .wes-result__value {
	white-space: pre-line;
	font-size: 1.05rem;
}

.wes-scan-btn--group {
	width: 100%;
	min-height: 60px;
	background: rgba(0, 0, 0, 0.3);
	border: 2px solid #fff;
	font-size: 1.15rem;
	border-radius: 14px;
}

/* Instant Check-In: 1.5s countdown bar before auto-reset. */
.wes-result__countdown {
	height: 6px;
	border-radius: 999px;
	background: rgba(255, 255, 255, 0.95);
	transform-origin: left center;
	animation: wes-countdown 1.5s linear forwards;
}

@keyframes wes-countdown {
	from {
		transform: scaleX(1);
	}
	to {
		transform: scaleX(0);
	}
}

/* Manual lookup drawer ----------------------------------------------------- */
.wes-drawer {
	position: absolute;
	inset: 0;
	z-index: 20;
}

.wes-drawer[hidden] {
	display: none;
}

.wes-drawer__backdrop {
	position: absolute;
	inset: 0;
	background: rgba(0, 0, 0, 0.55);
	opacity: 0;
	transition: opacity 0.2s;
}

.wes-drawer__panel {
	position: absolute;
	left: 0;
	right: 0;
	bottom: 0;
	max-height: 88%;
	display: flex;
	flex-direction: column;
	gap: 10px;
	padding: 16px;
	padding-bottom: max(16px, env(safe-area-inset-bottom));
	background: var(--wes-s-panel);
	border-radius: 18px 18px 0 0;
	transform: translateY(100%);
	transition: transform 0.2s ease-out;
}

.wes-drawer.is-open .wes-drawer__backdrop {
	opacity: 1;
}

.wes-drawer.is-open .wes-drawer__panel {
	transform: none;
}

.wes-drawer__head {
	display: flex;
	justify-content: space-between;
	align-items: center;
}

.wes-drawer__head h2 {
	margin: 0;
	font-size: 1.2rem;
	color: var(--wes-s-text);
}

.wes-drawer__close {
	width: 40px;
	height: 40px;
	border: 0;
	border-radius: 50%;
	background: #374151;
	color: #fff;
	font-size: 1.1rem;
	cursor: pointer;
}

.wes-drawer__input {
	width: 100%;
	min-height: 50px;
	padding: 10px 14px;
	border: 1px solid #374151;
	border-radius: 12px;
	background: var(--wes-s-bg);
	color: var(--wes-s-text);
	font-size: 16px;
}

.wes-drawer__hint {
	margin: 0;
	color: var(--wes-s-muted);
	font-size: 0.85rem;
}

.wes-drawer__results {
	list-style: none;
	margin: 0;
	padding: 0;
	overflow-y: auto;
	display: flex;
	flex-direction: column;
	gap: 10px;
	-webkit-overflow-scrolling: touch;
}

.wes-hit {
	padding: 12px 14px;
	border-radius: 12px;
	background: var(--wes-s-bg);
	border-left: 5px solid #6b7280;
}

.wes-hit--valid {
	border-left-color: var(--wes-s-ok);
}

.wes-hit--used,
.wes-hit--confirmed {
	border-left-color: #3b82f6;
}

.wes-hit--cancelled,
.wes-hit--blocked,
.wes-hit--invalid {
	border-left-color: var(--wes-s-bad);
}

.wes-hit__head {
	display: flex;
	justify-content: space-between;
	align-items: center;
	gap: 8px;
}

.wes-hit__name {
	font-size: 1.05rem;
}

.wes-hit__meta {
	color: var(--wes-s-muted);
	font-size: 0.85rem;
	word-break: break-word;
}

.wes-hit__mono {
	font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
}

.wes-hit__status {
	margin-top: 4px;
	font-weight: 700;
	font-size: 0.9rem;
}

.wes-hit__status:empty {
	display: none;
}

.wes-scan-btn--compact {
	min-height: 56px;
	margin-top: 10px;
	font-size: 1.15rem;
	box-shadow: 0 4px 0 rgba(0, 0, 0, 0.2);
}

.wes-badge {
	flex: none;
	padding: 2px 8px;
	border-radius: 6px;
	font-size: 0.7rem;
	font-weight: 800;
	letter-spacing: 0.05em;
	background: #374151;
	color: #fff;
}

.wes-badge--valid {
	background: var(--wes-s-ok);
}

.wes-badge--used {
	background: #2563eb;
}

.wes-badge--cancelled,
.wes-badge--blocked,
.wes-badge--invalid {
	background: var(--wes-s-bad);
}

/* Toasts (sync results) ---------------------------------------------------- */
.wes-toast {
	position: absolute;
	left: 12px;
	right: 12px;
	bottom: max(12px, env(safe-area-inset-bottom));
	z-index: 30;
	display: flex;
	flex-direction: column;
	gap: 8px;
	pointer-events: none;
}

.wes-toast[hidden] {
	display: none;
}

.wes-toast__item {
	padding: 12px 14px;
	border-radius: 12px;
	background: #1f2937;
	color: #fff;
	font-weight: 600;
	font-size: 0.9rem;
	box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
	animation: wes-pop 0.18s ease-out;
}

.wes-toast__item--ok {
	background: var(--wes-s-ok-dark);
}

.wes-toast__item--bad {
	background: var(--wes-s-bad);
}

/* Direction toggle + gate select (Phase 3) -------------------------------- */
.wes-scanner__bar-row--controls {
	gap: 8px;
}

.wes-direction {
	display: inline-flex;
	flex: 1;
	padding: 3px;
	border-radius: 12px;
	background: #0b1020;
	border: 1px solid #374151;
}

.wes-direction__btn {
	flex: 1;
	min-height: 40px;
	padding: 6px 10px;
	border: 0;
	border-radius: 9px;
	background: transparent;
	color: var(--wes-s-muted);
	font-weight: 800;
	font-size: 0.95rem;
	letter-spacing: 0.02em;
	cursor: pointer;
	-webkit-tap-highlight-color: transparent;
}

.wes-direction__btn.is-active[data-direction="in"] {
	background: var(--wes-s-ok);
	color: #fff;
}

.wes-direction__btn.is-active[data-direction="out"] {
	background: #7c3aed;
	color: #fff;
}

.wes-gate select {
	min-height: 46px;
	max-width: 46vw;
	padding: 6px 10px;
	border: 1px solid #374151;
	border-radius: 12px;
	background: #0b1020;
	color: var(--wes-s-text);
	font-size: 0.95rem;
	font-weight: 700;
}

.wes-scanner.needs-gate .wes-gate select {
	border-color: #f59e0b;
	box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.35);
}

.wes-scanner__reader-wrap {
	position: relative;
	width: 100%;
	max-width: 420px;
}

.wes-gate-required {
	position: absolute;
	inset: 0;
	display: grid;
	place-items: center;
	padding: 20px;
	border-radius: 16px;
	background: rgba(11, 16, 32, 0.88);
	text-align: center;
	font-weight: 800;
	font-size: 1.1rem;
	color: #fcd34d;
}

.wes-gate-required[hidden] {
	display: none;
}

/* Scan OUT: purple cues so staff never confuse the modes. */
.wes-scanner.is-out .wes-scanner__reader {
	box-shadow: 0 0 0 4px #7c3aed;
}

.wes-scanner.is-out .wes-scanner__hint {
	color: #c4b5fd;
	font-weight: 700;
}

.wes-result--out {
	background: #6d28d9;
}

/* Wrong gate: bold yellow interception. */
.wes-result--warn {
	background: #facc15;
	color: #111827;
}

.wes-result__title--warn {
	color: #111827;
	font-size: 1.7rem;
}

.wes-result--warn .wes-result__offline {
	background: #111827;
	color: #fcd34d;
}

.wes-result--warn .wes-result__details {
	background: rgba(0, 0, 0, 0.08);
}

.wes-result--warn .wes-result__row {
	border-bottom-color: rgba(0, 0, 0, 0.12);
}

.wes-result--warn .wes-result__group {
	background: #111827;
	color: #fff;
}

.wes-scan-btn--override {
	width: 100%;
	min-height: 72px;
	background: #111827;
	color: #facc15;
	font-size: 1.3rem;
	font-weight: 900;
	border-radius: 16px;
}

.wes-scan-btn--reject {
	width: 100%;
	min-height: 60px;
	background: #dc2626;
	color: #fff;
	font-size: 1.15rem;
	border-radius: 14px;
}

.wes-badge--passed_out {
	background: #7c3aed;
}

.wes-hit--passed_out,
.wes-hit--passout_confirmed {
	border-left-color: #7c3aed;
}

.wes-hit--warn {
	border-left-color: #facc15;
}

.wes-hit--warn .wes-hit__status {
	color: #fde047;
}

/* Ticket type / access level: the first thing staff should read. ------- */
.wes-result__type {
	--wes-type-color: #2563eb;
	padding: 14px 16px 16px;
	border-radius: 16px;
	background: #fff;
	color: #111827;
	text-align: center;
	border-top: 12px solid var(--wes-type-color);
	box-shadow: 0 6px 18px rgba(0, 0, 0, 0.18);
}

.wes-result__type-name {
	color: var(--wes-type-color);
	font-size: 2.6rem;
	font-weight: 900;
	line-height: 1.05;
	letter-spacing: 0.02em;
	text-transform: uppercase;
	word-break: break-word;
}

.wes-result__type-zone {
	margin-top: 6px;
	font-size: 1.1rem;
	font-weight: 800;
	color: #374151;
}

.wes-result__type--small {
	padding: 8px 12px 10px;
	border-top-width: 8px;
	box-shadow: none;
}

.wes-result__type--small .wes-result__type-name {
	font-size: 1.5rem;
}

@media (max-height: 640px) {
	.wes-result__type-name {
		font-size: 2rem;
	}
}

.wes-result__test {
	padding: 8px 12px;
	border-radius: 10px;
	background: repeating-linear-gradient(45deg, #fde047, #fde047 10px, #facc15 10px, #facc15 20px);
	color: #111827;
	font-weight: 900;
	font-size: 0.95rem;
	letter-spacing: 0.04em;
	text-align: center;
}

/* Keep the (paused) camera from receiving taps under the result. */
.wes-scanner.has-result .wes-scanner__camera {
	visibility: hidden;
}

/* Login / access gate ---------------------------------------------------- */
.wes-scan-gate {
	max-width: 420px;
	margin: 40px auto;
	padding: 28px 20px;
	text-align: center;
	background: #f9fafb;
	border: 1px solid #e5e7eb;
	border-radius: 14px;
}

.wes-scan-gate h3 {
	margin-top: 0;
}

.wes-scan-gate .wes-scan-btn {
	color: #fff;
}

@media (max-height: 640px) {
	.wes-result__title {
		font-size: 1.6rem;
	}

	.wes-result__value {
		font-size: 1.15rem;
	}

	.wes-scan-btn--mark {
		min-height: 70px;
		font-size: 1.3rem;
	}
}
