/*
 * The document intake review screen: a queue on the left, one entry in focus on the right.
 *
 * Every token here is one dok-theme.css actually defines. The first version of this file was written
 * against a vocabulary that does not exist in this product — --dok-border, --dok-surface,
 * --dok-surface-hover, --dok-text-muted, --dok-primary, --dok-space-4 — and CSS fails a declaration
 * silently when a custom property is undefined and has no fallback. So `border: 1px solid var(--dok-border)`
 * produced NO border and `background: var(--dok-surface)` NO background: the screen rendered as bare text
 * on the page, with the panels invisible and the section headers floating. It looked like a missing design;
 * it was a missing variable.
 *
 * The palette is the same one the rest of the app uses: --dok-card-* for containers, --dok-text-* for type,
 * --mud-palette-* for accents (there is no --dok-primary; MudBlazor owns the brand colour and follows the
 * light/dark theme, which a hardcoded hex would not).
 */

.dok-inbound {
    display: flex;
    flex-direction: column;
    gap: var(--dok-space-md);
}

/* ---------- operational summary ---------- */

/*
 * These are totals for the current queue query, not a second dashboard feed. Keeping them beside the
 * review queue means the user can trust a filter immediately: the cards and the list always describe
 * exactly the same set of inbound documents.
 */
.dok-inbound__summary {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: var(--dok-space-sm);
}

.dok-inbound__summary-card {
    display: flex;
    align-items: center;
    gap: var(--dok-space-sm);
    min-width: 0;
    padding: var(--dok-space-md);
    border: 1px solid var(--dok-card-border);
    border-radius: var(--dok-radius);
    background: var(--dok-card-bg);
    box-shadow: var(--dok-shadow-sm);
}

.dok-inbound__summary-icon {
    display: inline-flex;
    flex: 0 0 auto;
    align-items: center;
    justify-content: center;
    width: 2.5rem;
    height: 2.5rem;
    border-radius: var(--dok-radius-full);
}

.dok-inbound__summary-icon--primary {
    background: var(--dok-overlay-soft);
    color: var(--mud-palette-primary);
}

.dok-inbound__summary-icon--warning {
    background: color-mix(in srgb, var(--mud-palette-warning) 14%, transparent);
    color: var(--mud-palette-warning);
}

.dok-inbound__summary-icon--error {
    background: color-mix(in srgb, var(--mud-palette-error) 12%, transparent);
    color: var(--mud-palette-error);
}

.dok-inbound__summary-icon--neutral {
    background: var(--dok-overlay-subtle);
    color: var(--dok-text-secondary);
}

.dok-inbound__summary-value {
    overflow: hidden;
    color: var(--dok-text-primary);
    font-size: 1.35rem;
    font-weight: var(--dok-font-weight-bold);
    line-height: 1.15;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.dok-inbound__summary-value--date {
    font-size: var(--dok-font-size-sm);
}

.dok-inbound__summary-label {
    margin-top: .18rem;
    color: var(--dok-text-secondary);
    font-size: var(--dok-font-size-xs);
    font-weight: var(--dok-font-weight-semibold);
}

/* ---------- layout ---------- */

.dok-inbound__body {
    display: grid;
    grid-template-columns: minmax(280px, 360px) minmax(0, 1fr);
    gap: var(--dok-space-md);
    align-items: start;
}

@media (max-width: 1100px) {
    .dok-inbound__summary {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .dok-inbound__body {
        grid-template-columns: minmax(0, 1fr);
    }
}

@media (max-width: 560px) {
    .dok-inbound__summary {
        grid-template-columns: minmax(0, 1fr);
    }
}


/* ---------- shared container ---------- */

.dok-inbound__queue,
.dok-inbound__panel,
.dok-inbound__decision {
    border: 1px solid var(--dok-card-border);
    border-radius: var(--dok-radius);
    background: var(--dok-card-bg);
    box-shadow: var(--dok-shadow-sm);
}

/* ---------- the queue ---------- */

.dok-inbound__queue {
    overflow: hidden;
}

.dok-inbound__queue-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--dok-space-xs);
    padding: var(--dok-space-sm) var(--dok-space-md);
    border-bottom: 1px solid var(--dok-border-subtle);
    background: rgba(148, 163, 184, .05);
    font-size: var(--dok-font-size-xs);
    font-weight: var(--dok-font-weight-semibold);
    color: var(--dok-text-secondary);
    text-transform: uppercase;
    letter-spacing: .06em;
}

