/* ─────────────────────────────────────────────────────────────
 * Tickera Staff Check-In v2 — Modern dark-theme scanner
 * Mobile-first. Big tap targets. High contrast. Loud feedback.
 * ───────────────────────────────────────────────────────────── */

:root {
	--tscim-bg:        #0a0a0a;
	--tscim-bg-elev:   #141414;
	--tscim-bg-elev2:  #1d1d1d;
	--tscim-border:    #2a2a2a;
	--tscim-text:      #f5f5f5;
	--tscim-text-dim:  #9a9a9a;
	--tscim-accent:    #00D4FF;
	--tscim-success:   #00d97e;
	--tscim-warn:      #ffb547;
	--tscim-danger:    #ff4d5e;
	--tscim-shadow:    0 8px 32px rgba(0,0,0,0.4);
	--tscim-radius:    14px;
}

.tscim-app * {
	box-sizing: border-box;
	-webkit-tap-highlight-color: transparent;
}

/* HTML [hidden] attribute MUST win against display: flex on panels & result.
   Without this, .tscim-panel { display: flex } overrides the browser's default
   [hidden] { display: none } and all four overlays stack at boot. */
.tscim-app [hidden],
.tscim-panel[hidden],
.tscim-result[hidden] {
	display: none !important;
}

/* Full-screen app shell */
.tscim-app {
	position: fixed;
	inset: 0;
	background: var(--tscim-bg);
	color: var(--tscim-text);
	display: flex;
	flex-direction: column;
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
	z-index: 99999;
	overscroll-behavior: none;
	-webkit-user-select: none;
	user-select: none;
}

body.tscim-active { overflow: hidden; }
body.tscim-active #wpadminbar { display: none !important; }

/* Scanner page is a kiosk — hide every "Edit This" pill, WPBakery toolbar,
   TotalTheme edit links, etc. The :has() selector targets any page where the
   scanner app exists, even before tscim-active is added to body. */
body:has(.tscim-app) #wpadminbar,
body:has(.tscim-app) .vc_admin-bar,
body:has(.tscim-app) #vc_admin-bar,
body:has(.tscim-app) .vc_admin-bar-wrap,
body:has(.tscim-app) .vc_frontend-edit-link,
body:has(.tscim-app) #vc_inline-anchor,
body:has(.tscim-app) .wpex-edit-button,
body:has(.tscim-app) .wpex-front-end-editor,
body:has(.tscim-app) [id*="frontend-editor"],
body:has(.tscim-app) [class*="vc_frontend"],
body:has(.tscim-app) [class*="page-builder-button"] {
	display: none !important;
}
body:has(.tscim-app),
html:has(.tscim-app) {
	margin-top: 0 !important;
	padding-top: 0 !important;
}

/* Kiosk view switcher — flip between Dashboard (/dash) and Scanner (/checkin) */
.tscim-kiosk-switch {
	display: flex;
	gap: 6px;
	padding: 8px 10px;
	padding-top: max(8px, env(safe-area-inset-top));
	background: var(--tscim-bg-elev);
	border-bottom: 1px solid var(--tscim-border);
	flex-shrink: 0;
}
.tscim-kiosk-tab {
	flex: 1;
	text-align: center;
	padding: 11px 8px;
	border-radius: 10px;
	font-size: 15px;
	font-weight: 700;
	letter-spacing: 0.2px;
	text-decoration: none;
	color: var(--tscim-text-dim);
	background: transparent;
	border: 1px solid var(--tscim-border);
}
.tscim-kiosk-tab.is-active {
	color: #fff;
	background: var(--tscim-accent);
	border-color: transparent;
}

