/* Event Sync — project stylesheet on top of Bootstrap 5.3.
   Design tokens from the PRD (section 19.2). */

:root {
  --es-primary: #2563EB;
  --es-primary-hover: #1D4ED8;
  --es-primary-soft: #EFF6FF;
  --es-bg: #F8FAFC;
  --es-surface: #FFFFFF;
  --es-text: #0F172A;
  --es-muted: #64748B;
  --es-success: #059669;
  --es-danger: #DC2626;
  --es-warning: #D97706;
  --es-border: #E2E8F0;
  --es-radius: .75rem;
  --es-shadow: 0 1px 2px rgba(15, 23, 42, .04), 0 1px 3px rgba(15, 23, 42, .06);
  --es-sidebar-w: 248px;

  --bs-primary: var(--es-primary);
  --bs-primary-rgb: 37, 99, 235;
  --bs-success-rgb: 5, 150, 105;
  --bs-danger-rgb: 220, 38, 38;
  --bs-warning-rgb: 217, 119, 6;
  --bs-body-font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --bs-body-color: var(--es-text);
  --bs-body-bg: var(--es-bg);
  --bs-border-color: var(--es-border);
  --bs-secondary-color: var(--es-muted);
  --bs-link-color: var(--es-primary);
  --bs-link-color-rgb: 37, 99, 235;
  --bs-link-hover-color: var(--es-primary-hover);
  --bs-border-radius: .5rem;
  --bs-border-radius-lg: var(--es-radius);
  --bs-focus-ring-color: rgba(37, 99, 235, .35);
}

body { background: var(--es-bg); color: var(--es-text); font-size: .9375rem; -webkit-font-smoothing: antialiased; }
h1, h2, h3, h4, h5, h6 { color: var(--es-text); font-weight: 600; letter-spacing: -.01em; }
.text-muted, .text-secondary { color: var(--es-muted) !important; }
a { text-underline-offset: 2px; }

/* Buttons */
.btn { font-weight: 500; border-radius: .5rem; }
.btn-primary {
  --bs-btn-bg: var(--es-primary); --bs-btn-border-color: var(--es-primary);
  --bs-btn-hover-bg: var(--es-primary-hover); --bs-btn-hover-border-color: var(--es-primary-hover);
  --bs-btn-active-bg: #1E40AF; --bs-btn-active-border-color: #1E40AF;
  --bs-btn-disabled-bg: var(--es-primary); --bs-btn-disabled-border-color: var(--es-primary);
}
.btn-outline-primary {
  --bs-btn-color: var(--es-primary); --bs-btn-border-color: var(--es-primary);
  --bs-btn-hover-bg: var(--es-primary); --bs-btn-hover-border-color: var(--es-primary);
  --bs-btn-active-bg: var(--es-primary-hover); --bs-btn-active-border-color: var(--es-primary-hover);
}
.btn-light { --bs-btn-bg: #fff; --bs-btn-border-color: var(--es-border); --bs-btn-hover-bg: #F1F5F9; --bs-btn-hover-border-color: #CBD5E1; }
.btn-lg-touch { min-height: 48px; }
:focus-visible { outline: 3px solid rgba(37, 99, 235, .45); outline-offset: 2px; }

/* Cards & surfaces */
.card { border: 1px solid var(--es-border); border-radius: var(--es-radius); box-shadow: var(--es-shadow); }
.card-header { background: transparent; border-bottom: 1px solid var(--es-border); font-weight: 600; padding: .875rem 1.25rem; }
.card-body { padding: 1.25rem; }
.section-title { font-size: .75rem; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--es-muted); }

/* Forms */
.form-label { font-weight: 500; margin-bottom: .35rem; }
.form-control, .form-select { border-color: var(--es-border); border-radius: .5rem; padding: .55rem .8rem; }
.form-control:focus, .form-select:focus { border-color: var(--es-primary); box-shadow: 0 0 0 .2rem rgba(37, 99, 235, .15); }
.form-text { color: var(--es-muted); }
.required::after { content: " *"; color: var(--es-danger); }
.fieldset-card legend { font-size: 1rem; font-weight: 600; margin-bottom: 1rem; }

