/* Alcatraz Check-in — gepolijste UI
   Branding-variabelen worden door /api/settings/branding overschreven. */

:root {
    --primary: #0f172a;
    --primary-2: #1e293b;
    --secondary: #7c3aed;
    --secondary-hover: #6d28d9;
    --accent: #fde047;
    --bg: #f1f5f9;
    --bg-2: #e2e8f0;
    --text: #0f172a;
    --text-2: #475569;
    --muted: #94a3b8;
    --ok: #16a34a;
    --ok-bg: #dcfce7;
    --warn: #f59e0b;
    --warn-bg: #fef3c7;
    --err: #dc2626;
    --err-bg: #fee2e2;
    --card: #ffffff;
    --border: #e2e8f0;
    --border-strong: #cbd5e1;
    --shadow-sm: 0 1px 2px 0 rgba(15, 23, 42, .04);
    --shadow: 0 4px 12px -2px rgba(15, 23, 42, .08), 0 2px 4px -2px rgba(15, 23, 42, .04);
    --shadow-lg: 0 20px 40px -12px rgba(15, 23, 42, .15);
    --radius: 12px;
    --radius-sm: 8px;
    --radius-lg: 16px;
    --font: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; min-height: 100%; font-family: var(--font);
    background: var(--bg); color: var(--text); -webkit-tap-highlight-color: transparent;
    font-size: 15px; line-height: 1.5; }
body { padding-top: env(safe-area-inset-top); padding-bottom: env(safe-area-inset-bottom); }

/* ─── Top status bar (online/offline) ─────────────────────── */
#status-bar { position: fixed; top: 0; left: 0; right: 0; padding: 6px 14px; font-size: 12px;
    text-align: center; color: white; z-index: 1000; font-weight: 600; letter-spacing: .03em;
    transform: translateY(-100%); transition: transform .25s ease; }
