/*
The MIT License (MIT)

Copyright (C) 2012-2013 Anton Simonov <untone@gmail.com>
Copyright (C) 2014-2015 Vsevolod Stakhov <vsevolod@highsecure.ru>

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/

/* stylelint-disable selector-id-pattern */

:root {
    font-size: 14px;

    /* Tweak bootstrap 5 colors for better accessibility */
    --bs-danger-rgb: 221, 0, 0;
    --bs-success-rgb: 40, 139, 69;

    /* Light mode (default) colors */
    --rspamd-bg-card-gradient-start: #f9f9f9;
    --rspamd-bg-card-gradient-end: #ededed;
    --rspamd-text-primary: #000000;
    --rspamd-text-secondary: #666666;
    --rspamd-nav-active-bg: #e7e7e7;
    --rspamd-sidebar-bg: #ffffee;
    --rspamd-symbol-description-color: #484848;
    --rspamd-symbol-negative-bg: #eef9e7;
    --rspamd-symbol-positive-bg: #fbe9e5;
    --rspamd-symbol-special-bg: #e2e9fe;
    --rspamd-symbol-hover-bg: #e6e6e6;
    --rspamd-table-danger-bg: #fbe9e5;
    --rspamd-table-success-bg: #eef9e7;
    --rspamd-table-warning-bg: #fff8e6;
    --rspamd-bs-table-bg: #f8f9fa;

    /* Per-type hover colors (light theme) */
    --rspamd-symbol-negative-hover-bg: #dcf9d3;
    --rspamd-symbol-positive-hover-bg: #fbd6d1;
    --rspamd-symbol-special-hover-bg: #cddbff;

    /* Light mode logo display rules */
    --rspamd-display-logo-light: inline;
    --rspamd-display-logo-dark: none;
}

[data-theme="dark"] {
    /* Dark mode colors */
    --rspamd-bg-card-gradient-start: #2a2a2a;
    --rspamd-bg-card-gradient-end: #252525;
    --rspamd-text-primary: #cccccc;
    --rspamd-text-secondary: #b0b0b0;
    --rspamd-nav-active-bg: #404040;
    --rspamd-sidebar-bg: #444422;
    --rspamd-symbol-description-color: #848484;
    --rspamd-symbol-negative-bg: #1a3a1a;
    --rspamd-symbol-positive-bg: #3a1a1a;
    --rspamd-symbol-special-bg: #3a3a5a;
    --rspamd-symbol-hover-bg: #000000;
    --rspamd-table-danger-bg: #390b00;
    --rspamd-table-success-bg: #102d00;
    --rspamd-table-warning-bg: #43380b;
    --rspamd-bs-table-bg: #272b2f;

    /* Per-type hover colors (dark theme) */
    --rspamd-symbol-negative-hover-bg: #274f27;
    --rspamd-symbol-positive-hover-bg: #4b2b2b;
    --rspamd-symbol-special-hover-bg: #41426a;

    /* Dark mode logo display rules */
    --rspamd-display-logo-light: none;
    --rspamd-display-logo-dark: inline;
}

/* bootstrap 4 overrides */
body {
    font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
}
code {
    font-size: 90%;
}
small,
.small {
    font-size: 85%;
}
.text-secondary {
    color: var(--rspamd-text-secondary) !important;
}
.navbar {
    padding-top: 0;
    padding-bottom: 0;
    margin-bottom: 20px;
}
.nav-pills .nav-link.active {
    background-color: var(--rspamd-nav-active-bg);
}
.danger > td {
    background-color: var(--rspamd-table-danger-bg);
}
.success > td {
    background-color: var(--rspamd-table-success-bg);
}
td.warning {
    background-color: var(--rspamd-table-warning-bg);
}
@media (max-width: 1199px) {
    .navbar-collapse.order-3 {
        border-top: 1px solid #dee2e6 !important;
    }
    /* Avoid navbar toggler hiding on navbar collapse */
    .navbar-toggler {
        display: block !important;
    }
}

/* Tweak FooTable for Bootstrap 5 */
.footable .btn,
.footable .form-control {
    border-radius: 0.375rem;
}

