/* NK Politics uses the labsite design tokens defined in labsite/base.html. */

/* =========================================================
   Schema-level database workspace
   ========================================================= */

.nk-database-workspace {
    display: grid;
    grid-template-columns: 240px minmax(0, 1fr);
    min-height: calc(100vh - 106px);
}

.schema-sidebar {
    padding: 24px 20px;
    background: var(--surface);
    border-right: 1px solid var(--border);
}

.schema-sidebar-header {
    margin-bottom: 22px;
    font-size: 1.05rem;
}

.schema-menu-heading {
    margin: 28px 0 10px;
    color: var(--muted);
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.schema-menu {
    margin: 0;
    padding: 0;
    list-style: none;
}

.schema-menu li {
    margin: 4px 0;
}

.schema-menu a {
    display: block;
    padding: 8px 10px;
    border-radius: 5px;
    text-decoration: none;
}

.schema-menu a:hover,
.schema-menu a[aria-current="page"] {
    background: var(--background);
}

.schema-menu a[aria-current="page"] {
    font-weight: 700;
}

.nk-database-content {
    min-width: 0;
    padding: 28px 32px;
}

.nk-database-content .nk-page-shell {
    width: 100%;
    margin: 0;
    transform: none;
}

.nk-browser-grid {
    display: grid;
    grid-template-columns: minmax(300px, 40%) minmax(0, 60%);
    gap: 24px;
    align-items: start;
}


/* =========================================================
   General page layout
   ========================================================= */

.nk-page-shell {
    box-sizing: border-box;
    width: min(1500px, calc(100vw - 64px));
    margin: 0 0 28px 50%;
    transform: translateX(-50%);
}

.nk-page-shell h1 {
    margin-bottom: 10px;
}

.nk-page-shell h2 {
    color: var(--text);
}

.nk-breadcrumb {
    margin: 0 0 12px;
    color: var(--muted);
    font-size: 0.94rem;
}

.nk-page-header,
.nk-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 14px;
}

.nk-page-header {
    margin-bottom: 22px;
}

.nk-toolbar {
    justify-content: flex-end;
    margin-bottom: 18px;
}


/* =========================================================
   Panels and forms
   ========================================================= */

.nk-panel {
    padding: 22px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
}

.nk-form-panel {
    max-width: 860px;
}

.nk-tree-panel {
    overflow: auto;
}

.nk-tree-toolbar {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 12px;
    margin-bottom: 18px;
}

.nk-workspace-main {
    min-width: 0;
}


/* =========================================================
   Trees and lists
   ========================================================= */

.nk-tree-list,
.nk-tree-list ul,
.nk-page-shell details + ul {
    list-style: none;
}

.nk-page-shell ul {
    padding-left: 22px;
}

.nk-page-shell summary {
    padding: 3px 5px;
    border-radius: 4px;
    cursor: pointer;
}

.nk-page-shell hr {
    margin: 24px 0;
    border: 0;
    border-top: 1px solid var(--border);
}


/* =========================================================
   Buttons and inputs
   ========================================================= */

.nk-page-shell input[type="text"],
.nk-page-shell input[type="number"],
.nk-page-shell input[type="date"],
.nk-page-shell input[type="datetime-local"],
.nk-page-shell select,
.nk-page-shell textarea {
    width: min(100%, 680px);
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: 5px;
    background: var(--surface);
    color: var(--text);
    font: inherit;
}

.nk-page-shell textarea {
    min-height: 110px;
    resize: vertical;
}


/* =========================================================
   Tables
   ========================================================= */

.nk-table-scroll {
    overflow-x: auto;
}

.nk-data-table {
    width: 100%;
    border-collapse: collapse;
}

.nk-data-table th,
.nk-data-table td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    text-align: left;
    vertical-align: top;
}

.nk-data-table th {
    background: var(--background);
    color: var(--muted);
    font-size: 0.9rem;
}


