/* ============================================================
   CSS Custom Properties
   ============================================================ */

:root {
    /* Typography */
    --fz-xs:   11px;
    --fz-sm:   12px;
    --fz-base: 13px;

    /* Primary (blue) */
    --c-primary-text:          #cfe2ff;
    --c-primary-subtle:        #a8cce8;
    --c-primary-brand:         #7aadd8;
    --c-primary-ui:            #5d9ee3;
    --c-primary-grad:          #4878b0;
    --c-primary-prefix:        #2f5c8e;
    --c-primary-hover:         #265075;
    --c-primary:               #1e3d5c;
    --c-primary-active:        #162d45;
    --c-primary-dark:          #0f1f30;

    /* Success (green) */
    --c-success-text:          #d1e7dd;
    --c-success-hover:         #146c43;
    --c-success:               #0f5132;
    --c-success-active:        #0a3d25;

    /* Danger (red) */
    --c-danger-text:           #f8d7da;
    --c-danger-hover:          #842029;
    --c-danger:                #6a1a20;
    --c-danger-active:         #521318;
    --c-danger-outline:        #200e0e;
    --c-danger-outline-hover:  #5a1820;
    --c-danger-outline-active: #180a0a;
    --c-danger-bright:         #cc0000;

    /* Warning (yellow) */
    --c-warning-text:          #fff3cd;
    --c-warning:               #664d03;

    /* Neutral (gray) */
    --c-neutral:               #22262b;
    --c-neutral-hover:         #2d3238;
    --c-neutral-active:        #1a1e22;

    /* Surfaces */
    --surface-nav:             rgba(0, 0, 0, 0.25);
    --surface-nav-link:        rgba(255, 255, 255, 0.07);
    --surface-card:            rgba(0, 0, 0, 0.15);
}

/* ============================================================
   Page titles
   ============================================================ */

.page-title {
    background: linear-gradient(to bottom, #ffffff 0 25%, #dddddd 50% 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    display: inline-flex;
    align-items: center;
    gap: 7px;
    position: relative;
    padding-bottom: 3px;
    padding-left: 3px;
    font-size: 18px;
    text-transform: uppercase;
}

.page-title-icon {
    -webkit-text-fill-color: #bbbbbb;
    font-size: 0.9em;
    flex-shrink: 0;
}

.page-title::after {
    content: "";
    position: absolute;
    bottom: 0;
    left: 0;
    width: calc(100% + 40px);
    height: 1px;
    background: linear-gradient(to right, rgba(255, 255, 255, 0.15) calc(100% - 40px), transparent 100%);
}

/* ============================================================
   Navigation
   ============================================================ */

.site-nav {
    background-color: var(--surface-nav);
    
    border-bottom: 1px solid rgba(255, 255, 255, 0.15) !important;
}

.site-brand {
    display: flex;
    align-items: center;
    gap: 6px;
    background: linear-gradient(to bottom, var(--c-primary-brand), var(--c-primary-grad));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    letter-spacing: 1px;
}

.site-logo-icon {
    width: 48px;
    flex-shrink: 0;
}

.site-nav-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--bs-secondary-color);
    border-radius: 6px;
    padding: 4px 12px !important;
    transition: background-color 0.15s, color 0.15s;
}

.site-nav-icon {
    font-size: 0.8em;
    flex-shrink: 0;
}

.site-nav-link:hover {
    color: var(--bs-body-color);
    background-color: var(--surface-nav-link);
}

.site-nav-link.active {
    color: #fff !important;
    background-color: var(--surface-nav-link);
    font-weight: 500;
}

.site-nav-logout {
    background: none;
    border: none;
    opacity: 0.6;
}

.site-nav-logout:hover {
    opacity: 1;
}

.site-version {
    font-size: var(--fz-sm);
    font-weight: 100;
    -webkit-text-fill-color: var(--bs-secondary-color);
    color: var(--bs-secondary-color);
    opacity: 0.9;
    margin-left: 6px;
    letter-spacing: 0;
}

/* ============================================================
   Update toast
   ============================================================ */

#update-toast {
    background-color: #1a1e24;
    border: 1px solid rgba(255, 255, 255, 0.12);
    min-width: 300px;
    max-width: 360px;
    box-shadow: 0 0 5px rgba(0,0,0,0.5);
}

#update-toast .toast-header {
    background-color: rgba(0, 0, 0, 0.3);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    color: var(--c-primary-subtle);
}

.update-toast-close {
    width: 0.6em;
    height: 0.6em;
    font-size: 0.75rem;
}