/* bootstrap 4 additionals */
.btn-group-xs > .btn,
.btn-xs {
    padding: .06rem .3rem;
    font-size: .875rem;
    line-height: 1.5;
    border-radius: .2rem;
}
.btn.disabled,
.btn[disabled],
fieldset[disabled] .btn {
    pointer-events: auto;
    cursor: not-allowed;
}
.card.disabled,
.input-group.disabled {
    cursor: not-allowed;
    opacity: 0.65;
}
.card.disabled *,
.input-group.disabled * {
    pointer-events: none;
}
.w-1 {
    width: 1%;
}

a {
    outline: none;
}
textarea {
    font-family: "Courier New", Courier, monospace;
    resize: vertical;
}

/* Tweak FooTable for Bootstrap 4 */
.footable .dropdown-toggle::after {
    content: none;
}
.footable .btn-outline-secondary {
    border-color: rgb(108 117 125);
}
.footable .btn-group > .btn:not(:first-child),
.footable .btn-group > .btn-group:not(:first-child) > .btn {
    border-top-left-radius: 0;
    border-bottom-left-radius: 0;
}
.footable .input-sm {
    height: 30px;
}

.footable-header .fooicon {
    font-size: 12px;
}
.footable .pagination > li:last-child > a {
    border-top-right-radius:4px;
    border-bottom-right-radius:4px
}

/* FooTable dark mode */
[data-theme="dark"] .footable .pagination .footable-page-link,
[data-theme="dark"] .footable .form-control {
    color: #aaaaaa;
    background-color: var(--bs-body-bg);
    border-color: var(--bs-border-color)
}
[data-theme="dark"] .footable .btn-primary {
    color: #ffffff;
    background-color: #0d6efd;
    border-color: #0d6efd;
}
[data-theme="dark"] .footable .btn-primary:hover {
  background-color: #0b5ed7;
  border-color: #0a58ca;
}
[data-theme="dark"] .footable .btn-default {
    color: #ffffff;
    background-color: #6c757d;
    border-color: #6c757d;
}
[data-theme="dark"] .footable .btn-default:hover,
[data-theme="dark"] .footable .open > .dropdown-toggle.btn-default {
    background-color: #5c636a;
    border-color: #565e64;
}

[data-theme="dark"] .footable .dropdown-menu {
    background-color: var(--bs-body-bg);
    border-color: var(--bs-dropdown-border-color);
}
[data-theme="dark"] .footable .dropdown-menu > li > a {
    color: #aaaaaa;
}
[data-theme="dark"] .footable .dropdown-menu > li > a:hover {
    background-color: var(--bs-dropdown-link-hover-bg);
}

[data-theme="dark"] .footable .pagination > li a:hover {
    background-color: var(--bs-nav-link-disabled-color);
    border-color: var(--bs-border-color);
}
[data-theme="dark"] .footable .pagination .footable-page-link:hover {
    color: var(--bs-nav-link-hover-color);
}
[data-theme="dark"] .footable .pagination .footable-page.active .footable-page-link {
    background-color: var(--rspamd-nav-active-bg);
    color: var(--rspamd-text-primary);
}

/* local overrides */
.navbar-brand > img {
    height: 50px;
}
.logo-light {
    display: var(--rspamd-display-logo-light);
}
.logo-dark {
    display: var(--rspamd-display-logo-dark);
}
.btn-group > .btn.radius-right {
    border-top-right-radius: var(--bs-btn-border-radius) !important;
    border-bottom-right-radius: var(--bs-btn-border-radius) !important;
}

input.form-control[type="number"] {
    width: 4em;
    padding-left: 0;
    padding-right: 0;
    text-align: center;
}
input.action-scores {
    margin: 5px -7em 5px 0;
}
table#symbolsTable input[type="number"] {
    width: 6em;
    font-size: 11px;
}

.notification-area {
    position: fixed;
    z-index: 1050;
    top: 44px;
    left: 0;
    right: 0;
    padding: 8px;
}
.alert {
    margin-bottom: 4px;
}
.alert.alert-modal {
    top: 0;
}
.alert strong {
    display: inline-block;
    padding-left: 35px;
}
[data-theme="light"] .alert-success {
    color: #468847;
    background: #dff0d8;
    border-color: #d6e9c6;
}
[data-theme="light"] .alert-danger {
    color: #b94a48;
    background: #f2dede;
    border-color: #eed3d7;
}
[data-theme="light"] .alert-warning {
    color: #c09853;
}
[data-theme="light"] .alert-info {
    color: #3a87ad;
    background: #d9edf7;
    border-color: #bce8f1;
}

