/* ---------- Fonts (self-hosted) ----------
   Inter is served locally (no Google Fonts CDN) so no visitor IP ever reaches a
   third party — a GDPR requirement for EU clients. Inter v20 is a variable font,
   so one file per unicode-range covers every weight (100–900). Only latin +
   latin-ext are shipped (Western/Central European + € ™ etc.); add more ranges
   only if a client needs cyrillic/greek/vietnamese. Files: wwwroot/fonts/. */
@font-face {
    font-family: 'Inter';
    font-style: normal;
    font-weight: 100 900;
    font-display: swap;
    src: url('fonts/inter-latin.woff2') format('woff2');
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
    font-family: 'Inter';
    font-style: normal;
    font-weight: 100 900;
    font-display: swap;
    src: url('fonts/inter-latin-ext.woff2') format('woff2');
    unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

/* ---------- Design tokens for the custom CSS layer ----------
   MudBlazor components take their radius from AppTheme.cs (DefaultBorderRadius).
   The hand-written CSS below can't read that C# value, so its radii live here as
   the single place to change them — no bare px radius anywhere else in this file. */
:root {
    --app-radius-sm: 8px;   /* inputs, buttons, nav links, code chips */
    --app-radius-md: 10px;  /* brand mark */
    --app-radius-lg: 12px;  /* cards, panels */
}

/* FocusOnNavigate (Routes.razor) moves focus to the page <h1> after every navigation
   so screen readers announce the new page. The heading is not interactive, so hide the
   visible focus ring it would otherwise draw — real controls keep their rings. */
h1[tabindex="-1"]:focus,
h1[tabindex="-1"]:focus-visible {
    outline: none;
}

/* Respect users who ask for less motion (vestibular disorders): neutralize
   transitions/animations app-wide instead of auditing each one. */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

/* ---------- Brand mark (shared by app shell + auth pages) ---------- */
.brand-mark {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: var(--app-radius-sm);
    background: var(--mud-palette-primary);
    color: var(--mud-palette-primary-text);
    font-weight: 700;
    flex-shrink: 0;
}

.brand-mark-lg {
    width: 36px;
    height: 36px;
    border-radius: var(--app-radius-md);
}

/* ---------- Static-SSR auth pages ----------
   MudBlazor inputs need interactivity, so these forms use plain HTML — same split
   as the official Blazor Identity template. All colors come from the --mud-palette-*
   variables MudThemeProvider emits. */
.auth-page {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1.5rem;
    min-height: 100vh;
    padding: 1.5rem;
    background: var(--mud-palette-background);
}

.auth-brand {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    color: var(--mud-palette-text-primary);
    font-size: 1.125rem;
    font-weight: 600;
    text-decoration: none;
}

.auth-card {
    width: 100%;
    max-width: 420px;
    padding: 2rem;
    border: 1px solid var(--mud-palette-lines-default);
    border-radius: var(--app-radius-lg);
    background: var(--mud-palette-surface);
    /* MudBlazor's elevation tokens are computed per light/dark palette, so the card
       keeps a visible edge in dark mode (a raw rgba shadow would vanish there). */
    box-shadow: var(--mud-elevation-2);
}

.auth-card h1 {
    margin: 0 0 1.25rem;
    font-size: 1.375rem;
    font-weight: 600;
    color: var(--mud-palette-text-primary);
}

.auth-card p {
    margin: 1rem 0 0;
    font-size: 0.875rem;
    color: var(--mud-palette-text-secondary);
}

.auth-card a {
    color: var(--mud-palette-primary);
    text-decoration: none;
    font-weight: 500;
    border-radius: 2px;
}

.auth-card a:hover {
    text-decoration: underline;
}

.auth-card a:focus-visible {
    outline: 2px solid var(--mud-palette-primary);
    outline-offset: 2px;
}

.auth-field {
    display: flex;
    flex-direction: column;
    gap: 0.375rem;
    margin-bottom: 1rem;
}

.auth-field label {
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--mud-palette-text-secondary);
}

.auth-field input {
    padding: 0.625rem 0.75rem;
    border: 1px solid var(--mud-palette-lines-inputs);
    border-radius: var(--app-radius-sm);
    background: transparent;
    color: inherit;
    font-size: 0.9375rem;
    font-family: inherit;
}

.auth-field input:focus {
    outline: 2px solid var(--mud-palette-primary);
    outline-offset: -1px;
    border-color: var(--mud-palette-primary);
}

