/*
 * Shared SAST UI components.
 * Extends the workspace visual language without redefining base components.
 */

.sast-section {
    color: #2d3748;
}

.scan-details-page .page-header,
.scan-details-page .card,
.database-details-page .db-details-header,
.database-details-page .details-card {
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    background: #fff;
    box-shadow: none;
}

.scan-details-page .btn,
.database-details-page .btn {
    min-height: 40px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
}

.scan-details-page .btn.btn-sm,
.scan-details-page .btn.btn-small,
.database-details-page .btn.btn-sm,
.database-details-page .btn.btn-small {
    min-height: 40px;
    padding: 6px 12px;
    font-size: 12px;
}

.scan-details-page .page-subtitle,
.scan-details-page .meta-label,
.database-details-page .db-details-uuid,
.database-details-page .finding-complexity {
    color: #4a5568;
}

.scan-details-page .tabs-bar {
    max-width: 100%;
    overflow-x: auto;
    overscroll-behavior-inline: contain;
}

.scan-details-page .tab-btn {
    flex: 0 0 auto;
}

.sast-toolbar,
.sast-toolbar-actions,
.sast-finding-actions,
.sast-source-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.sast-toolbar {
    justify-content: space-between;
    margin: 20px 0 12px;
}

.sast-toolbar-actions select,
.sast-toolbar-actions input {
    min-height: 40px;
    border: 1px solid #cbd5e0;
    border-radius: 8px;
    background: #fff;
    color: #2d3748;
    padding: 8px 36px 8px 12px;
    font: inherit;
}

.sast-toolbar-actions select:focus-visible,
.sast-toolbar-actions input:focus-visible {
    outline: 3px solid rgba(102, 126, 234, 0.25);
    outline-offset: 1px;
    border-color: #667eea;
}

.sast-toolbar-title {
    margin: 0;
    color: #1a202c;
    font-size: 16px;
    font-weight: 600;
}

.sast-toolbar-count,
.sast-technical-id,
.sast-source-path,
.sast-source-meta {
    color: #4a5568;
    font-size: 12px;
}

.sast-technical-id,
.sast-source-path {
    font-family: Monaco, Menlo, Consolas, monospace;
    overflow-wrap: anywhere;
}

.sast-filter-label {
    color: #4a5568;
    font-size: 13px;
    font-weight: 600;
}

.sast-filter-chip {
    min-height: 40px;
    border: 1px solid #e2e8f0;
    border-radius: 999px;
    background: #fff;
    color: #2d3748;
    padding: 8px 12px;
    font: inherit;
    cursor: pointer;
}

.sast-filter-chip:hover {
    border-color: #cbd5e0;
    background: #f7fafc;
}

.sast-filter-chip.active,
.sast-filter-chip[aria-pressed="true"] {
    border-color: #667eea;
    background: #edf2ff;
    color: #44337a;
}

.semgrep-stat-card.sast-filter-chip {
    border-radius: 12px;
}

.sast-filter-chip:focus-visible,
.sast-code-viewer:focus-visible {
    outline: 3px solid rgba(102, 126, 234, 0.35);
    outline-offset: 2px;
}

.sast-table-wrap {
    width: 100%;
    overflow-x: auto;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    background: #fff;
}

.sast-table-wrap .data-table {
    min-width: 860px;
    margin: 0;
}

.sast-table-wrap .data-table th {
    color: #4a5568;
    font-size: 12px;
}

.sast-table-wrap .data-table td {
    vertical-align: top;
}

.sast-rule-title {
    display: block;
    color: #1a202c;
    font-weight: 600;
}

.sast-rule-id {
    display: block;
    margin-top: 2px;
    color: #4a5568;
    font-size: 12px;
}

.sast-finding-detail {
    display: grid;
    gap: 20px;
}

.sast-finding-heading {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
}

.sast-finding-heading h2 {
    margin: 0 0 4px;
    color: #1a202c;
    font-size: 20px;
    line-height: 1.35;
}

.sast-finding-heading-badges {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    flex-wrap: wrap;
}

.sast-finding-section {
    margin: 0;
}

.sast-finding-section > h3 {
    margin: 0 0 8px;
    color: #4a5568;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.sast-finding-section > p {
    margin: 0;
    color: #2d3748;
    font-size: 14px;
    line-height: 1.7;
    white-space: pre-wrap;
}

.sast-location-list {
    overflow: hidden;
    margin: 0;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
}

.sast-location-row {
    display: grid;
    grid-template-columns: minmax(90px, auto) minmax(0, 1fr);
    gap: 12px;
    align-items: baseline;
    padding: 10px 16px;
    border-bottom: 1px solid #edf2f7;
    font-size: 13px;
}

.sast-location-row:last-child {
    border-bottom: 0;
}

.sast-location-label {
    color: #4a5568;
    font-weight: 600;
}

.sast-location-value {
    min-width: 0;
    color: #2d3748;
}

.sast-location-value code {
    color: inherit;
    font-family: Monaco, Menlo, Consolas, monospace;
    font-size: 12px;
    overflow-wrap: anywhere;
}

.severity-badge {
    display: inline-flex;
    align-items: center;
    border-radius: 999px;
    padding: 4px 8px;
    font-size: 12px;
    font-weight: 700;
    line-height: 1.2;
}

.sast-code-viewer {
    position: relative;
    max-width: 100%;
    max-height: 380px;
    overflow: auto;
    border: 1px solid #2d3748;
    border-radius: 8px;
    background: #1a202c;
    color: #e2e8f0;
    font-family: Monaco, Menlo, Consolas, monospace;
    font-size: 13px;
    line-height: 1.6;
    overscroll-behavior: contain;
}

.sast-code-viewer--full {
    height: min(65vh, 760px);
    max-height: none;
}