#authInvalidCharFeedback,
#authUnauthorizedFeedback {
    position: unset;
    padding-top: 0.1rem;
    padding-bottom: 0.1rem;
}

.card-header,
.modal-header {
    background-image: linear-gradient(to bottom, var(--rspamd-bg-card-gradient-start), var(--rspamd-bg-card-gradient-end));
}
.card-header .h6 {
    font-size: 0.857rem;
}

.stat-box {
    background-image: linear-gradient(to bottom, var(--rspamd-bg-card-gradient-start), var(--rspamd-bg-card-gradient-end));
    line-height: 1;
}
.stat-box:not(.float-end) {
    min-width: 90px;
}
.stat-box .widget {
    font-size: 10px;
}
.stat-box .widget strong {
    font-size: 26px;
}

/* Symbols coloring */
.symbol-default {
    border-radius: 2px;
    padding-left: 2px;
    padding-right: 2px;
}
.symbol-default:hover {
    background-color: var(--rspamd-symbol-hover-bg);
}
.symbol-negative.symbol-negative {
    background-color: var(--rspamd-symbol-negative-bg);
}
.symbol-positive.symbol-positive {
    background-color: var(--rspamd-symbol-positive-bg);
}
.symbol-special {
    background-color: var(--rspamd-symbol-special-bg);
}
.symbol-negative:hover {
    background-color: var(--rspamd-symbol-negative-hover-bg);
}
.symbol-positive:hover {
    background-color: var(--rspamd-symbol-positive-hover-bg);
}
.symbol-special:hover {
    background-color: var(--rspamd-symbol-special-hover-bg);
}

/* Disable individual cell hover in status tables - use table-hover-cell instead */
.status-table tbody .symbol-negative:hover {
    background-color: var(--rspamd-symbol-negative-bg);
}
.status-table tbody .symbol-positive:hover {
    background-color: var(--rspamd-symbol-positive-bg);
}

/* For symbol description display on hover/focus */
.symbol-default.has-description:not(:focus) strong {
    text-decoration: underline dotted;
}
.symbol-description {
    display: none;
    color: var(--rspamd-symbol-description-color);
}
.symbol-default:hover .symbol-description,
.symbol-default:focus .symbol-description {
    display: unset;
}

.map-link {
    display: block;
    color: #0088cc;
    cursor: pointer;
}
.map-link:hover,
.map-link:focus {
    color: #005580;
    text-decoration: underline;
}

/* Font Awesome icons size */
.svg-inline--fa { /* stylelint-disable-line selector-class-pattern */
    font-size: 16px;
}
/* Increase refresh button spinner speed */
#refresh .fa-spin {
    -webkit-animation: fa-spin 1s linear infinite;
    animation: fa-spin 1s linear infinite;
}

/* Some spacing tweaks */
.notification-area div > button:not(.close) {
    margin-right: 9px;
}

.status-table thead th:first-child,
.status-table td:first-child {
    border-left: none;
}
.status-table thead th:last-child,
.status-table td:last-child {
    border-right: none;
}
.status-table thead tr {
    border-top: none;
}
.status-table tr:last-child,
.status-table tr:last-child td {
    border-bottom: none;
}

.footable-header,
.footable tr:not(.footable-detail-row) > td {
    font-size: 11px;
}
.footable-dropdown-btn-group {
    padding: 0 20px;
    margin: 7px 0;
}

.status-table tr:last-child td:last-child {
    border-radius: 0 0 calc(var(--bs-border-radius) + 1px);
}
.status-table :not(:has([rowspan])) tr:last-child td:first-child,
.status-table :nth-last-child(1 of tr:has([rowspan])) td:first-child  {
    border-radius: 0 0 0 calc(var(--bs-border-radius) + 1px);
}

/* Hover effect for table cells in tables with rowspan groups */
.status-table tbody td.table-hover-cell {
    --bs-table-color-state: var(--bs-table-hover-color);
    --bs-table-bg-state: var(--bs-table-hover-bg);
}