.auth-checkbox {
    display: block;
    margin-bottom: 1rem;
    font-size: 0.875rem;
    color: var(--mud-palette-text-secondary);
}

.auth-button {
    width: 100%;
    padding: 0.625rem 1.25rem;
    border: none;
    border-radius: var(--app-radius-sm);
    background: var(--mud-palette-primary);
    color: var(--mud-palette-primary-text);
    font-size: 0.9375rem;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
}

.auth-button:hover {
    background: var(--mud-palette-primary-darken);
}

.auth-button:focus-visible {
    outline: 2px solid var(--mud-palette-primary);
    outline-offset: 2px;
}

.auth-hint {
    font-size: 0.85rem;
    word-break: break-all;
    opacity: 0.8;
}

/* ---------- 2FA enrollment ---------- */

.twofa-setup {
    display: flex;
    gap: 2rem;
    flex-wrap: wrap;
    align-items: flex-start;
}

.twofa-qr-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
    padding: 1.25rem;
    border: 1px solid var(--mud-palette-lines-default);
    border-radius: var(--app-radius-lg);
}

.twofa-qr-card img {
    /* The QR PNG is black-on-white; keep the white plate in dark mode so it stays scannable. */
    background: #fff;
    padding: 0.5rem;
    border-radius: var(--app-radius-sm);
}

.twofa-key {
    font-size: 0.8125rem;
    word-break: break-all;
    text-align: center;
    max-width: 220px;
}

.twofa-steps {
    flex: 1;
    min-width: 280px;
}

.twofa-step {
    display: flex;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}

.twofa-step-number {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 1.5rem;
    height: 1.5rem;
    border-radius: 50%;
    background: color-mix(in srgb, var(--mud-palette-primary) 12%, transparent);
    color: var(--mud-palette-primary);
    font-size: 0.8125rem;
    font-weight: 600;
    flex-shrink: 0;
}

.twofa-step-title {
    font-weight: 500;
}

.twofa-recovery-codes {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 0.5rem;
    max-width: 640px;
}

.twofa-recovery-codes code {
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--mud-palette-lines-default);
    border-radius: var(--app-radius-sm);
    text-align: center;
}

/* ---------- Base ---------- */

body {
    font-family: var(--mud-typography-default-family, 'Inter', system-ui, sans-serif);
}

/* ---------- Shared components (colors via --mud-palette-* only) ---------- */

.stat-card-trend {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    margin-top: 0.5rem;
    font-size: 0.8125rem;
    font-weight: 500;
}

.stat-card-trend-up {
    color: var(--mud-palette-success);
}

.stat-card-trend-down {
    color: var(--mud-palette-error);
}

.stat-card-trend .mud-icon-root {
    font-size: 1rem;
}

.stat-card-trend-caption {
    color: var(--mud-palette-text-secondary);
    font-weight: 400;
}

.page-header .mud-breadcrumbs {
    font-size: 0.8125rem;
}

/* ---------- App shell ---------- */

.app-topbar {
    border-bottom: 1px solid var(--mud-palette-lines-default);
}

.app-sidebar {
    border-right: 1px solid var(--mud-palette-lines-default);
}

.app-sidebar .mud-drawer-content {
    display: flex;
    flex-direction: column;
}

.app-brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1.25rem 1.5rem;
}

.app-brand-name {
    font-size: 1rem;
    font-weight: 600;
    color: var(--mud-palette-text-primary);
}

.app-nav-section {
    padding: 1.25rem 0.75rem 0.375rem;
    font-size: 0.6875rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--mud-palette-text-secondary);
}

.app-nav .mud-nav-link {
    border-radius: var(--app-radius-sm);
    margin: 2px 0;
}

.app-nav .mud-nav-link.active {
    background: color-mix(in srgb, var(--mud-palette-primary) 10%, transparent);
    color: var(--mud-palette-primary);
}

.app-nav .mud-nav-link.active .mud-icon-root {
    color: var(--mud-palette-primary);
}

.app-page {
    max-width: 1200px;
    margin: 0 auto;
}

/* ---------- Mobile navigation ----------
   The layout is static SSR, so MudDrawer's responsive breakpoint (which needs a
   circuit) can't run. Instead a plain hamburger button toggles a `nav-open` class
   on <body> via inline JS (no circuit), and CSS slides the fixed sidebar in with a
   scrim. mobile-nav.js closes it again after a nav link is tapped. */
