/* CP019: native OJS colours with softer content surfaces and compact buttons. */
body.pkp_backend {
    color: #222;
    background: #f2f4f6;
    font-size: 16px;
    line-height: 24px;
}

/* Soften the large white reading surfaces, including PKP discussion modals. */
.pkp_backend .ui-tabs .ui-tabs-panel,
.pkp_backend .pkp_modal_panel,
.pkp_backend .pkp_modal_panel > .content,
.pkp_backend .ui-dialog,
.pkp_backend .ui-dialog .ui-dialog-content,
.pkp_backend .pkp_controllers_grid,
.pkp_backend .pkpListPanel,
.pkp_backend .pkp_structure_head .pkp_tasks .panel {
    background-color: #f6f8fa;
}

/* Use the native darker blue shade on the softened grey-white background. */
.pkp_backend a {
    color: #00577f;
}

.pkp_backend a:hover,
.pkp_backend a:focus {
    color: #004f73;
}

.pkp_backend .pkp_structure_head {
    background: #002c40;
    background-image: none;
}

.pkp_backend .pkp_structure_head .pkp_navigation_user {
    background: #002c40;
    background-image: none;
}

.pkp_backend .pkp_structure_head .pkp_nav_list a {
    font-family: inherit;
    font-size: 14px;
    font-weight: 700;
    line-height: 24px;
    text-shadow: none;
    overflow-wrap: normal;
    word-break: normal;
}

/* The fixed 32px user bar uses the native 12px secondary navigation size. */
.pkp_backend .pkp_structure_head .pkp_navigation_user a {
    font-size: 12px;
    line-height: 24px;
}

.pkp_backend .pkp_navigation_primary > li > a {
    padding: 12px 16px 12px 12px;
}

.pkp_backend .pkp_navigation_primary a,
.pkp_backend .pkp_nav_context > li > a,
.pkp_backend .pkp_nav_tasks > li > a,
.pkp_backend .pkp_nav_user a,
.pkp_backend .pkp_structure_head .pkp_site_name a,
.pkp_backend .pkp_structure_head .pkp_contexts a {
    color: #fff;
}

.pkp_backend .pkp_structure_head .pkp_nav_list ul,
.pkp_backend .pkp_structure_head .pkp_contexts {
    background: #004f73;
    box-shadow: 0 2px 8px rgba(20, 30, 40, .16);
}

.pkp_backend .pkp_navigation_primary a:hover,
.pkp_backend .pkp_navigation_primary a:focus,
.pkp_backend .pkp_navigation_primary [aria-expanded="true"] > a,
.pkp_backend .pkp_nav_context > li > a:hover,
.pkp_backend .pkp_nav_context > li > a:focus,
.pkp_backend .pkp_nav_context > li[aria-expanded="true"] > a,
.pkp_backend .pkp_nav_tasks > li > a:hover,
.pkp_backend .pkp_nav_tasks > li > a:focus,
.pkp_backend .pkp_nav_tasks > li[aria-expanded="true"] > a,
.pkp_backend .pkp_nav_user a:hover,
.pkp_backend .pkp_nav_user a:focus,
.pkp_backend .pkp_nav_user [aria-expanded="true"] > a,
.pkp_backend .pkp_structure_head .pkp_contexts a:hover,
.pkp_backend .pkp_structure_head .pkp_contexts a:focus {
    color: #fff;
    background: #004f73;
    border-color: #c5dced;
    text-shadow: none;
}

/* Native ARIA/left-position rules still decide whether this menu is open. */
.pkp_backend .pkp_nav_context .pkp_contexts {
    width: 320px;
    max-width: calc(100vw - 24px);
    max-height: min(400px, calc(100vh - 48px));
    overflow-y: auto;
    overscroll-behavior: contain;
}

.pkp_backend .pkp_structure_head .pkp_contexts a {
    padding: 8px 12px;
    font-size: 14px;
    line-height: 20px;
    white-space: normal;
    overflow-wrap: break-word;
    font-weight: 400;
}

/* Keep Tasks panel links readable on its white content background. */
.pkp_backend .pkp_structure_head .pkp_tasks .panel a {
    color: #00577f;
    font-size: 14px;
    background: transparent;
}

.pkp_backend .pkp_site_name a.is_img {
    min-height: 80px;
    padding: 12px 0;
}

.pkp_backend .pkp_site_name img {
    max-height: 80px;
}

.pkp_backend .pkp_structure_main .pkp_page_title {
    padding: 24px 32px;
    background: #ddd;
    border-bottom: 1px solid #ddd;
}

.pkp_backend .pkp_structure_main .pkp_page_title h1 {
    color: #222;
    font-size: 16px;
    line-height: 24px;
    font-weight: 700;
}

.pkp_backend .ui-widget {
    font-family: inherit;
    font-size: 14px;
}

.pkp_backend .ui-dialog {
    max-width: calc(100vw - 32px);
    box-sizing: border-box;
    border: 1px solid #ddd;
    border-radius: 3px;
    box-shadow: 0 8px 24px rgba(20, 30, 40, .18);
}

.pkp_backend .ui-dialog .ui-dialog-titlebar {
    color: #fff;
    background: #007ab2;
    background-image: none;
    border: 0;
    border-bottom: 1px solid #ddd;
    font-size: 16px;
    line-height: 24px;
}

.pkp_backend .ui-widget-overlay {
    background: #244863;
    opacity: .25;
}

/* OJS uses its own PKP modal wrapper for workflow discussions. */
.pkp_backend .pkp_modal {
    background: rgba(0, 44, 64, .45);
}

