/* CVEium Dashboard - Custom Styles */
/* Phase 1 UI Specification - Enterprise Control Plane */

/* CSS Variables */
:root {
    --color-critical: #dc2626;
    --color-high: #ea580c;
    --color-medium: #ca8a04;
    --color-low: #16a34a;
    --color-none: #6b7280;
    --color-success: #10b981;
    --color-warning: #f59e0b;
    --color-error: #ef4444;
    --color-info: #3b82f6;
    
    /* System colors */
    --bg-primary: #ffffff;
    --bg-secondary: #f8fafc;
    --text-primary: #0f172a;
    --text-secondary: #475569;
}

/* Base Styles */
* {
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    margin: 0;
    padding: 0;
}

/* ==================== Global Header (T-J101) ==================== */

.global-header {
    padding: 1rem 2rem;
    background: white;
    border-bottom: 1px solid rgba(148, 163, 184, 0.2);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.dark .global-header {
    background: #1e293b;
}

.env-tag {
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.env-dev {
    background: #fef3c7;
    color: #92400e;
}

.env-prod {
    background: #dcfce7;
    color: #166534;
}

.env-sandbox {
    background: #e0e7ff;
    color: #3730a3;
}

.system-clock {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-family: 'SF Mono', 'Monaco', 'Inconsolata', monospace;
    font-size: 0.875rem;
    color: #64748b;
}

.clock-icon {
    font-size: 1rem;
}

.health-indicator {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.375rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 500;
}

.health-dot {
    width: 0.5rem;
    height: 0.5rem;
    border-radius: 50%;
    animation: pulse 2s infinite;
}

.health-green {
    background: rgba(16, 185, 129, 0.1);
    color: #059669;
}

.health-green .health-dot {
    background: #10b981;
}

.health-amber {
    background: rgba(245, 158, 11, 0.1);
    color: #d97706;
}

.health-amber .health-dot {
    background: #f59e0b;
}

.health-red {
    background: rgba(239, 68, 68, 0.1);
    color: #dc2626;
}

.health-red .health-dot {
    background: #ef4444;
}

.health-unknown {
    background: rgba(148, 163, 184, 0.1);
    color: #64748b;
}

.health-unknown .health-dot {
    background: #94a3b8;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* ==================== Latency Strip (T-J103) ==================== */

.latency-strip {
    display: grid !important;
    grid-template-columns: repeat(4, 1fr) !important;
    background: white !important;
    border-radius: 0.75rem !important;
    border: 1px solid rgba(148, 163, 184, 0.2) !important;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05) !important;
    overflow: hidden;
}

.dark .latency-strip {
    background: #1e293b !important;
}

.latency-metric {
    padding: 1.25rem 1rem !important;
    text-align: center !important;
    border-right: 1px solid rgba(148, 163, 184, 0.15) !important;
    background: transparent !important;
}

.latency-metric:last-child {
    border-right: none !important;
}

.latency-label {
    font-size: 0.75rem !important;
    color: #64748b !important;
    margin-bottom: 0.75rem !important;
    white-space: nowrap !important;
    display: block !important;
}

.latency-value {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 0.5rem !important;
}

.latency-dot {
    width: 0.625rem !important;
    height: 0.625rem !important;
    border-radius: 50% !important;
    flex-shrink: 0 !important;
    display: inline-block !important;
}

.latency-green {
    background: #10b981 !important;
    box-shadow: 0 0 8px rgba(16, 185, 129, 0.5) !important;
}

.latency-amber {
    background: #f59e0b !important;
    box-shadow: 0 0 8px rgba(245, 158, 11, 0.5) !important;
}

.latency-red {
    background: #ef4444 !important;
    box-shadow: 0 0 8px rgba(239, 68, 68, 0.5) !important;
}

.latency-unknown {
    background: #94a3b8 !important;
}

.latency-number {
    font-size: 1.125rem !important;
    font-weight: 700 !important;
    font-family: 'SF Mono', 'Monaco', 'Inconsolata', monospace !important;
    color: #1e293b !important;
}

.dark .latency-number {
    color: #e2e8f0 !important;
}

/* Responsive for latency strip - 2x2 grid on smaller screens */
@media (max-width: 768px) {
    .latency-strip {
        grid-template-columns: repeat(2, 1fr) !important;
    }
    
    .latency-metric {
        border-bottom: 1px solid rgba(148, 163, 184, 0.15) !important;
    }
    
    .latency-metric:nth-child(2) {
        border-right: none !important;
    }
    
    .latency-metric:nth-child(3),
    .latency-metric:nth-child(4) {
        border-bottom: none !important;
    }
}

/* ==================== Coverage Summary (T-J104) ==================== */

.coverage-row {
    display: flex;
    align-items: center;
    padding: 0.75rem;
    border-radius: 0.5rem;
    transition: background 0.15s;
    cursor: pointer;
    text-decoration: none;
    color: inherit;
}

.coverage-dot {
    width: 0.625rem;
    height: 0.625rem;
    border-radius: 50%;
    margin-right: 0.75rem;
}

.coverage-label {
    flex: 1;
    font-size: 0.875rem;
}

.coverage-value {
    font-weight: 600;
    font-size: 1.125rem;
    font-family: 'SF Mono', 'Monaco', 'Inconsolata', monospace;
}

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

.badge-critical {
    background-color: rgba(220, 38, 38, 0.15);
    color: #dc2626;
}

.badge-high {
    background-color: rgba(234, 88, 12, 0.15);
    color: #ea580c;
}

.badge-medium {
    background-color: rgba(202, 138, 4, 0.15);
    color: #ca8a04;
}

.badge-low {
    background-color: rgba(22, 163, 74, 0.15);
    color: #16a34a;
}

.badge-none {
    background-color: rgba(107, 114, 128, 0.15);
    color: #6b7280;
}

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

.badge-success {
    background-color: rgba(16, 185, 129, 0.15);
    color: #10b981;
}

.badge-warning {
    background-color: rgba(245, 158, 11, 0.15);
    color: #f59e0b;
}

.badge-error {
    background-color: rgba(239, 68, 68, 0.15);
    color: #ef4444;
}

/* ==================== Toast Animations ==================== */

@keyframes slideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

@keyframes slideOut {
    from { transform: translateX(0); opacity: 1; }
    to { transform: translateX(100%); opacity: 0; }
}

.toast-enter {
    animation: slideIn 0.3s ease-out forwards;
}

.toast-exit {
    animation: slideOut 0.3s ease-in forwards;
}

/* ==================== Table Styles ==================== */

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

.data-table th,
.data-table td {
    padding: 0.75rem 1rem;
    text-align: left;
    border-bottom: 1px solid rgba(148, 163, 184, 0.2);
}

.data-table th {
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #64748b;
}

.data-table tbody tr:hover {
    background-color: rgba(148, 163, 184, 0.05);
}

.data-table tbody tr {
    cursor: pointer;
    transition: background-color 0.15s;
}

/* ==================== Card Styles ==================== */

.card {
    background: white;
    border-radius: 0.75rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    border: 1px solid rgba(148, 163, 184, 0.2);
}

.dark .card {
    background: #1e293b;
    border-color: rgba(148, 163, 184, 0.1);
}

/* ==================== Button Styles ==================== */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    font-weight: 500;
    border-radius: 0.5rem;
    border: none;
    cursor: pointer;
    transition: all 0.15s;
}

.btn-primary {
    background-color: #1a56db;
    color: white;
}

.btn-primary:hover {
    background-color: #1648b8;
}

.btn-secondary {
    background-color: #f1f5f9;
    color: #334155;
}

.btn-secondary:hover {
    background-color: #e2e8f0;
}

.dark .btn-secondary {
    background-color: #334155;
    color: #e2e8f0;
}

.dark .btn-secondary:hover {
    background-color: #475569;
}

.btn-danger {
    background-color: #ef4444;
    color: white;
}

.btn-danger:hover {
    background-color: #dc2626;
}

/* ==================== Input Styles ==================== */

.input, .form-input, .form-select {
    width: 100%;
    padding: 0.5rem 0.75rem;
    font-size: 0.875rem;
    border: 1px solid #cbd5e1;
    border-radius: 0.5rem;
    background: white;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.input:focus, .form-input:focus, .form-select:focus {
    outline: none;
    border-color: #1a56db;
    box-shadow: 0 0 0 3px rgba(26, 86, 219, 0.1);
}

.dark .input, .dark .form-input, .dark .form-select {
    background: #1e293b;
    border-color: #475569;
    color: #e2e8f0;
}

.dark .input:focus, .dark .form-input:focus, .dark .form-select:focus {
    border-color: #06b6d4;
    box-shadow: 0 0 0 3px rgba(6, 182, 212, 0.1);
}

/* ==================== Loading Spinner ==================== */

.spinner {
    display: inline-block;
    width: 1rem;
    height: 1rem;
    border: 2px solid currentColor;
    border-right-color: transparent;
    border-radius: 50%;
    animation: spin 0.75s linear infinite;
}

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

/* ==================== Stat Card ==================== */

.stat-card {
    padding: 1.5rem;
}

.stat-value {
    font-size: 2rem;
    font-weight: 700;
    line-height: 1;
    font-family: 'SF Mono', 'Monaco', 'Inconsolata', monospace;
}

.stat-label {
    font-size: 0.875rem;
    color: #64748b;
    margin-top: 0.25rem;
}

.stat-change {
    font-size: 0.75rem;
    margin-top: 0.5rem;
}

.stat-change.positive {
    color: #10b981;
}

.stat-change.negative {
    color: #ef4444;
}

/* ==================== Pagination ==================== */

.pagination {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.pagination-btn {
    padding: 0.5rem 0.75rem;
    border: 1px solid #cbd5e1;
    border-radius: 0.375rem;
    background: white;
    cursor: pointer;
    font-size: 0.875rem;
}

.pagination-btn:hover:not(:disabled) {
    background: #f1f5f9;
}

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

.pagination-btn.active {
    background: #1a56db;
    border-color: #1a56db;
    color: white;
}

.dark .pagination-btn {
    background: #334155;
    border-color: #475569;
    color: #e2e8f0;
}

.dark .pagination-btn:hover:not(:disabled) {
    background: #475569;
}

/* ==================== Modal ==================== */

.modal-backdrop,
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    z-index: 1000;
}

.modal-content {
    background: #1e293b;
    border-radius: 0.75rem;
    max-width: 32rem;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    padding: 1.5rem;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
}

.dark .modal-content {
    background: #1e293b;
}

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

.sidebar {
    width: 16rem;
    background: #0f172a;
    height: 100vh;
    position: fixed;
    left: 0;
    top: 0;
    display: flex;
    flex-direction: column;
}

.sidebar-logo {
    padding: 1.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar-nav {
    flex: 1;
    padding: 1rem 0;
    overflow-y: auto;
}

.sidebar-link {
    display: flex;
    align-items: center;
    padding: 0.75rem 1.5rem;
    color: #94a3b8;
    text-decoration: none;
    transition: all 0.15s;
}

.sidebar-link:hover {
    background: rgba(255, 255, 255, 0.05);
    color: #e2e8f0;
}

.sidebar-link.active {
    background: rgba(6, 182, 212, 0.1);
    color: #22d3ee;
    border-right: 3px solid #22d3ee;
}

.sidebar-section {
    padding: 0.75rem 1.5rem 0.5rem;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #64748b;
}

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

.main-content {
    margin-left: 16rem;
    min-height: 100vh;
}

.page-header {
    padding: 1.5rem 2rem;
    border-bottom: 1px solid rgba(148, 163, 184, 0.2);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: white;
}

.dark .page-header {
    background: #1e293b;
}

.page-title {
    font-size: 1.5rem;
    font-weight: 600;
}

.page-content {
    padding: 2rem;
}

/* ==================== Filter Bar ==================== */

.filter-bar {
    display: flex;
    gap: 1rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.filter-label {
    font-size: 0.75rem;
    font-weight: 500;
    color: #64748b;
}

/* ==================== Empty State ==================== */

.empty-state {
    text-align: center;
    padding: 3rem;
    color: #64748b;
}

.empty-state-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
}

/* ==================== Provenance Timeline (T-J106) ==================== */

.provenance-timeline {
    position: relative;
    padding-left: 2rem;
}

.provenance-timeline::before {
    content: '';
    position: absolute;
    left: 0.75rem;
    top: 0;
    bottom: 0;
    width: 2px;
    background: #e2e8f0;
}

.timeline-node {
    position: relative;
    padding-bottom: 1.5rem;
}

.timeline-node:last-child {
    padding-bottom: 0;
}

.timeline-dot {
    position: absolute;
    left: -1.75rem;
    top: 0.25rem;
    width: 1rem;
    height: 1rem;
    border-radius: 50%;
    border: 2px solid white;
    z-index: 1;
}

.timeline-dot.success { background: #10b981; }
.timeline-dot.pending { background: #f59e0b; }
.timeline-dot.error { background: #ef4444; }

.timeline-content {
    background: #f8fafc;
    padding: 0.75rem 1rem;
    border-radius: 0.5rem;
}

.dark .timeline-content {
    background: #334155;
}

/* ==================== Impact Section (T-J108) ==================== */

.cvss-score {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 3.5rem;
    height: 3.5rem;
    border-radius: 50%;
    font-size: 1.25rem;
    font-weight: 700;
    color: white;
}

.cvss-score.critical { background: #dc2626; }
.cvss-score.high { background: #ea580c; }
.cvss-score.medium { background: #ca8a04; }
.cvss-score.low { background: #16a34a; }
.cvss-score.none { background: #6b7280; }

.kev-banner {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem;
    background: rgba(220, 38, 38, 0.1);
    border: 1px solid rgba(220, 38, 38, 0.3);
    border-radius: 0.5rem;
    color: #991b1b;
}

.dark .kev-banner {
    background: rgba(220, 38, 38, 0.2);
    color: #fca5a5;
}

.ssvc-badge {
    display: inline-flex;
    align-items: center;
    padding: 0.375rem 0.75rem;
    border-radius: 0.375rem;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
}

.ssvc-immediate { background: #fee2e2; color: #991b1b; }
.ssvc-out-of-cycle { background: #ffedd5; color: #9a3412; }
.ssvc-scheduled { background: #fef3c7; color: #92400e; }
.ssvc-defer { background: #dcfce7; color: #166534; }

/* ==================== Download Panel (T-J109) ==================== */

.download-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 0.75rem;
}

.download-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 1rem;
    border: 1px solid #e2e8f0;
    border-radius: 0.5rem;
    background: white;
    cursor: pointer;
    transition: all 0.15s;
}

.download-btn:hover {
    border-color: #1a56db;
    background: #eff6ff;
}

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

.download-btn .format-icon {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
}

.download-btn .format-name {
    font-size: 0.75rem;
    font-weight: 500;
}

/* ==================== CWE Tags ==================== */

.cwe-tag {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.5rem;
    background: #f1f5f9;
    border-radius: 0.25rem;
    font-size: 0.75rem;
    font-family: 'SF Mono', 'Monaco', monospace;
    color: #475569;
    cursor: help;
}

.dark .cwe-tag {
    background: #334155;
    color: #cbd5e1;
}

/* ==================== Onboarding ==================== */

.onboarding-grid {
    display: grid;
    grid-template-columns: minmax(220px, 280px) 1fr;
    gap: 1.5rem;
}

.step-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem;
    border-radius: 0.5rem;
}

.step-item.active {
    background: rgba(6, 182, 212, 0.1);
}

.step-indicator {
    width: 2rem;
    height: 2rem;
    border-radius: 9999px;
    border: 2px solid #cbd5f5;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    color: #64748b;
}

.step-indicator.completed {
    background: #22c55e;
    border-color: #22c55e;
    color: #fff;
}

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

/* ==================== Operations ==================== */

.ops-health-card {
    border: 1px solid rgba(148, 163, 184, 0.2);
    border-radius: 0.75rem;
    padding: 0.75rem;
    background: rgba(255, 255, 255, 0.5);
}

.dark .ops-health-card {
    background: rgba(30, 41, 59, 0.7);
}

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

@media (max-width: 1024px) {
    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.3s;
        z-index: 50;
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .main-content {
        margin-left: 0;
    }
}

/* ==================== Loading Spinners ==================== */

.loading-spinner {
    width: 2rem;
    height: 2rem;
    border: 3px solid rgba(6, 182, 212, 0.2);
    border-top-color: #06b6d4;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.loading-spinner-sm {
    width: 1rem;
    height: 1rem;
    border: 2px solid rgba(6, 182, 212, 0.2);
    border-top-color: #06b6d4;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    display: inline-block;
    vertical-align: middle;
}

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