/* === Klantportaal (/portaal) ================================================
   Losse klantpagina buiten de XAF-schil. Issue #234: altijd in de kleuren van de app (groen); de huisstijlkleur van de studio
   (BrandingSettings.PrimaryColor) wordt hier niet gebruikt, ook niet voor iconen. */

.customer-portal {
    --cp-accent: var(--brand, #4f9f8b);
    max-width: 960px;
    margin: 0 auto;
    padding: 24px 16px 48px;
    box-sizing: border-box;
    color: var(--ink);
    font-size: .95rem;
}

.cp-header {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 3px solid var(--cp-accent);
}

.cp-logo {
    max-height: 56px;
    max-width: 180px;
    object-fit: contain;
}

.cp-header-title {
    flex: 1;
    min-width: 0;
}

.cp-header-title h1 {
    margin: 0;
    font-size: 1.4rem;
}

.cp-header-title span {
    color: var(--muted);
}

/* Issue #234: kop van het klantportaal: merk links, knoppen rechts, welkomstregel eronder. */
.cp-brand {
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: center;
}

.cp-brand h1 {
    margin: 0;
    font-size: 1.4rem;
    overflow-wrap: anywhere;
}

.cp-brand .cp-logo {
    max-width: min(200px, 100%);
}

.cp-header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.cp-welcome {
    margin: -8px 0 16px;
    color: var(--muted);
}

.cp-welcome strong {
    color: var(--ink);
    font-weight: 600;
}

.cp-sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Issue #234: alle acties (bekijken, PDF, uitloggen) in één stijl, zodat duidelijk is wat aanklikbaar is. */
.cp-action {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 12px;
    border: 1px solid var(--surface-line);
    border-radius: 999px;
    background: var(--surface-strong);
    color: var(--ink);
    font: inherit;
    font-size: .85rem;
    line-height: 1.3;
    text-decoration: none;
    white-space: nowrap;
    cursor: pointer;
}

.cp-action:hover,
.cp-action:focus-visible {
    border-color: var(--cp-accent);
    color: var(--cp-accent);
}

.cp-action .bi {
    font-size: .95em;
}

.cp-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 8px;
}

.cp-card {
    background: var(--surface-strong);
    border: 1px solid var(--surface-line);
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 16px;
    box-shadow: var(--shadow);
}

.cp-card h2 {
    margin: 0 0 12px;
    font-size: 1.1rem;
}

.cp-center {
    text-align: center;
    color: var(--muted);
}

