/* ── Design tokens (dark theme) ── */
:root {
	--bg: #000000;
	--surface: #161618;
	--surface-2: #202024;
	--border: #2a2a2e;
	--text: #f5f5f7;
	--text-2: #a1a1a6;
	--text-muted: #8e8e93;
	--brand: #9333ea;
	--brand-2: #b07cf0;
	--brand-hover: #7c22d0;
	--tabbar-h: 60px;
}

/* ── Reset & Base ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; -webkit-text-size-adjust: 100%; }
body {
	font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
	background: var(--bg);
	color: var(--text);
	min-height: 100vh;
	padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom, 0px));
}

/* ── Header (transparent, centered logo) ── */
.header-bar {
	position: sticky;
	top: 0;
	z-index: 100;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 14px 16px calc(14px + env(safe-area-inset-top, 0px));
	background: transparent;
}
.header-logo {
	display: block;
	width: 38px;
	height: 38px;
	filter: drop-shadow(0 2px 8px rgba(147,51,234,.45));
}
.header-lang {
	position: absolute;
	right: 12px;
	top: 50%;
	transform: translateY(-50%);
	/* Light pill with dark text — robustly readable across browsers (some render the
	   closed-select value with the option color, which on a dark bg becomes invisible). */
	background: #f5f5f7;
	color: #111827;
	border: 1px solid transparent;
	border-radius: 8px;
	padding: 4px 8px;
	font-size: 12px;
	cursor: pointer;
	max-width: 120px;
}
.header-lang option { color: #111827; background: #fff; }

/* ── Views ── */
.view { padding: 16px; }
.hidden { display: none !important; }

/* ── Empty state ── */
.empty-state { text-align: center; padding: 60px 20px; }
.empty-icon { margin-bottom: 16px; opacity: .7; }
.empty-state h2 { font-size: 20px; color: var(--text); margin-bottom: 8px; }
.empty-state p { font-size: 14px; color: var(--text-2); max-width: 300px; margin: 0 auto; }

/* ── Ticket list ── */
.ticket-list { display: flex; flex-direction: column; gap: 12px; max-width: 480px; margin: 0 auto; }
.ticket-card {
	background: var(--surface);
	border-radius: 14px;
	padding: 16px;
	box-shadow: 0 4px 16px rgba(0,0,0,.4);
	cursor: pointer;
	transition: transform .15s, box-shadow .15s;
	border-left: 4px solid var(--brand);
}
.ticket-card:active { transform: scale(.98); }
.ticket-card-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 8px; }
.ticket-card-event { font-size: 16px; font-weight: 600; color: var(--text); flex: 1; }
.ticket-card-status {
	font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .5px;
	padding: 2px 8px; border-radius: 10px; white-space: nowrap; margin-left: 8px;
}
.status-valid     { background: rgba(147,51,234,.20); color: #c9a7f5; }
.status-redeemed  { background: rgba(34,197,94,.18);  color: #4ade80; }
.status-expired   { background: rgba(245,158,11,.18); color: #fbbf24; }
.status-cancelled { background: rgba(239,68,68,.18);  color: #f87171; }
.status-receipt   { background: rgba(245,158,11,.18); color: #fbbf24; }

.ticket-card-meta { font-size: 13px; color: var(--text-2); }
.ticket-card-meta span { display: inline-block; margin-right: 12px; }
.ticket-card-shop { font-size: 12px; color: var(--text-muted); margin-top: 6px; }

/* ── Detail view ── */
.back-btn {
	background: none; border: none; color: var(--brand-2); font-size: 14px;
	cursor: pointer; padding: 4px 0; margin-bottom: 12px; font-weight: 500;
}
.ticket-detail { max-width: 480px; margin: 0 auto; }

/* ── Ticket pass (purple head + white QR body, classic ticket shape) ── */
.ticket-pass {
	max-width: 480px;
	margin: 0 auto;
	border-radius: 18px;
	overflow: hidden;
	box-shadow: 0 14px 40px rgba(0,0,0,.55);
	background: #fff;
}
.ticket-pass-head {
	background: linear-gradient(135deg, var(--brand), var(--brand-hover));
	color: #fff;
	padding: 18px 20px 20px;
	display: flex;
	justify-content: space-between;
	align-items: flex-start;
	gap: 14px;
}
.tp-head-left  { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1; }
.tp-head-right { display: flex; flex-direction: column; gap: 2px; text-align: right; flex-shrink: 0; max-width: 46%; }
.tp-kicker { font-size: 11px; text-transform: uppercase; letter-spacing: .6px; opacity: .8; }
.tp-event  { font-size: 18px; font-weight: 700; line-height: 1.2; word-break: break-word; }
.tp-no     { font-size: 13px; font-weight: 600; line-height: 1.3; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }

.ticket-pass-body {
	position: relative;
	background: #fff;
	color: #111827;
	padding: 22px 20px;
	display: flex;
	gap: 18px;
	align-items: center;
	flex-wrap: wrap;
	border-top: 2px dashed #e2c9fb;
}
/* Ticket notch: black half-circles biting into the seam on both edges. */
.ticket-pass-body::before,
.ticket-pass-body::after {
	content: '';
	position: absolute;
	top: -12px;
	width: 22px; height: 22px;
	background: var(--bg);
	border-radius: 50%;
}
.ticket-pass-body::before { left: -11px; }
.ticket-pass-body::after  { right: -11px; }

.tp-qr { background: #fff; border-radius: 10px; flex-shrink: 0; }
.tp-qr canvas { display: block; width: 150px; height: 150px; border-radius: 6px; }
.tp-info { flex: 1; min-width: 130px; display: flex; flex-direction: column; gap: 8px; }
.tp-info-row { display: flex; flex-direction: column; gap: 1px; }
.tp-info-label { font-size: 11px; text-transform: uppercase; letter-spacing: .4px; color: #9ca3af; }
.tp-info-value { font-size: 14px; font-weight: 600; color: #111827; word-break: break-word; }

/* ── Status pill below the pass ── */
.tp-status-pill {
	max-width: 480px;
	margin: 16px auto 0;
	text-align: center;
	padding: 13px 18px;
	border-radius: 12px;
	font-size: 15px;
	font-weight: 700;
	letter-spacing: .2px;
}
.tp-status-pill.status-redeemed  { background: #22c55e; color: #05290f; }
.tp-status-pill.status-valid     { background: rgba(147,51,234,.18); color: #d3b6f8; border: 1px solid rgba(147,51,234,.5); }
.tp-status-pill.status-expired   { background: rgba(245,158,11,.16); color: #fbbf24; border: 1px solid rgba(245,158,11,.4); }
.tp-status-pill.status-cancelled { background: rgba(239,68,68,.16);  color: #f87171; border: 1px solid rgba(239,68,68,.4); }

.detail-shop { margin-top: 16px; font-size: 12px; color: var(--text-muted); text-align: center; }

/* ── Receipt / generic detail card (kept for receipts) ── */
.detail-card {
	background: var(--surface);
	border-radius: 14px;
	padding: 20px;
	box-shadow: 0 6px 24px rgba(0,0,0,.45);
	text-align: center;
}
.detail-event-name { font-size: 20px; font-weight: 700; color: var(--text); margin-bottom: 4px; }
.detail-status { margin-bottom: 16px; }
.detail-qr { margin: 20px auto; padding: 12px; background: #fff; border-radius: 10px; display: inline-block; }
.detail-qr canvas { display: block; }
.detail-qr-label { font-size: 11px; color: #6b7280; margin-top: 8px; text-align: center; word-break: break-all; }
.detail-info { text-align: left; margin-top: 20px; border-top: 1px solid var(--border); padding-top: 16px; }
.detail-row { display: flex; justify-content: space-between; padding: 8px 0; font-size: 14px; border-bottom: 1px solid var(--border); }
.detail-label { color: var(--text-2); }
.detail-value { color: var(--text); font-weight: 500; text-align: right; }

/* ── Import / error ── */
.import-card, .error-card {
	background: var(--surface);
	border-radius: 14px;
	padding: 40px 20px;
	box-shadow: 0 6px 24px rgba(0,0,0,.45);
	text-align: center;
	margin-top: 40px;
}
.spinner {
	width: 32px; height: 32px;
	border: 3px solid var(--border);
	border-top-color: var(--brand);
	border-radius: 50%;
	animation: spin .7s linear infinite;
	margin: 0 auto 16px;
}
@keyframes spin { to { transform: rotate(360deg); } }
.error-icon { margin-bottom: 12px; }
.error-card h2 { margin-bottom: 8px; color: #f87171; }
.error-card p { color: var(--text-2); margin-bottom: 16px; }

/* ── Buttons ── */
.btn {
	display: inline-block; padding: 10px 20px; border: none; border-radius: 8px;
	font-size: 14px; font-weight: 600; cursor: pointer; text-decoration: none;
}
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:active { background: var(--brand-hover); }
.btn-link { background: none; color: var(--text-2); }
.btn-small { padding: 7px 14px; font-size: 13px; }
.btn-danger { background: rgba(239,68,68,.16); color: #f87171; }
.btn-danger:active { background: rgba(239,68,68,.28); }
.btn-secondary { background: var(--surface-2); color: var(--text); }
.btn-secondary:active { background: #2c2c30; }

/* ── Scanner ── */
.scanner-card { text-align: center; padding: 20px 0; }
.scanner-card h2 { color: var(--text); margin-bottom: 4px; }

/* ── Install banner ── */
.install-banner {
	position: fixed;
	bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom, 0px));
	left: 0; right: 0;
	background: var(--surface);
	border-top: 1px solid var(--border);
	padding: 12px 16px;
	box-shadow: 0 -2px 12px rgba(0,0,0,.5);
	display: flex; align-items: center; justify-content: space-between;
	z-index: 200;
}
.install-banner p { font-size: 14px; color: var(--text); flex: 1; }
.install-buttons { display: flex; gap: 8px; }

/* ── Bottom tab bar ── */
.tab-bar {
	position: fixed;
	left: 0; right: 0; bottom: 0;
	z-index: 150;
	display: flex;
	background: rgba(12,12,14,.92);
	backdrop-filter: saturate(160%) blur(14px);
	-webkit-backdrop-filter: saturate(160%) blur(14px);
	border-top: 1px solid var(--border);
	padding-bottom: env(safe-area-inset-bottom, 0px);
}
.tab-btn {
	flex: 1;
	background: none; border: none;
	color: var(--text-muted);
	display: flex; flex-direction: column; align-items: center; gap: 3px;
	padding: 9px 0 7px;
	font-size: 11px; font-weight: 500; cursor: pointer;
	transition: color .15s;
}
.tab-btn svg { width: 22px; height: 22px; }
.tab-btn:active, .tab-btn.active { color: var(--brand-2); }

/* ── Footer ── */
.app-footer { text-align: center; padding: 18px 16px 10px; font-size: 11px; color: var(--text-muted); }
.app-footer a { color: var(--text-muted); text-decoration: none; }
.app-footer a:hover { color: var(--text-2); }
#app-version { font-size: 10px; color: #bebebf; margin-top: 6px; }

/* ── Fullscreen QR overlay ── */
.qr-fullscreen {
	position: fixed; inset: 0; background: #000; z-index: 300;
	display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 20px;
}
.qr-fullscreen .qr-card { background: #fff; padding: 24px; border-radius: 16px; }
.qr-fullscreen canvas { max-width: 80vw; max-height: 80vw; display: block; }
.qr-fullscreen-close { margin-top: 24px; font-size: 16px; }

/* ── Receipt card (list) ── */
.receipt-card { border-left-color: #f59e0b; }
.ticket-card-footer { display: flex; justify-content: space-between; align-items: center; margin-top: 6px; }
.receipt-total { font-size: 15px; font-weight: 700; color: var(--text); }

/* ── Receipt items / totals (detail) ── */
.receipt-items-table { text-align: left; margin-top: 16px; border-top: 1px solid var(--border); padding-top: 12px; font-size: 13px; }
.receipt-items-header, .receipt-items-row { display: grid; grid-template-columns: 1fr 40px 60px 60px; gap: 4px; padding: 6px 0; align-items: center; }
.receipt-items-header { font-weight: 600; color: var(--text-2); font-size: 11px; text-transform: uppercase; letter-spacing: .3px; border-bottom: 1px solid var(--border); }
.receipt-items-row { border-bottom: 1px solid var(--border); }
.receipt-item-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text); }
.receipt-item-qty { text-align: center; color: var(--text-2); }
.receipt-item-price { text-align: right; color: var(--text-2); }
.receipt-item-total { text-align: right; font-weight: 500; color: var(--text); }
.receipt-totals { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--border); text-align: left; font-size: 14px; }
.receipt-totals-row { display: flex; justify-content: space-between; padding: 4px 0; color: var(--text-2); }
.receipt-totals-grand { font-weight: 700; color: var(--text); font-size: 16px; margin-top: 4px; padding-top: 8px; border-top: 1px solid var(--border); }
/* When only the paper bon is shown, drop the dark card frame so the bon floats on black. */
.detail-card--bon { background: none; box-shadow: none; padding: 0; }
.detail-card--bon .receipt-html-container { margin-top: 0; }

/* Receipt snapshot rendered as a real paper bon (mirrors pos-desk receipt-printer). */
.receipt-html-container {
	margin: 18px auto 0;
	max-width: 320px;
	background: #fff;
	color: #1f2937;
	font-family: ui-monospace, 'SFMono-Regular', Menlo, Consolas, 'Liberation Mono', monospace;
	font-size: 12px;
	line-height: 1.45;
	padding: 18px 20px 22px;
	border-radius: 10px;
	box-shadow: 0 10px 30px rgba(0,0,0,.55);
}
.receipt-html-container .vst-pos-receipt-copy-mark { text-align: center; font-weight: 700; font-size: 14px; margin: 0 0 8px; padding: 4px 0; border: 2px dashed #999; letter-spacing: 2px; }
.receipt-html-container .vst-pos-receipt-business { text-align: center; font-weight: 700; font-size: 14px; margin-bottom: 8px; }
.receipt-html-container .vst-pos-receipt-meta { text-align: center; color: #666; font-size: 11px; margin-bottom: 12px; padding-bottom: 8px; border-bottom: 1px dashed #999; }
.receipt-html-container .vst-pos-receipt-item { display: flex; justify-content: space-between; gap: 10px; margin: 2px 0; }
.receipt-html-container .vst-pos-receipt-items { border-bottom: 1px dashed #999; padding-bottom: 8px; margin-bottom: 8px; }
.receipt-html-container .vst-pos-receipt-totals div,
.receipt-html-container .vst-pos-receipt-change div { display: flex; justify-content: space-between; margin: 2px 0; }
.receipt-html-container .vst-pos-receipt-grand { font-weight: 700; font-size: 14px; border-top: 1px solid #333; padding-top: 4px; margin-top: 4px; }
.receipt-html-container .vst-pos-receipt-change { border-top: 1px dashed #999; padding-top: 8px; margin-top: 8px; }
.receipt-html-container .vst-pos-receipt-footer { text-align: center; color: #666; font-size: 10px; margin-top: 12px; padding-top: 8px; border-top: 1px dashed #999; }
/* Merchant QR (TXR|<id>) — let the cashier scan it from the customer's phone. */
.receipt-html-container .vst-pos-receipt-qr { text-align: center; margin-top: 12px; padding-top: 8px; border-top: 1px dashed #999; }
.receipt-html-container .vst-receipt-qr { display: flex; justify-content: center; margin: 4px 0; }
.receipt-html-container .vst-receipt-qr canvas { width: 150px; height: 150px; }
/* The "save to wallet" QR/promo is pointless once you're already in the wallet → hide it. */
.receipt-html-container .vst-pos-receipt-wallet { display: none; }

/* ── Item actions (congress, future types) ── */
.item-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 16px 0 4px; justify-content: center; }
.item-action.is-disabled { opacity: .5; cursor: not-allowed; }
.item-action-hint { font-size: .82em; color: var(--text-muted); }
.ticket-card-actions { display: inline-flex; gap: 6px; margin-left: auto; padding-left: 8px; }
.ticket-card-action-icon { text-decoration: none; font-size: 1.1em; line-height: 1; opacity: .9; }
.ticket-card-action-icon:hover { opacity: 1; }
.ticket-card-past { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .5px; padding: 2px 8px; border-radius: 10px; white-space: nowrap; margin-left: 6px; background: var(--surface-2); color: var(--text-2); }

/* ── Modal confirm dialog ── */
.wallet-modal-overlay {
	position: fixed; inset: 0; z-index: 400;
	background: rgba(0,0,0,.7);
	display: flex; align-items: center; justify-content: center; padding: 20px;
	animation: walletModalFade .15s ease;
}
@keyframes walletModalFade { from { opacity: 0; } to { opacity: 1; } }
.wallet-modal {
	background: var(--surface); border-radius: 16px; width: 100%; max-width: 380px;
	padding: 24px 22px 18px; box-shadow: 0 12px 40px rgba(0,0,0,.6);
	border: 1px solid var(--border);
	text-align: center; animation: walletModalPop .15s ease;
}
@keyframes walletModalPop { from { transform: scale(.95); } to { transform: scale(1); } }
.wallet-modal-title { font-size: 17px; font-weight: 700; color: var(--text); margin-bottom: 8px; }
.wallet-modal-body { font-size: 15px; color: var(--text-2); line-height: 1.45; margin-bottom: 20px; }
.wallet-modal-actions { display: flex; gap: 10px; }
.wallet-modal-actions .btn { flex: 1; }
.btn-secondary:active { background: #2c2c30; }
