/* app styles -- Tabler CSS is loaded via importmap */

:root {
    --tblr-font-sans-serif: "Inter", system-ui, -apple-system, sans-serif;
}

/* notification badge position */
.nav-link .badge-notification {
    top: 0 !important;
    right: 0 !important;
    transform: translate(-25%, 25%) !important;
}

/* notification dropdown: shrink to content, override Tabler's 11rem default + Bootstrap's width:100% on .dropdown-item */
.notifications-menu {
    min-width: 8rem !important;
}

.notifications-menu .dropdown-item {
    min-width: 0;
    width: auto;
    padding-inline: 1rem;
}

/* footer font size */
.footer {
    font-size: 0.875rem;
}

/* prevent browser scrollbar (Edge classic scrollbar) from shifting page content away from sidebar */
html {
    margin-left: 0 !important;
}

/* reduce gap between sidebar and content area */
@media (min-width: 992px) {
    .page-wrapper > .page-body > .container-xl,
    .page-wrapper > .page-header > .container-xl,
    .navbar > .container-xl,
    .footer > .container-xl {
        margin-inline-start: 0;
        padding-inline-start: var(--tblr-page-padding, 1rem);
    }
}

/* responsive table: overflow only on mobile so dropdown menus can escape on desktop */
@media (max-width: 767.98px) {
    .card-table {
        overflow-x: auto;
        scrollbar-width: thin;
        scrollbar-color: var(--tblr-border-color) var(--tblr-bg-surface-secondary);
    }

    .card-table::-webkit-scrollbar {
        height: 4px;
    }

    .card-table::-webkit-scrollbar-track {
        background: var(--tblr-bg-surface-secondary);
    }

    .card-table::-webkit-scrollbar-thumb {
        background: var(--tblr-border-color);
        border-radius: 2px;
    }
}

/* dropdown in table: use fixed positioning to escape overflow container */
.card-table .dropdown-menu {
    position: fixed;
}

/* tom-select: unified wrapper treatment — single and multi render identically.
   Wrapper padding must be 0 so .ts-control covers the full click area, including
   the Bootstrap chevron zone. The chevron background-image on .ts-wrapper shows
   through the transparent control; padding-inline-end on .ts-control reserves space. */
.ts-wrapper.form-select {
    padding: 0 !important;
    display: flex;
    align-items: stretch;
    min-height: 2.75rem !important;
}

.ts-wrapper.form-select .ts-control {
    flex: 1 1 0;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    border: 0 !important;
    background: transparent !important;
    box-shadow: none !important;
    padding: 0.375rem 2.25rem 0.375rem 0.75rem;
    gap: 0.25rem;
    min-height: unset;
}

.ts-wrapper.form-select .ts-control > input {
    margin: 0 !important;
}

/* hide TomSelect's internal caret; rely on Bootstrap form-select chevron */
.ts-wrapper.form-select .ts-control::after {
    display: none !important;
}

.ts-wrapper.form-select.focus {
    box-shadow: 0 0 0 0.25rem rgba(var(--tblr-primary-rgb), 0.25);
}

/* tom-select: selected item / chip in Tabler primary-light style (shared) */
.ts-wrapper .ts-control .item {
    background-color: var(--tblr-primary-lt) !important;
    background-image: none !important;
    color: var(--tblr-primary) !important;
    border: 1px solid color-mix(in srgb, var(--tblr-primary) 30%, transparent) !important;
    border-radius: 3px;
    padding: 3px 6px 3px 8px;
    box-shadow: none !important;
    text-shadow: none !important;
}

.ts-wrapper .ts-control .item .remove {
    color: var(--tblr-primary);
    border-left-color: color-mix(in srgb, var(--tblr-primary) 30%, transparent);
}

/* tom-select: dark mode */
[data-bs-theme="dark"] .ts-wrapper .ts-control,
[data-bs-theme="dark"] .ts-wrapper .ts-dropdown {
    background-color: var(--tblr-bg-surface);
    color: var(--tblr-body-color);
    border-color: var(--tblr-border-color);
}

[data-bs-theme="dark"] .ts-wrapper .ts-control .item {
    background-color: var(--tblr-secondary-bg);
    color: var(--tblr-body-color);
    border-color: var(--tblr-border-color);
}

[data-bs-theme="dark"] .ts-wrapper .ts-dropdown .option:hover,
[data-bs-theme="dark"] .ts-wrapper .ts-dropdown .option.active {
    background-color: var(--tblr-active-bg);
    color: var(--tblr-body-color);
}

/* tom-select: inactive option/item styling */
.ts-option-inactive {
    color: var(--tblr-secondary-color);
    font-style: italic;
}

