/* ==========================================================================
   Components: reusable building blocks for every page
   (dropdown, card, button, badge, search field, alert, table, form field)
   ========================================================================== */

/* ---------- Dropdown (data-dropdown + data-dropdown-toggle, see app.js) ---------- */

.dropdown {
    position: relative;
}

.dropdown__menu {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    z-index: 40;
    display: none;
    min-width: 180px;
    padding: 6px;
    border: 1px solid var(--color-line);
    border-radius: var(--radius-md);
    background: var(--color-surface);
    color: var(--color-text);
    box-shadow: var(--shadow-popover);
}

.dropdown.is-open > .dropdown__menu {
    display: block;
}

.dropdown__menu--right {
    left: auto;
    right: 0;
}

.dropdown__menu--grid {
    top: 100%;
    width: 560px;
    padding: 10px;
    border-radius: 0 0 var(--radius-md) var(--radius-md);
}

.dropdown.is-open > .dropdown__menu--grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px 10px;
}

.dropdown__heading {
    margin: 2px 10px 4px;
    color: var(--color-text-muted);
    font-size: 11px;
    letter-spacing: .06em;
    text-transform: uppercase;
}

.dropdown__item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 8px 10px;
    border-radius: var(--radius-sm);
    font-size: 13.5px;
    font-weight: 600;
    text-align: left;
    white-space: nowrap;
}

.dropdown__item:hover {
    background: var(--color-bg);
}

.dropdown__item.is-active {
    background: var(--color-brand-light);
    color: var(--color-brand-darker);
}

.dropdown__item .icon {
    color: var(--color-text-muted);
}

.dropdown__code {
    width: 22px;
    color: var(--color-text-muted);
    font-size: 12px;
}

.dropdown__header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 4px;
    padding: 8px 10px 10px;
    border-bottom: 1px solid var(--color-line-soft);
}

.dropdown__header b {
    display: block;
    font-size: 13.5px;
}

.dropdown__header small {
    color: var(--color-text-muted);
    font-size: 12px;
}

.avatar {
    display: grid;
    place-items: center;
    flex: none;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: #DDE8C9;
    color: var(--color-brand-darker);
    font-size: 10px;
    font-weight: 800;
}

/* ---------- Card ---------- */

.card {
    min-width: 0;
    margin-bottom: var(--space-5);
    padding: var(--space-5);
    border: 1px solid var(--color-card-border);
    border-radius: var(--radius-xl);
    background: var(--color-surface);
    box-shadow: var(--shadow-card);
}

.card__head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    margin-bottom: 14px;
}

.card__head h3 {
    font-size: var(--font-size-lg);
}

.card__head small {
    display: block;
    color: var(--color-text-muted);
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-normal);
}

.card__actions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-left: auto;
}

.card__actions form {
    display: contents;
}

.card__foot {
    display: flex;
    justify-content: flex-end;
    gap: var(--space-2);
    margin-top: var(--space-3);
}

.card__foot--start {
    justify-content: flex-start;
    padding-top: var(--space-3);
    border-top: 1px solid var(--color-line-soft);
}

.card__foot .link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
}

.card--warning {
    border-color: #F1DDB0;
    background: #FFFCF4;
}

.card--warning .card__icon {
    background: var(--color-warning-light);
    color: #9A6A08;
}

.card--warning .table tbody tr:nth-child(even) {
    background: rgba(251, 241, 220, .45);
}

.card__icon {
    display: grid;
    place-items: center;
    flex: none;
    width: 32px;
    height: 32px;
    border-radius: 9px;
    background: var(--color-brand-light);
    color: var(--color-brand-dark);
}

/* Compact link to a choice (icon, label, arrow) inside a choice grid */
.report-choice {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 14px;
    border: 1px solid var(--color-card-border);
    border-radius: var(--radius-md);
    color: var(--color-text);
    font-weight: 600;
    text-decoration: none;
    transition: border-color var(--transition), background var(--transition);
}

.report-choice .icon {
    color: var(--color-brand-dark);
}

.report-choice:hover {
    border-color: var(--color-brand);
    background: var(--color-brand-light);
}