.cp-login {
    max-width: 420px;
    margin-left: auto;
    margin-right: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.cp-login p {
    margin: 0;
}

.cp-block-button {
    width: 100%;
}

.cp-message {
    padding: 10px 14px;
    border-radius: 8px;
    margin-bottom: 16px;
}

.cp-message.is-info {
    background: color-mix(in srgb, var(--cp-accent) 12%, var(--surface-strong));
    border: 1px solid color-mix(in srgb, var(--cp-accent) 35%, var(--surface-line));
}

.cp-message.is-error {
    background: color-mix(in srgb, #c0392b 10%, var(--surface-strong));
    border: 1px solid color-mix(in srgb, #c0392b 40%, var(--surface-line));
    color: var(--ink);
}

/* Waarschuwing in de akkoord-popup, direct boven de knoppen */
.cp-warning {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin-top: 16px;
    padding: 10px 14px;
    border-radius: 8px;
    border: 1px solid color-mix(in srgb, var(--icon-warning, #e8c84a) 60%, var(--surface-line));
    background: color-mix(in srgb, var(--icon-warning, #e8c84a) 16%, var(--surface-strong));
    color: var(--ink);
    font-weight: 600;
}

.cp-warning i {
    color: var(--accent-label, #8f6f1a);
    margin-top: 2px;
}

/* Issue #96: bedrijfsnaam, naam en e-mail als vaste gegevens bovenaan "Mijn gegevens". */
.cp-identity {
    display: flex;
    flex-direction: column;
    gap: 2px;
    margin-bottom: 16px;
    padding-left: 12px;
    border-left: 3px solid var(--cp-accent);
}

.cp-identity-company {
    font-size: 1.15rem;
    font-weight: 600;
}

.cp-identity-name {
    font-size: 1.05rem;
    font-weight: 600;
}

.cp-identity-company + .cp-identity-name {
    font-size: 1rem;
    font-weight: 500;
}

.cp-identity-email {
    color: var(--muted);
    overflow-wrap: anywhere;
}

.cp-form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 12px 16px;
    margin-bottom: 8px;
}

.cp-form-grid label,
.cp-field {
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: .8rem;
    color: var(--muted);
}

.cp-field {
    margin: 12px 0;
}

.cp-hint,
.cp-muted,
.cp-empty {
    color: var(--muted);
    font-size: .85rem;
}

.cp-pre {
    white-space: pre-wrap;
}

/* Fotoalbums */
.cp-album-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 12px;
}

.cp-album {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    border: 1px solid var(--surface-line);
    border-radius: 10px;
    color: var(--ink);
    text-decoration: none;
    transition: border-color .15s ease, box-shadow .15s ease;
}

.cp-album:hover {
    border-color: var(--cp-accent);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--cp-accent) 22%, transparent);
    color: var(--ink);
}

.cp-album-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 44px;
    height: 44px;
    border-radius: 10px;
    background: color-mix(in srgb, var(--cp-accent) 16%, var(--surface-strong));
    color: var(--cp-accent);
    font-size: 1.3rem;
}

.cp-album-text {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-width: 0;
}

.cp-album-open {
    color: var(--muted);
}

/* Album met eventueel de link "Alle foto's downloaden" eronder (issue #7). */
.cp-album-item {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.cp-album-download {
    align-self: flex-start;
    padding: 2px 4px;
    color: var(--cp-accent);
    font-size: .9rem;
    text-decoration: none;
}

.cp-album-download:hover {
    text-decoration: underline;
}

/* Offertes */
.cp-quote {
    border: 1px solid var(--surface-line);
    border-radius: 10px;
    padding: 12px 14px;
    margin-bottom: 12px;
}

.cp-quote.can-accept {
    border-color: color-mix(in srgb, var(--cp-accent) 55%, var(--surface-line));
    background: color-mix(in srgb, var(--cp-accent) 6%, var(--surface-strong));
}

.cp-quote-head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 16px;
}

.cp-quote-head > div {
    flex: 1;
    min-width: 200px;
    display: flex;
    flex-direction: column;
}

.cp-quote-actions {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-top: 6px;
}

.cp-link {
    color: var(--cp-accent);
    font-size: .88rem;
}

/* A4-verhouding, zodat een hele pagina van de offerte in beeld past */
.cp-pdf {
    display: block;
    width: 100%;
    aspect-ratio: 1 / 1.414;
    max-height: 85vh;
    margin: 8px 0 12px;
    border: 1px solid var(--surface-line);
    border-radius: 8px;
    background: var(--surface-muted);
}

.cp-amount {
    font-size: 1.05rem;
}

.cp-status {
    padding: 2px 10px;
    border-radius: 999px;
    font-size: .78rem;
    font-weight: 600;
    background: var(--surface-muted);
    color: var(--muted);
}

.cp-status-sent {
    background: color-mix(in srgb, var(--cp-accent) 18%, var(--surface-strong));
    color: var(--ink);
}

.cp-status-accepted {
    background: color-mix(in srgb, var(--brand) 22%, var(--surface-strong));
    color: var(--brand-dark);
}

/* Tabellen */
.cp-table {
    width: 100%;
    border-collapse: collapse;
    margin: 8px 0 12px;
    font-size: .88rem;
}

.cp-table th,
.cp-table td {
    padding: 6px 8px;
    border-bottom: 1px solid var(--surface-line);
    text-align: left;
    vertical-align: top;
}

.cp-table th {
    color: var(--muted);
    font-weight: 600;
}

.cp-table .num {
    text-align: right;
    white-space: nowrap;
}

.cp-table tfoot td {
    border-bottom: none;
    color: var(--muted);
}

.cp-table tfoot .cp-total td {
    color: var(--ink);
    font-weight: 700;
    border-top: 2px solid var(--surface-line);
}

/* Issue #126: per offerte een dossier met de offerte, de opdracht en het betalen, als stappen onder elkaar. */
.cp-due-summary {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    margin-bottom: 16px;
    border-radius: 12px;
    border: 1px solid color-mix(in srgb, var(--cp-accent) 45%, var(--surface-line));
    background: color-mix(in srgb, var(--cp-accent) 8%, var(--surface-strong));
}

.cp-due-summary .bi {
    color: var(--cp-accent);
    font-size: 1.2rem;
}

.cp-dossier {
    border: 1px solid var(--surface-line);
    border-radius: 10px;
    margin-bottom: 16px;
    overflow: hidden;
}

.cp-dossier.needs-action {
    border-color: color-mix(in srgb, var(--cp-accent) 55%, var(--surface-line));
}

.cp-dossier-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 14px;
    background: color-mix(in srgb, var(--cp-accent) 7%, var(--surface-strong));
    border-bottom: 1px solid var(--surface-line);
}

.cp-dossier-title {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.cp-dossier-title strong {
    font-size: 1.05rem;
}

.cp-dossier-side {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 4px;
    flex-shrink: 0;
}

.cp-step {
    display: grid;
    grid-template-columns: 120px 1fr;
    gap: 12px;
    padding: 12px 14px;
}

.cp-step + .cp-step {
    border-top: 1px solid var(--surface-line);
}

.cp-step-label {
    color: var(--muted);
    font-weight: 600;
    font-size: .75rem;
    letter-spacing: .05em;
    text-transform: uppercase;
    padding-top: 2px;
}

.cp-step-label .bi {
    color: var(--cp-accent);
    margin-right: 4px;
}

.cp-step-body {
    min-width: 0;
}

.cp-step-line {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px 8px;
}

.cp-step-body p {
    margin: 6px 0 0;
}

.cp-step-body .cp-table:first-child {
    margin-top: 0;
}

.cp-status-paid,
.cp-status-delivered {
    background: color-mix(in srgb, var(--brand) 22%, var(--surface-strong));
    color: var(--brand-dark);
}

.cp-status-confirmed,
.cp-status-planned,
.cp-status-inprogress {
    background: color-mix(in srgb, var(--cp-accent) 18%, var(--surface-strong));
    color: var(--ink);
}

.cp-status-overdue {
    background: color-mix(in srgb, #e5484d 18%, var(--surface-strong));
    color: #b4232a;
}

.cp-status-partiallypaid {
    background: color-mix(in srgb, var(--cp-accent) 18%, var(--surface-strong));
    color: var(--ink);
}

.cp-payment {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    align-items: flex-start;
    padding: 12px;
    margin: 8px 0;
    border: 1px solid var(--surface-line);
    border-radius: 10px;
}

.cp-payment p {
    margin: 6px 0 0;
}

.cp-payment-qr {
    width: 120px;
    height: 120px;
    flex: none;
    background: #fff;
    padding: 4px;
    border-radius: 6px;
}

.cp-table td.cp-cell-actions {
    text-align: right;
    white-space: nowrap;
}

.cp-table td.cp-cell-actions .cp-action + .cp-action {
    margin-left: 6px;
}

@media (max-width: 640px) {
    .customer-portal {
        padding-top: 16px;
    }

    .cp-header {
        gap: 10px;
    }

    .cp-logo {
        max-height: 44px;
    }

    .cp-card {
        padding: 14px;
    }

    .cp-step {
        grid-template-columns: 1fr;
        gap: 6px;
    }

    .cp-dossier-head,
    .cp-step {
        padding: 12px;
    }

    .cp-payment-qr {
        width: 104px;
        height: 104px;
    }

    /* Issue #234: op een telefoon wordt elke rij een blokje: de titel bovenaan, daaronder per waarde het label links en de
       waarde rechts. Zonder kolomkoppen was niet te zien welk bedrag wat was. */
    .cp-table thead {
        display: none;
    }

    .cp-table,
    .cp-table tbody,
    .cp-table tfoot {
        display: block;
        width: 100%;
    }

    .cp-table tbody tr {
        display: block;
        padding: 10px 0;
        border-bottom: 1px solid var(--surface-line);
    }

    .cp-table tbody td {
        display: flex;
        justify-content: space-between;
        align-items: center;
        gap: 12px;
        padding: 2px 0;
        border: none;
        text-align: right;
    }

    .cp-table tbody td[data-label]::before {
        content: attr(data-label);
        color: var(--muted);
        text-align: left;
    }

    .cp-table tbody td:empty {
        display: none;
    }

    .cp-table tbody td.cp-cell-title {
        display: block;
        padding-bottom: 4px;
        font-weight: 600;
        text-align: left;
    }

    .cp-table tbody td.cp-cell-actions {
        justify-content: flex-start;
        gap: 8px;
        padding-top: 8px;
    }

    .cp-table td.cp-cell-actions .cp-action + .cp-action {
        margin-left: 0;
    }

    .cp-table tfoot tr {
        display: flex;
        justify-content: space-between;
        gap: 12px;
        padding: 6px 0 0;
    }

    .cp-table tfoot td {
        display: block;
        padding: 0;
        border: none;
    }

    .cp-table tfoot .cp-total {
        margin-top: 6px;
        padding-top: 8px;
        border-top: 2px solid var(--surface-line);
    }

    .cp-table tfoot .cp-total td {
        border-top: none;
    }
}

/* === Vragenlijst (/questionnaire, issue #48) ================================= */

.questionnaire-page {
    max-width: 760px;
}

.qn-question {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 12px 0;
    border-top: 1px solid var(--surface-line);
}

.cp-card h2 + .qn-question,
.cp-card .cp-hint + .qn-question {
    border-top: none;
}

.qn-label {
    font-weight: 600;
}

.qn-required {
    color: #c0392b;
    margin-left: 2px;
}

.qn-question.is-missing .qn-label,
.qn-missing-text {
    color: #c0392b;
}

.qn-missing-text {
    font-size: .85rem;
}

.qn-options {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.qn-options.qn-inline {
    flex-direction: row;
    gap: 20px;
}

.qn-option {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
}

.qn-option input {
    width: 18px;
    height: 18px;
    accent-color: var(--cp-accent);
}

.qn-narrow {
    max-width: 240px;
}

.qn-answer {
    padding: 8px 12px;
    border-radius: 8px;
    background: color-mix(in srgb, var(--cp-accent) 6%, var(--surface-strong));
}

.qn-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-end;
    gap: 12px;
}

.qn-actions .cp-muted {
    margin-right: auto;
}

/* === Contactformulier (/aanvraag, issue #54) ================================== */

/* Honeypot: voor mensen onzichtbaar, maar niet display:none (dat slaan sommige bots over). */
.cf-trap {
    position: absolute;
    left: -10000px;
    width: 1px;
    height: 1px;
    opacity: 0;
}

/* Issue #64: knop licht/donker in de kop van de klantpagina's. */
.cp-theme-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    flex-shrink: 0;
    border: 1px solid var(--surface-line);
    border-radius: 50%;
    background: var(--surface-strong);
    color: var(--ink);
    cursor: pointer;
}

.cp-theme-toggle:hover {
    background: color-mix(in srgb, var(--cp-accent) 12%, var(--surface-strong));
}

.cp-theme-toggle i {
    font-size: 1.05rem;
}

/* Donkere weergave: kleuren die op donker te weinig contrast hebben. */
body.dxbl-theme-dark .qn-required,
body.dxbl-theme-dark .qn-question.is-missing .qn-label,
body.dxbl-theme-dark .qn-missing-text {
    color: #f28b82;
}

body.dxbl-theme-dark .cp-status-accepted {
    color: var(--brand);
}

body.dxbl-theme-dark .cp-status-paid,
body.dxbl-theme-dark .cp-status-delivered {
    color: var(--brand);
}

body.dxbl-theme-dark .cp-status-overdue {
    color: #f28b82;
}

/* Issue #169: het voorbeeld van een vragenlijsttemplate in de app (popup): melding bovenaan met "Opnieuw beginnen". */
.questionnaire-page.is-preview {
    min-height: auto;
}

.qn-preview-banner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
}

/* Issue #234: "Te doen" bovenaan: wat de klant nog moet doen, elk met één knop naar het onderdeel zelf. */
.cp-todo {
    border-color: color-mix(in srgb, var(--cp-accent) 45%, var(--surface-line));
}

.cp-todo h2 .bi {
    color: var(--cp-accent);
    margin-right: 4px;
}

.cp-todo-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.cp-todo-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 0;
}

.cp-todo-item + .cp-todo-item {
    border-top: 1px solid var(--surface-line);
}

.cp-todo-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 36px;
    height: 36px;
    border-radius: 10px;
    background: color-mix(in srgb, var(--cp-accent) 14%, var(--surface-strong));
    color: var(--cp-accent);
}

