/* Shared application content primitives. Page-specific styles should use
   layout modifiers and add only domain-specific rules. */

:root {
    --content-border: #e4e7ec;
    --content-border-soft: #eaecf0;
    --content-text: #101828;
    --content-muted: #344054;
    --content-accent: #155eef;
    --content-accent-hover: #004eeb;
    --content-danger: #d92d20;
    --content-success: #12b76a;
    --content-success-bg: #effced;
    --content-success-border: #b7e3b0;
    --content-radius: 6px;
    --content-panel-max-height: calc(100vh - 220px);
    --content-panel-padding: 20px 24px;
    /* Shared action buttons follow the tender workspace button family
       (project-destination.css) so admin and tender screens look the same. */
    --content-action: #426797;
    --content-action-hover: #315783;
    --content-action-focus: rgba(66, 103, 151, 0.28);
    --content-action-danger: #a33b2e;
    --content-action-danger-soft: #fdf2f1;
    --content-control-height: 34px;
    --content-input-height: 38px;
    --content-disabled-border: #dfe7f1;
    --content-disabled-text: #687386;
    --content-disabled-bg: #f1f5f9;
    /* Surfaces and secondary copy for the list/editor admin pattern. */
    --content-subtle: #5f6b7e;
    --content-surface-muted: #f8fafc;
    --content-selected-bg: #edf4ff;
    --content-hover-bg: #f6f9fd;
    --content-input-border-hover: #cbd5e1;
    --content-panel-radius: 10px;
    --content-panel-shadow: 0 1px 2px rgba(16, 24, 40, 0.05), 0 1px 3px rgba(16, 24, 40, 0.03);
    --content-layout-gap: 20px;
}

.page-content {
    min-width: 0;
}

/* Labels that name a control for assistive technology where the visual design carries
   the meaning some other way, such as an icon-only column heading. */
.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Page header: a sentence-case title with a quiet one-line description, in the
   same voice as the card titles in the tender workspace. */
.page-heading {
    display: flex;
    align-items: center;
    gap: 16px;
    margin: 6px 0 20px;
}

.page-heading h1 {
    margin: 0 0 4px;
    color: var(--content-text);
    font-size: 22px;
    font-weight: 700;
    line-height: 1.25;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.page-heading-copy {
    min-width: 0;
}

.page-heading p {
    margin: 0;
    color: var(--content-subtle);
    font-size: 14px;
}

.page-layout {
    display: grid;
    align-items: stretch;
}

.page-layout > * {
    min-width: 0;
}

.page-layout--split {
    grid-template-columns: minmax(0, 1fr) minmax(0, 2fr);
    grid-template-rows: var(--content-panel-max-height);
    gap: var(--content-layout-gap);
}

.page-layout--split > .page-list-panel,
.page-layout--split > .page-editor {
    height: 100%;
    max-height: none;
    min-height: 0;
}

/* Pages whose second column carries a tree alongside the editor need the two columns
   to share the width evenly, rather than the list/editor weighting of --split. */
.page-layout--tree-editor {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: var(--content-layout-gap);
}

.page-panel,
.page-list-panel,
.page-editor {
    min-width: 0;
    border: 1px solid var(--content-border);
    border-radius: var(--content-panel-radius);
    background: #ffffff;
    box-shadow: var(--content-panel-shadow);
}

.page-list-panel {
    display: flex;
    flex-direction: column;
    max-height: var(--content-panel-max-height);
    padding: var(--content-panel-padding);
}

.page-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    min-height: var(--content-control-height);
    margin: 0 0 16px;
}

.page-section-title {
    margin: 0;
    color: var(--content-text);
    font-size: 18px;
    font-weight: 700;
    line-height: 1.3;
}

/* Record count and list-level status between the list toolbar and its table. */
.page-list-panel .list-count {
    margin: 0 0 8px;
    color: var(--content-disabled-text);
    font-size: 13px;
}

.page-list-panel > .message {
    margin: 0 0 8px;
}

/* Optional title block in a list toolbar: the section title with its record count
   (or list status) underneath, mirroring the editor's title and description. */
.page-toolbar-heading {
    display: grid;
    gap: 2px;
    min-width: 0;
}

.page-toolbar-heading .list-count {
    margin: 0;
}

