/* ==========================================================================
   sbom.day — Software Bill of Materials Dashboard
   Palette: #f8fafc #ffffff #e2e8f0 #f1f5f9 #0f172a #64748b #3b82f6
            #22c55e #f59e0b #ef4444
   Font: Inter (display + body), Source Code Pro (code)
   ========================================================================== */

*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --bg: #f8fafc;
    --surface: #ffffff;
    --surface-alt: #f1f5f9;
    --border: #e2e8f0;
    --text-primary: #0f172a;
    --text-secondary: #64748b;
    --blue: #3b82f6;
    --green: #22c55e;
    --amber: #f59e0b;
    --red: #ef4444;
    --sidebar-bg: #0f172a;
    --sidebar-text: #e2e8f0;
}

html, body {
    height: 100%;
}

body {
    background: var(--bg);
    color: var(--text-primary);
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    font-size: 0.875rem;
    line-height: 1.5;
    font-weight: 400;
    -webkit-font-smoothing: antialiased;
}

/* ==========================================================================
   Dashboard Layout
   ========================================================================== */

.dashboard {
    display: grid;
    grid-template-columns: 220px 1fr;
    min-height: 100vh;
}

/* ==========================================================================
   Sidebar
   ========================================================================== */

.sidebar {
    background: var(--sidebar-bg);
    color: var(--sidebar-text);
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,0.1) transparent;
}

.sidebar-header {
    padding: 24px 20px 20px;
    border-bottom: 1px solid rgba(226, 232, 240, 0.08);
}

.logo-mark {
    margin-bottom: 10px;
    opacity: 0.9;
}

.logo {
    font-size: 1.125rem;
    font-weight: 700;
    color: var(--blue);
    letter-spacing: -0.01em;
    line-height: 1.2;
}

.logo-tagline {
    font-size: 0.7rem;
    color: rgba(226, 232, 240, 0.4);
    margin-top: 3px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.sidebar-nav {
    padding: 12px 0;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 20px;
    color: rgba(226, 232, 240, 0.7);
    text-decoration: none;
    font-size: 0.8125rem;
    cursor: pointer;
    border-left: 3px solid transparent;
    transition: background 120ms ease, border-color 120ms ease, color 120ms ease;
    user-select: none;
}

.nav-icon {
    width: 14px;
    height: 14px;
    flex-shrink: 0;
    opacity: 0.7;
    transition: opacity 120ms;
}

.nav-item:hover {
    background: rgba(59, 130, 246, 0.08);
    color: rgba(226, 232, 240, 0.95);
}

.nav-item:hover .nav-icon { opacity: 1; }

.nav-item.active {
    background: rgba(59, 130, 246, 0.14);
    border-left-color: var(--blue);
    color: #93c5fd;
    font-weight: 600;
}

.nav-item.active .nav-icon { opacity: 1; }

.sidebar-footer {
    padding: 16px 20px;
    border-top: 1px solid rgba(226, 232, 240, 0.08);
}

.sidebar-meta {
    display: flex;
    flex-direction: column;
    margin-bottom: 8px;
}

.sidebar-meta:last-child { margin-bottom: 0; }

.meta-label {
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: rgba(226, 232, 240, 0.3);
    margin-bottom: 1px;
}

.meta-value {
    font-size: 0.75rem;
    color: rgba(226, 232, 240, 0.6);
    font-family: 'Source Code Pro', monospace;
}

/* ==========================================================================
   Main Content
   ========================================================================== */

.main-content {
    padding: 28px 36px;
    overflow-y: auto;
    min-height: 100vh;
}

/* ==========================================================================
   Tab Panels
   ========================================================================== */

.tab-panel {
    display: none;
}

.tab-panel.active {
    display: block;
}

/* ==========================================================================
   Top Bar
   ========================================================================== */

.top-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
    gap: 12px;
}

.top-bar-left {
    display: flex;
    align-items: baseline;
    gap: 12px;
}

.page-title {
    font-size: clamp(1.125rem, 2vw, 1.375rem);
    font-weight: 600;
    color: var(--text-primary);
    letter-spacing: -0.01em;
}

.date-label {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.top-bar-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.scan-status {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.75rem;
    color: var(--text-secondary);
    font-weight: 500;
    letter-spacing: 0.01em;
    padding: 4px 10px 4px 8px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 999px;
}

.scan-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--green);
    box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.55);
    animation: scanPulse 1.6s ease-out infinite;
}