.status.online { background: var(--ok); }
.status.online.show, .status.offline, .status.syncing { transform: translateY(0); }
.status.offline { background: var(--err); }
.status.syncing { background: var(--warn); color: #422006; }

/* ─── Layout ─────────────────────────────────────────────── */
#root { min-height: 100dvh; }

.page {
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 16px 32px;
}

/* App header — sticky bovenaan */
.app-header {
    position: sticky; top: 0; z-index: 50;
    background: var(--primary);
    color: white;
    padding: 12px 16px;
    display: flex; align-items: center; gap: 12px;
    box-shadow: var(--shadow);
    margin-bottom: 24px;
}
.app-header .brand {
    display: flex; align-items: center; gap: 10px;
    font-weight: 800; font-size: 17px; letter-spacing: -.01em;
    flex: 1; min-width: 0;
}
.app-header .brand-mark {
    width: 32px; height: 32px; border-radius: 8px;
    background: var(--secondary);
    display: grid; place-items: center;
    color: white; font-weight: 900; font-size: 14px;
}
.app-header .brand-mark-img {
    height: 32px; width: auto; max-width: 120px; object-fit: contain;
    /* logo'en op donkere header: laat ze als-is, maar val niet op bij kleurmismatch */
    filter: brightness(1) drop-shadow(0 1px 2px rgba(0,0,0,.2));
}
.app-header .page-title { font-size: 13px; opacity: .7; margin-left: 8px; font-weight: 500; }
.app-header nav { display: flex; gap: 6px; flex-wrap: wrap; }
.app-header nav button {
    background: rgba(255, 255, 255, .08);
    color: white;
    min-height: 38px;
    padding: 8px 14px;
    font-size: 14px;
    font-weight: 600;
    border-radius: var(--radius-sm);
    border: 1px solid rgba(255, 255, 255, .08);
}
.app-header nav button:hover { background: rgba(255, 255, 255, .18); }
.app-header nav button.active { background: var(--secondary); border-color: transparent; }

/* ─── Typography ─────────────────────────────────────────── */
h1, h2, h3 { margin: 0 0 12px; letter-spacing: -.015em; line-height: 1.25; }
h1 { font-size: 24px; font-weight: 800; }
h2 { font-size: 19px; font-weight: 700; }
h3 { font-size: 16px; font-weight: 700; }
.muted { color: var(--text-2); font-size: 13.5px; }
.tiny { font-size: 12px; color: var(--muted); }
code { background: var(--bg-2); padding: 2px 6px; border-radius: 4px; font-family: "SF Mono", Monaco, Consolas, monospace; font-size: 0.9em; }

/* ─── Buttons ────────────────────────────────────────────── */
button, .btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    background: var(--primary); color: white;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    padding: 10px 16px; font-size: 14.5px; font-weight: 600;
    cursor: pointer; user-select: none;
    min-height: 42px;
    transition: transform .05s, background .15s, box-shadow .15s;
    font-family: inherit;
}
button:hover { background: var(--primary-2); }
button:active { transform: scale(.98); }
button:focus-visible { outline: 2px solid var(--secondary); outline-offset: 2px; }
button.secondary { background: var(--card); color: var(--text); border-color: var(--border-strong); }
button.secondary:hover { background: var(--bg-2); }
button.success { background: var(--ok); }
button.success:hover { background: #15803d; }
button.danger { background: var(--err); }
button.danger:hover { background: #b91c1c; }
button.accent { background: var(--secondary); }
button.accent:hover { background: var(--secondary-hover); }
button.ghost { background: transparent; color: var(--text); border-color: transparent; min-height: 36px; }
button.ghost:hover { background: var(--bg-2); }
button.small { min-height: 32px; padding: 4px 10px; font-size: 13px; }
button[disabled] { opacity: .5; cursor: not-allowed; transform: none; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ─── Forms ──────────────────────────────────────────────── */
input, select, textarea {
    width: 100%; padding: 10px 12px; font-size: 14.5px;
    border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
    background: var(--card); color: var(--text);
    min-height: 42px;
    font-family: inherit;
    transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus {
    outline: none; border-color: var(--secondary);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--secondary) 25%, transparent);
}
textarea { min-height: 100px; font-family: "SF Mono", Monaco, Consolas, monospace; font-size: 13px; }
input[type="color"] { padding: 4px; min-height: 42px; cursor: pointer; }
input[type="file"] { padding: 8px; }
input[type="checkbox"] { width: auto; min-height: auto; transform: scale(1.2); margin: 0 6px 0 0; }

.field { margin-bottom: 14px; }
.field label { display: block; font-size: 12.5px; color: var(--text-2); font-weight: 600; margin-bottom: 6px; text-transform: uppercase; letter-spacing: .04em; }
.field-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; }

/* ─── Cards ──────────────────────────────────────────────── */
.card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 16px;
    box-shadow: var(--shadow-sm);
}
.card.dense { padding: 14px; }
.card-title { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.card-title h2, .card-title h3 { margin: 0; }

/* ─── Tabs ───────────────────────────────────────────────── */
.tabs {
    display: flex; gap: 2px;
    background: var(--card);
    border: 1px solid var(--border);
    padding: 4px;
    border-radius: var(--radius);
    margin-bottom: 20px;
    box-shadow: var(--shadow-sm);
    overflow-x: auto;
}
.tabs button {
    background: transparent;
    color: var(--text-2);
    padding: 8px 14px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    min-height: 38px;
    flex-shrink: 0;
    border: none;
}
.tabs button:hover { background: var(--bg-2); color: var(--text); }
.tabs button.active { background: var(--primary); color: white; }

/* ─── Tables ─────────────────────────────────────────────── */
.table-wrap {
    overflow-x: auto; -webkit-overflow-scrolling: touch;
    border: 1px solid var(--border); border-radius: var(--radius);
    background: var(--card);
}
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { padding: 10px 14px; text-align: left; border-bottom: 1px solid var(--border); }
th { color: var(--text-2); font-weight: 600; font-size: 12px; text-transform: uppercase;
    letter-spacing: .03em; background: var(--bg); position: sticky; top: 0; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--bg); }