.page-toolbar-heading .message {
    margin: 4px 0 0;
}

.page-table-wrap {
    min-height: 0;
    overflow-x: auto;
    border: 1px solid var(--content-border-soft);
    border-radius: var(--content-radius);
    background: #ffffff;
}

.page-list-panel .page-table-wrap {
    flex: 1 1 auto;
    overflow-y: auto;
}

/* Shared slim scrollbar treatment for migrated list and tree containers. */
.page-list-panel .page-table-wrap,
.page-list-panel .evaluation-tree-container {
    scrollbar-width: thin;
    scrollbar-color: #a8a8a8 transparent;
}

.page-list-panel .page-table-wrap::-webkit-scrollbar,
.page-list-panel .evaluation-tree-container::-webkit-scrollbar {
    width: 12px;
    height: 12px;
}

.page-list-panel .page-table-wrap::-webkit-scrollbar-thumb,
.page-list-panel .evaluation-tree-container::-webkit-scrollbar-thumb {
    border: 3px solid transparent;
    border-radius: 999px;
    background: #a8a8a8;
    background-clip: padding-box;
}

.page-list-panel .page-table-wrap::-webkit-scrollbar-track,
.page-list-panel .evaluation-tree-container::-webkit-scrollbar-track {
    background: transparent;
}

