/* ---- Base & Variables ---- */
:root {
    --primary-bg: #0f172a;       /* Dark slate base */
    --secondary-bg: #1e293b;     /* Soft blue-gray */
    --accent-color: #6366f1;     /* Calmer indigo */
    --text-primary: #f8fafc;     /* Bright white */
    --text-secondary: #94a3b8;   /* Soft gray for secondary text */
    --border-color: #334155;     /* Subtle border color */
    --severity-critical: #ef4444;
    --severity-high: #f59e0b;
    --severity-medium: #facc15;
    --severity-low: #3b82f6;
    --severity-unknown: #94a3b8;
}

body {
    background-color: var(--primary-bg);
    color: var(--text-primary);
    font-family: 'Inter', system-ui, sans-serif;
    line-height: 1.5;
    margin: 0;
}

/* ---- Core Layout (Header, Sidenav, Footer) ---- */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background-color: var(--secondary-bg);
    padding: 12px 25px;
    position: sticky;
    top: 0;
    z-index: 1000;
    border-bottom: 1px solid var(--border-color);
    transition: margin-left 0.3s;
}
.header-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    color: var(--text-primary);
    font-weight: 600;
    font-size: 1.2rem;
}
.header-logo img { width: 35px; height: 35px; }
.nav-items a {
    text-decoration: none;
    color: var(--text-secondary);
    font-size: 1rem;
    padding: 8px 12px;
    border-radius: 6px;
    transition: all 0.2s ease;
}
.nav-items a:hover { background-color: var(--primary-bg); color: var(--accent-color); }
.menu-icon { font-size: 28px; color: var(--accent-color); cursor: pointer; display: none; }

.sidenav {
    height: 100%;
    width: 250px;
    position: fixed;
    top: 0;
    left: -250px;
    background-color: var(--secondary-bg);
    padding-top: 60px;
    transition: 0.3s;
    z-index: 1002;
}
.sidenav a {
    padding: 10px 15px 10px 25px;
    text-decoration: none;
    font-size: 18px;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 15px;
}
.sidenav a:hover { background-color: var(--accent-color); }
.sidenav .closebtn { position: absolute; top: 0; right: 25px; font-size: 36px; margin-left: 50px; }

.main { margin-left: 0; padding: 20px; transition: margin-left 0.3s; min-height: calc(100vh - 120px); }
footer {
    background-color: var(--secondary-bg);
    padding: 1rem 0rem 2rem 2rem;
    font-size: 0.95rem;
    font-family: var(--font-primary);
}

footer a {
    color: var(--text-secondary);
    text-decoration: none;
    transition: color var(--transition-time);
    user-select: text;
}

footer a:hover,
footer a:focus {
    color: var(--accent-color);
    text-decoration: underline;
    outline: none;
}

footer .footer-content {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 2rem;
}

footer .footer-col {
    flex: 1 1 280px;
    margin-bottom: 1.5rem;
}

footer .footer-col img {
    height: 60px;
    margin-bottom: 1rem;
    margin-top: 2rem;
    filter: brightness(1.1);
}

footer .footer-col h5 {
    font-size: 1.2rem;
    font-weight: 700;
    margin-bottom: 1rem;
    color: var(--text-primary);
    user-select: text;
}

footer .footer-col p {
    margin: 0.4rem 0;
    user-select: text;
}

footer .footer-col small {
    display: block;
    color: #ccc;
    margin-bottom: 0.75rem;
    font-weight: 500;
    user-select: text;
}

footer .footer-col a {
    color: #d9eac7;
    font-weight: 600;
    text-decoration: none;
    transition: all 0.3s ease;
}

footer .footer-col a:hover {
    color: var(--color-primary-light);
    text-decoration: underline;
}

footer .footer-col i {
    margin-right: 0.5rem;
    color: var(--color-primary);
}

footer .footer-col a[target="_blank"]::after {
    content: " ↗";
    font-size: 0.85rem;
}

.footer-bottom {
    text-align: center;
    font-size: 0.85rem;
    color: #aab093;
    margin-top: 2rem;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    padding-top: 1rem;
}
.popup { /* Your popup styles */ }
.dashboard-container { max-width: 1400px; margin: 0 auto; padding: 2rem; }

