/* Dark palette, artwork, and Dark-only workspace overrides. Load after the Light stylesheet. */

/* Dark palette */
/* Workspace palette. Shared and page-specific styles consume these semantic color tokens. */
html[data-ui-theme="dark"] {
    color-scheme: dark;

    /* Canvas, component surfaces, and separators */
    --ui-page-bg: #141a21;
    --ui-surface: #1d2630;
    --ui-surface-tinted: #21303d;
    --ui-surface-raised: #263340;
    --ui-surface-hover: #2d3d4d;
    --ui-border: #4c6174;
    --ui-divider-subtle: #394b5c;

    /* Foreground, accents, and keyboard focus */
    --ui-text: #e9eef4;
    --ui-text-muted: #b5c2d0;
    --ui-accent: #8ec5ed;
    --ui-focus: #a5d6ff;
    --ui-link: #a0d3fb;

    /* Status foregrounds and their matching surfaces */
    --ui-success: #9bd5aa;
    --ui-success-surface: #20382d;
    --ui-warning: #f0c38b;
    --ui-warning-surface: #3b3021;
    --ui-danger: #ffacaa;
    --ui-danger-surface: #43282d;

    /* Overlays and elevated components */
    --ui-shadow: 0 4px 16px rgb(0 0 0 / 46%);
    --ui-overlay: rgb(12 17 23 / 94%);

    /* Navigation */
    --ui-nav-bg: #111921;
    --ui-nav-text: #d2dce7;

    /* Primary actions */
    --ui-primary-bg: #246342;
    --ui-primary-hover: #2a7350;
    --ui-primary-text: #f0fff5;

    /* Keep the original dark logo artwork visible on a light surface. */
    --ui-brand-backdrop: #dce6ef;
}

/* Sign-in and workspace entry */
html[data-ui-theme="dark"] .ui-page-home :is(.logo-container img, .atpai-menu-item img) {
    background: var(--ui-brand-backdrop);
    border-radius: .35rem;
}

/* Theme selector and workspace shell */
/* Keep the organization logo legible on graphite. */
html[data-ui-theme="dark"] .atpai-header .logotype-container img {
    background: var(--ui-brand-backdrop);
    border-radius: .35rem;
}

html[data-ui-theme="dark"] .atpai-header .app-version {
    color: #2e5371;
}

/* Match the stock source so an organization logo loaded on sign-in keeps its own styling. */
@media screen {
    html[data-ui-theme="dark"] :is(
        .atpai-header .logotype-container > img,
        .ui-page-home :is(.logo-container, .atpai-menu-item) img
    ):is([src="../assets/media/img/proposals-logo.png"], [src="/assets/media/img/proposals-logo.png"]) {
        content: url("../media/img/proposals-logo-dark.png") / "@PROPOSALS logo";
        background: transparent;
        border-radius: 0;
    }
    html[data-ui-theme="dark"] .atpai-header .logotype-container > img[src="../assets/media/img/proposals-logo.png"] + .app-version {
        color: var(--ui-accent);
    }
}

html[data-ui-theme="dark"] .footer .made-by-surveyors-for-surveyors {
    color: var(--ui-text-muted);
}

/* The authentication flow can prepend this notice above the header. */
html[data-ui-theme="dark"] .template-organization-banner {
    background: var(--ui-surface-raised);
    color: var(--ui-text);
    border-color: var(--ui-border);
}

html[data-ui-theme="dark"] .template-organization-banner-copy p {
    color: var(--ui-text-muted);
}

html[data-ui-theme="dark"] .template-organization-banner-icon {
    background: var(--ui-surface);
    color: var(--ui-accent);
    border-color: var(--ui-border);
}

/* The inset separator keeps the rail 55px wide. The marker overlaps it within the scroll area. */
html[data-ui-theme="dark"] #atpai-left-menu-bar {
    box-shadow: inset -1px 0 var(--ui-border);
    --ui-nav-marker: var(--ui-nav-bg);
    /* A non-overlay scrollbar belongs on the left, clear of the marker's edge. */
    direction: rtl;
}

html[data-ui-theme="dark"] #atpai-left-menu-bar > :is(.left-bar-menu-item, [data-action="collapse-mobile-navigation"]) {
    /* Only the scroll container uses RTL to place the scrollbar. Menu content stays LTR. */
    direction: ltr;
    margin-inline-end: 1px;
}

html[data-ui-theme="dark"] #atpai-left-menu-bar > [data-action="collapse-mobile-navigation"] {
    /* Keep the explicitly sized toggle clear of the shared inset separator. */
    max-width: calc(100% - 1px);
}

html[data-ui-theme="dark"] #atpai-left-menu-bar.left-menu-scroll-enabled::after {
    /* Keep the scroll fade off the separator at the bottom of the rail. */
    background-size: calc(100% - 1px) 100%;
    background-repeat: no-repeat;
}

html[data-ui-theme="dark"] #atpai-left-menu-bar .left-menu-current-section-triangle {
    /* Center within the actual row height, including auto-height rows with badges. */
    inset-block: 0;
    right: -1px;
    height: auto;
    margin: 0;
}

