@import "variables";

$box-shadow: 0 1px 4px 0 rgba(0, 0, 0, 0.37);
@function rgb($args...) {
    @return r#{g}#{b}(#{$args})
}


html.DARK {
    $default-font-color: #e6e6e6;
    scrollbar-color: #1f4a6e #0e1726; // firefox scrollbar (muted brand-blue thumb on dark navy track)

    // Text selection — brighter brand-blue on dark so selected text stays readable.
    ::selection { background: rgba(97, 175, 239, 0.40); color: #ffffff; }
    ::-moz-selection { background: rgba(97, 175, 239, 0.40); color: #ffffff; }
    // New UI standard background: brand blue (top-left) -> dark navy -> green (bottom-right)
    // with faint diagonal light streaks (same as login/dashboard/preloader). Replaces world.svg.
    background-color: #080c12;
    background-image:
        repeating-linear-gradient(135deg, transparent 0 140px, rgba(97, 175, 239, 0.04) 140px 141px, transparent 141px 320px),
        radial-gradient(120% 110% at 100% 100%, rgba(0, 137, 63, 0.45) 0%, rgba(0, 137, 63, 0) 55%),
        radial-gradient(120% 110% at 0% 0%, rgba(12, 83, 164, 0.55) 0%, rgba(12, 83, 164, 0) 55%),
        linear-gradient(135deg, #0c1626 0%, #0a1018 45%, #08120c 100%);
    background-repeat: no-repeat;
    background-attachment: fixed;
    background-size: cover;

    body {
        //backdrop-filter: blur(10px);
        background-color: transparent; min-height: 100vh;
        min-width: calc(100vw - 19px);
    }

    // New UI standard: global square-box grid overlay behind every page (fades toward edges).
    // z-index: -1 keeps it behind all content WITHOUT creating a stacking context on app-root
    // (which would trap Bootstrap modals below their body-level .modal-backdrop).
    body::before {
        content: "";
        position: fixed;
        inset: 0;
        pointer-events: none;
        z-index: -1;
        background-image:
            linear-gradient(to right, rgba(97, 175, 239, 0.10) 1px, transparent 1px),
            linear-gradient(to bottom, rgba(97, 175, 239, 0.10) 1px, transparent 1px);
        background-size: 56px 56px;
        -webkit-mask-image: radial-gradient(ellipse at center, black 30%, transparent 78%);
        mask-image: radial-gradient(ellipse at center, black 30%, transparent 78%);
    }

    $bg-text-dropdown: #464646;
    $shadow-lg: var(--mdc-dialog-container-elevation, 0px 11px 15px -7px rgba(0, 0, 0, 0.2), 0px 24px 38px 3px rgba(0, 0, 0, 0.14), 0px 9px 46px 8px rgba(0, 0, 0, 0.12));

    /* Handle — muted brand blue -> green gradient (subdued) */
    ::-webkit-scrollbar-thumb {
        background: linear-gradient(180deg, #1b3a5c 0%, #18424a 55%, #1a4d33 100%);
    }
    ::-webkit-scrollbar-thumb:hover {
        background: linear-gradient(180deg, #245f9f 0%, #1d6a5a 55%, #1d6d44 100%);
    }

    // New UI standard: brand-tinted dark navy surface for cards/modals (matches grids, inputs, tiles).
    // Flat fill (was a #17202e->#121925 gradient that tinted the surface unevenly).
    .modal-body, .modal-footer, .card {
        background-color: #141c29;
        background-image: none;
    }
    // Visible brand-blue divider between the body and the footer (Close/Save bar).
    .modal-footer { border-top: 1px solid rgba(97, 175, 239, 0.22); }

    .card { border: 1px solid rgba(97, 175, 239, 0.15); }

    // New UI standard: subtle brand blue -> green tinted header (over the dark navy surface).
    .modal-header, .card-header {
        background-color: #1b2636; // fallback
        background-image:
            linear-gradient(90deg, rgba(12, 83, 164, 0.28) 0%, rgba(12, 83, 164, 0.10) 45%, rgba(0, 137, 63, 0.10) 70%, rgba(0, 137, 63, 0.22) 100%),
            linear-gradient(180deg, #1d2940 0%, #161f30 100%);
        border-bottom: 1px solid rgba(97, 175, 239, 0.18);
    }

    // Round close button (dark) — brand navy surface + brand-blue hairline to
    // match cards/inputs; hover shifts to a soft danger wash since it's a close action.
    .modal-header .close,
    .modal-content > .close {
        background-color: rgba(20, 28, 41, 0.6);
        border: 1px solid rgba(97, 175, 239, 0.25);
        color: #9fb3cc;
        text-shadow: none;
    }
    .modal-header .close:hover,
    .modal-content > .close:hover {
        background-color: rgba(224, 108, 117, 0.18);
        border-color: rgba(224, 108, 117, 0.55);
        color: #ff8d94;
    }
    .modal-header .close:focus,
    .modal-content > .close:focus {
        border-color: rgba(97, 175, 239, 0.55);
        box-shadow: 0 0 0 0.2rem rgba(97, 175, 239, 0.25);
    }

    // Header action info/help glyph — brand blue (not the harsh Bootstrap cyan),
    // brightening on hover to read as interactive.
    .modal-header > .float-right > span,
    .modal-header > .float-right > span i.text-info {
        color: #61AFEF !important;
    }
    .modal-header > .float-right > span:hover i { color: #8cc6ff !important; }

    // Frosted-glass dropdown/menu popups are defined further down (single
    // source of truth); this opaque fallback is intentionally omitted so the
    // glass effect is not overridden.

    // New UI standard: top nav bar = deep navy base with a subtle brand blue -> green wash.
    .navbar {
        background-color: #0c1626; // fallback
        background-image:
            linear-gradient(90deg, rgba(12, 83, 164, 0.22) 0%, rgba(12, 83, 164, 0) 40%, rgba(0, 137, 63, 0) 70%, rgba(0, 137, 63, 0.20) 100%),
            linear-gradient(180deg, #0e1b2c 0%, #0a1421 100%);
        border-bottom: 1px solid rgba(97, 175, 239, 0.18);
        box-shadow: $box-shadow;
    }

    // Vertical separator between top-level navbar menu items (dark mode) — matches light.
    // Short, vertically-centered line between consecutive dropdown menu items.
    .navbar-nav > .nav-item.dropdown:not(.ml-auto) + .nav-item.dropdown:not(.ml-auto) {
        position: relative;
    }
    .navbar-nav > .nav-item.dropdown:not(.ml-auto) + .nav-item.dropdown:not(.ml-auto)::before {
        content: "";
        position: absolute;
        left: 0;
        top: 50%;
        transform: translateY(-50%);
        height: 22px;
        width: 1px;
        background: rgba(97, 175, 239, 0.20);
    }

    // Targeted navbar separators (left of moon toggle, before user/Admin menu) — dark variant.
    // Drawn as a short, vertically-centered line (via ::before) instead of a full-height
    // border so the divider doesn't span the whole navbar height.
    .navbar-nav > .nav-item.nav-divider-left {
        position: relative;
    }
    .navbar-nav > .nav-item.nav-divider-left::before {
        content: "";
        position: absolute;
        left: 0;
        top: 50%;
        transform: translateY(-50%);
        height: 22px;
        width: 1px;
        background: rgba(97, 175, 239, 0.20);
    }
    .navbar-nav > .nav-item.nav-divider-left > .nav-link { padding-left: 0.85rem !important; }
    // Separator between each right-side icon button (match light mode — keep icon widths identical).
    .navbar-nav > .nav-item:not(.dropdown):not(.ml-auto) + .nav-item:not(.dropdown):not(.ml-auto) {
        position: relative;
    }
    .navbar-nav > .nav-item:not(.dropdown):not(.ml-auto) + .nav-item:not(.dropdown):not(.ml-auto)::before {
        content: "";
        position: absolute;
        left: 0;
        top: 50%;
        transform: translateY(-50%);
        height: 20px;
        width: 1px;
        background: rgba(97, 175, 239, 0.16);
    }

    // Hover top-level nav item = light brand tint.
    .navbar-nav .nav-link:hover {
        background-image: linear-gradient(90deg, rgba(12, 83, 164, 0.28) 0%, rgba(0, 137, 63, 0.18) 100%);
        border-radius: 2px;
        color: #ffffff;
    }
    // Active / open top-level nav item = rich diagonal brand gradient, clearly visible.
    .navbar-nav .nav-item.active > .nav-link,
    .navbar-nav .nav-item.show > .nav-link,
    .navbar-nav .nav-link.active,
    .navbar-nav .nav-link.show {
        background-image: linear-gradient(135deg, rgba(12, 83, 164, 0.70) 0%, rgba(10, 106, 95, 0.55) 55%, rgba(0, 137, 63, 0.55) 100%);
        border-radius: 2px;
        color: #ffffff;
        //box-shadow: inset 0 -2px 0 #61AFEF;
    }

    // New UI standard: active/selected menu item = rich brand blue -> green gradient (not maroon).
    .dropdown-item { border-radius: 2px; }
    .dropdown-item.active, .dropdown-item:active {
        background-color: #16273d;
        background-image: linear-gradient(135deg, rgba(12, 83, 164, 0.50) 0%, rgba(10, 106, 95, 0.36) 55%, rgba(0, 137, 63, 0.32) 100%);
        border: 1px solid rgba(97, 175, 239, 0.25);
        color: #ffffff;
    }

    .form-control {
        // New UI standard: brand-tinted dark navy gradient fill (color-only).
        background-color: #1a2738; // fallback
        background-image: linear-gradient(160deg, #1c2a3d 0%, #141e2c 100%);
        // Subtle brand-blue hairline border — a touch brighter than the card edges.
        border: 1px solid rgba(97, 175, 239, 0.28);
        color: #d7dae0;
    }

    // Input-group prefix/suffix boxes (e.g. an "Every" prefix before a dropdown) — brand
    // navy fill matching the adjacent .form-control, instead of the bootswatch light/grey.
    .input-group-text {
        background-color: #1a2738;
        background-image: linear-gradient(160deg, #1c2a3d 0%, #141e2c 100%);
        border: 1px solid rgba(97, 175, 239, 0.28);
        color: #d7dae0;
    }

    // Password show/hide toggle (input-group append) — brand navy surface +
    // brand-blue hairline that matches the adjacent .form-control, instead of
    // a flat grey (bg-dark + #555 border).
    .input-group-text.input-pwd-toggle {
        background-color: #1a2738;
        background-image: linear-gradient(160deg, #1c2a3d 0%, #141e2c 100%);
        border: 1px solid rgba(97, 175, 239, 0.18);
        color: #9aa6b5;
        transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
    }
    .input-group-text.input-pwd-toggle:hover {
        background-image: none;
        background-color: rgba(12, 83, 164, 0.30);
        border-color: rgba(97, 175, 239, 0.45);
        color: #ffffff;
    }

    .form-control:focus {
        // Brand-blue focused state with a subtly brighter gradient.
        background-color: #1f3047; // fallback
        background-image: linear-gradient(160deg, #213a57 0%, #16243a 100%);
        border: 1px solid rgba(97, 175, 239, 0.55);
    }

    // New UI standard: brand-blue tinted utility borders (consistent with inputs/cards/grids).
    .border,
    .border-left, .border-right, .border-top, .border-bottom {
        border-color: rgba(97, 175, 239, 0.28) !important;
    }

    .footer {
        box-shadow: $box-shadow;
        color: var(-dark-content-primary--shade--three);
        background-color: var(--dark-bg-primary);
    }

    .shadow-sm { box-shadow: 0 0 3px #000 !important; }

    hr { border: 1px; border-top: 1px solid rgba(97, 175, 239, 0.18); }
    .table-bordered th, .table-bordered td { border: 1px solid rgba(97, 175, 239, 0.18); }

    // Heading standard — brand-blue accent (bright, readable on the dark canvas).
    h1, h2, h3, h4, h5, h6, .h1, .h2, .h3, .h4, .h5, .h6 { color: #61AFEF; }

    .modal-content {
        background-color: #141c29;   // was inheriting the bootswatch slate shade behind the body
        box-shadow: 0 4px 8px 0 rgb(17 17 17), 0 6px 20px 0 rgb(33 33 33);
        border-color: rgba(97, 175, 239, 0.20);
    }

    // Quill editor related style improvements.
    .ql-snow .ql-picker { color: var(--content-primary--shade--four); }
    .ql-container.ql-snow, .ql-toolbar.ql-snow { border: none; }
    .ql-toolbar.ql-snow { border-bottom: 1px solid #565656; }
    .ql-snow .ql-stroke { stroke: var(--content-primary--shade--four); }
    .ql-snow .ql-fill, .ql-snow .ql-stroke.ql-fill {
        fill: var(--content-primary--shade--four);
    }
    .ql-snow .ql-picker-options { background-color: var(--bg-primary); }
    .ql-toolbar.ql-snow .ql-picker.ql-expanded .ql-picker-options { border-color: #3c3c3c; }
    .ql-toolbar.ql-snow .ql-picker.ql-expanded .ql-picker-label { border-color: #464646; }

    // Quill editor table popup UI issue fix.
    .ql-table-menu { border: 1px solid #525252; background: #3a3a3a; }
    .ql-table-toggle { background: #2f2f2f; border: 2px solid #585858; }
    .ql-table-menu__item:hover { color: #f2f2f2; background-color: var(--accent-error--shade--five); }
    .ql-table-menu__item { padding: 5px 15px; }
    .ql-table-menu__item-icon { margin-right: 10px; svg { path { fill: #a2a2a2; }} }
    .ql-editor td { border: 1px solid #6f6f6f; padding: 5px 8px; }
    .ql-table-toggle { margin-left: -16px; }

    // Quill editor video modal popup bug fix.
    .ql-snow .ql-tooltip { margin-left: 159px; margin-top: -25px; background: #2f2f2f; border: 1px solid #585858; box-shadow: 0 0 5px #292929; color: #f2f2f2;
        input { background: #2f2f2f; border: 1px solid #585858; color: #f2f2f2; }
        input:focus-visible { outline: 1px solid #737373; }
    }
    // New UI standard: secondary / cancel button = neutral dark navy (brand-tinted), not flat grey.
    .btn-secondary {
        background-color: #1c2839;
        background-image: linear-gradient(180deg, #20293a 0%, #161f2d 100%);
        border: 1px solid rgba(97, 175, 239, 0.25);
        color: #d7dae0;
    }
    // Match Bootswatch's specificity (:not([disabled]):not(.disabled)) to beat its grey hover gradient.
    .btn-secondary:not([disabled]):not(.disabled):hover,
    .btn-secondary:not([disabled]):not(.disabled):focus,
    .btn-secondary:not([disabled]):not(.disabled):active,
    .btn-secondary:not([disabled]):not(.disabled).active {
        background-color: #243248;
        background-image: linear-gradient(180deg, #283449 0%, #1b2538 100%);
        background-repeat: no-repeat;
        border: 1px solid rgba(97, 175, 239, 0.4);
        color: #ffffff;
        filter: none;
    }

    // New UI standard: brand blue -> green gradient for primary, brand-green for success (color-only).
    .btn-primary { background-color: #0C53A4; background-image: linear-gradient(135deg, #0C53A4 0%, #0a6a5f 55%, #00893F 100%); border: 1px solid rgba(97, 175, 239, 0.45); }
    .btn-primary:hover, .btn-primary:focus, .btn-primary:active, .btn-primary.active,
    .btn-primary:not(:disabled):not(.disabled):active {
        background-color: #0e5fbd; background-image: linear-gradient(135deg, #0e5fbd 0%, #0b7a6c 55%, #00a04a 100%); border: 1px solid rgba(97, 175, 239, 0.6);
    }
    .btn-primary:disabled, .btn-primary.disabled { background-image: linear-gradient(135deg, #0C53A4 0%, #0a6a5f 55%, #00893F 100%); }

    .btn-success { background-color: #00893F; background-image: linear-gradient(135deg, #00A04A 0%, #00893F 60%, #006e32 100%); border: 1px solid rgba(38, 180, 127, 0.5); }
    .btn-success:hover, .btn-success:focus, .btn-success:active, .btn-success.active,
    .btn-success:not(:disabled):not(.disabled):active {
        background-color: #00a04a; background-image: linear-gradient(135deg, #00b855 0%, #00a04a 60%, #00813a 100%); border: 1px solid rgba(38, 180, 127, 0.65);
    }
    .btn-success:disabled, .btn-success.disabled { background-image: linear-gradient(135deg, #00A04A 0%, #00893F 60%, #006e32 100%); }

    // SEND button (api-testing filter-section) — brand blue -> green standard gradient.
    .send-request-btn.btn-success { background-color: #0C53A4; background-image: linear-gradient(135deg, #0C53A4 0%, #0a6a5f 55%, #00893F 100%); border: 1px solid rgba(97, 175, 239, 0.45); }
    .send-request-btn.btn-success:hover, .send-request-btn.btn-success:focus, .send-request-btn.btn-success:active, .send-request-btn.btn-success.active,
    .send-request-btn.btn-success:not(:disabled):not(.disabled):active {
        background-color: #0e5fbd; background-image: linear-gradient(135deg, #0e5fbd 0%, #0b7a6c 55%, #00a04a 100%); border: 1px solid rgba(97, 175, 239, 0.6);
    }
    .send-request-btn.btn-success:disabled, .send-request-btn.btn-success.disabled { background-image: linear-gradient(135deg, #0C53A4 0%, #0a6a5f 55%, #00893F 100%); }

    // Outline buttons (dark) — colored border + text on transparent; fill solid + white on hover.
    .btn-outline-primary { color: #61AFEF !important; border: 1px solid rgba(97, 175, 239, 0.5) !important; background: transparent !important; background-image: none !important; }
    .btn-outline-primary:hover, .btn-outline-primary:focus, .btn-outline-primary:active {
        color: #fff !important; background: #0C53A4 !important; background-image: none !important; border-color: #61AFEF !important;
    }
    .btn-outline-warning { color: #E5C07B !important; border: 1px solid rgba(229, 192, 123, 0.5) !important; background: transparent !important; background-image: none !important; }
    .btn-outline-warning:hover, .btn-outline-warning:focus, .btn-outline-warning:active {
        color: #1b2330 !important; background: #E5C07B !important; background-image: none !important; border-color: #E5C07B !important;
    }
    .btn-outline-danger { color: #E06C75 !important; border: 1px solid rgba(224, 108, 117, 0.5) !important; background: transparent !important; background-image: none !important; }
    .btn-outline-danger:hover, .btn-outline-danger:focus, .btn-outline-danger:active {
        color: #fff !important; background: #c0414b !important; background-image: none !important; border-color: #E06C75 !important;
    }
    .btn-outline-secondary { color: #9aa6b5 !important; border: 1px solid rgba(97, 175, 239, 0.35) !important; background: transparent !important; background-image: none !important; }
    .btn-outline-secondary:hover, .btn-outline-secondary:focus, .btn-outline-secondary:active {
        color: #fff !important; background: #22324a !important; background-image: none !important; border-color: rgba(97, 175, 239, 0.5) !important;
    }
    .btn-outline-info { color: #61AFEF !important; border: 1px solid rgba(97, 175, 239, 0.5) !important; background: transparent !important; background-image: none !important; }
    .btn-outline-info:hover, .btn-outline-info:focus, .btn-outline-info:active {
        color: #fff !important; background: #0C53A4 !important; background-image: none !important; border-color: #61AFEF !important;
    }
    .btn-outline-success { color: #2FB36A !important; border: 1px solid rgba(47, 179, 106, 0.5) !important; background: transparent !important; background-image: none !important; }
    .btn-outline-success:hover, .btn-outline-success:focus, .btn-outline-success:active {
        color: #fff !important; background: #00893F !important; background-image: none !important; border-color: #1d7a47 !important;
    }
    .btn-outline-light { color: #d7dae0 !important; border: 1px solid rgba(97, 175, 239, 0.35) !important; background: transparent !important; background-image: none !important; }
    .btn-outline-light:hover, .btn-outline-light:focus, .btn-outline-light:active {
        // Brand-blue tinted navy fill + light text (consistent with the other
        // outline variants), instead of inverting to a clashing light-grey fill.
        color: #ffffff !important; background: #22324a !important; background-image: none !important; border-color: rgba(97, 175, 239, 0.5) !important;
    }
    // Filled-on-hover outline buttons → white icons (warning fill is light, so excluded).
    .btn-outline-primary, .btn-outline-danger, .btn-outline-secondary, .btn-outline-info, .btn-outline-success, .btn-outline-light {
        &:hover, &:focus, &:active { i.fa, i.fas, i.far, i.fab { color: #fff !important; } }
    }

    .dropdown-menu {
        background: linear-gradient(160deg, rgba(20, 28, 41, 0.62) 0%, rgba(12, 18, 28, 0.55) 100%);
        backdrop-filter: blur(18px) saturate(135%);
        -webkit-backdrop-filter: blur(18px) saturate(135%);
        border: 1px solid rgba(97, 175, 239, 0.28);
        border-radius: 10px;
        box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08),
                    0 12px 32px rgba(0, 0, 0, 0.45);
    }
    .dropdown-item:hover, .dropdown-item:focus {
        color: #ffffff;
        background-color: #16273d;
        background-image: linear-gradient(135deg, rgba(12, 83, 164, 0.45) 0%, rgba(10, 106, 95, 0.32) 55%, rgba(0, 137, 63, 0.30) 100%);
    }

    .shadow-lg { box-shadow: $shadow-lg; }
    div.dropdown-menu { box-shadow: $shadow-lg; }
    .p-dropdown:not(.p-disabled).p-focus,
    .form-control:focus {
        -webkit-box-shadow: 0 0 0 0.2rem rgba(97, 175, 239, 0.35);
        box-shadow: 0 0 0 0.2rem rgba(97, 175, 239, 0.35);
    }

    // primeng sorting related fields.
    .p-datatable .p-sortable-column.p-highlight { color: #b0b0b0; }
    .p-datatable .p-sortable-column.p-highlight .p-sortable-column-icon { color: #b0b0b0; }

    // ===== Code-finder clickable Prism blocks — hover + selected (dark) =====
    // The result <pre class="language-javascript"> blocks are clickable; the selected one
    // gets `.bg-primary` (flat Bootstrap blue) from the click handler. Give them a brand
    // hover tint and a brand blue->green selected wash with an accent border instead.
    pre.language-javascript {
        border: 1px solid transparent;
        border-radius: 8px;
        transition: background-color 0.12s ease, border-color 0.12s ease, box-shadow 0.12s ease;
    }
    pre.language-javascript:hover {
        border-color: rgba(97, 175, 239, 0.30);
        box-shadow: 0 0 0 1px rgba(97, 175, 239, 0.15) inset;
    }
    pre.language-javascript.bg-primary {
        background-image: linear-gradient(135deg, rgba(12, 83, 164, 0.45) 0%, rgba(0, 137, 63, 0.28) 100%) !important;
        background-color: #16273d !important;
        border-color: rgba(97, 175, 239, 0.45) !important;
        box-shadow: inset 3px 0 0 #61AFEF !important;
    }
}