.ts-wrapper .ts-control .item.ts-item-inactive {
    background-color: var(--tblr-secondary-lt) !important;
    color: var(--tblr-secondary) !important;
    border-color: color-mix(in srgb, var(--tblr-secondary) 30%, transparent) !important;
    font-style: italic;
}

.ts-wrapper .ts-control .item.ts-item-inactive .remove {
    color: var(--tblr-secondary);
    border-left-color: color-mix(in srgb, var(--tblr-secondary) 30%, transparent);
}

/* theme toggle: show sun in light mode, moon in dark mode */
[data-bs-theme="dark"] .icon-sun {
    display: none;
}

[data-bs-theme="dark"] .icon-moon {
    display: inline-block !important;
}

/* sidebar: Tabler sets overflow-y:scroll (always visible). AssetMapper does not
   guarantee app.css loads after tabler.min.css, so !important is required to
   win the cascade. hidden beats OS "always show scrollbars" in Edge/Windows
   because there is simply no overflow container to attach a scrollbar to. */
.navbar-vertical.navbar-expand-lg,
.navbar-vertical.navbar-expand-md,
.navbar-vertical.navbar-expand-sm {
    overflow-y: hidden !important;
}

/* sidebar: chevron rotation for collapsible menu */
.nav-link-chevron {
    transition: transform 0.2s ease-in-out;
    flex-shrink: 0;
}

.nav-link:not(.collapsed) .nav-link-chevron {
    transform: rotate(90deg);
}

/* detail row hover */
.detail-row {
    margin-block-end: 0;
    padding: 0.5rem 0;
    border-radius: var(--tblr-border-radius);
    transition: background-color 0.15s ease-in-out;
}

.detail-row:nth-child(even) {
    background-color: var(--tblr-bg-surface-tertiary);
}

.detail-row:hover {
    background-color: var(--tblr-active-bg);
}

/* toast: opaque background, colored left border, faster fade-in */
.toast {
    background-color: var(--tblr-bg-surface) !important;
    border-left: 4px solid transparent !important;
    transition: opacity 0.15s ease-in-out !important;
}

.toast--success {
    border-left-color: var(--tblr-success) !important;
    background-color: color-mix(in srgb, var(--tblr-success) 8%, var(--tblr-bg-surface)) !important;
}
.toast--danger {
    border-left-color: var(--tblr-danger) !important;
    background-color: color-mix(in srgb, var(--tblr-danger) 8%, var(--tblr-bg-surface)) !important;
}
.toast--warning {
    border-left-color: var(--tblr-warning) !important;
    background-color: color-mix(in srgb, var(--tblr-warning) 8%, var(--tblr-bg-surface)) !important;
}
.toast--info {
    border-left-color: var(--tblr-info) !important;
    background-color: color-mix(in srgb, var(--tblr-info) 8%, var(--tblr-bg-surface)) !important;
}

/* turbo-frame: loading overlay + spinner while navigating */
turbo-frame[busy] {
    position: relative;
    display: block;
    min-height: 8rem;
}

turbo-frame[busy]::before {
    content: "";
    position: absolute;
    inset: 0;
    background-color: color-mix(in srgb, var(--tblr-bg-surface) 60%, transparent);
    z-index: 1;
}

turbo-frame[busy]::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 2.5rem;
    height: 2.5rem;
    margin-block-start: -1.25rem;
    margin-inline-start: -1.25rem;
    border: 0.25rem solid var(--tblr-primary);
    border-right-color: transparent;
    border-radius: 50%;
    animation: spinner-border 0.75s linear infinite;
    z-index: 2;
}

.table > tfoot > tr > th {
    font-size: 0.75rem;
    font-weight: var(--tblr-font-weight-medium);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--tblr-muted);
}

/* WCAG 2.3.3: honour a reduced-motion preference. The endless notification-badge blink is
   pure decoration and is switched off; loading spinners stay animated on purpose because they
   are essential status feedback, not decoration. */
@media (prefers-reduced-motion: reduce) {
    .badge-blink {
        animation: none;
    }
}

/* toast container: offset below the navbar using CSS variables instead of inline style */
.toast-container--offset {
    z-index: var(--tblr-zindex-toast, 1090);
    margin-block-start: var(--navbar-height, 4rem);
}

/* Severity / effective-risk palette (single source of truth). Hand-tuned + WCAG-checked risk ramp;
   the dedicated tokens keep it out of the `--tblr-*` status palette so the two axes never share a
   colour. Dark mode re-declares only the two darkest so the shield stays visible on the dark
   surface — retune a colour in exactly one place. Consumed by `.severity-badge--*` below. */