/* RRD summary */
#summary-row {
    padding-left: 80px;
    padding-right: 80px;
}
.col-fixed,
.col-fluid {
    position: relative;
    float: left;
}
.col-fixed {
    width: 200px;
    min-height: 1px; /* make an empty div take space */
}
.col-fluid {
    width: calc(100% - 200px);
}
#rrd-table_toggle {
    position: absolute;
    top: 0;
    height: 100%;
    width: 100%;
}
#rrd-table {
    margin-bottom: 2px;
    width: 100% !important;
    text-align: left;
    font-size: 12px;
    z-index: 100;

    --bs-table-bg: var(--rspamd-bs-table-bg);
}
#rrd-table td {
    color: inherit;
    padding-top: 2px;
    padding-bottom: 2px;
}
#rrd-total {
    padding-left: 8px;
    margin-bottom: 10px;
    text-align: left;
    font-size: 12px;
}

/* Throughput graph controls */
#graph_controls select {
    margin: 10px 20px 0;
    display: inline-block;
    width: auto;
    border: 1px solid grey;
}

/* history table */
.footable-details.table {
    margin-bottom: 0;
}
#historyTable_scan > tbody > tr > td,
#historyTable_scan > thead > tr > th,
#historyTable_history > tbody > tr > td,
#historyTable_history > thead > tr > th {
    padding: 4px;
}
#historyTable_scan > thead > tr > th,
#historyTable_history > thead > tr > th {
    padding-right: 20px;
}
@media (min-width: 576px) and (max-width: 1199px) {
    .history-col-time {
        /* Avoid taking multiple lines in every row when one of rows has long ID */
        white-space: nowrap;
    }
}
.footable-filtering-search .dropdown-menu .sym-order-toggle {
    display: none;
}

.search-syntax-icon {
    position: absolute;
    top: 50%;
    transform: translate(-150%, -50%);
    z-index: 3;
    opacity: 0.3;
    cursor: help;
    transition: opacity 0.2s ease-in-out;
}
.search-syntax-icon:hover {
    opacity: 0.6;
}

#history-from,
#history-count,
#history_page_size {
    width: 6em;
    text-align: center;
}

.outline-dashed-primary { outline: 2px dashed var(--bs-primary); }

#scanMsgSource:placeholder-shown,
#selectorsMsgArea:placeholder-shown {
  background-image: url("../img/drop-area.svg");
  background-repeat: no-repeat;
  background-position: center;
  opacity: 0.8;
}

#scanMsgSource:not(:placeholder-shown),
#selectorsMsgArea:not(:placeholder-shown) {
  background-image: none;
}

.scorebar-spam {
    background-color: rgb(240 0 0 / 0.1) !important;
}
.scorebar-ham {
    background: rgb(100 230 80 / 0.1) !important;
}

.danger .icon {
    color: #b94a48;
}
.success .icon {
    color: #468847;
}

#learnServers {
    display: flex;
}

#nprogress .bar {
    height: 1px;
}

@media (min-width: 992px) {
    #selectors > .card {
        height: calc(100vh - 96px);
    }
    #row-main {
        /* necessary to hide collapsed sidebar */
        overflow-x: hidden;
    }
    #content > div {
        display: flex;
    }
}
#content {
    transition: all 0.3s ease;
    transition-property: flex-basis, max-width, width;
}

.sidebar,
#sidebar-tab-left > a,
#sidebar-tab-right > a {
    background-color: var(--rspamd-sidebar-bg);
}
.sidebar {
    padding: 8px;
    transition: margin 0.3s ease;
}
.collapsed {
    /* hide it for small displays */
    display: none;
}
@media (min-width: 992px) {
    .collapsed {
        display: block;
    }
    #sidebar-left.collapsed {
        /* same width as sidebar */
        margin-left: -25%;
    }
    #sidebar-right.collapsed {
        /* same width as sidebar */
        margin-right: -25%;
    }
}

#selectors > .card > .card-body {
    min-height: 0;
}

