/* ==========================================================================
   Aanmeldformulier v3 - mobile-first
   Alleen voor index.php en success.php. Het admin-panel gebruikt style.css.
   ========================================================================== */

:root {
    --navy: #1e3a5f;
    --navy-deep: #152a45;
    --navy-wash: #eef3f9;
    --ink: #17283b;
    --muted: #5a6b7c;
    --paper: #f2f4f3;
    --card: #ffffff;
    --line: #d5dce2;
    --line-strong: #a9b6c2;
    --basil: #18794e;
    --basil-wash: #e4f3ea;
    --signal: #b5381f;
    --signal-wash: #fcece8;
    --amber-wash: #fff6e0;
    --amber-line: #f0d48a;

    --font: 'Figtree', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
    --radius: 14px;
    --radius-sm: 10px;
    --tap: 52px;
    --bar-h: 56px;
    --safe-b: env(safe-area-inset-bottom, 0px);
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }

body {
    margin: 0;
    font-family: var(--font);
    font-size: 16px;
    line-height: 1.5;
    color: var(--ink);
    background: var(--paper);
    -webkit-font-smoothing: antialiased;
    -webkit-tap-highlight-color: transparent;
}
body.rtl, body.rtl .input, body.rtl .btn { font-family: 'Noto Sans Arabic', var(--font); }

[hidden] { display: none !important; }