/* ---- Page-Specific & Component Styles ---- */
.hero-section { text-align: center; padding: 2rem 1rem; margin-bottom: 2rem; }
.hero-section h1 { font-size: 2.5rem; font-weight: 700; color: var(--text-primary); margin-bottom: 0.5rem; }
.hero-section .subtitle { font-size: 1.15rem; color: var(--text-secondary); max-width: 700px; margin: 0 auto; }

.info-cards-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 1.5rem; margin: 2rem 0; }
.info-card { background: var(--secondary-bg); padding: 1.5rem; border-radius: 8px; border: 1px solid var(--border-color); text-align: center; }
.card-icon { font-size: 2rem; margin-bottom: 1rem; color: var(--accent-color); }
.info-card h3 { color: var(--text-primary); margin: 0.5rem 0; font-size: 1.25rem; }
.info-card p { color: var(--text-secondary); font-size: 0.95rem; line-height: 1.5; margin: 0.5rem 0 1rem; }

.search-form .search-header { background: var(--secondary-bg); padding: 1.5rem; border-radius: 8px; margin-bottom: 2rem; border: 1px solid var(--border-color); }
.search-form .search-box { display: flex; gap: 1rem; }
.search-form .search-input { flex: 1; padding: 0.8rem 1.2rem; border: 1px solid var(--border-color); border-radius: 6px; background: var(--primary-bg); color: var(--text-primary); font-size: 1rem; }
.w3-button.w3-blue { background: var(--accent-color); color: white; border: none; padding: 0.8rem 1.5rem; border-radius: 6px; font-weight: 500; transition: all 0.2s ease; cursor: pointer; }
.w3-button.w3-blue:hover { background: #4f46e5; }

.table-header { display: flex; justify-content: space-between; align-items: center; margin: 2.5rem 0 1rem 0; padding-bottom: 0.5rem; border-bottom: 1px solid var(--border-color); }
.table-header h2 { font-size: 1.5rem; color: var(--text-primary); margin: 0; }
.view-all-link { color: var(--accent-color); text-decoration: none; font-weight: 500; transition: color 0.2s ease; }
.view-all-link:hover { color: var(--text-primary); }

.table-wrapper { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.vuln-table { width: 100%; border-collapse: collapse; background: var(--secondary-bg); border-radius: 8px; overflow: hidden; margin: 2rem 0; border: 1px solid var(--border-color); }
.vuln-table th, .vuln-table td { padding: 1rem; text-align: left; border-bottom: 1px solid var(--border-color); }
.vuln-table th { background: var(--primary-bg); font-weight: 600; color: var(--accent-color); }
.vuln-table a { color: var(--accent-color); text-decoration: none; }
.vuln-table a:hover { text-decoration: underline; }
.no-results-cell { text-align: center; padding: 2rem; color: var(--text-secondary); }

.severity-critical { color: var(--severity-critical); }
.severity-high { color: var(--severity-high); }
.severity-medium { color: var(--severity-medium); }
.severity-low { color: var(--severity-low); }
.severity-unknown { color: var(--severity-unknown); }

.classification-tag { padding: 4px 10px; border-radius: 12px; font-size: 0.8em; font-weight: bold; }
.tag-esv { background-color: rgba(99, 102, 241, 0.2); color: var(--accent-color); }
.tag-gpsv { background-color: rgba(148, 163, 184, 0.2); color: var(--text-secondary); }
.tag-unc { background-color: rgba(148, 163, 184, 0.2); color: var(--text-secondary); }

.pagination { text-align: center; margin: 2rem 0; }
.pagination .step-links a { color: var(--accent-color); text-decoration: none; padding: 5px 10px; border: 1px solid var(--border-color); border-radius: 4px; margin: 0 4px; }
.pagination .step-links a:hover { background: var(--accent-color); color: white; }
.pagination .current-page { margin: 0 10px; color: var(--text-secondary); }

/* ---- Vulnerability Detail Page Styles ---- */
.vuln-detail-header { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 1rem; margin-bottom: 1.5rem; padding-bottom: 1.5rem; border-bottom: 1px solid var(--border-color); }
.vuln-detail-header h1 { font-size: 2.25rem; font-weight: 600; margin: 0; }
.severity-badge { display: flex; align-items: center; gap: 0.75rem; padding: 0.5rem 1rem; border-radius: 8px; font-weight: bold; }
.severity-badge .score { background-color: rgba(0, 0, 0, 0.2); padding: 0.25rem 0.5rem; border-radius: 4px; font-size: 1.1rem; }
.severity-badge.severity-critical { background-color: var(--severity-critical); color: white; }
.severity-badge.severity-high { background-color: var(--severity-high); color: #1e293b; }
.severity-badge.severity-medium { background-color: var(--severity-medium); color: #1e293b; }
.severity-badge.severity-low { background-color: var(--severity-low); color: white; }
.severity-badge.severity-unknown { background-color: var(--severity-unknown); color: var(--primary-bg); }

.analysis-box { display: flex; align-items: center; gap: 1.5rem; background-color: var(--secondary-bg); border-left: 5px solid; padding: 1.5rem; border-radius: 8px; margin-bottom: 2rem; }
.classification-esv { border-color: var(--accent-color); }
.classification-gpsv { border-color: var(--text-secondary); }
.analysis-icon { font-size: 2.5rem; }
.classification-esv .analysis-icon { color: var(--accent-color); }
.classification-gpsv .analysis-icon { color: var(--text-secondary); }
.analysis-text h2 { margin: 0 0 0.5rem 0; font-size: 1.25rem; color: var(--text-primary); }
.analysis-text p { margin: 0; color: var(--text-secondary); line-height: 1.5; }

.details-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 1.5rem; margin-bottom: 2rem; }
.detail-item { background: var(--secondary-bg); padding: 1rem; border-radius: 6px; }
.detail-label { display: block; font-size: 0.9rem; color: var(--text-secondary); margin-bottom: 0.5rem; }
.detail-value { font-size: 1rem; font-weight: 500; }
.vector-string { font-family: 'Fira Code', 'Jetbrains Mono', monospace; font-size: 0.9rem; word-break: break-all; }

.description-section, .vendors-section { margin-bottom: 2rem; }
.description-section h2, .vendors-section h2 { padding-bottom: 0.5rem; border-bottom: 1px solid var(--border-color); margin-bottom: 1rem; font-size: 1.5rem; }
.description-section p { line-height: 1.6; color: var(--text-secondary); }
.vendor-tags { display: flex; flex-wrap: wrap; gap: 0.75rem; }
.vendor-tag { background-color: var(--secondary-bg); color: var(--text-secondary); padding: 0.3rem 0.8rem; border-radius: 15px; font-size: 0.85rem; border: 1px solid var(--border-color); }

/* ---- Responsive Styles ---- */
@media (max-width: 992px) {
    .header .nav-items { display: none; }
    .header .menu-icon { display: block; }
}
@media (max-width: 768px) {
    .vuln-table thead { display: none; }
    .vuln-table tr { display: block; border-bottom: 2px solid var(--accent-color); margin-bottom: 1.5rem; }
    .vuln-table td { display: block; text-align: right; border-bottom: 1px dotted var(--border-color); }
    .vuln-table td:last-child { border-bottom: none; }
    .vuln-table td::before { content: attr(data-label); float: left; font-weight: bold; color: var(--text-secondary); }
    .hero-section h1 { font-size: 2rem; }
}

/* --- Advanced Search and Filter Layout --- */
.list-page-grid {
    display: grid;
    grid-template-columns: 280px 1fr; /* Sidebar and main content */
    gap: 2rem;
    align-items: flex-start;
}

.filter-sidebar {
    position: sticky;
    top: 80px; /* Adjust based on your header height */
}

.advanced-filter-form {
    background: var(--secondary-bg);
    padding: 1.5rem;
    border-radius: 8px;
}

.advanced-filter-form h3 {
    margin-top: 0;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 0.75rem;
    margin-bottom: 1.5rem;
}

.form-group {
    margin-bottom: 1.25rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 0.6rem;
    background: var(--primary-bg);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    border-radius: 4px;
    font-size: 1rem;
}

select.select-multiple {
    height: 150px; /* Give the multi-select box a fixed height */
}

.form-help-text {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin: -0.25rem 0 0.5rem 0;
}

.form-actions {
    margin-top: 2rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.clear-filters-link {
    text-align: center;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.9rem;
}
.clear-filters-link:hover {
    color: var(--accent-color);
}

/* Responsive adjustments for the filter grid */
@media (max-width: 992px) {
    .list-page-grid {
        grid-template-columns: 1fr; /* Stack on smaller screens */
    }
    .filter-sidebar {
        position: static; /* Unstick the sidebar */
    }
}

/* --- New Dashboard Styles --- */

.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}
.kpi-card {
    background: var(--secondary-bg);
    padding: 1.5rem;
    border-radius: 8px;
    text-align: center;
}
.kpi-value {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--accent-color);
    line-height: 1.2;
}
.kpi-value.text-value { font-size: 1.5rem; padding-top: 1rem; }
.kpi-label { font-size: 0.9rem; color: var(--text-secondary); margin-top: 0.5rem; }

.charts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2.5rem;
}
.chart-container {
    background: var(--secondary-bg);
    padding: 1.5rem;
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    min-height: 350px;
}
.chart-container h3 {
    margin-top: 0;
    margin-bottom: 1rem;
    font-size: 1.1rem;
    font-weight: 500;
    color: var(--text-secondary);
    flex-shrink: 0;
}

.chart-wrapper {
    position: relative;
    flex-grow: 1;
}

.hot-lists-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}
.hot-list-container {
    background: var(--secondary-bg);
    padding: 1.5rem;
    border-radius: 8px;
}
.hot-list-container h3 {
    margin-top: 0;
    margin-bottom: 1rem;
    font-size: 1.1rem;
    font-weight: 500;
    color: var(--text-secondary);
}
.top-vendor-list {
    list-style: none;
    padding: 0;
    margin: 0;
}
.top-vendor-list li {
    display: flex;
    justify-content: space-between;
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--border-color);
}
.top-vendor-list li:last-child { border-bottom: none; }
.vendor-name { font-weight: 500; }
.vendor-count { color: var(--text-secondary); }