/* ─── KPI cards ──────────────────────────────────────────── */
.kpi { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 14px; margin-bottom: 16px; }
.kpi .card { text-align: center; padding: 24px 12px; }
.kpi .num { font-size: 38px; font-weight: 800; color: var(--secondary); letter-spacing: -.02em; line-height: 1; margin-bottom: 6px; }
.kpi .lbl { font-size: 11.5px; color: var(--text-2); text-transform: uppercase; letter-spacing: .06em; font-weight: 600; }

/* ─── Scanner ───────────────────────────────────────────── */
.scanner-view { position: relative; aspect-ratio: 4 / 3; background: #000;
    border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow-lg); margin-bottom: 16px; }
.scanner-view video { width: 100%; height: 100%; object-fit: cover; display: block; }
.scanner-overlay { position: absolute; inset: 0; pointer-events: none;
    background: radial-gradient(circle at center, transparent 35%, rgba(0,0,0,.55) 75%); }
.scanner-corner {
    position: absolute; width: 30px; height: 30px;
    border: 3px solid var(--accent);
}
.scanner-corner.tl { top: 25%; left: 18%; border-right: none; border-bottom: none; border-radius: 6px 0 0 0; }
.scanner-corner.tr { top: 25%; right: 18%; border-left: none; border-bottom: none; border-radius: 0 6px 0 0; }
.scanner-corner.bl { bottom: 25%; left: 18%; border-right: none; border-top: none; border-radius: 0 0 0 6px; }
.scanner-corner.br { bottom: 25%; right: 18%; border-left: none; border-top: none; border-radius: 0 0 6px 0; }