/* Top status bar */
.tscim-topbar {
	background: var(--tscim-bg-elev);
	border-bottom: 1px solid var(--tscim-border);
	padding: 12px 18px;
	display: flex;
	justify-content: space-between;
	align-items: center;
	flex-shrink: 0;
	padding-top: max(12px, env(safe-area-inset-top));
}
.tscim-topbar-left { display: flex; align-items: center; gap: 10px; }
.tscim-pulse {
	width: 10px; height: 10px;
	border-radius: 50%;
	background: var(--tscim-success);
	box-shadow: 0 0 12px var(--tscim-success);
	animation: tscim-pulse 2s ease-in-out infinite;
	flex-shrink: 0;
}
@keyframes tscim-pulse {
	0%,100% { opacity: 1; transform: scale(1); }
	50%     { opacity: 0.6; transform: scale(0.85); }
}
.tscim-count {
	font-size: 22px; font-weight: 800;
	color: var(--tscim-text);
	font-variant-numeric: tabular-nums;
	min-width: 22px; text-align: center;
}
.tscim-count-label {
	font-size: 12px; color: var(--tscim-text-dim);
	text-transform: uppercase; letter-spacing: 0.06em;
}
.tscim-topbar-right { display: flex; align-items: center; gap: 14px; font-size: 13px; }
.tscim-user  { color: var(--tscim-accent); font-weight: 600; }
.tscim-clock { color: var(--tscim-text-dim); font-variant-numeric: tabular-nums; }

/* Camera viewport */
.tscim-viewport {
	flex: 1; position: relative; overflow: hidden; background: #000;
}
.tscim-reader { position: absolute; inset: 0; }
.tscim-reader video {
	width: 100% !important; height: 100% !important; object-fit: cover !important;
}

/* Aiming reticle */
.tscim-reticle {
	position: absolute;
	top: 50%; left: 50%;
	transform: translate(-50%, -50%);
	width: min(70vw, 320px);
	aspect-ratio: 1;
	pointer-events: none;
}
.tscim-reticle-corner {
	position: absolute;
	width: 36px; height: 36px;
	border: 3px solid var(--tscim-accent);
	box-shadow: 0 0 16px rgba(0, 212, 255, 0.4);
}
.tscim-reticle-corner.tl { top: 0; left: 0;  border-right: none;  border-bottom: none; border-radius: 8px 0 0 0; }
.tscim-reticle-corner.tr { top: 0; right: 0; border-left: none;   border-bottom: none; border-radius: 0 8px 0 0; }
.tscim-reticle-corner.bl { bottom: 0; left: 0;  border-right: none; border-top: none; border-radius: 0 0 0 8px; }
.tscim-reticle-corner.br { bottom: 0; right: 0; border-left: none;  border-top: none; border-radius: 0 0 8px 0; }
.tscim-reticle-scanline {
	position: absolute;
	left: 6%; right: 6%;
	height: 2px;
	background: var(--tscim-accent);
	box-shadow: 0 0 12px var(--tscim-accent);
	animation: tscim-scan 2.5s ease-in-out infinite;
	border-radius: 2px;
}
@keyframes tscim-scan {
	0%, 100% { top: 8%; }
	50%      { top: 92%; }
}

/* Placeholder before camera starts */
.tscim-camera-placeholder {
	position: absolute; inset: 0;
	display: flex; flex-direction: column;
	align-items: center; justify-content: center;
	gap: 20px;
	color: var(--tscim-text-dim);
	background: var(--tscim-bg);
	z-index: 5;
}
.tscim-camera-placeholder p { margin: 0; font-size: 15px; }
.tscim-camera-placeholder svg { opacity: 0.5; }
.tscim-camera-start {
	background: var(--tscim-accent);
	color: #000; border: none;
	padding: 16px 32px;
	font-size: 16px; font-weight: 700;
	border-radius: 10px;
	cursor: pointer;
	box-shadow: 0 4px 16px rgba(0, 212, 255, 0.3);
}
.tscim-camera-start:active { transform: scale(0.97); }