.report-choice__arrow {
    margin-left: auto;
    color: #C3CBC0;
}

/* Label / value pairs */
.details {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: var(--space-3) var(--space-6);
    margin-bottom: var(--space-5);
}

.details dt {
    color: var(--color-text-muted);
    font-size: var(--font-size-xs);
    font-weight: var(--font-weight-bold);
    letter-spacing: .04em;
    text-transform: uppercase;
}

.details dd {
    margin-top: 2px;
    font-weight: 600;
    overflow-wrap: anywhere;
}

/* A row of form fields with the buttons at the end */
.form-row {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: var(--space-3);
}

.form-row .field {
    margin-bottom: 0;
}

.form-row__grow {
    flex: 1 1 260px;
    max-width: 420px;
}

.form-row__actions {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2);
}

.form-row .btn {
    height: 42px;
}

/* Choice cards: a few big options to pick from (e.g. type of advice) */
.choice-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(260px, 100%), 1fr));
    gap: var(--space-4);
}

.choice-card {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 22px;
    border: 1px solid var(--color-card-border);
    border-radius: var(--radius-xl);
    background: var(--color-surface);
    transition: border-color var(--transition), transform var(--transition), box-shadow var(--transition);
}

.choice-card:hover {
    border-color: var(--color-brand);
    box-shadow: 0 10px 24px rgba(16, 25, 22, .07);
    transform: translateY(-2px);
}

.choice-card .card__icon {
    width: 46px;
    height: 46px;
    border-radius: var(--radius-md);
}

.choice-card .card__icon .icon {
    width: 22px;
    height: 22px;
}

.choice-card h3 {
    font-size: 18px;
}

.choice-card p {
    color: var(--color-text-muted);
    line-height: 1.5;
}

.choice-card .link {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    align-self: flex-start;
}

.empty-state {
    padding: 36px;
    text-align: center;
}

.empty-state p {
    margin-top: 6px;
    color: var(--color-text-muted);
}

/* ---------- Section title ---------- */

.section-title {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: var(--space-3);
    margin: 6px 2px var(--space-3);
}

.section-title h2 {
    font-size: 19px;
    letter-spacing: -.3px;
}

.section-title span {
    color: var(--color-text-muted);
    font-size: 13px;
    font-weight: var(--font-weight-normal);
}

/* ---------- Button ---------- */

.btn {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    padding: 9px 14px;
    border-radius: var(--radius);
    background: var(--color-brand);
    color: #fff;
    font-size: 13.5px;
    font-weight: var(--font-weight-bold);
    text-decoration: none;
    white-space: nowrap;
}

.btn:hover {
    background: var(--color-brand-dark);
}

.btn:disabled {
    opacity: .45;
    cursor: not-allowed;
}

.btn--ghost {
    border: 1px solid var(--color-line);
    background: var(--color-surface);
    color: var(--color-text);
}

.btn--ghost:hover {
    background: var(--color-surface-alt);
}

.btn--danger {
    background: var(--color-danger);
}

.btn--danger:hover {
    background: #C2423E;
}

.btn--small {
    padding: 7px 11px;
    border-radius: 10px;
    font-size: 13px;
}

.btn--large {
    height: 50px;
    border-radius: 12px;
    font-size: 15px;
}

.btn--block {
    width: 100%;
    justify-content: center;
}

/* ---------- Text link ---------- */

.link {
    color: var(--color-brand-dark);
    font-weight: 600;
    text-decoration: underline;
    text-decoration-color: rgba(110, 154, 20, .4);
    text-decoration-thickness: 1.5px;
    text-underline-offset: 3px;
}

.link:hover {
    color: var(--color-brand-darker);
    text-decoration-color: currentColor;
}

/* Link to a detail screen ("Bekijk detail"), with an arrow */
.link--arrow {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    white-space: nowrap;
}

.link--arrow .icon {
    flex: none;
    width: 14px;
    height: 14px;
}

/* On its own line (not in a table) a long label may wrap on a narrow screen */
p > .link--arrow {
    white-space: normal;
}