.result-tent {
    display: flex; align-items: center; justify-content: space-between; gap: 16px;
    padding: 20px; background: linear-gradient(135deg, var(--primary), var(--primary-2));
    color: white; border-radius: var(--radius); margin-bottom: 16px;
}
.result-tent .num { font-size: 48px; font-weight: 900; line-height: 1; letter-spacing: -.03em; }
.result-tent .label { font-size: 12px; opacity: .7; text-transform: uppercase; letter-spacing: .05em; margin-bottom: 4px; }
.result-tent .counter { font-size: 30px; font-weight: 800; color: var(--accent); }
.result-tent.error { background: linear-gradient(135deg, #991b1b, var(--err)); }

/* ─── Feedback / toasts ─────────────────────────────────── */
.feedback {
    position: fixed; top: 30%; left: 50%; transform: translate(-50%, -50%) scale(.5);
    background: var(--ok); color: white;
    padding: 20px 32px; border-radius: var(--radius-lg);
    font-size: 22px; font-weight: 800; z-index: 999;
    box-shadow: var(--shadow-lg); opacity: 0;
    transition: transform .15s ease, opacity .15s ease;
}
.feedback.show { transform: translate(-50%, -50%) scale(1); opacity: 1; }
.feedback.err { background: var(--err); }

.queue-badge {
    display: inline-block; background: var(--warn-bg); color: #92400e;
    padding: 3px 10px; border-radius: 999px; font-size: 11px; font-weight: 700;
    text-transform: uppercase; letter-spacing: .04em;
}
.test-badge {
    display: inline-block; background: #fef3c7; color: #92400e;
    padding: 2px 8px; border-radius: 999px; font-size: 10px; font-weight: 700;
    letter-spacing: .05em; margin-left: 6px;
}

.toast {
    position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%) translateY(20px);
    background: var(--primary); color: white;
    padding: 12px 20px; border-radius: var(--radius);
    z-index: 1500; opacity: 0;
    transition: opacity .2s, transform .2s;
    box-shadow: var(--shadow-lg);
    font-weight: 500;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ─── Modal ─────────────────────────────────────────────── */
.modal-overlay {
    position: fixed; inset: 0;
    background: rgba(15, 23, 42, .55);
    z-index: 2000;
    display: grid; place-items: center;
    padding: 20px;
    backdrop-filter: blur(2px);
    animation: fadeIn .15s ease;
}
.modal-card {
    background: var(--card);
    border-radius: var(--radius-lg);
    padding: 24px;
    max-width: 540px;
    width: 100%;
    max-height: 90vh; overflow-y: auto;
    box-shadow: var(--shadow-lg);
    animation: zoomIn .15s ease;
}
@keyframes fadeIn { from { opacity: 0 } to { opacity: 1 } }
@keyframes zoomIn { from { transform: scale(.96); opacity: 0 } to { transform: scale(1); opacity: 1 } }

mark { background: var(--accent); color: var(--text); padding: 0 2px; border-radius: 3px; font-weight: 600; }

/* ─── Floor plan grid ───────────────────────────────────── */
.floorplan-grid {
    display: grid;
    gap: 3px;
    background: var(--bg-2);
    padding: 6px;
    border-radius: var(--radius);
    overflow-x: auto;
}
.fp-cell {
    background: var(--card);
    aspect-ratio: 1;
    display: flex; align-items: center; justify-content: center;
    font-size: 10px; font-weight: 700;
    border-radius: 4px;
    min-width: 28px;
}
.fp-cell.tent { background: #fde68a; color: #78350f; }
.fp-cell.tent.partial { background: var(--accent); color: #422006; }
.fp-cell.tent.full { background: var(--ok); color: white; }
.fp-cell.label { background: var(--secondary); color: white; font-size: 9px; }
.fp-cell.path { background: var(--accent); }
.fp-cell.target { background: var(--err); color: white; box-shadow: 0 0 0 3px var(--err-bg); }
.fp-cell.empty { background: transparent; }

/* ─── Customer screen ───────────────────────────────────── */
.customer-screen { background: var(--primary); color: white;
    min-height: 100vh; padding: 0; position: relative; overflow: hidden;
    display: flex; align-items: center; justify-content: center; }
.cs-center { display: flex; align-items: center; justify-content: center; width: 100%; min-height: 100vh; }
.cs-canvas, .cs-canvas-idle { transform-origin: center; }

/* Elk blok heeft een vaste structuur: kleine label bovenaan + hoofdcontent eronder.
   overflow:hidden voorkomt dat grote getallen over naburige blokken vloeien. */
.cs-block {
    display: flex; flex-direction: column; justify-content: center;
    overflow: hidden; padding: 8px 4px;
}
.cs-label {
    font-size: 13px; opacity: .45; text-transform: uppercase;
    letter-spacing: .08em; margin-bottom: 6px; font-weight: 600;
    flex: 0 0 auto;
}
.cs-block .cs-content {
    flex: 1 1 auto; display: flex; align-items: center; justify-content: flex-start;
    min-height: 0; min-width: 0;
}
.cs-qr .cs-content { justify-content: center; }
.cs-qr .cs-content img { max-width: 100%; max-height: 100%; width: 100%; height: 100%; }

.cs-qr {
    text-align: center;
}
.cs-qr img {
    width: 100%; height: 100%; background: white;
    padding: 10px; border-radius: 14px;
    object-fit: contain; image-rendering: pixelated;
    box-sizing: border-box;
}
.cs-tent {
    font-size: 96px; font-weight: 900; line-height: 1;
    letter-spacing: -.04em;
}
.cs-counter {
    font-size: 48px; font-weight: 800; color: var(--accent);
    letter-spacing: -.02em; line-height: 1;
}

/* ─── Login ─────────────────────────────────────────────── */
.login-wrap {
    min-height: 100dvh;
    display: grid; place-items: center;
    padding: 24px;
    background: linear-gradient(135deg, var(--primary), var(--primary-2));
}
.login-card {
    background: var(--card);
    border-radius: var(--radius-lg);
    padding: 32px;
    max-width: 380px;
    width: 100%;
    box-shadow: var(--shadow-lg);
}
.login-card .brand-mark {
    width: 56px; height: 56px; border-radius: 14px;
    background: var(--secondary);
    display: grid; place-items: center;
    color: white; font-weight: 900; font-size: 24px;
    margin-bottom: 16px;
}

/* ─── Import preview ────────────────────────────────────── */
.diff-summary {
    display: flex; gap: 12px; margin: 12px 0; flex-wrap: wrap;
}
.diff-pill {
    background: var(--bg); padding: 8px 14px; border-radius: var(--radius-sm);
    font-size: 13px; font-weight: 600;
    border: 1px solid var(--border);
}
.diff-pill.add { color: var(--ok); background: var(--ok-bg); border-color: transparent; }
.diff-pill.upd { color: #92400e; background: var(--warn-bg); border-color: transparent; }
.diff-pill.skip { color: var(--text-2); }

.preview-rows {
    max-height: 360px; overflow-y: auto;
    border: 1px solid var(--border); border-radius: var(--radius);
    background: var(--card);
}
.preview-rows table { font-size: 12.5px; }
.preview-rows th, .preview-rows td { padding: 6px 10px; }

/* ─── Utility ───────────────────────────────────────────── */
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.row > input, .row > select { flex: 1; min-width: 120px; }
.spacer { flex: 1; }
.text-right { text-align: right; }
.text-center { text-align: center; }
.hidden { display: none !important; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 16px; }
.mb-2 { margin-bottom: 8px; }
.mb-3 { margin-bottom: 16px; }

@media (max-width: 640px) {
    .app-header { padding: 10px 12px; gap: 8px; }
    .app-header .brand { font-size: 15px; }
    .app-header .page-title { display: none; }
    .app-header nav button { padding: 6px 10px; font-size: 13px; min-height: 36px; }
    .page { padding: 0 12px 24px; }
    h1 { font-size: 21px; }
    .cs-tent { font-size: 72px; }
    .cs-counter { font-size: 36px; }
}

/* ─── Plattegrond met pin (PDF kaart + OCR markers) ────────── */
.map-wrap {
    position: relative; width: 100%; max-height: 70vh; overflow: auto;
    background: white; border-radius: 10px; padding: 8px;
    -webkit-overflow-scrolling: touch;
}
.map-img { display: block; width: 100%; height: auto; user-select: none; pointer-events: none; }
.map-pin { position: absolute; transform: translate(-50%, -100%); pointer-events: none; z-index: 5; }
.map-pin-dot {
    background: #dc2626; color: white; border: 3px solid white; border-radius: 999px;
    min-width: 44px; height: 44px; padding: 0 10px;
    display: flex; align-items: center; justify-content: center;
    font-weight: 900; font-size: 16px;
    box-shadow: 0 4px 12px rgba(0,0,0,.35), 0 0 0 2px #dc2626;
    position: relative; z-index: 2; white-space: nowrap;
}
.map-pin-dot::after {
    content: ""; position: absolute; bottom: -12px; left: 50%;
    transform: translateX(-50%); border: 8px solid transparent;
    border-top-color: #dc2626; filter: drop-shadow(0 2px 2px rgba(0,0,0,.25));
}
.map-pin-pulse {
    position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
    width: 44px; height: 44px; border-radius: 999px;
    background: rgba(220, 38, 38, .55);
    animation: map-pin-pulse 1.6s ease-out infinite; z-index: 1;
}
@keyframes map-pin-pulse {
    0%   { transform: translate(-50%, -50%) scale(1);   opacity: .8; }
    100% { transform: translate(-50%, -50%) scale(3.5); opacity: 0; }
}
@media (max-width: 640px) {
    .map-pin-dot { min-width: 36px; height: 36px; font-size: 13px; padding: 0 8px; }
    .map-pin-pulse { width: 36px; height: 36px; }
}