/* =========================================================
   Transition tree
   ========================================================= */

.transition-tree-summary {
    padding: 2px 4px;
}

.transition-tree-summary.selected-tree-org,
summary.selected-tree-org {
    padding: 2px 4px;
    border-left: 4px solid #d39e00;
    background: #fff3cd;
    font-weight: 700;
}

.transition-tree-org-button {
    color: var(--link);
    cursor: pointer;
    text-decoration: underline;
}

.transition-org-row {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 8px;
    align-items: baseline;
    margin-bottom: 4px;
}


/* =========================================================
   Full-height entity browser workspace
   ========================================================= */

.nk-database-content--flush {
    display: flex;
    min-width: 0;
    padding: 0;
    overflow: hidden;
}

.nk-browser-page {
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
    width: 100%;
    min-width: 0;
    min-height: calc(100vh - 106px);
    background: var(--surface);
}

.nk-browser-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 16px;
    min-height: 74px;
    padding: 16px 24px;
    border-bottom: 1px solid var(--border);
    background: var(--surface);
}

.nk-browser-header h1 {
    margin: 0;
    font-size: 1.45rem;
}

.nk-browser-actions {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 16px;
}

.nk-browser-body {
    display: grid;
    grid-template-columns:
        minmax(320px, 38%)
        minmax(0, 62%);
    min-width: 0;
    min-height: 0;
    overflow: hidden;
}

.nk-browser-tree {
    min-width: 0;
    min-height: 0;
    padding: 20px;
    overflow: auto;
    border-right: 1px solid var(--border);
    background: var(--surface);
}

.nk-browser-detail {
    min-width: 0;
    min-height: 0;
    padding: 24px 28px;
    overflow: auto;
    background: var(--background);
}

.nk-browser-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 16px;
}

.nk-browser-panel-header h2 {
    margin: 0;
    font-size: 1.05rem;
}

.nk-browser-empty {
    display: grid;
    place-items: center;
    min-height: 240px;
    color: var(--muted);
    text-align: center;
}

/* =========================================================
   Officials directory
   ========================================================= */

.nk-official-search {
    margin-bottom: 20px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--border);
}

.nk-official-search label {
    display: block;
    margin-bottom: 8px;
    color: var(--muted);
    font-size: 0.9rem;
    font-weight: 600;
}

.nk-official-search input {
    box-sizing: border-box;
    width: 100%;
    padding: 9px 10px;
    border: 1px solid var(--border);
    border-radius: 5px;
    background: var(--surface);
    color: var(--text);
    font: inherit;
}

.nk-official-search-actions {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-top: 10px;
}

.nk-official-list {
    margin: 0;
    padding: 0;
    list-style: none;
}

.nk-official-list li {
    margin: 0;
    border-bottom: 1px solid var(--border);
}

.nk-official-list a {
    display: block;
    padding: 11px 10px;
    text-decoration: none;
}

.nk-official-list a:hover,
.nk-official-list a.is-selected {
    background: var(--background);
}

.nk-official-list a.is-selected {
    border-left: 4px solid var(--link);
    padding-left: 8px;
}

.nk-official-list-name {
    display: block;
    color: var(--text);
    font-weight: 600;
}

.nk-official-list-id {
    display: block;
    margin-top: 3px;
    color: var(--muted);
    font-size: 0.82rem;
}

.nk-official-list-empty {
    padding: 14px 10px;
    color: var(--muted);
}

.nk-official-detail-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 18px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--border);
}

.nk-official-detail-header h2 {
    margin: 0 0 6px;
}

.nk-official-detail-header p {
    margin: 0;
}

.nk-official-detail-actions {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 14px;
}

.nk-official-facts {
    margin: 22px 0 0;
}

.nk-official-resume {
    margin-top: 30px;
}

/* =========================================================
   Editor workbenches
   ========================================================= */

.nk-form-record-heading {
    margin-bottom: 22px;
    font-size: 1.2em;
}