@keyframes scanPulse {
    0%   { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.55); }
    70%  { box-shadow: 0 0 0 8px rgba(34, 197, 94, 0); }
    100% { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0); }
}

@media (prefers-reduced-motion: reduce) {
    .scan-dot { animation: none; }
}

.action-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 7px 14px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 0.8125rem;
    font-family: 'Inter', sans-serif;
    font-weight: 500;
    color: var(--text-primary);
    cursor: pointer;
    transition: background 120ms, border-color 120ms;
}

.action-btn:hover {
    background: var(--surface-alt);
    border-color: #cbd5e1;
}

/* ==========================================================================
   Summary Metric Cards
   ========================================================================== */

.summary-cards {
    display: flex;
    gap: 1rem;
    margin-bottom: 28px;
    flex-wrap: wrap;
}

.metric-card {
    flex: 1;
    min-width: 140px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    position: relative;
    overflow: hidden;
    transition: box-shadow 150ms;
}

.metric-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--border);
    border-radius: 8px 8px 0 0;
}

.metric-card:hover {
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}

.metric-value {
    font-size: 2rem;
    font-weight: 600;
    color: var(--text-primary);
    line-height: 1.1;
    letter-spacing: -0.02em;
}

.metric-label {
    font-size: 0.7375rem;
    color: var(--text-secondary);
    margin-top: 5px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    font-weight: 500;
}

.metric-trend {
    font-size: 0.72rem;
    font-weight: 500;
    margin-top: 10px;
    display: flex;
    align-items: center;
    gap: 4px;
}

.metric-trend.up { color: var(--green); }
.metric-trend.down { color: var(--red); }
.metric-trend.neutral { color: var(--text-secondary); }