.mini-vuln-table .mini-vuln-row {
    display: flex;
    justify-content: space-between;
    padding: 0.5rem 0;
}
.mini-vuln-table a { color: var(--text-primary); text-decoration: none; font-family: 'Fira Code', monospace; }
.mini-vuln-table a:hover { color: var(--accent-color); }

/* Responsive Adjustments for Dashboard */
@media (max-width: 992px) {
    .charts-grid {
        grid-template-columns: 2fr 1g; /* Stack charts */
    }
}

.sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5); /* Semi-transparent black */
    z-index: 1001; /* Sits just below the sidebar */
    opacity: 0;
    visibility: hidden; /* Completely hidden and not interactable */
    transition: opacity 0.3s ease-in-out, visibility 0.3s ease-in-out;
}

/* When the body has the 'sidebar-open' class, do the following: */
body.sidebar-open .sidenav {
    left: 0; /* Slide the sidebar into view */
}

body.sidebar-open .sidebar-overlay {
    opacity: 1;
    visibility: visible; /* Make the overlay visible and clickable */
}

body.sidebar-open .main,
body.sidebar-open .header {
    margin-left: 250px; /* Push the content and header to the right */
}

/* Responsive adjustment for the push effect */
@media (max-width: 992px) {
    /* On smaller screens, we don't want to push the content.
       Instead, the sidebar will overlay it. */
    body.sidebar-open .main,
    body.sidebar-open .header {
        margin-left: 0;
    }
}

