/* Theme Variables */
:root[data-theme="dark"] {
    --bg: #0d1117;
    --surface: #161b22;
    --surface2: #1c2129;
    --surface-hover: #21262d;
    --border: #30363d;
    --text: #e6edf3;
    --text-muted: #8b949e;
    --critical: #f85149;
    --high: #f0883e;
    --medium: #d29922;
    --low: #3fb950;
    --info: #58a6ff;
    --undefined: #8b949e;
    --accent: #1f6feb;
    --sidebar-bg: #0d1117;
    --modal-overlay: rgba(0, 0, 0, 0.75);
}

:root[data-theme="light"] {
    --bg: #ffffff;
    --surface: #f6f8fa;
    --surface2: #ffffff;
    --surface-hover: #f3f4f6;
    --border: #d0d7de;
    --text: #24292f;
    --text-muted: #57606a;
    --critical: #d1242f;
    --high: #d97917;
    --medium: #bf8700;
    --low: #1a7f37;
    --info: #0969da;
    --undefined: #656d76;
    --accent: #0969da;
    --sidebar-bg: #f6f8fa;
    --modal-overlay: rgba(101, 109, 118, 0.5);
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    overflow-x: hidden;
}

/* Header */
.dashboard-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 24px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-left h1 {
    font-size: 20px;
    font-weight: 600;
    margin-bottom: 4px;
}

.header-meta {
    font-size: 13px;
    color: var(--text-muted);
}

/* Theme Toggle */
.theme-toggle {
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 8px 12px;
    cursor: pointer;
    font-size: 18px;
    transition: all 0.2s;
}

.theme-toggle:hover {
    background: var(--surface-hover);
}

/* Loading Screen */
.loading-screen {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 400px;
    color: var(--text-muted);
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 16px;
}

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

/* Main Layout */
.main-layout {
    display: flex;
    min-height: calc(100vh - 73px);
}

/* Sidebar */
.sidebar {
    width: 280px;
    background: var(--sidebar-bg);
    border-right: 1px solid var(--border);
    padding: 20px;
    overflow-y: auto;
    position: sticky;
    top: 73px;
    height: calc(100vh - 73px);
    transition: transform 0.3s ease, margin-left 0.3s ease;
}

.sidebar.collapsed {
    transform: translateX(-100%);
    margin-left: -280px;
}

/* Sidebar Toggle Button */
.sidebar-toggle {
    position: fixed;
    left: 280px;
    top: 50%;
    transform: translateY(-50%);
    z-index: 99;
    background: var(--surface);
    border: 1px solid var(--border);
    border-left: none;
    border-radius: 0 6px 6px 0;
    padding: 12px 8px;
    cursor: pointer;
    transition: left 0.3s ease;
    box-shadow: 2px 0 8px rgba(0,0,0,0.1);
}

.sidebar-toggle:hover {
    background: var(--surface-hover);
}

.sidebar-toggle .toggle-icon {
    display: block;
    font-size: 16px;
    transition: transform 0.3s ease;
}

.sidebar.collapsed ~ .sidebar-toggle {
    left: 0;
}

.sidebar.collapsed ~ .sidebar-toggle .toggle-icon {
    transform: rotate(180deg);
}

.sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.sidebar-header h3 {
    font-size: 16px;
    font-weight: 600;
}

.btn-link {
    background: none;
    border: none;
    color: var(--accent);
    cursor: pointer;
    font-size: 13px;
    padding: 4px;
}

.btn-link:hover {
    text-decoration: underline;
}

/* Project List */
.project-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.project-item {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 12px;
    cursor: pointer;
    transition: all 0.2s;
}

.project-item:hover {
    background: var(--surface-hover);
}

.project-item.selected {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
}

.project-item.selected .project-meta {
    color: rgba(255, 255, 255, 0.8);
}

.project-checkbox {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}

.project-checkbox input[type="checkbox"] {
    width: 16px;
    height: 16px;
    cursor: pointer;
}

.project-name {
    font-weight: 500;
    font-size: 14px;
}

.project-meta {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 4px;
}