.app-nav-toggle {
    display: none;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    margin-right: 0.5rem;
    border: none;
    border-radius: var(--app-radius-sm);
    background: transparent;
    color: var(--mud-palette-text-primary);
    cursor: pointer;
}

.app-nav-toggle:hover {
    background: color-mix(in srgb, var(--mud-palette-text-primary) 8%, transparent);
}

.app-nav-toggle svg {
    width: 22px;
    height: 22px;
}

.app-nav-backdrop {
    display: none;
}

@media (max-width: 959.98px) {
    .app-nav-toggle {
        display: inline-flex;
    }

    .mud-main-content,
    .mud-appbar {
        margin-left: 0 !important;
        left: 0 !important;
    }

    .app-sidebar {
        transform: translateX(-100%);
        transition: transform 0.2s ease;
        z-index: 1300;
    }

    body.nav-open .app-sidebar {
        transform: translateX(0);
        box-shadow: var(--mud-elevation-8);
    }

    .app-nav-backdrop {
        display: block;
        position: fixed;
        inset: 0;
        z-index: 1200;
        background: var(--mud-palette-overlay-dark, rgba(15, 23, 42, 0.5));
        opacity: 0;
        pointer-events: none;
        transition: opacity 0.2s ease;
    }

    body.nav-open .app-nav-backdrop {
        opacity: 1;
        pointer-events: auto;
    }
}

.settings-card {
    max-width: 720px;
}

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

.table-card {
    overflow: hidden;
}

.table-toolbar {
    border-bottom: 1px solid var(--mud-palette-lines-default);
}

.table-search {
    max-width: 320px;
}

.table-cell-primary {
    font-weight: 500;
}

.table-card .mud-table-row:hover {
    cursor: pointer;
}

/* ---------- Form pattern ---------- */

.form-page {
    max-width: 720px;
}

/* ---------- Status pages (404 / error) ---------- */

.status-page {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 60vh;
    text-align: center;
}

.status-page-code {
    font-size: 4rem;
    font-weight: 700;
    line-height: 1;
    color: var(--mud-palette-primary);
    margin-bottom: 0.5rem;
}

/* ---------- Empty state (EmptyState.razor) ---------- */

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 2.5rem 1.5rem;
}

.empty-state-lg {
    padding: 4rem 1.5rem;
}

.empty-state-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 3.5rem;
    height: 3.5rem;
    border-radius: 50%;
    background: color-mix(in srgb, var(--mud-palette-primary) 10%, transparent);
    color: var(--mud-palette-primary);
}

.empty-state-text {
    max-width: 42ch;
}

/* ---------- Status chip (StatusChip.razor + DocumentStatusChip.razor) ---------- */

.status-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.15rem 0.6rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 500;
    line-height: 1.6;
    white-space: nowrap;
}

.status-chip-dot {
    width: 0.5rem;
    height: 0.5rem;
    border-radius: 50%;
    background: currentColor;
    flex-shrink: 0;
}

.status-chip-icon.mud-icon-root {
    font-size: 0.9rem;
}

/* ---------- Action-required pill (ActionRequiredPill.razor) ---------- */

.action-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.15rem 0.6rem 0.15rem 0.45rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
    line-height: 1.6;
    white-space: nowrap;
}

.action-pill-normal {
    color: var(--mud-palette-warning);
    background: color-mix(in srgb, var(--mud-palette-warning) 14%, transparent);
}

.action-pill-urgent {
    color: var(--mud-palette-error);
    background: color-mix(in srgb, var(--mud-palette-error) 14%, transparent);
}

.action-pill-icon.mud-icon-root {
    font-size: 0.95rem;
}

.action-pill-count {
    min-width: 1.15rem;
    padding: 0 0.3rem;
    border-radius: 999px;
    background: currentColor;
    text-align: center;
    font-size: 0.7rem;
    line-height: 1.15rem;
}

/* The count sits on the pill's own colour, so punch its glyph back out to the surface. */
.action-pill-count {
    color: var(--mud-palette-surface);
}

/* ---------- Master-detail layout (MasterDetailLayout.razor) ---------- */

.master-detail {
    display: grid;
    grid-template-columns: minmax(280px, 340px) 1fr;
    gap: 1.5rem;
    align-items: start;
}

.master-detail-list,
.master-detail-detail {
    min-width: 0; /* let children (tables) shrink instead of overflowing the grid track */
}