/* Phones: only the arrow (the link keeps its label in aria-label) */
@media (max-width: 640px) {
    .link--arrow .link__label {
        display: none;
    }
    .link--arrow .icon {
        width: 18px;
        height: 18px;
    }
}

/* ---------- Badge / chip ---------- */

.badge {
    display: inline-block;
    padding: 2px 7px;
    border-radius: 7px;
    background: var(--color-brand-light);
    color: #4C7010;
    font-size: var(--font-size-xs);
    font-weight: var(--font-weight-bold);
    white-space: nowrap;
}

.badge--danger { background: var(--color-danger-light); color: var(--color-danger); }
.badge--warning { background: var(--color-warning-light); color: #8A5E07; }
.badge--muted  { background: #EEF0EC; color: var(--color-text-muted); }
.badge--dark {
    background: var(--color-dark);
    color: var(--color-brand-mid);
    font-size: 10px;
    letter-spacing: .04em;
    text-transform: uppercase;
}

/* ---------- Account status (Beheer > Account) ---------- */

.account-status {
    --accent: var(--color-brand-dark);
    --tint: var(--color-brand-light);
    display: flex;
    align-items: center;
    gap: var(--space-4);
    margin-bottom: var(--space-5);
    padding: 18px 22px;
    border: 1px solid var(--color-card-border);
    border-left: 4px solid var(--accent);
    border-radius: var(--radius-lg);
    background: var(--color-surface);
}

.account-status--expiring { --accent: var(--color-warning); --tint: var(--color-warning-light); }
.account-status--expired  { --accent: var(--color-danger);  --tint: var(--color-danger-light); }

.account-status__icon {
    display: grid;
    flex: none;
    place-items: center;
    width: 44px;
    height: 44px;
    border-radius: 12px;
    background: var(--tint);
    color: var(--accent);
}

.account-status__icon .icon {
    width: 22px;
    height: 22px;
}

.account-status__text {
    display: grid;
    flex: 1;
    gap: 2px;
    min-width: 0;
}

.account-status__label {
    color: var(--color-text-muted);
    font-size: var(--font-size-sm);
    font-weight: 600;
}

.account-status__value {
    color: var(--color-text);
    font-size: var(--font-size-lg);
    font-weight: var(--font-weight-bold);
}

@media (max-width: 640px) {
    .account-status {
        flex-wrap: wrap;
        gap: var(--space-3);
        padding: 14px 16px;
    }
}

/* ---------- Search field ---------- */

.search-field {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    height: 42px;
    padding: 0 12px;
    border: 1px solid #DCE3D6;
    border-radius: 10px;
    background: var(--color-surface-alt);
    color: var(--color-text-muted);
    transition: border-color var(--transition), box-shadow var(--transition);
}

.search-field:focus-within {
    border-color: var(--color-brand);
    box-shadow: 0 0 0 4px var(--color-brand-ring);
    color: var(--color-brand-dark);
}

.search-field input {
    flex: 1;
    min-width: 0;
    border: 0;
    outline: 0;
    background: none;
    color: var(--color-text);
}

.search-field--compact {
    width: 300px;
    height: 38px;
    background: var(--color-surface);
}

@media (max-width: 640px) {
    .search-field--compact { width: min(200px, 52vw); }
}

/* ---------- Alert (flash messages) ---------- */

.flash-list {
    display: grid;
    gap: var(--space-2);
    margin-bottom: var(--space-5);
}

.alert {
    padding: 12px 16px;
    border: 1px solid #D6E8B5;
    border-radius: var(--radius-md);
    background: var(--color-brand-light);
    color: var(--color-brand-darker);
    font-weight: 600;
    cursor: pointer;
}

.alert--error {
    border-color: #F2C9C7;
    background: var(--color-danger-light);
    color: #A33B37;
}

.alert--warning {
    border-color: #F1DDB0;
    background: var(--color-warning-light);
    color: #8A5E07;
}

/* ---------- Table ---------- */

.table-wrap {
    margin: 0 -4px;
    overflow-x: auto;
}

.table {
    width: 100%;
    border-collapse: collapse;
    font-size: var(--font-size-table);
}

.table th {
    padding: 9px 10px;
    border-bottom: 1px solid var(--color-line);
    color: var(--color-text-muted);
    font-size: var(--font-size-table-head);
    font-weight: var(--font-weight-bold);
    letter-spacing: .03em;
    text-align: right;
    text-transform: uppercase;
    white-space: nowrap;
}

.table td {
    padding: 10px;
    text-align: right;
    white-space: nowrap;
}

.table .is-left {
    text-align: left;
}

.table tbody tr:nth-child(even) {
    background: var(--color-surface-alt);
}

.table tbody tr:hover {
    background: #F0F5E8;
}

.table tr.is-total td {
    border-top: 1px solid var(--color-line);
    background: #EDF2E5;
    font-weight: var(--font-weight-bold);
}

.table a:not(.link):not(.icon-button) {
    color: var(--color-text);
}

.table a:not(.link):not(.icon-button):hover {
    color: var(--color-brand-dark);
}

.table th[data-sort] {
    cursor: pointer;
    user-select: none;
}

.table th[data-sort]:hover,
.table th.is-sorted {
    color: var(--color-text);
}

.table th.is-sorted::after {
    content: " ↑";
    color: var(--color-brand-dark);
}

.table th.is-sorted-desc::after {
    content: " ↓";
}

/* Cells with free text (names, e-mail addresses) may wrap */
.table .is-wrap {
    min-width: 160px;
    white-space: normal;
    overflow-wrap: anywhere;
}

.table .table__sub {
    display: block;
    margin-top: 2px;
    color: var(--color-text-muted);
    font-size: var(--font-size-sm);
    white-space: nowrap;
}

.table .table__check {
    width: 40px;
    text-align: center;
}

.table .table__actions {
    width: 1%;
    text-align: right;
}

/* Long text (names, descriptions) may wrap instead of widening the table */
.table td.is-wrap {
    min-width: 8em;
    white-space: normal;
}

/* hide-mobile: hidden on tablets and phones; hide-phone: only on phones */
@media (max-width: 899px) {
    .table .hide-mobile { display: none; }
}

@media (max-width: 640px) {
    .table .hide-phone { display: none; }
}

.table tr.is-inactive td {
    color: var(--color-text-muted);
}

.table-status:empty {
    display: none;
}

.table-status {
    padding: var(--space-3);
    text-align: center;
}

/* Toolbar above a table: tabs left, search right */
.toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 10px;
}

/* ---------- Tabs (underlined, e.g. under a card head) ---------- */

.tabs {
    display: flex;
    gap: 4px;
    margin: 0 -4px;
    padding: 0 4px;
    overflow-x: auto;
    border-bottom: 1px solid var(--color-line);
    scrollbar-width: none;
}

.tabs__item {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 10px 12px;
    color: var(--color-text-muted);
    font-size: 13.5px;
    font-weight: var(--font-weight-bold);
    text-decoration: none;
    white-space: nowrap;
}

.tabs__item:hover {
    color: var(--color-text);
    text-decoration: none;
}

.tabs__item.is-active {
    color: var(--color-brand-darker);
}

.tabs__item.is-active::after {
    content: "";
    position: absolute;
    left: 8px;
    right: 8px;
    bottom: -1px;
    height: 3px;
    border-radius: 3px 3px 0 0;
    background: var(--color-brand);
}

.card > .tabs:last-child {
    margin-bottom: calc(-1 * var(--space-5));
}

/* ---------- Segmented control (tabs as buttons) ---------- */

.segmented {
    display: inline-flex;
    gap: 2px;
    max-width: 100%;
    padding: 3px;
    overflow-x: auto;
    border-radius: 10px;
    background: #F0F3EC;
    scrollbar-width: none;
}

.segmented__item {
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    color: var(--color-text-muted);
    font-size: 13px;
    font-weight: var(--font-weight-bold);
    white-space: nowrap;
}

.segmented__item:hover {
    color: var(--color-text);
}

.segmented__item.is-active {
    background: var(--color-surface);
    box-shadow: 0 1px 2px rgba(0, 0, 0, .08);
    color: var(--color-text);
}

/* ---------- Switch (on/off checkbox) ---------- */

.switch {
    position: relative;
    display: inline-flex;
    cursor: pointer;
}

.switch input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.switch span {
    position: relative;
    width: 36px;
    height: 20px;
    border-radius: 12px;
    background: #D5DCD0;
    transition: background var(--transition);
}

.switch span::after {
    content: "";
    position: absolute;
    top: 2px;
    left: 2px;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 1px 2px rgba(0, 0, 0, .2);
    transition: left var(--transition);
}

.switch input:checked + span {
    background: var(--color-brand);
}

.switch input:checked + span::after {
    left: 18px;
}

.switch input:focus-visible + span {
    box-shadow: 0 0 0 3px var(--color-brand-ring);
}

.switch input:disabled + span {
    opacity: .5;
}

/* Avatar + name in a table cell */
.person {
    display: inline-flex;
    align-items: center;
    gap: 10px;
}

/* ---------- Checkbox ---------- */

.checkbox {
    width: 17px;
    height: 17px;
    accent-color: var(--color-brand);
    vertical-align: middle;
    cursor: pointer;
}

/* ---------- Icon buttons (row actions) ---------- */

.icon-actions {
    display: inline-flex;
    gap: 2px;
}

.icon-actions form {
    display: contents;
}

/* Labelled buttons side by side in a table row */
.btn-actions {
    display: inline-flex;
    justify-content: flex-end;
    gap: 6px;
}

@media (max-width: 640px) {
    .btn-actions {
        flex-direction: column;
        align-items: flex-end;
    }
}

.icon-button {
    display: grid;
    place-items: center;
    width: 30px;
    height: 30px;
    border-radius: var(--radius-sm);
    color: var(--color-text-muted);
    text-decoration: none;
}

.icon-button:hover {
    background: #F0F3EC;
    color: var(--color-text);
}

.icon-button--inline {
    display: inline-grid;
    width: 24px;
    height: 24px;
    margin-right: 6px;
    vertical-align: middle;
    color: var(--color-brand-dark);
}

.icon-button--danger:hover {
    background: var(--color-danger-light);
    color: var(--color-danger);
}

/* ---------- Form field ---------- */

.field {
    display: block;
    margin-bottom: var(--space-4);
}

.field__label {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    margin-bottom: 7px;
    color: #3A4540;
    font-size: 13px;
    font-weight: var(--font-weight-bold);
}

.field__label .link {
    font-size: var(--font-size-sm);
}

.field__hint {
    display: block;
    margin-top: 6px;
    color: var(--color-text-muted);
    font-size: 12px;
}

/* Input with a leading icon (and optional show-password button) */
.input-icon {
    display: flex;
    align-items: center;
    gap: 10px;
    height: 48px;
    padding: 0 12px;
    border: 1px solid #DCE3D6;
    border-radius: 12px;
    background: var(--color-surface);
    color: var(--color-text-muted);
    transition: border-color var(--transition), box-shadow var(--transition);
}

.input-icon:focus-within {
    border-color: var(--color-brand);
    box-shadow: 0 0 0 4px var(--color-brand-ring);
    color: var(--color-brand-dark);
}

.input-icon input {
    flex: 1;
    min-width: 0;
    height: 100%;
    border: 0;
    outline: 0;
    background: none;
    color: var(--color-text);
    font-size: 15px;
}

.input-icon__toggle {
    display: grid;
    place-items: center;
    width: 30px;
    height: 30px;
    border-radius: var(--radius-sm);
    color: var(--color-text-muted);
}

.input-icon__toggle:hover {
    background: var(--color-bg);
}

.input {
    width: 100%;
    height: 42px;
    padding: 0 12px;
    border: 1px solid #DCE3D6;
    border-radius: 10px;
    outline: 0;
    background: var(--color-surface);
    transition: border-color var(--transition), box-shadow var(--transition);
}

textarea.input {
    height: auto;
    padding: 10px 12px;
    resize: vertical;
}

.input:focus {
    border-color: var(--color-brand);
    box-shadow: 0 0 0 4px var(--color-brand-ring);
}