.sast-code-table {
    width: max-content;
    min-width: 100%;
    border: 0;
    border-collapse: collapse;
    background: #1a202c;
    color: #e2e8f0;
    font: inherit;
}

.sast-code-line {
    background: #1a202c;
}

.sast-code-line.is-highlighted {
    background: #4a252b;
    box-shadow: inset 3px 0 #fc8181;
}

.sast-code-line-number {
    position: sticky;
    left: 0;
    z-index: 1;
    width: 1%;
    min-width: 52px;
    padding: 2px 12px;
    border-right: 1px solid rgba(255, 255, 255, 0.08);
    background: #171e2b;
    color: #a0aec0;
    text-align: right;
    user-select: none;
    white-space: nowrap;
}

.sast-code-line.is-highlighted .sast-code-line-number {
    background: #4a252b;
    color: #feb2b2;
}

.sast-code-line-content {
    min-width: 100%;
    padding: 2px 16px 2px 12px;
    color: #e2e8f0;
    text-align: left;
    white-space: pre;
}

.sast-code-line-content code {
    color: inherit;
    font: inherit;
}

.bsl-token-keyword {
    color: #b794f4;
    font-weight: 600;
}

.bsl-token-string {
    color: #9ae6b4;
}

.bsl-token-comment {
    color: #a0aec0;
    font-style: italic;
}

.bsl-token-number {
    color: #fbd38d;
}

.bsl-token-directive {
    color: #90cdf4;
}

.sast-code-empty {
    padding: 20px;
    color: #cbd5e0;
    text-align: center;
}

.sast-modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 9000;
    align-items: center;
    justify-content: center;
    padding: 16px;
    background: rgba(26, 32, 44, 0.55);
}

.sast-modal-overlay.is-open {
    display: flex;
}

.sast-modal-dialog {
    display: flex;
    width: min(960px, calc(100vw - 32px));
    max-width: min(960px, calc(100vw - 32px));
    max-height: 90vh;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    background: #fff;
    box-shadow: 0 20px 60px rgba(26, 32, 44, 0.28);
}

.sast-modal-dialog .modal-header,
.sast-modal-dialog .modal-body,
.sast-modal-dialog .modal-footer {
    padding-right: 24px;
    padding-left: 24px;
}

.sast-modal-dialog .modal-body {
    overflow: auto;
}

.sast-finding-tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 20px;
    border-bottom: 1px solid #e2e8f0;
}

.sast-finding-tab {
    padding: 10px 14px;
    border: 0;
    border-bottom: 2px solid transparent;
    background: transparent;
    color: #4a5568;
    font: inherit;
    font-weight: 600;
    cursor: pointer;
}

.sast-finding-tab.is-active {
    border-bottom-color: #805ad5;
    color: #6b46c1;
}

.sast-finding-tab:focus-visible {
    outline: 2px solid #805ad5;
    outline-offset: 2px;
}

.sast-ai-state {
    min-height: 160px;
}

.sast-ai-consent,
.sast-ai-unavailable,
.sast-ai-error,
.sast-ai-loading {
    padding: 24px;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    background: #f8fafc;
    text-align: center;
}

.sast-ai-consent p,
.sast-ai-unavailable p,
.sast-ai-error p {
    max-width: 620px;
    margin: 8px auto 16px;
    color: #4a5568;
}

.sast-ai-icon {
    margin-bottom: 8px;
    color: #805ad5;
    font-size: 32px;
}

.sast-ai-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.sast-ai-spinner {
    width: 20px;
    height: 20px;
    border: 2px solid #d6bcfa;
    border-top-color: #6b46c1;
    border-radius: 50%;
    animation: sast-ai-spin .8s linear infinite;
}

@keyframes sast-ai-spin {
    to { transform: rotate(360deg); }
}

.sast-ai-meta {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 16px;
    color: #718096;
    font-size: 12px;
}

.sast-ai-badge {
    padding: 3px 8px;
    border-radius: 999px;
    background: #e9d8fd;
    color: #553c9a;
    font-weight: 700;
}

.sast-ai-result section {
    margin-bottom: 18px;
}

.sast-ai-result h3 {
    margin: 0 0 6px;
    color: #2d3748;
    font-size: 14px;
}

.sast-ai-result p,
.sast-ai-result li {
    color: #2d3748;
    line-height: 1.65;
    overflow-wrap: anywhere;
}

.sast-ai-result ul {
    margin: 0;
    padding-left: 22px;
}

.sast-modal-dialog .modal-close,
.sast-modal-dialog .modal-close-btn {
    display: inline-flex;
    width: 40px;
    height: 40px;
    align-items: center;
    justify-content: center;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: #4a5568;
    font-size: 24px;
    cursor: pointer;
}

.sast-modal-dialog .modal-close:hover,
.sast-modal-dialog .modal-close-btn:hover {
    background: #edf2f7;
    color: #1a202c;
}

@media (max-width: 768px) {
    .sast-toolbar {
        align-items: stretch;
        flex-direction: column;
    }

    .sast-toolbar-actions {
        align-items: stretch;
        flex-direction: column;
    }

    .sast-toolbar-actions select,
    .sast-toolbar-actions input,
    .sast-toolbar-actions button {
        width: 100%;
        min-height: 40px;
    }

    .sast-finding-heading,
    .sast-finding-heading-badges {
        align-items: flex-start;
        flex-direction: column;
    }

    .sast-location-row {
        grid-template-columns: 1fr;
        gap: 4px;
    }

    .sast-code-viewer {
        font-size: 12px;
    }

    .sast-modal-overlay {
        padding: 8px;
    }

    .sast-modal-dialog {
        width: calc(100vw - 16px);
        max-width: calc(100vw - 16px);
        max-height: calc(100vh - 16px);
    }
}
