/* ==========================================================================
   PHARMAPLUS MAIL V3.2.5
   DARK-MODE FINISHING LAYER
   Autofill • Message separators • Scrollbar
   ========================================================================== */

/*
 * Scope contract:
 *   - dark mode only
 *   - no navigation palette changes
 *   - no layout geometry changes
 *   - no recipient/compose behavior changes
 *   - no autocomplete/password-manager changes
 */

/* --------------------------------------------------------------------------
   01. CHROME / WEBKIT AUTOFILL
   Keep saved credentials visually inside the established dark login palette.
   -------------------------------------------------------------------------- */

html.dark-mode body.task-login #login-form
:is(#rcmloginuser, #rcmloginpwd):-webkit-autofill,
html.dark-mode body.task-login #login-form
:is(#rcmloginuser, #rcmloginpwd):-webkit-autofill:hover,
html.dark-mode body.task-login #login-form
:is(#rcmloginuser, #rcmloginpwd):-webkit-autofill:active {
    -webkit-text-fill-color: #F1F5F2 !important;
    caret-color: #F1F5F2 !important;

    background-color: #202A23 !important;

    -webkit-box-shadow:
        0 0 0 1000px #202A23 inset !important;
    box-shadow:
        0 0 0 1000px #202A23 inset !important;

    border-color: #364239 !important;
}

html.dark-mode body.task-login #login-form
:is(#rcmloginuser, #rcmloginpwd):-webkit-autofill:focus {
    -webkit-text-fill-color: #F1F5F2 !important;
    caret-color: #F1F5F2 !important;

    background-color: #222D25 !important;

    -webkit-box-shadow:
        0 0 0 1000px #222D25 inset,
        0 0 0 3px rgba(50,178,74,.10) !important;
    box-shadow:
        0 0 0 1000px #222D25 inset,
        0 0 0 3px rgba(50,178,74,.10) !important;

    border-color: rgba(50,178,74,.82) !important;
}

/* --------------------------------------------------------------------------
   02. DARK MAIL MESSAGE SEPARATORS
   V3.2's light #EDF0EE !important rule currently wins in dark mode.
   Override only the row divider. Unread/selected/flagged semantics stay intact.
   -------------------------------------------------------------------------- */

html.dark-mode body.task-mail .messagelist tr > td {
    border-bottom-color: rgba(255,255,255,.09) !important;
}

/* Preserve a clean boundary on selected rows without increasing contrast. */
html.dark-mode body.task-mail .messagelist tr.selected > td {
    border-bottom-color: rgba(255,255,255,.10) !important;
}

/* --------------------------------------------------------------------------
   03. DARK SCROLLBARS
   Elastic uses #007bb7 in dark mode. Replace only the browser scrollbar
   chrome with a restrained Pharmaplus-compatible green.
   -------------------------------------------------------------------------- */

html.dark-mode {
    scrollbar-color: #3C744A #202A23;
}

html.dark-mode:not(.touch) ::-webkit-scrollbar-track {
    background-color: #202A23;
}

html.dark-mode:not(.touch) ::-webkit-scrollbar-thumb {
    background-color: #3C744A;
    border-radius: 4px;
}

html.dark-mode:not(.touch) ::-webkit-scrollbar-thumb:hover {
    background-color: #4A8759;
}

/*
 * Elastic's .webkit-scroller thumb has a white border in the stock skin.
 * In dark mode keep that inset border matched to the track.
 */
html.dark-mode .webkit-scroller::-webkit-scrollbar-thumb {
    background-color: #3C744A;
    border-color: #202A23;
}

html.dark-mode .webkit-scroller::-webkit-scrollbar-thumb:hover {
    background-color: #4A8759;
}

/* --------------------------------------------------------------------------
   04. REDUCED MOTION
   -------------------------------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
    html.dark-mode body.task-login #login-form
    :is(#rcmloginuser, #rcmloginpwd),
    html.dark-mode body.task-mail .messagelist tr > td {
        transition: none !important;
    }
}