.update-toast-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: var(--c-primary-ui);
    flex-shrink: 0;
}

#update-toast .toast-body {
    color: var(--bs-body-color);
    font-size: var(--fz-sm);
}

#update-toast .toast-body a {
    color: var(--c-primary-ui);
}

.update-toast-notes {
    max-height: 25vh;
    overflow-y: auto;
}

.update-toast-notes h2 {
    font-size: var(--fz-sm);
    font-weight: 600;
    color: var(--c-primary-subtle);
    margin-top: 0.75rem;
    margin-bottom: 0.25rem;
}

.update-toast-notes h2:first-child {
    margin-top: 0;
}

.update-toast-notes ul {
    padding-left: 1.1rem;
    margin-bottom: 0;
}

.update-toast-notes li {
    margin-bottom: 0.2rem;
}

.btn-link-muted {
    background: none;
    border: none;
    padding: 0;
    font-size: inherit;
    font-family: inherit;
    color: var(--bs-secondary-color);
    opacity: 0.7;
    cursor: pointer;
    text-decoration: underline;
    text-underline-offset: 2px;
}

.btn-link-muted:hover {
    opacity: 1;
    color: var(--bs-body-color);
}

/* ============================================================
   Typography
   ============================================================ */

body {
    font-family: "Source Code Pro", ui-monospace, monospace;
    font-size: var(--fz-base);
    line-height: 1.6;
}

/* ============================================================
   Labels
   Shared style for .detail-label, .section-label, .form-label
   ============================================================ */

.detail-label, .section-label, .form-label {
    font-size: var(--fz-xs) !important;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--bs-secondary-color) !important;
}

.detail-label {
    width: 140px;
    white-space: nowrap;
    vertical-align: middle;
}

.section-label {
    margin-bottom: 8px;
}

.form-label {
    margin-bottom: 4px;
}

/* ============================================================
   Tables
   ============================================================ */

.table {
    --bs-table-bg: transparent;
    --bs-table-striped-bg: transparent;
    --bs-table-hover-bg: rgba(255, 255, 255, 0.03);
}

thead tr {
    background-color: rgba(255, 255, 255, 0.05);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1) !important;
}

th {
    font-size: var(--fz-sm) !important;
    font-weight: 700 !important;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    color: var(--bs-secondary-color) !important;
}

.col-date {
    white-space: nowrap;
}

/* ============================================================
   Cards
   ============================================================ */

.card-body {
    background-color: var(--surface-card);
    box-shadow: 0 0 5px rgba(0,0,0,0.5);
}

.card-subtitle {
    color: var(--c-primary-ui) !important;
    font-weight: 700 !important;
    font-size: var(--fz-xs) !important;
    text-transform: uppercase;
    letter-spacing: 1px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--bs-border-color);
    margin-bottom: 12px;
}

.card-subtitle::before {
    color: var(--bs-border-color);
    content: "// ";
}

/* Email list cards */

.card.mb-2 {
    transition: background-color 0.1s;
    cursor: pointer;
}

.card.mb-2:hover {
    background-color: rgba(255, 255, 255, 0.04);
}

.card.mb-2:active {
    background-color: rgba(255, 255, 255, 0.07);
}

.card-rule {
    border-left: 3px solid var(--bs-primary) !important;
}

/* ============================================================
   Stat cards
   ============================================================ */

.stat-value {
    font-size: 28px;
    font-weight: 700;
}

.score-progress {
    height: 6px;
    max-width: 100px;
}

/* ============================================================
   Spam score colors
   ============================================================ */

.score-high {
    color: var(--bs-danger-text-emphasis);
    font-weight: 600;
}

.score-med {
    color: var(--bs-warning-text-emphasis);
    font-weight: 600;
}

.score-low {
    color: var(--bs-success-text-emphasis);
}

/* ============================================================
   Badge color overrides
   ============================================================ */

.text-bg-success {
    background-color: var(--c-success) !important;
    color: var(--c-success-text) !important;
}

.text-bg-danger {
    background-color: var(--c-danger) !important;
    color: var(--c-danger-text) !important;
}

.text-bg-warning {
    background-color: var(--c-warning) !important;
    color: var(--c-warning-text) !important;
}

.text-bg-primary {
    background-color: var(--c-primary) !important;
    color: var(--c-primary-text) !important;
}

/* ============================================================
   Buttons
   ============================================================ */

.form-control, .form-select, .btn {
    font-size: var(--fz-base);
}