html[data-ui-theme="dark"] #atpai-left-menu-bar .left-bar-menu-item.active .left-menu-current-section-triangle > span {
    border-block-width: 8px;
    border-right-width: 8px !important;
}

/* Dashboard and activity feed */
/* Status and selection colors used by the shared Dashboard rules. */
html[data-ui-theme="dark"]:where([data-ui-theme-components~="dashboard"])
body.proposals-dashboard-page {
    --dashboard-open-row: #213241;
    --dashboard-signed-row: #20382d;
    --dashboard-closed-row: #2e3238;
    --dashboard-selected-bg: #274656;
    --dashboard-cyan: #84cddd;
    --dashboard-purple: #dda8e7;
}

/* Titles and secondary information in the Dashboard and activity feed. */
html[data-ui-theme="dark"]:where([data-ui-theme-components~="dashboard"])
body.proposals-dashboard-page .section-heading-titles {
    background: var(--ui-surface);
}

/* Keep the AXIS link indicator readable without changing the row layout. */
html[data-ui-theme="dark"]:where([data-ui-theme-components~="dashboard"])
body.proposals-dashboard-page .proposals-list--axis-binding-icon-area > img[src="/assets/media/img/AXIS-V7-2026.png"] {
    content: url("../media/img/AXIS-V7-2026-dark.png") / "@AXIS";
}

/* Clients, Storage, Templates, and Statistics */
html[data-ui-theme="dark"]:where([data-ui-theme-components~="libraries"])
.ui-page-clients :is(
    .client-view-proposals--active, .modal-client-view-proposals-active, .bulk-recipient-icon
) {
    color: #dda8e7;
}

html[data-ui-theme="dark"]:where([data-ui-theme-components~="libraries"])
.ui-page-storage .storage-section-tabs .action-tab .img i {
    color: var(--ui-accent);
}

html[data-ui-theme="dark"]:where([data-ui-theme-components~="libraries"])
:is(.ui-page-storage, .ui-page-editproposal) .aws-s3-folder-related-to-some-proposal {
    color: #dda8e7;
}

/* Editors and Production templates */
html[data-ui-theme="dark"]:where([data-ui-theme-components~="editor"])
body:is(.edit-proposal-page, .proposal-webdoc-template-editor, .proposal-webdoc-section-editor) {
    --editor-selection-bg: #28506b;
    --editor-document-accent: #dda8e7;
}

html[data-ui-theme="dark"]:where([data-ui-theme-components~="editor"])
.edit-proposal-page .proposal-edition-tabs-content {
    box-shadow: inset 0 1px var(--ui-border);
}

/* Use a distinct Dark surface for computed or locked staff fields. The selector
   excludes document paper, PDF pricing and materials, and QuickBooks preview tables. */
html[data-ui-theme="dark"]:where([data-ui-theme-components~="editor"])
.ui-page-editproposal :is(input, select, textarea)[readonly]:not(:where(
    .page-block *, .proposal-rates-page *, .qbo-preview-table-scroll *, #export-pt-pdf-output-area-wrapper *
)) {
    background-color: var(--ui-surface-raised);
    border-color: var(--ui-border);
    color: var(--ui-text-muted);
}

html[data-ui-theme="dark"]:where([data-ui-theme-components~="editor"])
#edit-proposal-primary-info .proposal-fields-group-label {
    /* Group bands currently declare their background in the editor markup. */
    background: var(--ui-surface-raised) !important;
    box-shadow: inset 2px 0 var(--ui-border);
}

html[data-ui-theme="dark"]:where([data-ui-theme-components~="editor"])
#edit-proposal-primary-info .category-text-rotated {
    fill: var(--ui-text);
}

html[data-ui-theme="dark"]:where([data-ui-theme-components~="editor"])
#edit-proposal-primary-info .proposal-field-subdescription[style*="color: red"] {
    color: var(--ui-danger) !important;
}

html[data-ui-theme="dark"]:where([data-ui-theme-components~="editor"])
#rates-templates-std-pt-template-name-row {
    color: var(--ui-text-muted);
}

html[data-ui-theme="dark"]:where([data-ui-theme-components~="editor"])
.edit-proposal-page .proposal-resync-warning {
    color: var(--ui-warning);
}

/* Match the Dark readonly surface over the inline fill applied when STD pricing is locked. */
html[data-ui-theme="dark"]:where([data-ui-theme-components~="editor"])
#proposal-standard-invoice-editor .std-production-table-editor-content
input[readonly]:is(
    [data-role="group-name"], [data-role="group-code"], [data-role="group-description"],
    [data-role="item-price-input"], [data-role="item-count-input"]
) {
    background-color: var(--ui-surface-raised) !important;
}