.nk-form-panel-heading,
.nk-form-record-summary {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 24px;
    align-items: baseline;
}

.nk-form-panel-heading {
    align-items: center;
    margin-bottom: 18px;
}

.nk-form-panel-heading--compact {
    gap: 16px;
    margin-bottom: 12px;
}

.nk-form-panel-heading h2 {
    margin: 0;
}

.nk-form-tree-scroll {
    max-height: 72vh;
    overflow-y: auto;
    padding-right: 12px;
}

.nk-form-record-name {
    font-size: 1.2em;
}

.nk-form-danger-zone {
    margin-top: 20px;
}

.nk-tree-list--flush {
    padding-left: 0;
}

.transition-org-column {
    width: 45%;
}

.transition-direction-column {
    width: 10%;
}

.transition-org-cell {
    vertical-align: top;
}

.transition-direction-cell {
    text-align: center;
    vertical-align: middle;
    font-size: 1.4em;
}

.transition-add-action {
    margin-top: 12px;
}

/* =========================================================
   Organization roster
   ========================================================= */

.nk-roster-root {
    margin-bottom: 18px;
    font-weight: 700;
}

.nk-position-list details {
    margin-bottom: 12px;
    border-bottom: 1px solid var(--border);
}

.nk-position-list summary {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
    padding: 9px 6px;
    cursor: pointer;
}

.nk-position-list summary > span:first-child {
    color: var(--text);
    font-weight: 600;
}

.nk-roster-entry-list {
    margin: 0 0 12px;
    padding: 0;
    list-style: none;
}

.nk-roster-entry-list li {
    margin: 0;
}

.nk-roster-entry-list a {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 12px;
    align-items: baseline;
    padding: 8px 10px;
    text-decoration: none;
}

.nk-roster-entry-list a:hover,
.nk-roster-entry-list a.is-selected {
    background: var(--background);
}

.nk-roster-entry-list a.is-selected {
    border-left: 4px solid var(--link);
    padding-left: 6px;
}

.nk-roster-entry-name {
    color: var(--text);
    font-weight: 600;
}

.nk-roster-entry-dates {
    color: var(--muted);
    font-size: 0.82rem;
    white-space: nowrap;
}

.nk-roster-entry-empty {
    padding: 8px 10px 12px;
    color: var(--muted);
}

/* =========================================================
   Responsive layout
   ========================================================= */

@media screen and (max-width: 900px) {

    .nk-form-panel-heading,
    .nk-form-record-summary {
        grid-template-columns: 1fr;
        gap: 8px;
    }

    .nk-browser-grid {
        grid-template-columns: 1fr;
    }

    .nk-page-shell {
        width: calc(100vw - 32px);
    }

    .nk-database-content .nk-page-shell {
        width: 100%;
    }

    .nk-page-shell > div[style*="grid-template-columns: 40%"],
    .nk-page-shell > div[style*="grid-template-columns: 360px"] {
        grid-template-columns: 1fr !important;
    }

    .nk-page-shell aside:not(.schema-sidebar) {
        padding-right: 0 !important;
        padding-bottom: 20px;
        border-right: 0 !important;
        border-bottom: 1px solid var(--border);
    }

    .nk-browser-page {
        min-height: auto;
    }

    .nk-browser-body {
        grid-template-columns: 1fr;
        overflow: visible;
    }

    .nk-browser-tree {
        max-height: 55vh;
        border-right: 0;
        border-bottom: 1px solid var(--border);
    }

    .nk-browser-detail {
        min-height: 60vh;
    }
}

@media screen and (max-width: 760px) {
    .nk-database-workspace {
        grid-template-columns: 1fr;
    }

    .schema-sidebar {
        border-right: 0;
        border-bottom: 1px solid var(--border);
    }

    .nk-database-content {
        padding: 20px 16px;
    }

    .nk-database-content--flush {
        display: block;
        overflow: visible;
    }
}