.project-stats {
    display: flex;
    gap: 12px;
    margin-top: 8px;
    font-size: 12px;
}

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

.stat-critical { color: var(--critical); }
.stat-high { color: var(--high); }

/* Main Content */
.main-content {
    flex: 1;
    padding: 24px;
    overflow-y: auto;
    transition: margin-left 0.3s ease;
}

.sidebar.collapsed ~ .main-content {
    margin-left: 0;
}

/* Summary Section */
.summary-section h2 {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.summary-count {
    font-size: 14px;
    color: var(--text-muted);
    font-weight: 400;
}

.summary-cards {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    margin-bottom: 24px;
}

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 16px;
    display: flex;
    flex-direction: column;
    min-width: 140px;
    flex: 0 1 auto;
}
    align-items: center;
    gap: 8px;
}

.card .count {
    font-size: 32px;
    font-weight: 600;
}

.card .label {
    font-size: 13px;
    color: var(--text-muted);
    text-align: center;
}

.card.critical .count { color: var(--critical); }
.card.high .count { color: var(--high); }
.card.medium .count { color: var(--medium); }
.card.low .count { color: var(--low); }
.card.total .count { color: var(--accent); }

/* Metric Cards (for trends view) */
.metric-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 20px 24px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    min-width: 180px;
    flex: 0 1 auto;
}

.metric-label {
    font-size: 13px;
    color: var(--text-muted);
    font-weight: 500;
    text-align: center;
}

.metric-value {
    font-size: 32px;
    font-weight: 600;
    color: var(--text);
    text-align: center;
}

.metric-sublabel {
    font-size: 12px;
    color: var(--text-muted);
    text-align: center;
}

/* Charts */
.charts-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
    margin-bottom: 24px;
}

.chart-container {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 20px;
}

.chart-container.chart-wide {
    grid-column: 1 / -1;
}

.chart-container h3 {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 16px;
}

.chart-canvas-wrap {
    position: relative;
    height: 300px;
}

/* Resource Tabs */
.resource-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
    border-bottom: 1px solid var(--border);
}

.resource-tab {
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    padding: 12px 16px;
    transition: all 0.2s;
}

.resource-tab:hover {
    color: var(--text);
}

.resource-tab.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
}

/* Filters */
.filters-row {
    display: flex;
    gap: 12px;
    margin-bottom: 16px;
}

.search-box-container {
    flex: 1;
}

.search-box {
    width: 100%;
    padding: 10px 12px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text);
    font-size: 14px;
}

.search-box:focus {
    outline: none;
    border-color: var(--accent);
}

/* View Containers */
.view-container {
    display: none;
}

.view-container.active {
    display: block;
}

/* Tables */
.table-container {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
}

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

.resource-table thead {
    background: var(--surface2);
}

.resource-table th {
    padding: 12px;
    text-align: left;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
}

.resource-table th.sortable {
    cursor: pointer;
    user-select: none;
}

.resource-table th.sortable:hover {
    color: var(--text);
}

.resource-table td {
    padding: 12px;
    font-size: 14px;
    border-bottom: 1px solid var(--border);
}

.resource-table tbody tr:hover {
    background: var(--surface-hover);
}

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

.resource-name {
    font-weight: 500;
    color: var(--accent);
    cursor: pointer;
}

.resource-name:hover {
    text-decoration: underline;
}

.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
}

.badge.critical { background: var(--critical); color: white; }
.badge.high { background: var(--high); color: white; }
.badge.medium { background: var(--medium); color: white; }
.badge.low { background: var(--low); color: white; }

/* Severity column styling in tables */
.resource-table th.critical,
.resource-table td.critical {
    color: var(--critical);
}

.resource-table th.high,
.resource-table td.high {
    color: var(--high);
}

.resource-table th.medium,
.resource-table td.medium {
    color: var(--medium);
}

.resource-table th.low,
.resource-table td.low {
    color: var(--low);
}

/* Timeframe Selector */
.timeframe-selector {
    display: flex;
    gap: 0;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 6px;
    overflow: hidden;
}