:root {
    --severity-critical: #b02a37;
    --severity-high: #e8590c;
    --severity-medium: #f59f00;
    --severity-low: #2f9e44;
    --severity-info: #6c757d;
}
[data-bs-theme="dark"] {
    --severity-critical: #e4606d;
    --severity-low: #51cf66;
}

/* Severity / effective-risk badge: a coloured Tabler shield glyph + text label — deliberately a
   different visual language from the light-tint status badges (`bg-*-lt`) so the two axes never
   look alike in the same list. The shield SHAPE (per VulnerabilitySeverity::icon()) is the primary
   non-colour cue, the text label the second (WCAG 1.4.1), so Critical vs High no longer rely on the
   red/orange hue split alone. Colour token comes from *::color(); the shield inherits it via
   `currentColor`, the label stays body-coloured for legibility on both themes. */
.severity-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    white-space: nowrap;
    font-weight: var(--tblr-font-weight-medium);
    line-height: 1;
}
.severity-badge__icon {
    inline-size: 1.15em;
    block-size: 1.15em;
    flex-shrink: 0;
}
.severity-badge__label {
    color: var(--tblr-body-color);
}
.severity-badge--red .severity-badge__icon {
    color: var(--severity-critical);
}
.severity-badge--orange .severity-badge__icon {
    color: var(--severity-high);
}
.severity-badge--yellow .severity-badge__icon {
    color: var(--severity-medium);
}
.severity-badge--green .severity-badge__icon {
    color: var(--severity-low);
}
.severity-badge--secondary .severity-badge__icon {
    color: var(--severity-info);
}

/* Global audit timeline table (issue #32): rows with changes expand to reveal the field diff. */
.audit-row {
    cursor: pointer;
}
.audit-chevron {
    transition: transform 0.15s ease-in-out;
}
.audit-row[aria-expanded="true"] .audit-chevron {
    transform: rotate(90deg);
}
.audit-detail-row > td {
    background-color: var(--tblr-bg-surface-secondary);
    border-block-start: 0;
}

/* Import-status page: the table gets its own page, so it grows with the viewport instead of the
   22rem the dashboard card used. The subtracted 16rem covers navbar, page header and card footer;
   the min-height keeps the container usable on short viewports where the subtraction bottoms out.
   The header stays pinned; a solid surface background keeps rows from bleeding through
   under the collapsed-border table header while scrolling. */
.import-status-scroll {
    min-block-size: 12rem;
    max-block-size: calc(100dvh - 16rem);
    overflow-y: auto;
}

.import-status-scroll thead th {
    position: sticky;
    inset-block-start: 0;
    z-index: 1;
    background-color: var(--tblr-bg-surface);
}

/* Advisory tab: importer-written text is plain text with meaningful line structure (CVE list,
   "## heading" blocks per CVE). It is NOT rendered as Markdown on purpose — it is untrusted
   third-party input, and Markdown to HTML would mean |raw on external content (see SEC-002 in
   _detail_row.html.twig). pre-wrap keeps the structure without any parsing; the capped height
   keeps a 5k-character kernel bundle from burying the provenance data below it.

   Tabler styles bare <pre> as a dark code block (near-white text on a dark surface). This is
   body copy, not code, so both the colour and the scrollbar tint have to be reset explicitly —
   overriding only the background leaves white-on-light text that is invisible in light mode. */
.advisory-text {
    max-block-size: 20rem;
    overflow-y: auto;
    padding: 0.75rem;
    border: 1px solid var(--tblr-border-color);
    border-radius: var(--tblr-border-radius);
    background: var(--tblr-bg-surface-secondary);
    color: var(--tblr-body-color);
    --tblr-scrollbar-color: var(--tblr-body-color);
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    font-family: inherit;
    font-size: 0.875rem;
}

/* A bare <summary> only shows its disclosure triangle while it stays display:list-item — any
   utility class that switches it to block silently removes the affordance. Hence an explicit
   chevron that rotates on open, plus link colouring, so "expandable" is never in doubt. */
details.advisory-block > summary {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    cursor: pointer;
    color: var(--tblr-primary);
    font-weight: var(--tblr-font-weight-medium);
    list-style: none;
}

details.advisory-block > summary::-webkit-details-marker {
    display: none;
}

details.advisory-block > summary:hover {
    text-decoration: underline;
}

.advisory-chevron {
    flex: 0 0 auto;
    transition: transform 0.15s ease-in-out;
}

details.advisory-block[open] > summary .advisory-chevron {
    transform: rotate(90deg);
}

@media (prefers-reduced-motion: reduce) {
    .advisory-chevron {
        transition: none;
    }
}