.cp-todo-item.is-urgent .cp-todo-icon {
    background: color-mix(in srgb, #e5484d 16%, var(--surface-strong));
    color: #b4232a;
}

.cp-todo-text {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.cp-todo-actions {
    flex-shrink: 0;
}

/* De hoofdactie: gevuld in de app-kleur. */
.cp-action.is-primary {
    border-color: var(--cp-accent);
    background: var(--cp-accent);
    color: #fff;
}

.cp-action.is-primary:hover,
.cp-action.is-primary:focus-visible {
    background: color-mix(in srgb, var(--cp-accent) 85%, #000);
    color: #fff;
}

/* Afgeronde opdrachten: ingeklapt onderaan, zodat ze niet tussen de lopende zaken staan. */
.cp-finished {
    margin-top: 8px;
}

.cp-finished > summary {
    cursor: pointer;
    padding: 8px 0;
    color: var(--muted);
    font-weight: 600;
}

.cp-finished > summary:hover {
    color: var(--ink);
}

.cp-finished[open] > summary {
    margin-bottom: 8px;
}

.cp-finished .cp-dossier-head {
    background: var(--surface-muted, var(--surface-strong));
}

body.dxbl-theme-dark .cp-todo-item.is-urgent .cp-todo-icon {
    color: #f28b82;
}

@media (max-width: 640px) {
    .cp-todo-item {
        flex-wrap: wrap;
    }

    .cp-todo-actions {
        flex-basis: 100%;
        padding-left: 48px;
    }
}

/* Wat "Te doen" in beeld scrollt, niet tegen de bovenrand. */
.cp-dossier,
.cp-payment {
    scroll-margin-top: 12px;
}

/* === Betaallink (/betalen, issue #127) ======================================== */

.cp-pay-page {
    max-width: 560px;
}

.cp-pay-facts {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 6px 16px;
    margin: 0 0 16px;
}

.cp-pay-facts dt {
    color: var(--muted);
    font-weight: 400;
}

.cp-pay-facts dd {
    margin: 0;
    text-align: right;
}

.cp-pay-amount {
    font-size: 1.3rem;
    font-weight: 700;
}

.cp-pay-button {
    width: 100%;
    justify-content: center;
    padding: 10px 16px;
    font-size: 1rem;
}

.cp-pay-button:disabled {
    opacity: .7;
    cursor: default;
}

.cp-pay .cp-muted {
    margin: 10px 0 0;
    text-align: center;
}

.cp-pay-result {
    display: flex;
    gap: 14px;
    align-items: flex-start;
}

.cp-pay-result > .bi {
    font-size: 2rem;
    color: var(--cp-accent);
}

.cp-pay-result.is-pending > .bi {
    color: var(--muted);
}

.cp-pay-result h2 {
    margin: 2px 0 6px;
}

.cp-pay-result p {
    margin: 0;
}

/* Terug naar het klantportaal, onder de betaalkaart. */
.cp-pay-back {
    display: flex;
    justify-content: center;
}