.timeframe-btn {
    padding: 8px 16px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-muted);
    background: transparent;
    border: none;
    border-right: 1px solid var(--border);
    cursor: pointer;
    transition: all 0.2s;
}

.timeframe-btn:last-child {
    border-right: none;
}

.timeframe-btn:hover {
    background: var(--surface-hover);
    color: var(--text);
}

.timeframe-btn.active {
    background: var(--accent);
    color: white;
}

/* CVE View */
.cve-grid {
    display: grid;
    gap: 16px;
}

.cve-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 16px;
    cursor: pointer;
    transition: all 0.2s;
}

.cve-card:hover {
    background: var(--surface-hover);
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}

.cve-header {
    display: flex;
    justify-content: space-between;
    align-items: start;
    margin-bottom: 8px;
}

.cve-id {
    font-weight: 600;
    font-size: 16px;
    color: var(--accent);
}

.cve-description {
    color: var(--text-muted);
    font-size: 14px;
    margin-bottom: 12px;
    line-height: 1.5;
}

.cve-details {
    display: flex;
    gap: 16px;
    font-size: 13px;
    color: var(--text-muted);
}

.cve-affected {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--border);
    font-size: 13px;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background: var(--modal-overlay);
    backdrop-filter: blur(4px);
}

.modal.active {
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background: var(--surface);
    border-radius: 12px;
    max-width: 1200px;
    width: 95%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 24px;
    border-bottom: 1px solid var(--border);
}

.modal-header h2 {
    font-size: 20px;
    font-weight: 600;
}

.modal-close {
    background: none;
    border: none;
    font-size: 28px;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-close:hover {
    color: var(--text);
}

.modal-body {
    padding: 24px;
}

.modal-section {
    margin-bottom: 24px;
}

.modal-section h3 {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 12px;
}

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

.affected-resource-item {
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 12px;
}

.resource-type-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 500;
    text-transform: uppercase;
    margin-right: 8px;
}

.resource-type-badge.ecr {
    background: rgba(88, 166, 255, 0.2);
    color: var(--info);
}

.resource-type-badge.lambda {
    background: rgba(63, 185, 80, 0.2);
    color: var(--low);
}

/* Pagination */
.pagination-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-top: none;
    border-radius: 0 0 8px 8px;
    font-size: 14px;
}

.pagination-info {
    color: var(--text-muted);
}

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

.pagination-btn {
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 6px 12px;
    cursor: pointer;
    color: var(--text);
    font-size: 14px;
    transition: all 0.2s;
}

.pagination-btn:hover:not(:disabled) {
    background: var(--surface-hover);
}

.pagination-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.pagination-btn.active {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
}

.items-per-page {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-muted);
}

.items-per-page select {
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 6px 8px;
    color: var(--text);
    cursor: pointer;
}

/* Modal Search */
.modal-search {
    margin-bottom: 16px;
}

.modal-search input {
    width: 100%;
    padding: 10px 12px;
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text);
    font-size: 14px;
}

.modal-search input:focus {
    outline: none;
    border-color: var(--accent);
}

.search-results-info {
    font-size: 13px;
    color: var(--text-muted);
    margin-bottom: 12px;
}
@media (max-width: 1024px) {
    .sidebar {
        width: 240px;
    }
}

@media (max-width: 768px) {
    .main-layout {
        flex-direction: column;
    }

    .sidebar {
        width: 100%;
        height: auto;
        position: relative;
        top: 0;
    }

    .sidebar.collapsed {
        transform: translateY(-100%);
        margin-left: 0;
        margin-top: -100%;
    }

    .sidebar-toggle {
        left: 50%;
        top: auto;
        bottom: 20px;
        transform: translateX(-50%);
        border-radius: 6px;
        border: 1px solid var(--border);
    }

    .sidebar.collapsed ~ .sidebar-toggle {
        left: 50%;
        bottom: 20px;
    }

    .summary-cards {
        grid-template-columns: repeat(2, 1fr);
    }

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

    .chart-container.chart-wide {
        grid-column: 1;
    }
}