/* Tables */
.table { --bs-table-bg: transparent; margin-bottom: 0; }
.table > :not(caption) > * > * { padding: .75rem 1rem; border-bottom-color: var(--es-border); vertical-align: middle; }
.table thead th { font-size: .75rem; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--es-muted); background: #F8FAFC; white-space: nowrap; }
.table-hover > tbody > tr:hover > * { --bs-table-hover-bg: #F8FAFC; }
.table-responsive { border-radius: 0 0 var(--es-radius) var(--es-radius); }
.cell-sub { display: block; font-size: .8125rem; color: var(--es-muted); }

/* Status badges: soft background + icon + label (never colour alone) */
.badge-soft { font-weight: 500; font-size: .75rem; padding: .35em .6em; border-radius: 999px; border: 1px solid transparent; white-space: nowrap; }
.badge-soft .bi { margin-right: .15rem; }
.badge-soft-success { background: #ECFDF5; color: #047857; border-color: #A7F3D0; }
.badge-soft-danger { background: #FEF2F2; color: #B91C1C; border-color: #FECACA; }
.badge-soft-warning { background: #FFFBEB; color: #92400E; border-color: #FDE68A; }
.badge-soft-info { background: #EFF6FF; color: #1D4ED8; border-color: #BFDBFE; }
.badge-soft-secondary { background: #F1F5F9; color: #334155; border-color: #CBD5E1; }
.badge-soft-light { background: #F8FAFC; color: #475569; border-color: var(--es-border); }

/* App shell */
.skip-link { position: absolute; left: 1rem; top: 1rem; z-index: 2000; background: #fff; padding: .5rem 1rem; border-radius: .5rem; }
.app-shell { display: flex; min-height: 100vh; }
.app-sidebar { background: #fff; border-right: 1px solid var(--es-border); }
@media (min-width: 992px) {
  .app-sidebar { width: var(--es-sidebar-w); position: sticky; top: 0; height: 100vh; flex-shrink: 0; overflow-y: auto; }
}
.app-brand { display: flex; align-items: center; gap: .6rem; font-weight: 700; font-size: 1.05rem; color: var(--es-text); text-decoration: none; padding: 1.1rem 1.25rem; }
.app-brand-mark { width: 32px; height: 32px; border-radius: .5rem; background: var(--es-primary); color: #fff; display: inline-flex; align-items: center; justify-content: center; font-size: 1rem; }
.app-nav { padding: .25rem .75rem 1rem; }
.app-nav .nav-heading { font-size: .7rem; font-weight: 600; text-transform: uppercase; letter-spacing: .08em; color: #94A3B8; padding: 1rem .75rem .4rem; }
.app-nav .nav-link { display: flex; align-items: center; gap: .7rem; color: #334155; border-radius: .5rem; padding: .55rem .75rem; font-weight: 500; }
.app-nav .nav-link .bi { font-size: 1.05rem; color: #64748B; }
.app-nav .nav-link:hover { background: #F1F5F9; color: var(--es-text); }
.app-nav .nav-link.active { background: var(--es-primary-soft); color: var(--es-primary); }
.app-nav .nav-link.active .bi { color: var(--es-primary); }
.app-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.app-topbar { position: sticky; top: 0; z-index: 1020; background: rgba(255, 255, 255, .92); backdrop-filter: blur(8px); border-bottom: 1px solid var(--es-border); display: flex; align-items: center; gap: .75rem; padding: .65rem 1.25rem; min-height: 60px; }
.app-topbar .page-title { font-size: 1.05rem; font-weight: 600; margin: 0; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.app-content { padding: 1.5rem 1.25rem 3rem; max-width: 1320px; width: 100%; }
@media (min-width: 992px) { .app-content { padding: 1.75rem 2rem 3rem; } }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--es-primary-soft); color: var(--es-primary); display: inline-flex; align-items: center; justify-content: center; font-weight: 600; font-size: .8rem; }

/* Page header */
.page-header { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: 1rem; margin-bottom: 1.5rem; }
.page-header h1 { font-size: 1.5rem; margin-bottom: .25rem; }
.page-header p { margin: 0; color: var(--es-muted); }

/* Metric cards */
.metric { display: flex; flex-direction: column; gap: .25rem; }
.metric-label { font-size: .8125rem; color: var(--es-muted); font-weight: 500; display: flex; align-items: center; gap: .4rem; }
.metric-value { font-size: 1.75rem; font-weight: 700; letter-spacing: -.02em; line-height: 1.2; }
.metric-icon { width: 36px; height: 36px; border-radius: .6rem; display: inline-flex; align-items: center; justify-content: center; font-size: 1.1rem; }
.metric-icon.primary { background: var(--es-primary-soft); color: var(--es-primary); }
.metric-icon.success { background: #ECFDF5; color: var(--es-success); }
.metric-icon.warning { background: #FFFBEB; color: var(--es-warning); }
.metric-icon.slate { background: #F1F5F9; color: #475569; }

.progress { height: .5rem; background: #F1F5F9; border-radius: 999px; }
.progress-bar { background-color: var(--es-success); }

/* Empty states */
.empty-state { text-align: center; padding: 3rem 1.5rem; }
.empty-state .bi { font-size: 2.25rem; color: #94A3B8; }
.empty-state h2, .empty-state h3 { font-size: 1.05rem; margin-top: .75rem; }
.empty-state p { color: var(--es-muted); max-width: 420px; margin: .25rem auto 1rem; }

/* Copy link field */
.copy-field { display: flex; gap: .5rem; }
.copy-field input { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .85rem; background: #F8FAFC; }

/* Filters bar */
.filters .form-control, .filters .form-select { min-width: 140px; }

/* Description list */
.dl-compact dt { font-weight: 500; color: var(--es-muted); font-size: .8125rem; }
.dl-compact dd { margin-bottom: .85rem; }

/* Public pages */
.public-header { background: #fff; border-bottom: 1px solid var(--es-border); }
.public-hero { border-radius: var(--es-radius); overflow: hidden; background: linear-gradient(135deg, #1E3A8A, #2563EB); min-height: 180px; }
.public-hero img { width: 100%; height: 280px; object-fit: cover; display: block; }
@media (max-width: 575.98px) { .public-hero img { height: 180px; } }
.event-meta { list-style: none; padding: 0; margin: 0; }
.event-meta li { display: flex; gap: .75rem; padding: .6rem 0; }
.event-meta .bi { color: var(--es-primary); font-size: 1.15rem; margin-top: .1rem; }
.price-tag { font-size: 1.5rem; font-weight: 700; }
.event-card { transition: border-color .15s ease; }
.event-card:hover { border-color: #93C5FD; }
.event-card .date-chip { width: 56px; border-radius: .6rem; background: var(--es-primary-soft); color: var(--es-primary); text-align: center; padding: .4rem 0; flex-shrink: 0; }
.event-card .date-chip .m { font-size: .7rem; font-weight: 600; text-transform: uppercase; }
.event-card .date-chip .d { font-size: 1.35rem; font-weight: 700; line-height: 1; }
.status-hero { text-align: center; padding: 2rem 1rem 1rem; }
.status-hero .status-icon { width: 72px; height: 72px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-size: 2.2rem; margin-bottom: 1rem; }
.status-icon.success { background: #ECFDF5; color: var(--es-success); }
.status-icon.warning { background: #FFFBEB; color: var(--es-warning); }
.status-icon.danger { background: #FEF2F2; color: var(--es-danger); }

/* Scanner */
.scanner-wrap { max-width: 640px; margin: 0 auto; }
.scanner-viewport { position: relative; background: #0F172A; border-radius: var(--es-radius); overflow: hidden; aspect-ratio: 1 / 1; max-height: 62vh; width: 100%; display: flex; align-items: center; justify-content: center; }
@media (min-width: 768px) { .scanner-viewport { aspect-ratio: 4 / 3; } }
.scanner-viewport #reader { width: 100%; height: 100%; }
.scanner-viewport #reader video { width: 100% !important; height: 100% !important; object-fit: cover; }
.scanner-viewport #reader img[alt="Info icon"], .scanner-viewport #reader__dashboard_section_csr { display: none !important; }
.scanner-placeholder { color: #CBD5E1; text-align: center; padding: 1.5rem; position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .75rem; }
.scanner-placeholder .bi { font-size: 3rem; color: #94A3B8; }
.scan-frame { position: absolute; inset: 15%; border: 3px solid rgba(255, 255, 255, .85); border-radius: 1rem; box-shadow: 0 0 0 9999px rgba(15, 23, 42, .35); pointer-events: none; display: none; }
.scanning .scan-frame { display: block; }
.scan-result { border-radius: var(--es-radius); padding: 1.25rem; border: 2px solid var(--es-border); background: #fff; display: flex; gap: 1rem; align-items: flex-start; }
.scan-result .result-icon { font-size: 2.75rem; line-height: 1; flex-shrink: 0; }
.scan-result .result-title { font-size: 1.5rem; font-weight: 700; margin: 0; text-transform: uppercase; letter-spacing: .02em; }
.scan-result .result-name { font-size: 1.35rem; font-weight: 600; margin: .25rem 0 .15rem; word-break: break-word; }
.scan-result.is-success { border-color: var(--es-success); background: #ECFDF5; }
.scan-result.is-success .result-icon, .scan-result.is-success .result-title { color: #047857; }
.scan-result.is-warning { border-color: var(--es-warning); background: #FFFBEB; }
.scan-result.is-warning .result-icon, .scan-result.is-warning .result-title { color: #92400E; }
.scan-result.is-danger { border-color: var(--es-danger); background: #FEF2F2; }
.scan-result.is-danger .result-icon, .scan-result.is-danger .result-title { color: #B91C1C; }
.scan-result.is-idle .result-icon { color: #94A3B8; }
.scan-counter { font-variant-numeric: tabular-nums; }
.recent-scans .list-group-item { display: flex; justify-content: space-between; align-items: center; gap: .75rem; padding: .7rem 1rem; }
.recent-scans .name { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pass-input { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; letter-spacing: .08em; text-transform: uppercase; }

/* Auth */
.auth-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 1.5rem; }
.auth-card { width: 100%; max-width: 420px; }

/* Utilities */
.min-w-0 { min-width: 0; }
.text-pre-wrap { white-space: pre-wrap; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.row-new { animation: rowflash 2s ease-out; }
@keyframes rowflash { from { background: #EFF6FF; } to { background: transparent; } }
@media (prefers-reduced-motion: reduce) { .row-new { animation: none; } * { scroll-behavior: auto !important; } }
.spinner-inline { width: 1rem; height: 1rem; border-width: .15em; }