@media (max-width: 959.98px) {
    .master-detail {
        grid-template-columns: 1fr;
    }
}

/* ---------- Contractdossier detail (cluster D4) ---------- */

/* Read-only fact grid used on the Overzicht tab and inside Static dialog fields. */
.detail-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 1.25rem 2rem;
}

.detail-field {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    min-width: 0;
}

.detail-field-label {
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--mud-palette-text-secondary);
}

.detail-field-value {
    font-size: 0.9375rem;
    color: var(--mud-palette-text-primary);
}

.detail-field-empty {
    font-size: 0.9375rem;
    color: var(--mud-palette-text-disabled);
    font-style: italic;
}

.detail-field-hint {
    font-size: 0.8125rem;
    color: var(--mud-palette-text-secondary);
}

/* Contactpersoon-slots (algemeen / administratie / tekenbevoegd). */
.slot-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 1rem;
}

.slot-card {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.slot-head {
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.slot-title {
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--mud-palette-text-secondary);
}

.slot-person {
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
}

/* Logboek timeline. */
.logboek {
    display: flex;
    flex-direction: column;
}

.logboek-regel {
    display: flex;
    gap: 0.85rem;
    padding-bottom: 1.1rem;
    position: relative;
}

.logboek-regel:not(:last-child)::before {
    content: "";
    position: absolute;
    left: 5px;
    top: 0.9rem;
    bottom: 0;
    width: 1px;
    background: var(--mud-palette-lines-default);
}

.logboek-dot {
    width: 11px;
    height: 11px;
    border-radius: 50%;
    background: var(--mud-palette-primary);
    margin-top: 0.3rem;
    flex-shrink: 0;
    z-index: 1;
}

.logboek-body {
    min-width: 0;
    flex: 1;
}

/* ---------- Rol-dashboard (cluster D2) ---------- */

.dash-tiles {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 1.25rem;
}

.dash-tile {
    cursor: pointer;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.dash-tile:hover {
    border-color: var(--mud-palette-primary);
    box-shadow: var(--mud-elevation-2);
}

.dash-feed-head {
    background: var(--mud-palette-background-gray);
}

.dash-feed .mud-list-item {
    border-bottom: 1px solid var(--mud-palette-lines-default);
}

.dash-feed .mud-list-item:last-child {
    border-bottom: none;
}

.dash-feed-dot {
    width: 0.6rem;
    height: 0.6rem;
    border-radius: 50%;
    background: var(--mud-palette-warning);
    flex-shrink: 0;
}

.dash-feed-dot-urgent {
    background: var(--mud-palette-error);
}

.capability-list .mud-list-item {
    padding-top: 0.25rem;
    padding-bottom: 0.25rem;
}

/* ---------- Opdracht/bieding detail (cluster D3) ---------- */

.detail-stack {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.blokkade-list {
    margin: 0 0 1rem;
    padding-left: 1.15rem;
    list-style: disc;
    color: var(--mud-palette-text-secondary);
    font-size: 0.875rem;
}

.blokkade-list li {
    margin-bottom: 0.25rem;
}

/* ---------- Documentstromen (cluster D5) ---------- */

.doc-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 1rem;
}

.doc-card {
    display: flex;
    flex-direction: column;
}

.doc-meta {
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
}

/* ---------- Registratie-wizard / invitatie (cluster D7) ---------- */

.wizard-page {
    display: flex;
    justify-content: center;
    padding: 1rem 0 2rem;
}

.wizard-card {
    width: 100%;
    max-width: 520px;
}

.wizard-choice-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1rem;
}

.wizard-choice {
    display: flex;
    flex-direction: column;
    cursor: pointer;
    transition: border-color 0.15s ease, background 0.15s ease;
}

.wizard-choice:hover {
    border-color: var(--mud-palette-primary);
}

.wizard-choice-selected {
    border-color: var(--mud-palette-primary);
    background: color-mix(in srgb, var(--mud-palette-primary) 8%, transparent);
}

/* ---------- Mailbeheer preview (cluster D8) ---------- */

.mail-preview {
    background: var(--mud-palette-background);
}

.mail-preview-subject {
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--mud-palette-text-primary);
}

.mail-preview-body {
    white-space: pre-wrap;
    font-size: 0.875rem;
    line-height: 1.6;
    color: var(--mud-palette-text-secondary);
}