.pkp_backend .pkp_modal_panel > .header {
    min-height: 48px;
    padding: 12px 56px 12px 16px;
    box-sizing: border-box;
    color: #fff;
    background: #007ab2;
    background-image: none;
    font-size: 16px;
    line-height: 24px;
}

.pkp_backend .pkp_modal_panel > .close {
    width: 48px;
    height: 48px;
    line-height: 48px;
    color: #fff;
}

.pkp_backend .pkp_modal_panel > .close:before {
    font-size: 20px;
    line-height: 48px;
}

.pkp_backend .pkp_modal_panel > .close:hover,
.pkp_backend .pkp_modal_panel > .close:focus {
    color: #fff;
    background: #00577f;
}

.pkp_backend .pkp_modal_panel > .footer {
    background: #eee;
    border-top: 1px solid #ddd;
}

/* Match native and Vue-backed list headers to the same OJS palette. */
.pkp_backend .ui-tabs .ui-tabs-nav {
    background: #ddd;
    background-image: none;
}

.pkp_backend .pkpListPanel__header,
.pkp_backend .pkp_controllers_grid > .header {
    background: #eee;
    background-image: none;
}

.pkp_backend .ui-tabs .ui-tabs-nav .ui-tabs-anchor {
    color: #00577f;
}

.pkp_backend .pkpListPanel__title {
    color: #222;
}

.pkp_backend .ui-tabs .ui-tabs-nav .ui-state-active .ui-tabs-anchor {
    color: #666;
    background: #f6f8fa;
}

.pkp_backend .ui-tabs .ui-tabs-nav .ui-state-active .ui-tabs-anchor:before {
    background: #007ab2;
}

.pkp_backend .pkp_controllers_grid thead th {
    background: #eee;
    color: #666;
}

/* The native primary shade remains readable on light-grey header surfaces. */
.pkp_backend .pkpListPanel__header a {
    color: #00577f;
}

.pkp_backend .pkp_controllers_grid tr.category td {
    background: #eee;
    color: #222;
}

.pkp_backend a:focus-visible,
.pkp_backend button:focus-visible,
.pkp_backend input:focus-visible,
.pkp_backend select:focus-visible,
.pkp_backend textarea:focus-visible {
    outline: 2px solid #007ab2;
    outline-offset: 2px;
}

.pkp_backend .pkp_structure_head a:focus-visible,
.pkp_backend .pkp_modal_panel > .close:focus-visible {
    outline-color: #fff;
    outline-offset: -3px;
}

/* Two existing admin lists, aligned without changing templates or actions. */
.pkp_backend .pkp_page_admin {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px 24px;
    max-width: 960px;
    padding: 24px;
    box-sizing: border-box;
    align-items: start;
}

.pkp_backend .pkp_page_admin > h3 {
    margin: 0;
    color: #222;
    font-size: 16px;
    font-weight: 700;
    line-height: 24px;
}

.pkp_backend .pkp_page_admin > h3:first-of-type {
    grid-column: 1;
    grid-row: 1;
}

.pkp_backend .pkp_page_admin > h3:nth-of-type(2) {
    grid-column: 2;
    grid-row: 1;
}

.pkp_backend .pkp_page_admin > ul {
    margin: 0;
    padding: 12px 16px;
    background: #f6f8fa;
    border: 1px solid #ddd;
    border-radius: 3px;
    min-width: 0;
}

.pkp_backend .pkp_page_admin > ul:first-of-type {
    grid-column: 1;
    grid-row: 2;
}

.pkp_backend .pkp_page_admin > ul:nth-of-type(2) {
    grid-column: 2;
    grid-row: 2;
}

.pkp_backend .pkp_page_admin > ul a {
    color: #00577f;
    font-size: 14px;
    line-height: 24px;
    overflow-wrap: break-word;
}

/* Reserve room for the larger brand logo in the native absolute footer. */
.pkp_backend .pkp_structure_page {
    padding-bottom: 168px;
}

.pkp_backend .pkp_structure_footer {
    height: auto;
    min-height: 72px;
    padding: 16px 24px;
    box-sizing: border-box;
    background: #f2f4f6;
    border-top: 1px solid #ddd;
}

.pkp_backend .pkp_brand_footer img {
    width: 120px;
    max-width: 100%;
    height: auto;
}

@media (max-width: 991px) {
    .pkp_backend .pkp_page_admin {
        display: block;
    }
    .pkp_backend .pkp_page_admin > h3 {
        margin: 24px 0 8px;
    }
    .pkp_backend .pkp_page_admin > h3:first-of-type {
        margin-top: 0;
    }
}

/* Keep the native 192px sidebar on desktop, stacking it on narrow screens. */
@media (max-width: 767px) {
    .pkp_backend .pkp_structure_page {
        margin-left: 0;
        margin-right: 0;
        padding-top: 0;
    }
    .pkp_backend .pkp_structure_head {
        position: relative;
        width: 100%;
        height: auto;
        padding-top: 32px;
        box-sizing: border-box;
    }
    .pkp_backend .pkp_site_name a.is_img {
        min-height: 0;
        padding: 8px 12px;
    }
    .pkp_backend .pkp_site_name img {
        max-height: 48px;
    }
    .pkp_backend .pkp_navigation_primary {
        display: flex;
        flex-wrap: wrap;
        padding: 0 8px 8px;
    }
    .pkp_backend .pkp_navigation_primary > li {
        flex: 1 1 140px;
        min-width: 0;
    }
    .pkp_backend .pkp_navigation_primary > li[aria-expanded="true"] > ul {
        top: 100%;
        left: 0;
        max-width: calc(100vw - 24px);
    }
    .pkp_backend .pkp_navigation_primary > li:nth-child(even)[aria-expanded="true"] > ul {
        left: auto;
        right: 0;
    }
}
