/**
 * Ghostbuster Werfapp demo — /demoPwa/
 *
 * Mobile first. Grote raakvlakken, hoog contrast, weinig tekst per scherm.
 * Geen framework: de demo moet zonder buildstap en zonder CDN werken, want de
 * service worker moet alles offline kunnen serveren.
 */

:root {
    --navy: #002147;
    --navy-2: #06304f;
    --gold: #ffd700;
    --blue: #0398c8;
    --orange: #ff7e03;

    --bg: #061725;
    --surface: #0d2438;
    --surface-2: #12314a;
    --line: #1d4568;
    --text: #eef7f8;
    --muted: #9fb7be;
    --ok: #3ddc84;
    --warn: #ffbf5f;
    --crit: #ff7474;

    --radius: 14px;
    --tap: 52px;
    --safe-top: env(safe-area-inset-top, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
    --safe-left: env(safe-area-inset-left, 0px);
    --safe-right: env(safe-area-inset-right, 0px);
    --nav-h: 64px;
}

:root[data-theme="light"] {
    --bg: #eef2f6;
    --surface: #ffffff;
    --surface-2: #f4f7fa;
    --line: #d3dde6;
    --text: #10222f;
    --muted: #55707f;
    --ok: #0f8a4b;
    --warn: #a76a00;
    --crit: #b3261e;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--text);
    font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
    -webkit-text-size-adjust: 100%;
}

body {
    min-height: 100svh;
    padding-bottom: calc(var(--nav-h) + var(--safe-bottom));
}

button, input, select, textarea { font: inherit; color: inherit; }

:focus-visible {
    outline: 3px solid var(--gold);
    outline-offset: 2px;
    border-radius: 6px;
}

.visually-hidden {
    position: absolute; width: 1px; height: 1px;
    margin: -1px; padding: 0; overflow: hidden;
    clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ------------------------------------------------------------------ header */
.wa-header {
    position: sticky;
    top: 0;
    z-index: 20;
    background: var(--navy);
    color: #fff;
    padding: calc(10px + var(--safe-top)) calc(14px + var(--safe-right)) 10px calc(14px + var(--safe-left));
    border-bottom: 1px solid var(--line);
}
.wa-header__row { display: flex; align-items: center; gap: 10px; }

.wa-brand { display: flex; align-items: center; gap: 9px; min-width: 0; }
.wa-brand__mark {
    display: inline-flex; align-items: center; justify-content: center;
    width: 32px; height: 32px; flex: none;
    border-radius: 9px; background: var(--gold); color: #000;
    font-weight: 800; font-size: 17px;
}
.wa-brand__text { display: flex; flex-direction: column; line-height: 1.15; min-width: 0; }
.wa-brand__text strong { font-size: 14px; }
.wa-brand__text span { font-size: 12px; color: #b9d3dd; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.wa-header__actions { margin-left: auto; display: flex; align-items: center; gap: 6px; }

.wa-iconbtn {
    min-width: 40px; height: 40px;
    display: inline-flex; align-items: center; justify-content: center;
    background: rgba(255, 255, 255, .08);
    border: 1px solid rgba(255, 255, 255, .18);
    border-radius: 10px; cursor: pointer; padding: 0 10px;
}
.wa-iconbtn:hover { border-color: var(--gold); }

.wa-badges { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 9px; }
.wa-badge {
    font-size: 11px; font-weight: 700; letter-spacing: .2px;
    padding: 3px 8px; border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, .22); color: #dfeaf2;
}
.wa-badge--dummy { background: var(--gold); color: #000; border-color: var(--gold); }
.wa-badge--net[data-state="offline"] { background: rgba(255, 191, 95, .16); border-color: var(--warn); color: var(--warn); }
.wa-badge--net[data-state="online"] { background: rgba(61, 220, 132, .13); border-color: var(--ok); color: var(--ok); }

/* -------------------------------------------------------------------- main */
.wa-main {
    max-width: 760px;
    margin: 0 auto;
    padding: 16px calc(14px + var(--safe-right)) 24px calc(14px + var(--safe-left));
}
.wa-screen[hidden] { display: none; }

.wa-card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 16px;
    margin-bottom: 14px;
}
.wa-card__title { margin: 0 0 4px; font-size: 15px; font-weight: 800; letter-spacing: .2px; }
.wa-card__sub { margin: 0 0 12px; color: var(--muted); font-size: 13px; }

h1.wa-h1 { font-size: 22px; margin: 0 0 2px; }
h2.wa-h2 { font-size: 18px; margin: 22px 0 10px; }
.wa-lead { color: var(--muted); margin: 0 0 14px; font-size: 14px; }

/* ------------------------------------------------------------- statusblok */
.wa-status {
    background: linear-gradient(140deg, var(--navy) 0%, var(--navy-2) 100%);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 18px 16px;
    color: #fff;
    margin-bottom: 14px;
}
.wa-status__label { display: flex; align-items: center; gap: 8px; font-size: 13px; color: #b9d3dd; }
.wa-status__dot { width: 11px; height: 11px; border-radius: 50%; flex: none; background: var(--muted); }
.wa-status__dot[data-state="working"] { background: var(--ok); box-shadow: 0 0 0 4px rgba(61, 220, 132, .2); }
.wa-status__dot[data-state="paused"] { background: var(--warn); box-shadow: 0 0 0 4px rgba(255, 191, 95, .2); }
.wa-status__dot[data-state="travelling"] { background: var(--blue); box-shadow: 0 0 0 4px rgba(3, 152, 200, .22); }
.wa-status__dot[data-state="arrived"] { background: var(--gold); box-shadow: 0 0 0 4px rgba(255, 215, 0, .2); }
.wa-status__dot[data-state="stopped"] { background: #8aa; }

.wa-timer {
    font-variant-numeric: tabular-nums;
    font-size: 44px; font-weight: 800; line-height: 1.1;
    margin: 8px 0 2px; letter-spacing: 1px;
}
.wa-timer__hint { color: #b9d3dd; font-size: 13px; margin: 0 0 16px; }

.wa-btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    min-height: var(--tap); width: 100%;
    padding: 14px 18px;
    font-weight: 800; font-size: 17px;
    border-radius: 12px; border: 2px solid transparent;
    cursor: pointer; text-decoration: none;
    background: var(--gold); color: #000;
}
.wa-btn:hover { background: var(--orange); }
.wa-btn--ghost { background: transparent; color: #fff; border-color: rgba(255, 255, 255, .35); }
.wa-btn--ghost:hover { background: rgba(255, 255, 255, .08); border-color: var(--gold); }
.wa-btn--danger { background: transparent; color: var(--crit); border-color: var(--crit); }
.wa-btn--danger:hover { background: rgba(255, 116, 116, .12); }
.wa-btn--sm { min-height: 44px; font-size: 15px; padding: 10px 14px; width: auto; }
.wa-btn[disabled] { opacity: .5; cursor: not-allowed; }

.wa-btnrow { display: flex; flex-wrap: wrap; gap: 10px; }
.wa-btnrow .wa-btn { width: auto; flex: 1 1 160px; }

/* ------------------------------------------------------------------- lijst */
.wa-list { list-style: none; margin: 0; padding: 0; }
.wa-list li {
    display: flex; gap: 12px; align-items: flex-start;
    padding: 12px 0; border-bottom: 1px solid var(--line);
}
.wa-list li:last-child { border-bottom: 0; }
.wa-time { font-variant-numeric: tabular-nums; color: var(--muted); font-size: 13px; flex: none; min-width: 46px; }
.wa-empty { color: var(--muted); font-size: 14px; font-style: italic; margin: 4px 0 0; }

.wa-kv { display: grid; grid-template-columns: 1fr auto; gap: 6px 12px; }
.wa-kv dt { color: var(--muted); font-size: 14px; }
.wa-kv dd { margin: 0; font-weight: 700; font-variant-numeric: tabular-nums; }

.wa-tag {
    display: inline-block; font-size: 11px; font-weight: 800;
    padding: 2px 8px; border-radius: 999px; border: 1px solid var(--line);
    color: var(--muted); flex: none;
}
.wa-tag--uitgevoerd { color: var(--ok); border-color: var(--ok); }
.wa-tag--opmerking { color: var(--blue); border-color: var(--blue); }
.wa-tag--probleem { color: var(--crit); border-color: var(--crit); }
.wa-tag--veiligheid { color: var(--warn); border-color: var(--warn); }

/* ---------------------------------------------------------------- formulier */
.wa-field { margin-bottom: 12px; }
.wa-field label { display: block; font-size: 13px; font-weight: 700; margin-bottom: 5px; }
.wa-input, .wa-select, .wa-textarea {
    width: 100%; min-height: 48px;
    padding: 11px 12px;
    background: var(--surface-2);
    border: 1px solid var(--line);
    border-radius: 10px;
}
.wa-textarea { min-height: 88px; resize: vertical; }
.wa-grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

/* ------------------------------------------------------------------ taken */
.wa-task { display: flex; align-items: center; gap: 12px; min-height: var(--tap); padding: 8px 0; border-bottom: 1px solid var(--line); }
.wa-task:last-child { border-bottom: 0; }
.wa-task input[type="checkbox"] { width: 30px; height: 30px; flex: none; accent-color: var(--blue); }
/* Het label vult de rest van de rij, zodat de hele regel een comfortabel
   raakvlak is en niet alleen het vierkantje. */
.wa-task label { flex: 1; cursor: pointer; padding: 12px 0; }
.wa-task[data-status="klaar"] label { color: var(--muted); text-decoration: line-through; }

/* ------------------------------------------------------------------ foto's */
.wa-photos { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
.wa-photo { border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: var(--surface-2); }
.wa-photo img { display: block; width: 100%; aspect-ratio: 4 / 3; object-fit: cover; background: var(--surface-2); }
.wa-photo__body { padding: 8px 10px 10px; }
.wa-photo__cap { font-size: 13px; margin: 0 0 8px; word-break: break-word; }
.wa-filebtn { position: relative; overflow: hidden; }
.wa-filebtn input[type="file"] { position: absolute; inset: 0; opacity: 0; cursor: pointer; }

/* --------------------------------------------------------------- dagrapport */
.wa-report { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; }
.wa-report h3 { font-size: 14px; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); margin: 20px 0 8px; }
.wa-report h3:first-of-type { margin-top: 0; }
.wa-report__head { border-bottom: 2px solid var(--gold); padding-bottom: 12px; margin-bottom: 4px; }
.wa-report__head p { margin: 2px 0 0; color: var(--muted); font-size: 14px; }

/* ------------------------------------------------------------------ QR blok */
.wa-qr { display: flex; flex-wrap: wrap; gap: 18px; align-items: flex-start; }
.wa-qr__code { width: 176px; flex: none; background: #fff; border-radius: 12px; padding: 10px; }
.wa-qr__code svg { display: block; width: 100%; height: auto; }
.wa-qr__body { flex: 1 1 220px; min-width: 0; }
.wa-url {
    display: block; font-family: ui-monospace, Consolas, monospace; font-size: 13px;
    background: var(--surface-2); border: 1px solid var(--line); border-radius: 8px;
    padding: 9px 10px; margin: 8px 0 12px; word-break: break-all;
}

/* ------------------------------------------------------------------- modal */
.wa-modal { border: none; padding: 0; background: transparent; max-width: 92vw; width: 420px; }
.wa-modal::backdrop { background: rgba(0, 0, 0, .6); }
.wa-modal__inner {
    background: var(--surface); color: var(--text);
    border: 1px solid var(--line); border-radius: var(--radius);
    padding: 20px;
}
.wa-modal h2 { margin: 0 0 8px; font-size: 19px; }
.wa-modal ol { padding-left: 20px; margin: 0 0 16px; }
.wa-modal li { margin-bottom: 6px; }

/* ------------------------------------------------------------------ toasts */
.wa-toasts {
    position: fixed; left: 50%; transform: translateX(-50%);
    bottom: calc(var(--nav-h) + var(--safe-bottom) + 12px);
    z-index: 60; width: min(92vw, 420px);
    display: flex; flex-direction: column; gap: 8px;
}
.wa-toast {
    background: var(--navy); color: #fff; border: 1px solid var(--gold);
    border-radius: 10px; padding: 11px 14px; font-size: 14px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, .35);
}

/* --------------------------------------------------------------- bottom nav */
.wa-nav {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
    display: grid; grid-template-columns: repeat(5, 1fr);
    background: var(--navy);
    border-top: 1px solid var(--line);
    padding-bottom: var(--safe-bottom);
}
.wa-nav button {
    background: none; border: 0; cursor: pointer;
    min-height: var(--nav-h);
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
    color: #9fb7be; font-size: 11px; font-weight: 700;
    border-top: 3px solid transparent;
}
.wa-nav button svg { width: 21px; height: 21px; }
.wa-nav button[aria-current="page"] { color: var(--gold); border-top-color: var(--gold); }

/* ------------------------------------------------------------------ desktop */
@media (min-width: 900px) {
    body { padding-bottom: 0; }
    .wa-main { max-width: 1040px; padding-top: 22px; }
    .wa-nav {
        position: sticky; top: 0; bottom: auto;
        max-width: 1040px; margin: 0 auto;
        grid-template-columns: repeat(5, minmax(0, 180px));
        justify-content: start;
        border-top: 0; border-bottom: 1px solid var(--line);
        background: transparent;
    }
    .wa-nav button { min-height: 54px; flex-direction: row; gap: 8px; font-size: 14px; border-top: 0; border-bottom: 3px solid transparent; }
    .wa-nav button[aria-current="page"] { border-bottom-color: var(--gold); }
    .wa-toasts { bottom: 20px; }
    /* Volle breedte is op een telefoon het juiste raakvlak, op een breed
       scherm wordt dezelfde knop een balk. */
    .wa-card .wa-btn, .wa-status .wa-btn { width: auto; min-width: 240px; }
    .wa-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; align-items: start; }
    .wa-cols > * { margin-bottom: 0; }
}

/* -------------------------------------------------------------------- print */
@media print {
    .wa-header, .wa-nav, .wa-toasts, .wa-noprint { display: none !important; }
    body { background: #fff; color: #000; padding: 0; }
    .wa-main { max-width: none; padding: 0; }
    .wa-report { border: 0; padding: 0; background: #fff; color: #000; }
    .wa-report h3 { color: #444; }
    .wa-card { border-color: #bbb; break-inside: avoid; }
    .wa-photos { grid-template-columns: repeat(3, 1fr); }
    a[href]::after { content: ""; }
}

@media (prefers-reduced-motion: reduce) {
    * { animation: none !important; transition: none !important; }
}