.btn {
    --bs-btn-border-color: transparent;
    --bs-btn-hover-border-color: transparent;
    --bs-btn-active-border-color: transparent;
    --bs-btn-disabled-border-color: transparent;
    text-transform: uppercase;
    font-weight: 700;
    text-shadow: 1px 1px 0 rgba(0, 0, 0, 0.8);
}

.btn-primary {
    --bs-btn-bg: var(--c-primary);
    --bs-btn-hover-bg: var(--c-primary-hover);
    --bs-btn-active-bg: var(--c-primary-active);
    --bs-btn-disabled-bg: var(--c-primary);
}

.btn-outline-primary {
    --bs-btn-bg: var(--c-primary-dark);
    --bs-btn-color: var(--c-primary-brand);
    --bs-btn-hover-bg: var(--c-primary);
    --bs-btn-hover-color: var(--c-primary-subtle);
    --bs-btn-active-bg: var(--c-primary-active);
}

.btn-outline-secondary {
    --bs-btn-bg: var(--c-neutral);
    --bs-btn-color: var(--bs-secondary-color);
    --bs-btn-hover-bg: var(--c-neutral-hover);
    --bs-btn-active-bg: var(--c-neutral-active);
}

.btn-outline-danger {
    --bs-btn-bg: var(--c-danger-outline);
    --bs-btn-color: var(--bs-danger-text-emphasis);
    --bs-btn-hover-bg: var(--c-danger-outline-hover);
    --bs-btn-hover-color: var(--c-danger-text);
    --bs-btn-active-bg: var(--c-danger-outline-active);
}

.btn-success {
    --bs-btn-bg: var(--c-success);
    --bs-btn-color: var(--c-success-text);
    --bs-btn-hover-bg: var(--c-success-hover);
    --bs-btn-hover-color: var(--c-success-text);
    --bs-btn-active-bg: var(--c-success-active);
    --bs-btn-active-color: var(--c-success-text);
}

.btn-danger {
    --bs-btn-bg: var(--c-danger);
    --bs-btn-color: var(--c-danger-text);
    --bs-btn-hover-bg: var(--c-danger-hover);
    --bs-btn-hover-color: var(--c-danger-text);
    --bs-btn-active-bg: var(--c-danger-active);
    --bs-btn-active-color: var(--c-danger-text);
}

/* ============================================================
   Rule editor column widths
   ============================================================ */

.cond-field {
    min-width: 200px;
}

.cond-operator {
    width: 200px;
    flex-shrink: 0;
}

.action-type {
    width: 210px;
    flex-shrink: 0;
}

/* ============================================================
   Overlays
   ============================================================ */

.overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    background-color: rgba(0, 0, 0, 0.4);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
}

.overlay-box {
    width: 100%;
    max-width: 440px;
    margin: 1rem;
}

.overlay-box-lg {
    max-width: 700px;
}

/* ============================================================
   Log table
   ============================================================ */

.log-DEBUG td {
    color: var(--bs-secondary-color);
}

.log-WARNING td {
    color: var(--bs-warning-text-emphasis);
}

.log-ERROR td {
    color: var(--bs-danger-text-emphasis);
}

.log-linked {
    cursor: pointer;
}

/* ============================================================
   Raw headers
   ============================================================ */

pre {
    white-space: pre-wrap;
    overflow-wrap: break-word;
    word-break: break-all;
}

/* ============================================================
   Dry run banner
   ============================================================ */

.dryrun-banner {
    background-color: rgba(240, 25, 25, 0.15);
    color: #fff;
    border-bottom: 1px solid rgba(255, 255, 255, 0.15) !important;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.45);
}

.dryrun-banner-link {
    color: #fff;
    text-decoration: underline;
    opacity: 0.8;
}

.dryrun-banner-link:hover {
    opacity: 1;
    color: var(--c-danger-text);
}

/* ============================================================
   Login page
   ============================================================ */

.login-box {
    width: 480px;
    max-width: calc(100vw - 2rem);
    overflow: hidden;
}

.login-header {
    background-color: rgba(0, 0, 0, 0.3);
    border-bottom: 1px solid var(--bs-border-color);
    padding: 24px;
}

.login-brand {
    font-size: 22px;
    font-weight: 700;
}

/* ============================================================
   Responsive (max-width: 767.98px)
   ============================================================ */

@media (max-width: 767.98px) {
    #navMenu .site-nav-link {
        width: 100%;
        border: 1px solid var(--bs-border-color);
        border-radius: 6px;
        padding: 10px 14px !important;
    }

    .action-forms {
        flex-direction: column;
    }

    .action-forms form,
    .action-forms .btn {
        width: 100%;
    }
}