.page-editor {
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

.page-table {
    width: 100%;
    border-collapse: collapse;
    color: var(--content-text);
    font-size: 14px;
}

.page-table th,
.page-table td {
    border-bottom: 1px solid var(--content-border);
    padding: 11px 14px;
    text-align: left;
    vertical-align: middle;
}

/* Column headings match the tender document grid: small, uppercase, muted. */
.page-table th {
    position: sticky;
    top: 0;
    z-index: 1;
    background: var(--content-surface-muted);
    color: var(--content-subtle);
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.page-table tbody tr:focus-visible {
    outline: 3px solid var(--content-action-focus);
    outline-offset: -3px;
}

.page-table tr:last-child td {
    border-bottom: 0;
}

.page-table tbody tr {
    cursor: pointer;
}

.page-table tbody tr {
    transition: background-color 120ms ease;
}

.page-table tbody tr:hover {
    background: var(--content-hover-bg);
}

.page-table tbody tr[aria-selected="true"] {
    position: relative;
    background: var(--content-selected-bg);
    color: var(--content-text);
    font-weight: 600;
    outline: 0;
    box-shadow: inset 3px 0 var(--content-action);
}

.page-editor {
    position: static;
    padding: 0 24px;
}

/* Editor header: starts at the panel's top padding like the list toolbar, so the
   two panel titles share a baseline; a hairline separates it from the form. */
.page-editor-head {
    margin: 0 0 20px;
    border: 0;
    border-bottom: 1px solid var(--content-border-soft);
    padding: 20px 0 16px;
    background: transparent;
}

.page-editor-head h2 {
    margin: 0 0 2px;
    color: var(--content-text);
    font-size: 18px;
    font-weight: 700;
    line-height: 1.3;
}

.page-editor-head p {
    margin: 0;
    color: var(--content-subtle);
    font-size: 13px;
}

/* Nothing selected: a calm, centred prompt that does not out-shout the panel titles. */
.page-editor-placeholder {
    display: flex;
    min-height: 0;
    flex: 1 1 auto;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 6px;
    padding: 24px 0 56px;
    color: var(--content-subtle);
    text-align: center;
    font-size: 14px;
}

.page-editor-placeholder > i {
    display: grid;
    place-items: center;
    width: 56px;
    height: 56px;
    margin-bottom: 10px;
    border-radius: 50%;
    color: var(--content-action);
    background: var(--content-selected-bg);
    font-size: 22px;
}

.page-editor-placeholder strong {
    color: var(--content-text);
    font-size: 16px;
    font-weight: 700;
}

.page-editor-placeholder span {
    max-width: 40ch;
    line-height: 1.6;
}

/* Empty list state inside a list panel. */
.page-list-panel > .empty {
    border: 1px dashed var(--content-border);
    border-radius: var(--content-radius);
    padding: 28px 16px;
    color: var(--content-subtle);
    background: var(--content-surface-muted);
    text-align: center;
}

.page-list-panel > .empty p {
    margin: 0;
}

.page-editor-body {
    padding: 0;
}

/* Editor footer: actions sit together at the start, primary first. */
.page-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 8px;
    border-top: 1px solid var(--content-border-soft);
    padding: 16px 0 24px;
}

.page-field {
    display: grid;
    gap: 6px;
    margin-bottom: 16px;
}

.page-field label {
    color: var(--content-text);
    font-size: 13px;
    font-weight: 600;
}

.page-field label span {
    color: var(--content-danger);
}

.page-field input[type="text"],
.page-field input[type="number"],
.page-field textarea,
.page-field select {
    width: 100%;
    min-height: var(--content-input-height);
    border: 1px solid var(--content-border);
    border-radius: var(--content-radius);
    padding: 7px 12px;
    font: inherit;
    background: #ffffff;
    transition: border-color 120ms ease;
}

.page-field input::placeholder,
.page-field textarea::placeholder {
    color: #98a2b3;
}

.page-field input:hover:not(:disabled):not(:focus):not([aria-invalid="true"]),
.page-field textarea:hover:not(:disabled):not(:focus):not([aria-invalid="true"]),
.page-field select:hover:not(:disabled):not(:focus):not([aria-invalid="true"]) {
    border-color: var(--content-input-border-hover);
}

.page-field input:disabled,
.page-field textarea:disabled,
.page-field select:disabled {
    color: var(--content-disabled-text);
    background: var(--content-disabled-bg);
    cursor: not-allowed;
}

.page-field input:focus,
.page-field textarea:focus,
.page-field select:focus {
    border-color: var(--content-action);
    outline: 3px solid var(--content-action-focus);
    outline-offset: 0;
}

/* Field-level validation: the message sits directly under the control it
   describes. Banners in .page-messages are for page-level outcomes only. */
.page-field.has-error input,
.page-field.has-error textarea,
.page-field.has-error select,
.page-field [aria-invalid="true"] {
    border-color: var(--content-danger);
}

.page-field.has-error input:focus,
.page-field.has-error textarea:focus,
.page-field.has-error select:focus {
    outline-color: rgba(217, 45, 32, 0.2);
}

.page-field-error {
    display: flex;
    align-items: flex-start;
    gap: 6px;
    margin: 0;
    color: #b42318;
    font-size: 13px;
}

.page-field-error > i {
    margin-top: 2px;
}

.page-messages {
    display: grid;
    gap: 6px;
    margin-bottom: 12px;
}

.page-editor.has-message .page-messages {
    margin-bottom: 0;
}

.page-messages .message.success {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0 0 16px;
    border: 1px solid var(--content-success-border);
    border-radius: var(--content-radius);
    padding: 10px 14px;
    color: var(--content-text);
    background: var(--content-success-bg);
}

.page-messages .message.error {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0 0 16px;
    border: 1px solid #fecdca;
    border-radius: var(--content-radius);
    padding: 10px 14px;
    color: #b42318;
    background: #fef3f2;
}

.page-messages .message.success > i {
    flex: 0 0 auto;
    color: var(--content-success);
    font-size: 18px;
}

.page-messages .message.error > i {
    flex: 0 0 auto;
    color: #d92d20;
    font-size: 18px;
}

.page-messages .message strong {
    font-size: 14px;
}

.page-messages .message.success .message-copy {
    min-width: 0;
}

.page-messages .message.error .message-copy {
    min-width: 0;
}

.page-messages .message.success strong,
.page-messages .message.success .message-copy span {
    display: block;
}

.page-messages .message.error strong,
.page-messages .message.error .message-copy span {
    display: block;
}

.page-messages .message.success strong {
    margin-bottom: 2px;
}

.page-messages .message.error strong {
    margin-bottom: 2px;
}

.page-messages .message.success .message-close {
    min-height: 0;
    margin-left: auto;
    border: 0;
    padding: 0;
    color: var(--content-text);
    background: transparent;
    font-size: 22px;
    line-height: 1;
}

.page-messages .message.success .message-close:hover {
    border: 0;
    background: rgba(16, 24, 40, 0.06);
}

.page-messages .message.error .message-close {
    min-height: 0;
    margin-left: auto;
    border: 0;
    padding: 0;
    color: #b42318;
    background: transparent;
    font-size: 22px;
    line-height: 1;
}

.page-messages .message.error .message-close:hover {
    border: 0;
    background: rgba(180, 35, 24, 0.08);
}

/* Banner dismiss buttons: a round 28px target instead of a bare glyph. */
.page-messages .message .message-close {
    display: inline-grid;
    flex: 0 0 auto;
    place-items: center;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    font-size: 20px;
    transition: background-color 120ms ease;
}

.page-messages .message .message-close:focus-visible {
    outline: 3px solid var(--content-action-focus);
    outline-offset: 1px;
}

.page-note {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin: 12px 0 10px;
    border: 1px solid #f5c451;
    border-radius: var(--content-radius);
    padding: 12px 14px;
    color: #7a4b00;
    background: #fff8e1;
}

.page-note > i {
    flex: 0 0 auto;
    color: #b54708;
    font-size: 22px;
}

.page-note > span {
    min-width: 0;
}

/* Shared action buttons for list toolbars and editor footers. Sizing, colour
   and focus follow the tender document toolbar (Add document / Export documents). */
.page-toolbar button,
.page-actions button,
.page-upload-actions button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    min-height: var(--content-control-height);
    border: 1px solid var(--content-action);
    border-radius: 5px;
    padding: 6px 14px;
    color: var(--content-action);
    background: #ffffff;
    font-size: 13px;
    font-weight: 700;
    line-height: 1.2;
    white-space: nowrap;
}