/* The count is a chip, not a number adrift at the other end of the header. */
.dok-inbound__queue-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 1.5rem;
    height: 1.5rem;
    padding: 0 .45rem;
    border-radius: var(--dok-radius-full);
    background: var(--dok-overlay-soft);
    color: var(--mud-palette-primary);
    font-size: var(--dok-font-size-xs);
    font-weight: var(--dok-font-weight-bold);
    letter-spacing: 0;
}

.dok-inbound__queue-list {
    display: flex;
    flex-direction: column;
    max-height: 68vh;
    overflow-y: auto;
}

.dok-inbound__entry {
    display: flex;
    flex-direction: column;
    gap: .2rem;
    width: 100%;
    padding: var(--dok-space-sm) var(--dok-space-md);
    border: 0;
    border-bottom: 1px solid var(--dok-border-subtle);
    border-left: 3px solid transparent;
    background: transparent;
    text-align: left;
    cursor: pointer;
    color: inherit;
    font: inherit;
    transition: background var(--dok-transition), border-color var(--dok-transition);
}

.dok-inbound__entry:last-child {
    border-bottom: 0;
}

.dok-inbound__entry:hover {
    background: var(--dok-overlay-subtle);
}

/* Keyboard reachability is a requirement of this screen, not a nicety: the whole point is resolving a
   queue quickly, and the fastest way through a list is arrow keys and Enter. */
.dok-inbound__entry:focus-visible {
    outline: 2px solid var(--mud-palette-primary);
    outline-offset: -2px;
}

.dok-inbound__entry--selected {
    background: var(--dok-overlay-soft);
    border-left-color: var(--mud-palette-primary);
}

.dok-inbound__entry-name {
    font-weight: var(--dok-font-weight-semibold);
    font-size: var(--dok-font-size-sm);
    color: var(--dok-text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.dok-inbound__entry-meta {
    display: flex;
    align-items: center;
    gap: var(--dok-space-xs);
    font-size: var(--dok-font-size-xs);
    color: var(--dok-text-secondary);
}

/* ---------- the focus panel ---------- */

.dok-inbound__focus {
    display: flex;
    flex-direction: column;
    gap: var(--dok-space-md);
    min-width: 0;
}

.dok-inbound__panel {
    padding: var(--dok-space-md);
}

.dok-inbound__panel-title {
    font-size: var(--dok-font-size-xs);
    font-weight: var(--dok-font-weight-semibold);
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--dok-text-secondary);
    margin-bottom: var(--dok-space-sm);
}

/* ---------- the document preview ---------- */

.dok-inbound__preview-frame {
    width: 100%;
    height: 60vh;
    min-height: 320px;
    border: 1px solid var(--dok-card-border);
    border-radius: var(--dok-radius-sm);
    background: rgba(148, 163, 184, .06);
}

.dok-inbound__preview-image {
    max-width: 100%;
    max-height: 60vh;
    border-radius: var(--dok-radius-sm);
    border: 1px solid var(--dok-card-border);
}

.dok-inbound__preview-fallback {
    display: flex;
    align-items: center;
    gap: var(--dok-space-sm);
    padding: var(--dok-space-md);
    border: 1px dashed var(--dok-card-border);
    border-radius: var(--dok-radius-sm);
    color: var(--dok-text-secondary);
}

/* ---------- suggestion cards ---------- */

.dok-inbound__suggestions {
    display: flex;
    flex-direction: column;
    gap: var(--dok-space-xs);
}

.dok-inbound__suggestion {
    display: flex;
    flex-direction: column;
    gap: var(--dok-space-xs);
    width: 100%;
    padding: var(--dok-space-sm) var(--dok-space-md);
    border: 1px solid var(--dok-card-border);
    border-radius: var(--dok-radius-sm);
    background: var(--dok-card-bg);
    text-align: left;
    cursor: pointer;
    color: inherit;
    font: inherit;
    transition: border-color var(--dok-transition), background var(--dok-transition), box-shadow var(--dok-transition);
}

.dok-inbound__suggestion:hover {
    border-color: var(--mud-palette-primary);
    box-shadow: var(--dok-shadow-sm);
}

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

.dok-inbound__suggestion--selected {
    border-color: var(--mud-palette-primary);
    background: var(--dok-overlay-subtle);
}

.dok-inbound__suggestion-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--dok-space-xs);
}