/* Result overlay */
.tscim-result {
	position: fixed; inset: 0;
	z-index: 100002;
	display: flex; align-items: center; justify-content: center;
	padding: 24px;
	animation: tscim-result-in 0.18s ease-out;
}
@keyframes tscim-result-in {
	from { opacity: 0; transform: scale(0.95); }
	to   { opacity: 1; transform: scale(1); }
}
.tscim-result[data-state="success"]   { background: linear-gradient(135deg, #00d97e 0%, #00a85e 100%); }
.tscim-result[data-state="duplicate"] { background: linear-gradient(135deg, #ffb547 0%, #f08400 100%); }
.tscim-result[data-state="outside_window"] { background: linear-gradient(135deg, #ff8a3d 0%, #d04f00 100%); }
.tscim-result[data-state="invalid"]   { background: linear-gradient(135deg, #ff4d5e 0%, #cc1f30 100%); }
.tscim-result[data-state="error"]     { background: linear-gradient(135deg, #555 0%, #222 100%); }
.tscim-result-inner {
	max-width: 480px; width: 100%;
	text-align: center; color: #fff;
	display: flex; flex-direction: column; align-items: center;
	gap: 12px;
}
.tscim-result-icon {
	font-size: 96px; line-height: 1;
	margin-bottom: 8px;
	filter: drop-shadow(0 4px 12px rgba(0,0,0,0.3));
}
.tscim-result-headline {
	font-size: clamp(38px, 9vw, 56px);
	font-weight: 900; margin: 0;
	letter-spacing: -0.02em; line-height: 1.05;
	text-transform: uppercase;
}
.tscim-result-attendee {
	font-size: clamp(24px, 6vw, 32px);
	font-weight: 700; margin: 8px 0 0;
}
.tscim-result-event {
	font-size: 16px; margin: 0;
	opacity: 0.9; font-weight: 500;
}
.tscim-result-detail {
	font-size: 14px; margin: 8px 0 0;
	opacity: 0.85;
	max-width: 380px; line-height: 1.5;
}
.tscim-result-dismiss {
	margin-top: 24px;
	background: rgba(255,255,255,0.2);
	border: 2px solid rgba(255,255,255,0.4);
	color: #fff;
	padding: 14px 28px;
	font-size: 14px; font-weight: 600;
	border-radius: 999px;
	cursor: pointer;
	backdrop-filter: blur(8px);
}
.tscim-result-dismiss:active {
	transform: scale(0.96);
	background: rgba(255,255,255,0.3);
}

/* Override button — only visible for outside_window state. Higher
   visual weight than dismiss so staff can spot it quickly at the door. */
.tscim-result-override {
	margin-top: 20px;
	background: #fff;
	border: none;
	color: #d04f00;
	padding: 16px 32px;
	font-size: 16px;
	font-weight: 800;
	border-radius: 999px;
	cursor: pointer;
	letter-spacing: 0.02em;
	box-shadow: 0 6px 20px rgba(0,0,0,0.25);
}
.tscim-result-override:active {
	transform: scale(0.97);
	background: #f5f5f5;
}
.tscim-result-override:disabled {
	opacity: 0.6;
	cursor: not-allowed;
}
.tscim-result-override[hidden] { display: none !important; }

/* Slide-up panels */
.tscim-panel {
	position: fixed; left: 0; right: 0; bottom: 0; top: auto;
	max-height: 80vh;
	background: var(--tscim-bg-elev);
	border-top: 1px solid var(--tscim-border);
	border-radius: 20px 20px 0 0;
	z-index: 100001;
	box-shadow: 0 -16px 48px rgba(0,0,0,0.5);
	animation: tscim-panel-up 0.22s ease-out;
	display: flex; flex-direction: column;
	padding-bottom: env(safe-area-inset-bottom);
}
@keyframes tscim-panel-up {
	from { transform: translateY(100%); }
	to   { transform: translateY(0); }
}
.tscim-panel-header {
	display: flex; justify-content: space-between; align-items: center;
	padding: 18px 24px 12px;
	border-bottom: 1px solid var(--tscim-border);
}
.tscim-panel-header h2 {
	margin: 0; font-size: 18px; font-weight: 700;
	color: var(--tscim-text);
}
.tscim-panel-close {
	background: var(--tscim-bg-elev2); border: none;
	color: var(--tscim-text-dim);
	width: 36px; height: 36px;
	border-radius: 50%;
	font-size: 16px; cursor: pointer;
}
.tscim-panel-close:active { transform: scale(0.95); }
.tscim-panel-body {
	padding: 20px 24px 32px;
	overflow-y: auto; flex: 1;
}
.tscim-panel-body label {
	display: block;
	font-size: 12px; color: var(--tscim-text-dim);
	text-transform: uppercase; letter-spacing: 0.06em;
	margin-bottom: 8px;
}
.tscim-panel-body input[type="text"] {
	width: 100%;
	background: var(--tscim-bg-elev2);
	border: 2px solid var(--tscim-border);
	color: var(--tscim-text);
	padding: 16px;
	font-size: 18px;
	border-radius: 12px;
	margin-bottom: 16px;
	font-variant-numeric: tabular-nums;
}
.tscim-panel-body input[type="text"]:focus {
	outline: none; border-color: var(--tscim-accent);
}
.tscim-primary-btn {
	width: 100%;
	background: var(--tscim-accent);
	color: #000; border: none;
	padding: 18px;
	font-size: 17px; font-weight: 700;
	border-radius: 12px;
	cursor: pointer;
	box-shadow: 0 4px 16px rgba(0, 212, 255, 0.25);
}
.tscim-primary-btn:active { transform: scale(0.98); }
.tscim-hint {
	font-size: 13px; color: var(--tscim-text-dim);
	margin: 12px 0 0; line-height: 1.5;
}

/* Search results */
.tscim-search-results { margin-top: 8px; }
.tscim-search-result {
	background: var(--tscim-bg-elev2);
	border-radius: 10px;
	padding: 14px 16px;
	margin-bottom: 8px;
	display: flex; justify-content: space-between; align-items: center;
	gap: 12px;
}
.tscim-search-result-info { flex: 1; min-width: 0; }
.tscim-search-result-name {
	font-weight: 600; margin: 0; color: var(--tscim-text);
}
.tscim-search-result-meta {
	font-size: 12px; color: var(--tscim-text-dim); margin: 2px 0 0;
}
.tscim-search-result-status {
	font-size: 11px;
	padding: 4px 8px; border-radius: 6px;
	background: var(--tscim-success); color: #000;
	font-weight: 700; text-transform: uppercase;
}
.tscim-search-result-checkin {
	background: var(--tscim-accent);
	color: #000; border: none;
	padding: 8px 14px;
	font-size: 13px; font-weight: 700;
	border-radius: 8px; cursor: pointer;
}

/* Recent scans */
.tscim-recent-list { display: flex; flex-direction: column; gap: 8px; }
.tscim-recent-item {
	background: var(--tscim-bg-elev2);
	border-radius: 10px;
	padding: 12px 14px;
	display: flex; gap: 12px; align-items: center;
}
.tscim-recent-dot {
	width: 8px; height: 8px;
	border-radius: 50%; flex-shrink: 0;
}
.tscim-recent-dot[data-result="success"]   { background: var(--tscim-success); }
.tscim-recent-dot[data-result="duplicate"] { background: var(--tscim-warn); }
.tscim-recent-dot[data-result="invalid"],
.tscim-recent-dot[data-result="error"]     { background: var(--tscim-danger); }
.tscim-recent-name {
	font-weight: 600; color: var(--tscim-text);
	margin: 0; font-size: 14px;
}
.tscim-recent-time {
	font-size: 12px; color: var(--tscim-text-dim);
	margin: 2px 0 0;
	font-variant-numeric: tabular-nums;
}

/* Bottom action bar */
.tscim-actionbar {
	background: var(--tscim-bg-elev);
	border-top: 1px solid var(--tscim-border);
	display: grid;
	grid-template-columns: repeat(5, 1fr);
	flex-shrink: 0;
	padding-bottom: env(safe-area-inset-bottom);
}
.tscim-action-btn {
	background: transparent; border: none;
	color: var(--tscim-text-dim);
	padding: 12px 6px;
	display: flex; flex-direction: column;
	align-items: center; gap: 4px;
	cursor: pointer;
	font-size: 11px; font-weight: 600;
	transition: color 0.15s;
}
.tscim-action-btn:active {
	color: var(--tscim-accent);
	background: rgba(0, 212, 255, 0.08);
}
.tscim-action-btn:disabled {
	opacity: 0.3; cursor: not-allowed;
}
.tscim-action-btn[data-active="true"] { color: var(--tscim-accent); }
.tscim-action-btn svg { width: 24px; height: 24px; }

/* Gate (logged-out / not-configured) */
.tscim-gate {
	max-width: 480px; margin: 80px auto;
	padding: 40px 32px;
	background: var(--tscim-bg-elev);
	color: var(--tscim-text);
	border-radius: var(--tscim-radius);
	text-align: center;
	box-shadow: var(--tscim-shadow);
}
.tscim-gate h2 { margin: 0 0 12px; font-size: 22px; }
.tscim-gate p { color: var(--tscim-text-dim); margin: 0 0 16px; }
.tscim-gate-btn {
	display: inline-block;
	background: var(--tscim-accent);
	color: #000;
	padding: 12px 28px;
	border-radius: 8px;
	text-decoration: none;
	font-weight: 700;
	margin-top: 8px;
}

/* ─────────────────────────────────────────────────────────────
 * Stats panel
 * Used in two contexts:
 *   1. Scanner page slide-up panel (dark, mobile-first)
 *   2. Admin Reconciliation page (.tscim-admin-stats, light-on-white)
 * Shared shell uses the inherited panel/admin background; this
 * section only styles the inner filter row + grouped results +
 * sticky summary footer.
 * ───────────────────────────────────────────────────────────── */

.tscim-stats-filters {
	display: flex;
	flex-direction: column;
	gap: 10px;
	margin-bottom: 16px;
}
.tscim-stats-filters label {
	display: flex;
	flex-direction: column;
	gap: 4px;
	font-size: 12px;
	color: var(--tscim-text-dim);
	text-transform: uppercase;
	letter-spacing: 0.06em;
	margin: 0;
}
.tscim-stats-filters select {
	width: 100%;
	background: var(--tscim-bg-elev2);
	border: 2px solid var(--tscim-border);
	color: var(--tscim-text);
	padding: 12px;
	font-size: 15px;
	border-radius: 10px;
	font-family: inherit;
	-webkit-appearance: none;
	appearance: none;
	background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%239a9a9a'><path d='M7 10l5 5 5-5z'/></svg>");
	background-repeat: no-repeat;
	background-position: right 10px center;
	background-size: 22px;
	padding-right: 36px;
}
.tscim-stats-filters select:focus {
	outline: none;
	border-color: var(--tscim-accent);
}

.tscim-stats-results {
	display: flex;
	flex-direction: column;
	gap: 12px;
}
.tscim-stats-event {
	background: var(--tscim-bg-elev2);
	border-radius: 12px;
	padding: 14px 16px;
}
.tscim-stats-event-head {
	display: flex;
	justify-content: space-between;
	align-items: baseline;
	gap: 12px;
	margin-bottom: 8px;
	padding-bottom: 8px;
	border-bottom: 1px solid var(--tscim-border);
}
.tscim-stats-event-name {
	font-weight: 700;
	font-size: 15px;
	color: var(--tscim-text);
	line-height: 1.25;
	flex: 1;
	min-width: 0;
}
.tscim-stats-event-total {
	font-weight: 800;
	font-size: 22px;
	color: var(--tscim-success);
	font-variant-numeric: tabular-nums;
}
.tscim-stats-day {
	display: flex;
	justify-content: space-between;
	align-items: baseline;
	padding: 6px 0;
	gap: 12px;
}
.tscim-stats-day-label {
	font-size: 13px;
	color: var(--tscim-text-dim);
	flex-shrink: 0;
}
.tscim-stats-day-count {
	font-size: 14px;
	font-weight: 600;
	color: var(--tscim-text);
	font-variant-numeric: tabular-nums;
	text-align: right;
}
.tscim-stats-issues {
	color: var(--tscim-warn);
	font-weight: 500;
	font-size: 12px;
}

/* Sticky-ish summary footer inside the panel scroll area */
.tscim-stats-summary {
	position: sticky;
	bottom: 0;
	margin-top: 16px;
	padding: 14px 16px;
	background: var(--tscim-bg-elev);
	border-top: 1px solid var(--tscim-border);
	border-radius: 10px;
	font-size: 14px;
	color: var(--tscim-text);
	text-align: center;
	font-variant-numeric: tabular-nums;
}
.tscim-stats-summary strong {
	font-size: 18px;
	color: var(--tscim-success);
}

/* Desktop variant for the panel filters: horizontal row when there's space */
@media (min-width: 520px) {
	.tscim-stats-filters {
		flex-direction: row;
		flex-wrap: wrap;
	}
	.tscim-stats-filters label {
		flex: 1;
		min-width: 140px;
	}
}

/* ─────────────────────────────────────────────────────────────
 * Admin Reconciliation page variant — light theme, table-ish look
 * Mirrors the same DOM as the scanner panel but readable inside
 * the WordPress admin chrome.
 * ───────────────────────────────────────────────────────────── */
.tscim-admin-stats {
	background: #fff;
	padding: 20px;
	border: 1px solid #c3c4c7;
	border-radius: 4px;
	margin-top: 12px;
	max-width: 960px;
	color: #1d2327;
}
.tscim-admin-stats .tscim-stats-filters {
	flex-direction: row;
	flex-wrap: wrap;
	align-items: flex-end;
}
.tscim-admin-stats .tscim-stats-filters label {
	color: #50575e;
	flex: 1;
	min-width: 180px;
}
.tscim-admin-stats .tscim-stats-filters select {
	background: #fff;
	border: 1px solid #8c8f94;
	color: #2c3338;
	background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%23646970'><path d='M7 10l5 5 5-5z'/></svg>");
}
.tscim-admin-stats .tscim-stats-event {
	background: #f6f7f7;
	border: 1px solid #dcdcde;
}
.tscim-admin-stats .tscim-stats-event-head {
	border-bottom-color: #dcdcde;
}
.tscim-admin-stats .tscim-stats-event-name { color: #1d2327; }
.tscim-admin-stats .tscim-stats-event-total { color: #008a20; }
.tscim-admin-stats .tscim-stats-day-label { color: #50575e; }
.tscim-admin-stats .tscim-stats-day-count { color: #1d2327; }
.tscim-admin-stats .tscim-stats-issues { color: #b26200; }
.tscim-admin-stats .tscim-stats-summary {
	background: #f0f6fc;
	border-top: 1px solid #c5d9ed;
	color: #1d2327;
}
.tscim-admin-stats .tscim-stats-summary strong { color: #008a20; }
.tscim-admin-stats .tscim-hint { color: #50575e; }

/* Export CSV link sits next to the filter dropdowns on the admin page.
   The `span` placeholder above the link keeps the row visually aligned
   with the other label/control pairs. */
.tscim-stats-export-wrap { flex: 0 0 auto !important; }
.tscim-stats-export-wrap > span { visibility: hidden; }
.tscim-admin-stats .tscim-stats-export-wrap .button { display: inline-block; }

/* Desktop tweaks */
@media (min-width: 768px) {
	.tscim-app {
		position: relative; inset: auto;
		max-width: 480px; margin: 40px auto;
		height: 80vh; min-height: 600px;
		border-radius: var(--tscim-radius);
		box-shadow: var(--tscim-shadow);
		overflow: hidden;
		z-index: auto;
	}
	.tscim-panel {
		left: auto; right: auto;
		max-width: 480px;
	}
}

.tscim-reader #qr-shaded-region { display: none !important; }

/* ───── Undo check-in button (result overlay) ───── */
.tscim-result-undo {
	margin-top: 14px;
	background: transparent;
	border: 2px solid rgba(255, 255, 255, 0.85);
	color: #fff;
	padding: 13px 28px;
	font-size: 15px;
	font-weight: 800;
	border-radius: 999px;
	cursor: pointer;
	letter-spacing: 0.02em;
}
.tscim-result-undo:active { transform: scale(0.97); }
.tscim-result-undo:disabled { opacity: 0.6; cursor: default; }
.tscim-result-undo[hidden] { display: none !important; }

/* ───── Undo button (Recent Scans rows) ───── */
.tscim-recent-undo {
	flex-shrink: 0;
	background: transparent;
	border: 1px solid var(--tscim-border);
	color: var(--tscim-text-dim);
	font-size: 12px;
	font-weight: 700;
	padding: 6px 12px;
	border-radius: 999px;
	cursor: pointer;
}
.tscim-recent-undo:active { transform: scale(0.96); }
.tscim-recent-undo:disabled { opacity: 0.6; cursor: default; }