.page-toolbar button:hover,
.page-actions button:hover,
.page-upload-actions button:hover {
    color: #ffffff;
    background: var(--content-action);
}

.page-toolbar button:focus,
.page-actions button:focus,
.page-upload-actions button:focus {
    border-color: var(--content-action);
    outline: none;
}

.page-toolbar button:focus-visible,
.page-actions button:focus-visible,
.page-upload-actions button:focus-visible {
    outline: 3px solid var(--content-action-focus);
    outline-offset: 2px;
}

.page-toolbar button.primary,
.page-actions button.primary,
.page-upload-actions button.primary {
    border-color: var(--content-action);
    color: #ffffff;
    background: var(--content-action);
}

.page-toolbar button.primary:hover,
.page-actions button.primary:hover,
.page-upload-actions button.primary:hover {
    border-color: var(--content-action-hover);
    background: var(--content-action-hover);
}

.page-toolbar button.danger,
.page-actions button.danger,
.page-upload-actions button.danger {
    border-color: var(--content-action-danger);
    color: var(--content-action-danger);
    background: #ffffff;
}

.page-toolbar button.danger:hover,
.page-actions button.danger:hover,
.page-upload-actions button.danger:hover {
    color: var(--content-action-danger);
    background: var(--content-action-danger-soft);
}

/* spek-admin.css hides every disabled button. Shared action buttons stay
   visible but inert, so permission-controlled actions remain discoverable
   (see docs/design/spek-web-asset-standard.md). [hidden] still hides. */
.page-toolbar button:disabled:not([hidden]),
.page-actions button:disabled:not([hidden]),
.page-upload-actions button:disabled:not([hidden]) {
    display: inline-flex !important;
    border-color: var(--content-disabled-border);
    color: var(--content-disabled-text);
    background: var(--content-disabled-bg);
    cursor: not-allowed;
}

.page-editor.has-message .page-editor-body {
    padding-top: 0;
}

.page-editor.has-message .message.success {
    margin-bottom: 12px;
}
@media (max-width: 1100px) {
    .page-layout--split,
    .page-layout--tree-editor {
        grid-template-columns: 1fr;
        grid-template-rows: auto;
    }

    .page-layout--split > .page-list-panel,
    .page-layout--split > .page-editor,
    .page-layout--tree-editor > .page-list-panel,
    .page-layout--tree-editor > .page-editor {
        height: auto;
        max-height: none;
    }

    .page-editor-placeholder {
        min-height: 360px;
    }

    /* Stacked layout: keep the list short enough that the editor below it
       is reachable without scrolling past every record. */
    .page-layout--split > .page-list-panel {
        max-height: min(60vh, 520px);
    }
}