svg { width: 1em; height: 1em; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

:focus-visible { outline: 3px solid rgba(30, 58, 95, .35); outline-offset: 2px; }

/* ---------- Topbar + voortgang ---------- */
.topbar {
    position: sticky; top: 0; z-index: 20;
    background: var(--navy);
    color: #fff;
    padding-top: env(safe-area-inset-top, 0px);
}
.topbar-inner {
    max-width: 640px; margin: 0 auto;
    height: var(--bar-h);
    padding: 0 16px;
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand-mark {
    width: 32px; height: 32px; border-radius: 9px;
    background: rgba(255,255,255,.12);
    display: grid; place-items: center; font-size: 18px; flex-shrink: 0;
}
.brand-name { font-weight: 600; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.langs { display: flex; gap: 2px; background: rgba(255,255,255,.1); border-radius: 999px; padding: 3px; flex-shrink: 0; }
.lang {
    color: rgba(255,255,255,.75); text-decoration: none;
    font-size: 13px; font-weight: 600;
    min-width: 36px; height: 30px; padding: 0 8px;
    display: grid; place-items: center; border-radius: 999px;
}
.lang.is-active { background: #fff; color: var(--navy); }

.progress { display: flex; gap: 3px; height: 4px; max-width: 640px; margin: 0 auto; padding: 0 16px 10px; box-sizing: content-box; }
.progress-seg { flex: 1; border-radius: 2px; background: rgba(255,255,255,.18); transition: background .3s; }
.progress-seg.is-done { background: #7fd1a6; }
.progress-seg.is-current { background: #fff; }
.no-js .progress { display: none; }

/* ---------- Pagina ---------- */
.page {
    max-width: 640px; margin: 0 auto;
    padding: 20px 16px calc(150px + var(--safe-b));
}

.notice {
    border-radius: var(--radius-sm); padding: 12px 14px; margin-bottom: 16px;
    background: var(--signal-wash); color: var(--signal); font-weight: 500;
}
.notice-success { background: var(--basil-wash); color: var(--basil); }

.resume {
    display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
    background: var(--navy-wash); color: var(--navy);
    border-radius: var(--radius-sm); padding: 10px 14px; margin-bottom: 16px; font-size: 14px;
}
.link-btn { background: none; border: 0; padding: 4px 0; font: inherit; font-weight: 600; color: var(--navy); text-decoration: underline; cursor: pointer; }

.hp { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

/* ---------- Stappen ---------- */
.js .step { display: none; }
.js .step.is-active { display: block; animation: stepIn .28s ease both; }
.no-js .step { background: var(--card); border-radius: var(--radius); padding: 20px 16px; margin-bottom: 16px; }
.no-js .step-count { display: none; }

@keyframes stepIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.step-count { margin: 0 0 4px; font-size: 14px; font-weight: 600; color: var(--muted); }
.step-title { margin: 0 0 6px; font-size: 26px; line-height: 1.2; font-weight: 700; letter-spacing: -.01em; color: var(--ink); }
.step-lead { margin: 0 0 22px; color: var(--muted); max-width: 60ch; }
.sub-title { font-size: 17px; font-weight: 700; margin: 26px 0 10px; }
.sub-title .opt, .label .opt, .slot-title .opt { font-weight: 500; color: var(--muted); font-size: 14px; }

.group { border: 0; padding: 0; margin: 0 0 8px; min-width: 0; }
.group + .field, .field + .group, .group + .group { margin-top: 18px; }
.group-title { font-size: 17px; font-weight: 700; padding: 0; margin: 4px 0 10px; }
.group[data-show-type="zzp"] {
    background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
    padding: 14px 14px 2px; margin-bottom: 18px;
}

/* ---------- Velden ---------- */
.field { margin-bottom: 18px; position: relative; min-width: 0; }
.label { display: block; font-weight: 600; font-size: 15px; margin-bottom: 6px; }

.input {
    display: block; width: 100%;
    min-height: var(--tap);
    padding: 12px 14px;
    font: inherit; font-size: 16px; /* 16px voorkomt inzoomen op iPhone */
    color: var(--ink);
    background: var(--card);
    border: 1.5px solid var(--line);
    border-radius: var(--radius-sm);
    appearance: none; -webkit-appearance: none;
    transition: border-color .15s, box-shadow .15s;
}
.input::placeholder { color: #9aa7b3; }
.input:focus { outline: none; border-color: var(--navy); box-shadow: 0 0 0 3px rgba(30,58,95,.15); }
textarea.input { min-height: 96px; resize: vertical; }
select.input {
    padding-inline-end: 40px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%235a6b7c' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat; background-size: 20px; background-position: right 12px center;
}
.rtl select.input { background-position: left 12px center; }
.input::-webkit-calendar-picker-indicator { display: none !important; }
.rtl .input[inputmode="numeric"], .rtl .input[type="tel"], .rtl .input[type="email"], .rtl .input-mono, .rtl #postcode, .rtl #huisnummer { direction: ltr; text-align: right; }
.input-mono { font-variant-numeric: tabular-nums; letter-spacing: .04em; }
.input-date { font-variant-numeric: tabular-nums; letter-spacing: .03em; }

.field.is-valid > .input {
    border-color: #8cc9a8;
    padding-inline-end: 42px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2318794e' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12.5l4.5 4.5L19 7.5'/%3E%3C/svg%3E");
    background-repeat: no-repeat; background-size: 20px; background-position: right 12px center;
}
.rtl .field.is-valid > .input { background-position: left 12px center; }
.field.is-valid > select.input { background-image: none; }

.field.is-invalid > .input,
.input.is-invalid { border-color: var(--signal); background-color: #fffafa; }
.field.is-invalid > .input:focus { box-shadow: 0 0 0 3px rgba(181,56,31,.15); }

.field-help { margin: 6px 0 0; font-size: 14px; color: var(--muted); }
.field-hint { margin: 6px 0 0; font-size: 14px; color: var(--navy); }
.field-hint button { font: inherit; font-weight: 700; color: var(--navy); background: none; border: 0; padding: 0; text-decoration: underline; cursor: pointer; }
.field-error { margin: 6px 0 0; font-size: 14px; font-weight: 600; color: var(--signal); }
.field-error:empty { display: none; }
.field-error::before { content: "! "; }

.row-2 { display: grid; grid-template-columns: 1fr; gap: 0 14px; }
@media (min-width: 520px) { .row-2 { grid-template-columns: 1fr 1fr; } }
.row-tight { grid-template-columns: 1fr 1fr; }

.static-value { margin: 0; min-height: var(--tap); display: flex; align-items: center; font-weight: 600; font-variant-numeric: tabular-nums; }

.shake { animation: shake .35s ease; }
@keyframes shake { 0%,100% { transform: none; } 25% { transform: translateX(-5px); } 75% { transform: translateX(5px); } }

/* ---------- Keuzekaarten (stap 1 + 2) ---------- */
.choices { display: grid; gap: 10px; }
.choice { display: block; cursor: pointer; }
.choice { position: relative; }
.choice input { position: absolute; top: 0; left: 0; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.choice-body {
    display: flex; align-items: center; gap: 14px;
    min-height: 76px; padding: 14px 16px;
    background: var(--card);
    border: 1.5px solid var(--line);
    border-radius: var(--radius);
    transition: border-color .15s, background .15s, transform .1s;
}
.choice:active .choice-body { transform: scale(.99); }
.choice-icon {
    width: 44px; height: 44px; border-radius: 12px; flex-shrink: 0;
    display: grid; place-items: center; font-size: 22px;
    background: var(--paper); color: var(--navy);
}
.choice-text { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.choice-title { font-weight: 700; font-size: 17px; line-height: 1.3; }
.choice-sub { color: var(--muted); font-size: 14px; line-height: 1.35; }
.choice-check {
    width: 24px; height: 24px; border-radius: 50%; flex-shrink: 0;
    border: 2px solid var(--line-strong);
    display: grid; place-items: center;
}
.choice input:checked + .choice-body { border-color: var(--navy); background: var(--navy-wash); box-shadow: inset 0 0 0 1px var(--navy); }
.choice input:checked + .choice-body .choice-icon { background: var(--navy); color: #fff; }
.choice input:checked + .choice-body .choice-check { border-color: var(--navy); background: var(--navy); }
.choice input:checked + .choice-body .choice-check::after {
    content: ""; width: 10px; height: 6px; border: solid #fff; border-width: 0 0 2.5px 2.5px;
    transform: translateY(-1px) rotate(-45deg);
}
.choice input:focus-visible + .choice-body { outline: 3px solid rgba(30,58,95,.35); outline-offset: 2px; }

/* ---------- Pills (geslacht, ja/nee, ID/paspoort) ---------- */
.pills { display: flex; flex-wrap: wrap; gap: 8px; }
.pill { flex: 1 1 0; min-width: 96px; cursor: pointer; }
.pills-stack .pill { flex-basis: 100%; }
@media (min-width: 520px) { .pills-stack .pill { flex-basis: 0; } }
.pill { position: relative; }
.pill input { position: absolute; top: 0; left: 0; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.pill span {
    display: flex; align-items: center; justify-content: center; text-align: center;
    min-height: var(--tap); padding: 8px 12px;
    background: var(--card); border: 1.5px solid var(--line); border-radius: var(--radius-sm);
    font-weight: 600; font-size: 15px; line-height: 1.3;
    transition: border-color .15s, background .15s;
}
.pill input:checked + span { border-color: var(--navy); background: var(--navy); color: #fff; }
.pill input:focus-visible + span { outline: 3px solid rgba(30,58,95,.35); outline-offset: 2px; }
.field.is-invalid .pill span, .field.is-invalid .choice-body { border-color: var(--signal); }

/* ---------- Adres lookup ---------- */
.lookup {
    display: flex; align-items: center; gap: 8px;
    margin: -8px 0 16px; font-size: 14px; font-weight: 600; color: var(--muted);
}
.lookup.is-found { color: var(--basil); }
.lookup.is-busy::before {
    content: ""; width: 14px; height: 14px; border-radius: 50%;
    border: 2px solid var(--line); border-top-color: var(--navy); animation: spin .7s linear infinite;
}
.input.is-autofilled { background-color: #f6fbf8; }

/* ---------- Upload-vakken: het opvallende element van dit formulier ---------- */
.slots { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-bottom: 4px; }
@media (max-width: 340px) { .slots { grid-template-columns: 1fr; } }

.slot { margin-bottom: 0; }
.slot-input { position: absolute; width: 1px; height: 1px; opacity: 0; overflow: hidden; }
.slot-box {
    display: flex; flex-direction: column; height: 100%;
    background: var(--card);
    border: 1.5px dashed var(--line-strong);
    border-radius: var(--radius);
    padding: 10px;
    cursor: pointer;
    transition: border-color .15s, background .15s;
}
.slot-input:focus-visible + .slot-box { outline: 3px solid rgba(30,58,95,.35); outline-offset: 2px; }
.slot-visual {
    position: relative; display: grid; place-items: center;
    aspect-ratio: 86 / 56; width: 100%;
    border-radius: 9px; overflow: hidden;
    background: var(--paper);
}
.slot-art { width: 78%; height: auto; }
.slot-art .a-frame { fill: #fff; stroke: var(--line-strong); stroke-width: 1.5; }
.slot-art .a-photo { fill: #dfe6ec; stroke: none; }
.slot-art .a-face { fill: none; stroke: #9fb0c0; stroke-width: 1.5; }
.slot-art .a-line rect { fill: #cfd8e0; stroke: none; }
.slot-art .a-mrz rect { fill: #b8c4cf; stroke: none; }
.slot-art .a-chip { fill: #e7c873; stroke: none; }
.slot-art .a-tag { font: 700 14px var(--font); fill: var(--navy); stroke: none; }
.slot-preview { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }

.slot-text { display: flex; flex-direction: column; gap: 1px; padding: 10px 2px 2px; }
.slot-title { font-weight: 700; font-size: 15px; line-height: 1.3; }
.slot-side { display: block; font-size: 13px; font-weight: 600; color: var(--navy); }
.slot-status { font-size: 13px; color: var(--muted); }
.slot-action {
    position: absolute; top: 18px; inset-inline-end: 18px;
    width: 32px; height: 32px; border-radius: 50%;
    background: var(--navy); color: #fff; display: grid; place-items: center; font-size: 18px;
    box-shadow: 0 2px 6px rgba(21,42,69,.25);
}

.slot.is-busy .slot-status::before {
    content: ""; display: inline-block; vertical-align: -2px; margin-inline-end: 6px;
    width: 12px; height: 12px; border-radius: 50%;
    border: 2px solid var(--line); border-top-color: var(--navy); animation: spin .7s linear infinite;
}
.slot.has-file .slot-box { border-style: solid; border-color: #8cc9a8; background: #fbfefc; }
.slot.has-file .slot-status { color: var(--basil); font-weight: 600; }
.slot.has-file .slot-action { display: none; }
.slot.has-file.is-pdf .slot-visual::after {
    content: "PDF"; position: absolute; inset-inline-end: 8px; bottom: 8px;
    background: var(--signal); color: #fff; font: 700 12px var(--font); padding: 2px 6px; border-radius: 4px;
}
.slot.is-invalid .slot-box { border-color: var(--signal); border-style: solid; background: #fffafa; }

.slot-remove {
    position: absolute; top: 18px; inset-inline-end: 18px;
    width: 34px; height: 34px; border-radius: 50%; border: 0;
    background: rgba(23, 40, 59, .72); color: #fff;
    display: grid; place-items: center; font-size: 16px; cursor: pointer;
}

.doc-note {
    display: flex; gap: 10px; align-items: flex-start;
    background: var(--amber-wash); border: 1px solid var(--amber-line);
    border-radius: var(--radius-sm); padding: 12px 14px; margin-bottom: 6px;
}
.doc-note svg { font-size: 20px; flex-shrink: 0; margin-top: 2px; color: #8a6510; }
.doc-note p { margin: 0; font-size: 15px; }

.photo-tip { margin: 18px 0 0; font-size: 14px; color: var(--muted); }

/* ---------- Samenvatting ---------- */
.summary { margin-bottom: 22px; }
.sum-block { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; margin-bottom: 10px; }
.sum-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 4px; }
.sum-head h3 { margin: 0; font-size: 15px; font-weight: 700; }
.sum-edit { font: inherit; font-size: 14px; font-weight: 600; color: var(--navy); background: none; border: 0; padding: 6px 0; cursor: pointer; text-decoration: underline; }
.sum-list { margin: 0; display: grid; grid-template-columns: auto 1fr; gap: 2px 12px; font-size: 14px; }
.sum-list dt { color: var(--muted); }
.sum-list dd { margin: 0; font-weight: 600; overflow-wrap: anywhere; }

/* ---------- Handtekening ---------- */
.declaration { margin: 0 0 14px; padding: 12px 14px; background: var(--card); border-inline-start: 3px solid var(--navy); border-radius: 4px; }
.sign { position: relative; }
.sign-canvas {
    display: block; width: 100%; height: 190px;
    background: #fff; border: 1.5px solid var(--line); border-radius: var(--radius);
    touch-action: none; cursor: crosshair;
}
.field.is-invalid .sign-canvas { border-color: var(--signal); }
.sign-hint {
    position: absolute; inset: 0; display: grid; place-items: center; padding: 0 20px;
    color: #a3b0bc; font-size: 15px; text-align: center; pointer-events: none;
}
.sign.has-ink .sign-hint { display: none; }
.sign-line { position: absolute; left: 22px; right: 22px; bottom: 44px; border-bottom: 1.5px dashed #cdd6de; pointer-events: none; }
.sign-clear {
    position: absolute; top: 8px; inset-inline-end: 8px;
    font: inherit; font-size: 14px; font-weight: 600;
    background: var(--paper); color: var(--ink); border: 0; border-radius: 999px; padding: 6px 12px; cursor: pointer;
}

/* ---------- Knoppen + actiebalk ---------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    min-height: var(--tap); padding: 0 22px;
    font: inherit; font-size: 16px; font-weight: 700;
    border-radius: 999px; border: 0; cursor: pointer;
    transition: background .15s, opacity .15s, transform .1s;
    -webkit-user-select: none; user-select: none;
}
.btn svg { font-size: 20px; }
.rtl .btn svg { transform: scaleX(-1); }
.btn:active { transform: scale(.98); }
.btn-primary { background: var(--navy); color: #fff; flex: 1; }
.btn-primary:hover { background: var(--navy-deep); }
.btn-primary.is-incomplete { background: #7d8fa3; }
.btn-ghost { background: transparent; color: var(--ink); padding: 0 14px; }
.btn[disabled] { opacity: .55; cursor: not-allowed; }

.actions {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 15;
    display: flex; flex-wrap: wrap; align-items: center; gap: 8px;
    padding: 10px 16px calc(10px + var(--safe-b));
    background: rgba(255,255,255,.96);
    -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
    border-top: 1px solid var(--line);
}
.actions > .btn-submit { display: none; }
.actions.is-last > #btnNext { display: none; }
.actions.is-last > .btn-submit { display: inline-flex; }
.actions.is-first > #btnPrev { visibility: hidden; width: 0; padding: 0; }
.actions-hint { flex-basis: 100%; margin: 0; text-align: center; font-size: 13px; font-weight: 600; color: var(--muted); }
.actions-hint:empty { display: none; }
.actions-hint.is-error { color: var(--signal); }
@media (min-width: 680px) {
    .actions { left: 50%; right: auto; width: 640px; transform: translateX(-50%); bottom: 16px; border: 1px solid var(--line); border-radius: 999px; padding: 8px; box-shadow: 0 8px 28px rgba(21,42,69,.12); }
    .actions-hint { position: absolute; bottom: 100%; left: 0; right: 0; margin-bottom: 8px; }
    .page { padding-bottom: 130px; }
}
.no-js .actions { position: static; transform: none; width: auto; background: none; border: 0; box-shadow: none; }
.no-js #btnPrev, .no-js #btnNext { display: none; }
.no-js .actions > .btn-submit { display: inline-flex; }

/* ---------- Verzend-overlay ---------- */
.overlay { position: fixed; inset: 0; z-index: 50; background: rgba(21,42,69,.55); display: grid; place-items: center; padding: 24px; }
.overlay-card { background: #fff; border-radius: 20px; padding: 28px 24px; width: 100%; max-width: 340px; text-align: center; }
.send-ring { position: relative; width: 84px; height: 84px; margin: 0 auto 14px; }
.send-ring svg { width: 84px; height: 84px; transform: rotate(-90deg); }
.ring-bg { stroke: var(--paper); stroke-width: 5; }
.ring-fg { stroke: var(--basil); stroke-width: 5; stroke-dasharray: 125.66; stroke-dashoffset: 125.66; transition: stroke-dashoffset .25s; }
.send-ring span { position: absolute; inset: 0; display: grid; place-items: center; font-weight: 700; font-variant-numeric: tabular-nums; }
.overlay-title { margin: 0 0 4px; font-weight: 700; font-size: 18px; }
.overlay-sub { margin: 0; color: var(--muted); font-size: 14px; }

@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Footer ---------- */
.foot { max-width: 640px; margin: 0 auto; padding: 0 16px 24px; color: var(--muted); font-size: 13px; text-align: center; }
.foot p { margin: 2px 0; }
.js .foot { display: none; }

/* ---------- Success-pagina ---------- */
.done { text-align: center; padding: 24px 0; }
.done-mark {
    width: 84px; height: 84px; border-radius: 50%; margin: 8px auto 18px;
    background: var(--basil); color: #fff; display: grid; place-items: center; font-size: 42px;
    animation: pop .45s cubic-bezier(.2,1.4,.4,1) both;
}
.done-mark svg { stroke-width: 3; }
@keyframes pop { from { transform: scale(.4); opacity: 0; } to { transform: none; opacity: 1; } }
.done h1 { font-size: 26px; margin: 0 0 8px; line-height: 1.2; }
.done p { color: var(--muted); margin: 0 auto 8px; max-width: 46ch; }
.ref {
    display: inline-block; margin: 14px 0 6px; padding: 12px 20px;
    background: var(--card); border: 1.5px dashed var(--line-strong); border-radius: var(--radius);
    font-size: 22px; font-weight: 700; letter-spacing: .04em; font-variant-numeric: tabular-nums; direction: ltr;
}
.next-steps { text-align: start; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px 6px; margin: 20px 0; }
.next-steps h2 { font-size: 16px; margin: 0 0 8px; }
.next-steps ol { margin: 0; padding-inline-start: 20px; }
.next-steps li { margin-bottom: 8px; }

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