.dok-inbound__suggestion-name {
    font-weight: var(--dok-font-weight-semibold);
    color: var(--dok-text-primary);
}

.dok-inbound__suggestion-rationale {
    font-size: var(--dok-font-size-sm);
    color: var(--dok-text-secondary);
}

/*
 * Q5: a discreet bar, never a percentage. A number invites the user to argue with the model instead of
 * looking at the document, which is the one thing only they can do.
 */
.dok-inbound__confidence {
    height: 4px;
    border-radius: var(--dok-radius-full);
    background: var(--dok-border-subtle);
    overflow: hidden;
}

.dok-inbound__confidence-fill {
    display: block;
    height: 100%;
    border-radius: var(--dok-radius-full);
    background: var(--mud-palette-primary);
}

/* Colour only below the threshold, so it means something when it appears. */
.dok-inbound__confidence-fill--low {
    background: var(--mud-palette-warning);
}

/* ---------- the decision footer ---------- */

.dok-inbound__decision {
    position: sticky;
    bottom: var(--dok-space-xs);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--dok-space-sm);
    padding: var(--dok-space-sm) var(--dok-space-md);
    box-shadow: var(--dok-shadow-md);
}

.dok-inbound__decision-actions {
    display: flex;
    align-items: center;
    gap: var(--dok-space-xs);
}

/*
 * The empty states carry this screen most of the time — an intake queue is empty whenever the routing is
 * working. They get a real illustration slot and centred copy instead of a line of grey text adrift in a
 * column, which is what the reporter saw.
 */
.dok-inbound__empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: var(--dok-space-xs);
    min-height: 16rem;
    padding: var(--dok-space-xl) var(--dok-space-md);
    color: var(--dok-text-secondary);
    text-align: center;
}

.dok-inbound__empty .mud-icon-root {
    margin-bottom: var(--dok-space-2xs);
    padding: var(--dok-space-sm);
    border-radius: var(--dok-radius-full);
    background: rgba(148, 163, 184, .1);
    color: var(--dok-text-secondary);
}

/* The right-hand pane's placeholder has to fill the space the document will occupy, or the page collapses
   to a short strip with a large blank below it. */
.dok-inbound__focus .dok-inbound__empty {
    min-height: 24rem;
}

/* ==========================================================================
 * DOK-547 — the way IN: drop zone plus one row per file.
 *
 * Lives in this file rather than a new one because it is the same area of the
 * product as the queue above and this stylesheet is already linked from
 * App.razor. Same token vocabulary, for the reason the header of this file
 * gives at length: a name dok-theme.css does not define fails silently and
 * renders as bare text.
 * ========================================================================== */

.dok-inbound-upload {
    display: flex;
    flex-direction: column;
    gap: var(--dok-space-md);
}

/*
 * The hidden <input type="file"> lives here. Kept in the layout rather than
 * display:none: the drop-zone script reaches into this host for the input and
 * assigns the dropped FileList to it, and a display:none input still receives
 * files, but removing it from the tree would make the query fail.
 */
.dok-inbound-upload__picker-host {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
}

.dok-inbound-upload__dropzone {
    border: 2px dashed var(--dok-card-border);
    border-radius: var(--dok-radius);
    background: var(--dok-card-bg);
    transition: border-color var(--dok-transition), background var(--dok-transition);
}

.dok-inbound-upload__dropzone--active {
    border-color: var(--mud-palette-primary);
    background: var(--dok-overlay-soft);
}

.dok-inbound-upload__dropzone-surface {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--dok-space-sm);
    padding: var(--dok-space-xl);
    background: transparent;
    text-align: center;
}