.sidebar-nav {
    width: 20px;
}
.sidebar-nav .nav-link,
.sidebar-nav .nav-link:hover {
    border: 1px solid var(--bs-card-border-color);
}
#sidebar-tab-left > a,
#sidebar-tab-right > a {
    margin-left: 12px;
    margin-right: 12px;
}
#sidebar-tab-left {
    transform: rotate(180deg);
}
#sidebar-tab-text-left {
    transform: rotate(180deg);
}
@media (min-width: 992px) {
    #sidebar-left {
        border-bottom-left-radius: 3.5px;
    }
    #sidebar-right {
        border-bottom-right-radius: 3.5px;
    }
    .sidebar-nav {
        padding-right: 0;
        display: block;
    }
    #content {
        border-left: 1px solid var(--bs-card-border-color);
        border-right: 1px solid var(--bs-card-border-color);
    }
    #sidebar-tab-left {
        display: flex;
        transform: translateX(-50%) rotate(90deg) translate(50%, -50%);
    }
    #sidebar-tab-right {
        float: right;
        transform: translateX(50%) rotate(-90deg)  translate(-50%, -50%);
    }
}
@media (max-width: 991.98px) {
    #sidebar-right {
        border-bottom-left-radius: 3.5px;
        border-bottom-right-radius: 3.5px;
    }
    #content {
        border-top: 1px solid var(--bs-card-border-color);
        border-bottom: 1px solid var(--bs-card-border-color);
    }
    #sidebar-tab-right {
        bottom: 0;
        right: 0;
    }
}

#navBar .navbar-nav .nav-link {
    padding: 15px;
}

#modalDialog > .modal-dialog {
    /* Center the modal vertically */
    top: 50%;
    transform: translate(0, -50%);
    -webkit-transform: translate(0, -50%);
}

.codejar-wrap,
#editor.map-textarea {
    border-radius: 6px;
    max-height: calc(100vh - 178px);
    max-width: 100%;
    min-width: 100%;
    overflow: auto;
    resize: both;
}
#editor.map-textarea {
    height: calc(100vh - 178px);
    width: calc(100vw - 36px - 3rem);
}
.codejar-wrap,
#editor.map-textarea,
#editor.map-textarea:focus {
    background: rgb(0 47 79);
    color: silver;
}
.codejar-wrap {
    /* Fix line wrapping */
    scrollbar-width: thin;
}
.codejar-linenumbers-inner-wrap {
    bottom: unset;
}
.codejar-linenumbers {
    background: rgb(255 255 255 / 0.07) !important;
}
.codejar-linenumber {
    color: rgb(120 120 120 / 1) !important;
    text-align: right;
}
.editor {
    font-family: monospace;
    font-size: 14px;
    font-weight: 400;
    letter-spacing: normal;
    margin-left: 10px;
    margin-right: 10px;
    resize: unset !important;
    tab-size: 4;
    -moz-tab-size: 4;
    overflow: unset !important;
}

/* Prism show-invisibles plugin overrides */
.token.tab:not(:empty)::before {
    content: "\23af\27F6";
}
/* Temporarily remove CR and LF tokens as they overflow line width */
.token.cr::before,
.token.crlf::before,
.token.lf::before {
    content: "";
}

/* Preloader */
.blinking {
    animation: blinker 1.2s ease-in-out infinite;
}
@keyframes blinker {
    50% {
        -webkit-filter: invert(1);
        filter: invert(1);
    }
}

/* Dark mode overrides for Bootstrap tables */
[data-theme="dark"] .table {
    --bs-table-color-state: var(--rspamd-text-primary);
}

/* Dark mode overrides for D3Evolution */
[data-theme="dark"] .d3evolution .grid line {
    stroke: #404040;
}
[data-theme="dark"] .d3evolution .cursor .background {
    stroke: #1a1a1a;
}
[data-theme="dark"] .d3evolution .cursor .x.foreground {
    stroke: #4db8ff;
}
[data-theme="dark"] .d3evolution .cursor circle.foreground {
    stroke: white;
}
[data-theme="dark"] .d3evolution .chart-title,
[data-theme="dark"] .d3evolution .axis,
[data-theme="dark"] .d3evolution .legend,
[data-theme="dark"] .d3evolution .y.label,
[data-theme="dark"] .d3evolution .cursor-time {
    fill: var(--rspamd-text-primary);
}

/* Dark mode overrides for D3Pie */
[data-theme="dark"] .d3pie .chart-title,
[data-theme="dark"] .d3pie .outer-label,
[data-theme="dark"] .d3pie .total-text,
[data-theme="dark"] .d3pie .total-value {
    fill: var(--rspamd-text-primary);
}
[data-theme="dark"] .d3pie .slice-g.first-slice .inner-label {
    fill: #666666;
}
[data-theme="dark"] .d3pie-tooltip {
    background-color: rgb(80 80 80 / 80%);
}

/* Dark mode for NProgress */
[data-theme="dark"] #nprogress .bar {
    background: #4db8ff;
}