/* Vulnerability severity card variants */
.vuln-critical::before { background: var(--red); }
.vuln-high::before { background: #f97316; }
.vuln-medium::before { background: var(--amber); }
.vuln-low::before { background: var(--green); }

/* ==========================================================================
   Severity Row (Overview)
   ========================================================================== */

.severity-row {
    display: grid;
    grid-template-columns: 1fr 260px;
    gap: 1rem;
    margin-bottom: 28px;
}

.section-label {
    font-size: 0.7375rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
    font-weight: 600;
    margin-bottom: 10px;
}

.severity-bar-container {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1rem 1.25rem;
}

.severity-bar {
    display: flex;
    height: 32px;
    border-radius: 6px;
    overflow: hidden;
    gap: 2px;
}

.sev-segment {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 8px;
    font-size: 0.7rem;
    font-weight: 600;
    color: #fff;
    transition: opacity 150ms;
    min-width: 60px;
}

.sev-segment.critical { background: #dc2626; }
.sev-segment.high { background: #ea580c; }
.sev-segment.medium { background: #d97706; }
.sev-segment.low { background: #16a34a; }

.sev-segment:hover { opacity: 0.88; }

.compliance-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1rem 1.25rem;
}

.compliance-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.compliance-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.8125rem;
    color: var(--text-primary);
}

.compliance-item.warn { color: var(--text-secondary); }

/* ==========================================================================
   Table Container
   ========================================================================== */

.table-container {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
    margin-bottom: 24px;
}

.table-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 20px;
    border-bottom: 1px solid var(--border);
    gap: 12px;
    flex-wrap: wrap;
}

.table-title {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-primary);
    flex-shrink: 0;
}

.table-subtitle {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.table-controls {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.search-input {
    padding: 6px 10px;
    border: 1px solid var(--border);
    border-radius: 5px;
    font-size: 0.8125rem;
    font-family: 'Inter', sans-serif;
    color: var(--text-primary);
    background: var(--bg);
    width: 200px;
    transition: border-color 120ms;
}

.search-input:focus {
    outline: none;
    border-color: var(--blue);
    background: var(--surface);
}

.search-input::placeholder { color: #94a3b8; }

.filter-select {
    padding: 6px 10px;
    border: 1px solid var(--border);
    border-radius: 5px;
    font-size: 0.8125rem;
    font-family: 'Inter', sans-serif;
    color: var(--text-primary);
    background: var(--bg);
    cursor: pointer;
    transition: border-color 120ms;
}

.filter-select:focus {
    outline: none;
    border-color: var(--blue);
}

/* ==========================================================================
   Data Table
   ========================================================================== */

.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table thead th {
    text-align: left;
    padding: 0.5rem 1rem;
    background: var(--surface-alt);
    border-bottom: 2px solid var(--border);
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-secondary);
    white-space: nowrap;
    user-select: none;
}

.data-table th.sortable {
    cursor: pointer;
    transition: color 120ms;
}

.data-table th.sortable:hover {
    color: var(--blue);
}

.data-table th.sortable:hover .sort-icon path {
    opacity: 0.8;
}

.data-table th.sort-asc .sort-icon path:first-child,
.data-table th.sort-desc .sort-icon path:last-child {
    opacity: 1;
    fill: var(--blue);
}

.data-table th.sort-asc,
.data-table th.sort-desc {
    color: var(--blue);
    background: #eff6ff;
    font-weight: 700;
}

.sort-icon {
    display: inline-block;
    vertical-align: middle;
    margin-left: 4px;
    color: var(--text-secondary);
}

.data-table td {
    padding: 0.625rem 1rem;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

.data-table tbody tr.data-row:last-child td {
    border-bottom: none;
}

.data-table tbody tr.data-row:nth-child(even) {
    background: #fafbfc;
}

.data-table tbody tr.data-row:hover {
    background: #f0f7ff;
    transition: background 80ms;
}

.col-expand {
    width: 40px;
}

/* ==========================================================================
   Code Inline
   ========================================================================== */

code {
    font-family: 'Source Code Pro', 'Fira Code', monospace;
    font-size: 0.8rem;
    background: var(--surface-alt);
    color: #334155;
    padding: 2px 6px;
    border-radius: 3px;
    border: 1px solid var(--border);
    white-space: nowrap;
}

/* ==========================================================================
   Badges
   ========================================================================== */

.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.675rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    white-space: nowrap;
}

.badge-low     { background: #dcfce7; color: #166534; }
.badge-medium  { background: #fef3c7; color: #92400e; }
.badge-high    { background: #ffedd5; color: #9a3412; }
.badge-critical{ background: #fee2e2; color: #991b1b; }

/* ==========================================================================
   Ecosystem Tags
   ========================================================================== */

.ecosystem-tag {
    display: inline-block;
    padding: 2px 7px;
    border-radius: 3px;
    font-size: 0.675rem;
    font-weight: 600;
    text-transform: lowercase;
    letter-spacing: 0.02em;
}

.ecosystem-tag.npm    { background: #fef2f2; color: #cc1415; border: 1px solid #fecaca; }
.ecosystem-tag.pypi   { background: #eff6ff; color: #1d4ed8; border: 1px solid #bfdbfe; }
.ecosystem-tag.system { background: #f0fdf4; color: #15803d; border: 1px solid #bbf7d0; }

/* ==========================================================================
   Status Badges
   ========================================================================== */

.status-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.675rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.status-open   { background: #fee2e2; color: #991b1b; }
.status-review { background: #fef3c7; color: #92400e; }
.status-pass   { background: #dcfce7; color: #166534; }

/* ==========================================================================
   Expand Button & Detail Rows
   ========================================================================== */

.expand-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    background: none;
    border: 1px solid var(--border);
    border-radius: 5px;
    cursor: pointer;
    color: var(--text-secondary);
    transition: background 120ms, border-color 120ms, color 120ms;
}

.expand-btn:hover {
    background: #eff6ff;
    border-color: var(--blue);
    color: var(--blue);
}

.expand-icon {
    transition: transform 200ms ease;
}

.expand-btn.is-open .expand-icon {
    transform: rotate(180deg);
}

.detail-row {
    background: var(--surface-alt);
}

.detail-row.hidden {
    display: none;
}

.detail-content {
    padding: 14px 16px;
    border-top: 1px solid var(--border);
    opacity: 1;
    transition: opacity 200ms ease;
}

.detail-content.fade-in {
    animation: fadeIn 200ms ease forwards;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-4px); }
    to   { opacity: 1; transform: translateY(0); }
}

.detail-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.detail-section h4.detail-heading {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-secondary);
    font-weight: 600;
    margin-bottom: 8px;
}

.detail-section p {
    font-size: 0.8125rem;
    color: var(--text-primary);
    margin-bottom: 4px;
    line-height: 1.5;
}

/* ==========================================================================
   Dependency Tree
   ========================================================================== */

.dep-tree {
    display: flex;
    flex-direction: column;
    gap: 3px;
    font-family: 'Source Code Pro', monospace;
    font-size: 0.775rem;
    color: var(--text-secondary);
}

.dep-item {
    display: block;
    line-height: 1.6;
}

.dep-root {
    color: var(--text-primary);
    font-weight: 600;
    margin-bottom: 2px;
}

.dep-indent {
    padding-left: 24px;
}

/* ==========================================================================
   CVE List
   ========================================================================== */

.cve-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.cve-entry {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.8125rem;
}

.cve-id {
    font-family: 'Source Code Pro', monospace;
    font-size: 0.775rem;
    color: var(--text-primary);
    font-weight: 500;
}

.cve-desc {
    color: var(--text-secondary);
}

.cve-count {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-align: center;
}

/* ==========================================================================
   Table Footer / Pagination
   ========================================================================== */

.table-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 20px;
    border-top: 1px solid var(--border);
    background: var(--surface-alt);
}

.table-count {
    font-size: 0.775rem;
    color: var(--text-secondary);
}

.pagination {
    display: flex;
    align-items: center;
    gap: 4px;
}

.page-btn {
    padding: 4px 10px;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--surface);
    font-size: 0.775rem;
    font-family: 'Inter', sans-serif;
    color: var(--text-primary);
    cursor: pointer;
    transition: background 120ms, border-color 120ms;
}

.page-btn:hover { background: var(--surface-alt); }
.page-btn.active {
    background: var(--blue);
    border-color: var(--blue);
    color: #fff;
    font-weight: 600;
}

.page-ellipsis {
    font-size: 0.775rem;
    color: var(--text-secondary);
    padding: 0 4px;
}

/* ==========================================================================
   Ecosystem Cards (Components Tab)
   ========================================================================== */

.ecosystem-cards {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
    margin-bottom: 24px;
}

.ecosystem-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.ecosystem-icon {
    width: 36px;
    height: 36px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.6875rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.npm-icon    { background: #fef2f2; color: #cc1415; border: 1px solid #fecaca; }
.pypi-icon   { background: #eff6ff; color: #1d4ed8; border: 1px solid #bfdbfe; }
.system-icon { background: #f0fdf4; color: #15803d; border: 1px solid #bbf7d0; }

.ecosystem-stats {
    display: flex;
    flex-direction: column;
}

.eco-count {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text-primary);
    line-height: 1.2;
    letter-spacing: -0.01em;
}

.eco-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-top: 2px;
}

.eco-bar {
    height: 5px;
    background: var(--border);
    border-radius: 3px;
    overflow: hidden;
}

.eco-fill {
    height: 100%;
    background: var(--blue);
    border-radius: 3px;
    transition: width 600ms ease;
}

/* ==========================================================================
   License Distribution
   ========================================================================== */

.license-overview {
    display: grid;
    gap: 1rem;
}

.inline-bar {
    display: inline-block;
    width: 80px;
    height: 6px;
    background: var(--border);
    border-radius: 3px;
    overflow: hidden;
    vertical-align: middle;
    margin-left: 8px;
}

.inline-fill {
    height: 100%;
    background: var(--blue);
    border-radius: 3px;
}

/* ==========================================================================
   Responsive
   ========================================================================== */

@media (max-width: 900px) {
    .dashboard {
        grid-template-columns: 1fr;
    }

    .sidebar {
        position: relative;
        height: auto;
        padding: 12px 0;
    }

    .sidebar-header {
        padding: 12px 16px 12px;
    }

    .sidebar-nav {
        flex-direction: row;
        overflow-x: auto;
        padding: 4px 8px;
        gap: 2px;
    }

    .nav-item {
        border-left: none;
        border-bottom: 3px solid transparent;
        white-space: nowrap;
        padding: 8px 12px;
    }

    .nav-item.active {
        border-left-color: transparent;
        border-bottom-color: var(--blue);
    }

    .sidebar-footer {
        display: none;
    }

    .main-content {
        padding: 20px 16px;
    }

    .summary-cards {
        flex-direction: column;
    }

    .severity-row {
        grid-template-columns: 1fr;
    }

    .detail-grid {
        grid-template-columns: 1fr;
    }

    .ecosystem-cards {
        grid-template-columns: 1fr;
    }

    .search-input { width: 100%; }
}

@media (max-width: 600px) {
    .top-bar { flex-direction: column; align-items: flex-start; }
    .top-bar-left { flex-direction: column; gap: 4px; }
    .table-header { flex-direction: column; align-items: flex-start; }
}