.dok-inbound-upload__dropzone-icon {
    color: var(--mud-palette-primary);
}

.dok-inbound-upload__limits {
    color: var(--dok-text-secondary);
}

.dok-inbound-upload__list {
    display: flex;
    flex-direction: column;
    gap: var(--dok-space-sm);
}

.dok-inbound-upload__list-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--dok-space-sm);
}

.dok-inbound-upload__empty {
    display: flex;
    flex-direction: column;
    gap: var(--dok-space-xs);
    padding: var(--dok-space-xl);
    border-radius: var(--dok-radius);
    text-align: center;
}

.dok-inbound-upload__entry {
    padding: var(--dok-space-sm) var(--dok-space-md);
    border-radius: var(--dok-radius);
}

.dok-inbound-upload__entry-line {
    display: flex;
    align-items: center;
    gap: var(--dok-space-sm);
    min-width: 0;
}

.dok-inbound-upload__entry-icon {
    color: var(--dok-text-secondary);
}

/* min-width:0 so a long file name truncates instead of pushing the status chip off the row. */
.dok-inbound-upload__entry-main {
    display: flex;
    flex-direction: column;
    min-width: 0;
    flex: 1 1 auto;
}

.dok-inbound-upload__entry-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--dok-text-primary);
    font-weight: var(--dok-font-weight-semibold);
}

.dok-inbound-upload__entry-meta,
.dok-inbound-upload__entry-message {
    color: var(--dok-text-secondary);
    font-size: var(--dok-font-size-sm);
}

/* The message wraps: it carries the server's own sentence, which is not short. */
.dok-inbound-upload__entry-message {
    margin-top: var(--dok-space-xs);
    white-space: normal;
    overflow-wrap: anywhere;
}

.dok-inbound-upload__status {
    flex: 0 0 auto;
    padding: .1rem .5rem;
    border-radius: var(--dok-radius-full);
    background: var(--dok-overlay-subtle);
    font-size: var(--dok-font-size-xs);
    font-weight: var(--dok-font-weight-semibold);
}

.dok-inbound-upload__status--busy {
    color: var(--mud-palette-primary);
}

.dok-inbound-upload__status--ok {
    color: var(--mud-palette-primary);
}

.dok-inbound-upload__status--neutral {
    color: var(--dok-text-secondary);
}

.dok-inbound-upload__status--error {
    color: var(--mud-palette-error);
}

@media (max-width: 900px) {
    .dok-inbound-upload__dropzone-surface {
        padding: var(--dok-space-md);
    }
}

/* ---------- DOK-555: the proposal, while somebody is still looking ---------- */

.dok-inbound-upload__waiting {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--dok-space-sm);
    margin-top: var(--dok-space-xs);
    flex-wrap: wrap;
}

.dok-inbound-upload__proposal {
    display: flex;
    flex-direction: column;
    gap: var(--dok-space-xs);
    margin-top: var(--dok-space-sm);
    padding: var(--dok-space-sm);
    border-radius: var(--dok-radius-sm);
    background: var(--dok-overlay-subtle);
}

.dok-inbound-upload__proposal-head {
    display: flex;
    align-items: baseline;
    gap: var(--dok-space-sm);
    flex-wrap: wrap;
}

.dok-inbound-upload__proposal-name {
    color: var(--dok-text-primary);
    font-weight: var(--dok-font-weight-bold);
}

.dok-inbound-upload__proposal-score {
    color: var(--mud-palette-primary);
    font-size: var(--dok-font-size-sm);
    font-weight: var(--dok-font-weight-semibold);
}

/*
 * The recorded reason a person is needed — NO_CANDIDATE, LOW_CONFIDENCE, AMBIGUOUS, AI_NOT_CONFIGURED.
 * Deliberately shown as the raw code rather than translated prose: it is what somebody quotes when asking
 * for help, and it is the same string the queue screen and the logs carry.
 */
.dok-inbound-upload__proposal-reason {
    align-self: flex-start;
    padding: .05rem .4rem;
    border-radius: var(--dok-radius-sm);
    background: var(--dok-overlay-soft);
    color: var(--dok-text-secondary);
    font-size: var(--dok-font-size-xs);
    font-family: monospace;
}