/* Keep distinct numeric and formula cues in Dark across the proposal and template editors. */
html[data-ui-theme="dark"]:where([data-ui-theme-components~="editor"])
:is(#proposal-estimation-sections, #ateam-edit-cs-estimate-template-modal)
[data-role="cell-formula-editor"] {
    background-color: var(--ui-surface-raised);
    border-color: var(--ui-border);
    color: var(--ui-link);
}

html[data-ui-theme="dark"]:where([data-ui-theme-components~="editor"])
:is(#proposal-estimation-sections, #ateam-edit-cs-estimate-template-modal)
[data-role="cell-formula-editor"].cell-type-formula {
    border-color: var(--editor-document-accent);
    color: var(--editor-document-accent);
}

html[data-ui-theme="dark"]:where([data-ui-theme-components~="editor"])
:is(#proposal-estimation-sections, #ateam-edit-cs-estimate-template-modal)
[data-role="cell-formula-editor"]:hover {
    background-color: var(--ui-surface-hover);
}

html[data-ui-theme="dark"]:where([data-ui-theme-components~="editor"])
:is(#proposal-estimation-sections, #ateam-edit-cs-estimate-template-modal)
.cs-estimate-column-buttons-readonly {
    color: var(--ui-text-muted);
}

html[data-ui-theme="dark"]:where([data-ui-theme-components~="editor"])
:is(#proposal-estimation-sections, #ateam-edit-cs-estimate-template-modal)
.cs-estimate-main-table-group-top-label {
    color: var(--editor-document-accent);
}

/* Keep status cues readable on recipient table cells and match the legacy rule importance. */
html[data-ui-theme="dark"]:where([data-ui-theme-components~="editor"])
.edit-proposal-page :is(
    .proposal-bulk-recipient-archived, .proposal-bulk-recipient-row-ARCHIVED, .bulk-client-presented-in-the-list
) td {
    background-color: var(--ui-surface-raised) !important;
    color: var(--ui-text);
}

html[data-ui-theme="dark"]:where([data-ui-theme-components~="editor"])
.edit-proposal-page :is(.proposal-bulk-recipient-rejected, .proposal-bulk-recipient-row-REJECTED) td {
    background-color: var(--ui-danger-surface) !important;
    color: var(--ui-text);
}

html[data-ui-theme="dark"]:where([data-ui-theme-components~="editor"])
.edit-proposal-page :is(.proposal-bulk-recipient-signed, .proposal-bulk-recipient-row-SIGNED) td {
    background-color: var(--ui-success-surface) !important;
    color: var(--ui-text);
}

html[data-ui-theme="dark"]:where([data-ui-theme-components~="editor"])
.edit-proposal-page :is(
    .proposal-bulk-recipient-archived, .proposal-bulk-recipient-row-ARCHIVED,
    .proposal-bulk-recipient-rejected, .proposal-bulk-recipient-row-REJECTED,
    .proposal-bulk-recipient-signed, .proposal-bulk-recipient-row-SIGNED
):hover td {
    background-color: var(--ui-surface-hover) !important;
}

/* Account, administration, FAQ, and support */
/* These help glyphs carry inline colors in the page markup. */
html[data-ui-theme="dark"]:where([data-ui-theme-components~="administration"])
body.ui-page-organization-settings .faq-inner-text-link i {
    color: var(--ui-link) !important;
}

/* The tab icons have legacy inline colors that are too dark for the dark surface. */
html[data-ui-theme="dark"]:where([data-ui-theme-components~="administration"])
body.ui-page-support .support-ticket-heading-tab[data-tabcode="my-organization-tickets"] i {
    color: var(--ui-success) !important;
}

html[data-ui-theme="dark"]:where([data-ui-theme-components~="administration"])
body.ui-page-support .support-ticket-heading-tab[data-tabcode="tickets-admin"] i {
    color: var(--ui-accent) !important;
}

/* Staff document previews and thumbnails */
/* Staff document sheets and section thumbnails
   Apply the default paper tint to screen rendering. Print and public pages keep
   their renderer backgrounds, and authored elements keep their own display styles. */
@media screen {

    /* The document editor and the section preview renderer use different holders.
       Target the outermost page in either holder to leave authored descendants intact. */

    html[data-ui-theme="dark"]:where([data-ui-theme-components~="paper"])
    :is(
        .ui-page-editproposal, .ui-page-editsection, .ui-page-edittemplate
    ) #sections-editor .next-page-area-cell
    > [data-role="page-block-outer-holder"] > .page-block:not(:where(.page-block *)),
    html[data-ui-theme="dark"]:where([data-ui-theme-components~="paper"])
    :is(
        .ui-page-editproposal, .ui-page-editsection, .ui-page-edittemplate, .ui-page-storage, .ui-page-templates
    ) .section-content-area .next-page-area-cell
    > .page-block-holder > .page-block:not(:where(.page-block *)) {
        background-color: #bac1c8;
    }

    /* The editor grid image has white gaps. Blend it with the paper to keep the tint visible. */

    html[data-ui-theme="dark"]:where([data-ui-theme-components~="paper"])
    :is(
        .ui-page-editproposal, .ui-page-editsection, .ui-page-edittemplate
    ) #sections-editor .next-page-area-cell
    > [data-role="page-block-outer-holder"] > .page-block.grid-shown:not(:where(.page-block *)) {
        background-blend-mode: multiply;
    }
}