/*******************************************************
*                                                      *
*      NEW, MINIMAL SIDEBAR & RESPONSIVE FIXES         *
*                                                      *
********************************************************/

/* --- Sidebar State & Overlay --- */
.sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 1001;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease-in-out, visibility 0.3s ease-in-out;
}

/* Rules for when the sidebar is open */
body.sidebar-open .sidenav {
    left: 0;
}
body.sidebar-open .sidebar-overlay {
    opacity: 1;
    visibility: visible;
}


/* --- Responsive Breakpoints --- */

/* Desktop view (screens 993px and wider) */
@media (min-width: 993px) {
    .header .menu-icon {
        display: none; /* Hide hamburger icon on desktop */
    }

    /* On desktop, PUSH the content instead of overlaying */
    body.sidebar-open .main,
    body.sidebar-open .header {
        margin-left: 250px;
    }
    body.sidebar-open .sidebar-overlay {
        visibility: hidden;
        opacity: 0;
    }
    footer .footer-content {
       display: flex;
       flex-direction: row;         /* horizontal layout */
       justify-content: space-between; /* space between columns */
       align-items: flex-start;     /* align content to the top */
       text-align: left;            /* align text inside each column */
       flex-wrap: wrap;             /* allow wrapping on smaller screens */
       gap: 2rem;                   /* optional: spacing between columns */
   }

   footer .footer-col {
     flex: 1 1 25%;               /* each column takes up ~25% width */
     min-width: 200px;            /* prevent being too narrow on small screens */
   }

}

