/* Portal additions on top of admin-styles.css (the admin console stylesheet).
   Only layout the console does not have; colours come from its variables. */

/* No sidebar: header over one full-width main area. */
.dashboard.portal-dashboard {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto minmax(0, 1fr);
    grid-template-areas:
        "stage"
        "header"
        "main";
}

.header-left a { display: flex; }

.portal-auth-links { display: flex; justify-content: space-between; }
.auth-form p { color: var(--text-color); font-size: 14px; line-height: 1.5; }

.portal-link {
    background: none;
    border: 0;
    padding: 0;
    color: var(--info-color);
    text-decoration: underline;
    cursor: pointer;
    font: inherit;
    font-size: 14px;
}

/* Header: one line. Logo | Back, path (last part is the page title), details | actions. */
.portal-header { padding: 0 24px; min-height: 60px; }
.portal-header .header-left { min-width: 0; gap: 20px; }
.portal-head {
    display: flex;
    align-items: center;
    gap: 16px;
    min-width: 0;
    padding-left: 20px;
    border-left: 1px solid rgba(255, 255, 255, 0.12);
}
.portal-crumbs { display: flex; align-items: center; min-width: 0; white-space: nowrap; }
.portal-back {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    margin-right: 12px;
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 6px;
    color: var(--text-color);
    text-decoration: none;
}
.portal-back .material-icons { font-size: 18px; }
.portal-crumb { color: #9aa4b2; font-size: 15px; text-decoration: none; }
.portal-sep { font-size: 18px; color: #5f6b7a; margin: 0 4px; }
.portal-current { color: var(--text-color-light); font-size: 16px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; }
.portal-detail {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
    padding-left: 16px;
    border-left: 1px solid rgba(255, 255, 255, 0.12);
    font-size: 13px;
    white-space: nowrap;
}
.portal-detail:empty { display: none; }
.portal-detail .status-badge { font-size: 11px; padding: 3px 10px; }
.portal-actions { display: flex; gap: 8px; }
.portal-who { display: flex; flex-direction: column; line-height: 1.2; }
.portal-version { color: #9aa4b2; font-size: 11px; white-space: nowrap; }
.portal-version-auth { text-align: center; margin-top: 16px; }
.portal-ok { color: var(--success-color); }
.portal-error { color: var(--error-color); }
.portal-error:empty { display: none; }

.portal-card {
    background: var(--input-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 20px;
    margin: 0 0 20px;
}
.portal-card h3 {
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--text-color-light);
    font-size: 18px;
    font-weight: 600;
    margin: 0 0 12px;
}

.portal-list { list-style: none; }
.portal-list li { padding: 10px 0; border-top: 1px solid rgba(255, 255, 255, 0.08); }
.portal-list li:first-child { border-top: 0; }
.portal-list a, .data-table a { color: var(--info-color); font-weight: 600; }

.portal-muted { color: #9aa4b2; }

/* Plain table: no box, no header band; faint lines between rows only. */
.portal-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.portal-table th {
    text-align: left;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    color: #9aa4b2;
    padding: 0 16px 10px 0;
}
.portal-table td { padding: 12px 16px 12px 0; border-top: 1px solid rgba(255, 255, 255, 0.07); color: var(--text-color); vertical-align: middle; }
.portal-table .num { text-align: right; padding-right: 32px; }
.portal-table a { color: var(--info-color); font-weight: 600; text-decoration: none; }
.portal-table .portal-row-action { text-align: right; padding-right: 0; }
.portal-table .portal-row-action .action-button { display: inline-flex; padding: 6px 14px; }
.portal-upload-row td { border-top: 0; padding-top: 0; }
.portal-upload { display: flex; align-items: center; flex-wrap: wrap; gap: 16px; padding: 14px 16px; background: var(--input-bg); border-radius: var(--border-radius); }
.portal-upload label { display: flex; align-items: center; gap: 10px; color: var(--text-color-light); font-size: 13px; }
.portal-upload.dragging { outline: 2px dashed var(--primary-accent); outline-offset: -2px; }
.portal-upload .form-input { width: 220px; padding: 9px 12px; font-size: 14px; }
.portal-up-pick {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-width: 280px;
    padding: 9px 14px;
    background: var(--bg-color);
    border: 1px dashed var(--border-color);
    border-radius: var(--border-radius);
    color: #9aa4b2;
    font: inherit;
    font-size: 14px;
    cursor: pointer;
}
.portal-up-pick .material-icons { font-size: 18px; }
.portal-up-pick.chosen { border-style: solid; color: var(--text-color-light); }
.portal-up-msg { font-size: 13px; }

/* New comments in the header: the count, then two matching small buttons. */
.portal-newbox { display: inline-flex; align-items: center; gap: 8px; }
.portal-newbox[hidden] { display: none; }
.portal-newn { display: inline-flex; align-items: center; height: 30px; padding: 0 12px; border-radius: 15px; background: rgba(240, 173, 78, 0.18); color: var(--warning-color); font-size: 13px; font-weight: 600; white-space: nowrap; }
.portal-tool { display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 12px; border: 1px solid rgba(255, 255, 255, 0.18); border-radius: 6px; background: transparent; color: var(--text-color-light); font: inherit; font-size: 13px; cursor: pointer; white-space: nowrap; }
.portal-tool .material-icons { font-size: 16px; }
.portal-tool:hover { border-color: rgba(255, 255, 255, 0.4); }

/* Document | Comments switch, and the All / New filter in the Comments view */
.portal-tabs { display: inline-flex; border: 1px solid rgba(255, 255, 255, 0.18); border-radius: 6px; overflow: hidden; }
.portal-tab { display: inline-flex; align-items: center; height: 30px; padding: 0 12px; background: transparent; border: 0; color: var(--text-color); font: inherit; font-size: 13px; text-decoration: none; cursor: pointer; white-space: nowrap; }
.portal-tab + .portal-tab { border-left: 1px solid rgba(255, 255, 255, 0.18); }
.portal-tab.on { background: rgba(255, 255, 255, 0.1); color: var(--text-color-light); font-weight: 600; }

/* Comments view: threads with the most recent activity first, plain lines, replies indented */
.cv-bar { display: flex; align-items: center; flex-wrap: wrap; gap: 12px; margin: 0 0 8px; }
/* The person filter: the shared .filter-select with the arrow the admin console's modal selects use, at the height of the tab groups beside it. */
.cv-bar .filter-select { -webkit-appearance: none; appearance: none; height: 32px; padding: 0 36px 0 12px; font-size: 13px; cursor: pointer; background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23888' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e"); background-repeat: no-repeat; background-position: right 12px center; background-size: 16px; }
.cv-thread { padding: 18px 0; border-top: 1px solid rgba(255, 255, 255, 0.08); max-width: 980px; }
.cv-head { display: flex; align-items: baseline; flex-wrap: wrap; gap: 6px 12px; margin-bottom: 10px; }
.cv-req { font-weight: 700; color: var(--info-color); text-decoration: none; font-variant-numeric: tabular-nums; }
.cv-title { color: var(--text-color-light); font-weight: 600; }
.cv-read { height: 26px; }
.cv-list { list-style: none; display: grid; gap: 12px; }
.cv-c.d1 { margin-left: 24px; } .cv-c.d2 { margin-left: 48px; } .cv-c.d3 { margin-left: 72px; }
.cv-c.d1, .cv-c.d2, .cv-c.d3 { padding-left: 12px; border-left: 2px solid rgba(255, 255, 255, 0.1); }
.cv-meta { font-size: 13px; }
.cv-meta b { color: var(--text-color-light); }
.cv-new { height: auto; padding: 1px 8px; font-size: 11px; margin-left: 6px; }
.cv-body { white-space: pre-wrap; margin-top: 3px; color: var(--text-color); line-height: 1.5; }
.cv-show { height: 26px; margin-top: 6px; text-decoration: none; }
.cv-open-reply { margin-top: 10px; }
.cv-reply { display: grid; gap: 8px; margin-top: 12px; }
.cv-reply textarea { width: 100%; min-height: 64px; padding: 8px 10px; font-size: 14px; resize: vertical; box-sizing: border-box; }
.cv-reply-actions { display: flex; gap: 8px; }

.status-badge.portal-open { background: rgba(240, 173, 78, 0.2); color: var(--warning-color); }

/* Loading line: always centred in the content area, whatever the page. */
.main-content { position: relative; }
.portal-loading {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    color: var(--text-color);
    font-size: 14px;
}
.portal-loading img { width: 32px; height: 32px; }

/* Document page: the frame fills everything under the header, so the
   document's own scrollbar is the only one. */
.main-content.portal-doc-main { padding: 0; overflow: hidden; }
.portal-doc-main #view { height: 100%; }
.portal-doc-frame { position: absolute; inset: 0; display: block; width: 100%; height: 100%; border: 0; background: var(--bg-color); visibility: hidden; }
.portal-doc-frame.ready { visibility: visible; }

@media (max-width: 768px) {
    .main-content { padding: 16px; }
    .portal-header { padding: 8px 16px; }
    .portal-header .header-logo, .admin-user-info, .portal-crumb, .portal-sep, .portal-detail span:not(.status-badge) { display: none; }
    .portal-head { padding-left: 0; border-left: 0; }
    .portal-table { font-size: 13px; }
    .portal-table th:nth-child(n+5), .portal-table td:nth-child(n+5) { display: none; }
}
/* Comments view: a pane over the document frame, swapped by the Document | Comments tabs. */
.portal-cv-pane { position: absolute; inset: 0; z-index: 2; overflow: auto; padding: 24px; background: var(--bg-color); }
.portal-cv-pane[hidden] { display: none; }
.portal-cv-on .portal-doc-frame { visibility: hidden; }
@media (max-width: 768px) { .portal-cv-pane { padding: 16px; } }

/* Header fitting (fitHeader in app.js): each level drops more detail until the header fits on one line. */
.portal-header .header-content { min-width: 0; gap: 16px; }
.portal-header .header-right { min-width: 0; flex: none; }
.portal-header .portal-head { min-width: 0; }
.portal-header .admin-user-info { min-width: 0; }
.fit-1 .portal-detail .portal-muted, .fit-1 .portal-version { display: none; }
.fit-2 .portal-tool .tl { display: none; }
.fit-2 .portal-tool { padding: 0 8px; }
.fit-2 #doc-new-n { font-size: 0; }
.fit-2 #doc-new-n::after { content: attr(data-short); font-size: 13px; }
.fit-3 .portal-who { display: none; }
.fit-4 .portal-crumb, .fit-4 .portal-sep { display: none; }
.fit-5 .header-logo { display: none; }

/* Archived versions: a closed box under the document in the list, and the archived page's badge. */
.portal-arch-row td { border-top: 0; padding-top: 0; }
.portal-arch > summary { cursor: pointer; color: var(--text-secondary, #9aa4b2); font-size: 13px; width: max-content; }
.portal-arch > summary:hover { color: var(--text-color); }
.portal-arch ul { list-style: none; margin: 8px 0 4px; padding: 0; display: grid; gap: 6px; }
.portal-arch li { display: flex; flex-wrap: wrap; gap: 4px 12px; align-items: baseline; }
.portal-table .portal-row-action .portal-archive { margin-right: 8px; }
.status-badge.portal-archived { background: rgba(255, 255, 255, 0.08); color: var(--text-color); }

.portal-arch .portal-changes { display: inline-flex; gap: 4px; align-items: center; font-weight: 600; }
.portal-arch .portal-changes .material-icons { font-size: 15px; }
.portal-arch .portal-changes-up { cursor: pointer; }

/* Files on comments, in the Comments view */
.cv-files, .cv-chosen { list-style: none; margin: 6px 0 0; padding: 0; display: grid; gap: 4px; }
.cv-file { text-transform: none; }
.cv-chosen li { font-size: 13px; display: flex; gap: 8px; align-items: center; }
.cv-reply-actions label.portal-tool { cursor: pointer; }

/* Nearfield staff: the stage line above the header (LIVE or DEV data) */
.portal-stage { grid-area: stage; display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px; padding: 4px 24px; font-size: 13px; background: rgba(255, 255, 255, 0.04); border-bottom: 1px solid rgba(255, 255, 255, 0.07); color: var(--text-secondary, #9aa4b2); }
.portal-stage.hidden { display: none; }
.portal-stage .portal-tab { padding: 2px 10px; font-size: 12px; }
.portal-stage.other { background: rgba(240, 173, 78, 0.18); border-bottom-color: rgba(240, 173, 78, 0.6); color: var(--warning-color, #f0ad4e); }
.portal-stage.other .portal-stage-note { font-weight: 700; }
