/* Aegis Dashboard - Dark Mode Theme (VSCode/Claude Code inspired) */

:root {
    /* Base colors */
    --bg-primary: #1e1e1e;
    --bg-secondary: #252526;
    --bg-tertiary: #2d2d30;
    --bg-hover: #3c3c3c;

    /* Text colors */
    --text-primary: #cccccc;
    --text-secondary: #9d9d9d;
    --text-muted: #6e6e6e;

    /* Accent colors */
    --accent-primary: #569cd6;
    --accent-secondary: #4ec9b0;
    --accent-highlight: #dcdcaa;

    /* Status colors */
    --green: #4ec9b0;
    --green-bg: rgba(78, 201, 176, 0.15);
    --yellow: #dcdcaa;
    --yellow-bg: rgba(220, 220, 170, 0.15);
    --orange: #ce9178;
    --orange-bg: rgba(206, 145, 120, 0.15);
    --red: #f14c4c;
    --red-bg: rgba(241, 76, 76, 0.15);
    --blue: #569cd6;
    --blue-bg: rgba(86, 156, 214, 0.15);

    /* Borders */
    --border-color: #3c3c3c;
    --border-subtle: #2d2d30;

    /* Shadows */
    --shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
    --shadow-sm: 0 2px 6px rgba(0, 0, 0, 0.3);
}

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

html {
    /* Prevent layout shift when scrollbar appears/disappears between pages */
    overflow-y: scroll;
    scrollbar-gutter: stable;
}

body {
    font-family: 'Segoe UI', -apple-system, BlinkMacSystemFont, Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.6;
}

/* Navigation Bar */
.navbar {
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 1000;
}

.nav-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 48px;
}

.nav-brand {
    font-size: 1.3em;
    font-weight: 600;
    color: var(--accent-secondary);
    letter-spacing: 1px;
}

a.nav-brand {
    color: var(--accent-secondary);
    text-decoration: none;
}

.nav-links {
    display: flex;
    gap: 4px;
}

.nav-link {
    padding: 6px 14px;
    text-decoration: none;
    color: var(--text-secondary);
    border-radius: 4px;
    transition: all 0.15s ease;
    font-size: 0.9em;
    font-weight: 500;
}

.nav-link:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.nav-link.active {
    background: var(--bg-hover);
    color: var(--accent-primary);
}

/* Container */
.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 24px 20px;
}

/* Header */
header {
    background: var(--bg-secondary);
    padding: 24px;
    border-radius: 6px;
    border: 1px solid var(--border-color);
    margin-bottom: 24px;
}

h1 {
    color: var(--text-primary);
    font-size: 1.8em;
    font-weight: 600;
    margin-bottom: 8px;
}

h2 {
    color: var(--text-primary);
    font-size: 1.3em;
    font-weight: 600;
    margin: 24px 0 12px;
}

h3 {
    color: var(--text-primary);
    font-weight: 600;
}

h4 {
    color: var(--text-secondary);
    font-weight: 600;
    margin: 20px 0 10px;
}

.subtitle {
    color: var(--text-secondary);
    font-size: 0.95em;
}

/* Status Bar */
.status-bar {
    display: flex;
    gap: 16px;
    margin-top: 20px;
    flex-wrap: wrap;
}

.status-item {
    flex: 1;
    min-width: 180px;
    padding: 16px;
    background: var(--bg-tertiary);
    border-radius: 6px;
    border-left: 3px solid var(--accent-primary);
}

.status-label {
    font-size: 0.75em;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: 600;
}

.status-value {
    font-size: 1.6em;
    font-weight: 600;
    margin-top: 4px;
    font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
}

.status-value.green { color: var(--green); }
.status-value.yellow { color: var(--yellow); }
.status-value.orange { color: var(--orange); }
.status-value.red { color: var(--red); }

/* Alert Banner */
.alert-banner {
    background: var(--yellow-bg);
    border: 1px solid var(--yellow);
    border-left: 4px solid var(--yellow);
    border-radius: 6px;
    padding: 16px 20px;
    margin-bottom: 20px;
    display: flex;
    gap: 16px;
    align-items: center;
}

.alert-banner.red {
    background: var(--red-bg);
    border-color: var(--red);
}

.alert-banner.green {
    background: var(--green-bg);
    border-color: var(--green);
}

.alert-icon {
    font-size: 2em;
}

.alert-title {
    font-size: 1.1em;
    font-weight: 600;
    color: var(--yellow);
    margin-bottom: 4px;
}

.alert-banner.red .alert-title {
    color: var(--red);
}

.alert-banner.green .alert-title {
    color: var(--green);
}

.alert-message {
    color: var(--text-secondary);
    line-height: 1.5;
    font-size: 0.9em;
}

/* Charts */
.chart-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(480px, 1fr));
    gap: 20px;
    margin-bottom: 20px;
}

.chart-container {
    background: var(--bg-secondary);
    padding: 20px;
    border-radius: 6px;
    border: 1px solid var(--border-color);
}

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

.chart-title {
    font-size: 1.1em;
    font-weight: 600;
    margin-bottom: 12px;
    color: var(--text-primary);
}

.chart-subtitle {
    font-size: 0.85em;
    color: var(--text-muted);
    margin-bottom: 8px;
}

/* Signals List */
.signals-list {
    padding: 12px;
    background: var(--bg-tertiary);
    border-radius: 6px;
}

.signal-item {
    padding: 10px 12px;
    margin-bottom: 6px;
    background: var(--bg-secondary);
    border-left: 3px solid var(--accent-primary);
    border-radius: 4px;
    font-size: 0.9em;
}

.signal-item:last-child {
    margin-bottom: 0;
}

.signal-item.warning {
    border-left-color: var(--yellow);
    background: var(--yellow-bg);
}

.signal-item.critical {
    border-left-color: var(--red);
    background: var(--red-bg);
}

/* Time Selector & Tabs */
.time-selector,
.dimension-tabs {
    display: flex;
    gap: 8px;
    margin-top: 16px;
    flex-wrap: wrap;
}

.time-btn,
.dim-tab {
    padding: 6px 14px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    border-radius: 4px;
    cursor: pointer;
    font-weight: 500;
    font-size: 0.85em;
    transition: all 0.15s ease;
}

.time-btn:hover,
.dim-tab:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
    border-color: var(--text-muted);
}

.time-btn.active,
.dim-tab.active {
    background: var(--accent-primary);
    color: var(--bg-primary);
    border-color: var(--accent-primary);
}

/* Dimension Views */
.dimension-view {
    animation: fadeIn 0.2s ease;
}

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

.dimension-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--bg-secondary);
    padding: 20px;
    border-radius: 6px;
    border: 1px solid var(--border-color);
    margin-bottom: 16px;
}

.dimension-score {
    font-size: 2.5em;
    font-weight: 600;
    color: var(--accent-secondary);
    font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
}

.dimension-description {
    background: var(--bg-secondary);
    padding: 14px 16px;
    border-radius: 6px;
    border-left: 3px solid var(--accent-primary);
    margin-bottom: 16px;
    color: var(--text-secondary);
    line-height: 1.6;
    font-size: 0.9em;
}

/* Methodology Page Styles */
.methodology-content {
    background: var(--bg-secondary);
    padding: 28px;
    border-radius: 6px;
    border: 1px solid var(--border-color);
}

.method-section {
    margin-bottom: 32px;
    padding-bottom: 28px;
    border-bottom: 1px solid var(--border-color);
}

.method-section:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

.method-section h2 {
    margin-top: 0;
    margin-bottom: 16px;
}

.method-section p {
    color: var(--text-secondary);
    margin-bottom: 12px;
}

.method-section ul,
.method-section ol {
    margin-left: 24px;
    line-height: 1.8;
    color: var(--text-secondary);
}

.method-section li {
    margin-bottom: 4px;
}

.method-section strong {
    color: var(--text-primary);
}

.method-section a {
    color: var(--accent-primary);
    text-decoration: none;
}

.method-section a:hover {
    text-decoration: underline;
}

/* Tables in methodology */
.method-section table {
    width: 100%;
    border-collapse: collapse;
    margin: 16px 0;
    font-size: 0.9em;
}

.method-section th {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    padding: 10px 12px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
    font-weight: 600;
}

.method-section td {
    padding: 8px 12px;
    border-bottom: 1px solid var(--border-subtle);
    color: var(--text-secondary);
}

.method-section tr:hover td {
    background: var(--bg-tertiary);
}

/* Dimension Cards */
.dimension-card {
    background: var(--bg-tertiary);
    padding: 20px;
    border-radius: 6px;
    border-left: 3px solid var(--accent-primary);
    margin-bottom: 16px;
}

.dimension-card h3 {
    color: var(--accent-primary);
    margin-bottom: 12px;
    font-size: 1.1em;
}

.dimension-card.tactical {
    border-left-color: var(--red);
}

.dimension-card.tactical h3 {
    color: var(--red);
}

.dimension-card.strategic {
    border-left-color: var(--yellow);
}

.dimension-card.strategic h3 {
    color: var(--yellow);
}

.dimension-card.canary {
    border-left-color: var(--orange);
}

.dimension-card.canary h3 {
    color: var(--orange);
}

.dimension-card.narrative {
    border-left-color: var(--blue);
}

.dimension-card.narrative h3 {
    color: var(--blue);
}

.dimension-card p {
    margin-bottom: 10px;
}

.dimension-card ul {
    margin-left: 20px;
}

/* Alert Tiers */
.alert-tiers {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin: 20px 0;
}

.tier-card {
    padding: 20px;
    border-radius: 6px;
    text-align: center;
    border: 1px solid;
}

.tier-card h3 {
    margin-bottom: 8px;
    font-size: 1em;
}

.tier-card p {
    font-size: 0.85em;
    margin-bottom: 4px;
}

.tier-card.green {
    background: var(--green-bg);
    border-color: var(--green);
}

.tier-card.green h3 {
    color: var(--green);
}

.tier-card.yellow {
    background: var(--yellow-bg);
    border-color: var(--yellow);
}

.tier-card.yellow h3 {
    color: var(--yellow);
}

.tier-card.red {
    background: var(--red-bg);
    border-color: var(--red);
}

.tier-card.red h3 {
    color: var(--red);
}

.tier-card.orange {
    background: var(--orange-bg);
    border-color: var(--orange);
}

.tier-card.orange h3 {
    color: var(--orange);
}

/* Text utility classes */
.text-green { color: var(--green); }
.text-yellow { color: var(--yellow); }
.text-orange { color: var(--orange); }
.text-red { color: var(--red); }
.text-blue { color: var(--blue); }

/* Code Block */
.code-block {
    background: var(--bg-primary);
    padding: 16px;
    border-radius: 6px;
    font-family: 'SF Mono', 'Fira Code', 'Consolas', 'Courier New', monospace;
    font-size: 0.85em;
    overflow-x: auto;
    margin: 16px 0;
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    line-height: 1.5;
}

pre {
    background: var(--bg-primary);
    color: var(--text-primary);
    padding: 16px;
    border-radius: 6px;
    overflow-x: auto;
    font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
    font-size: 0.85em;
    border: 1px solid var(--border-color);
}

/* Loading & Error States */
.loading {
    text-align: center;
    padding: 40px;
    color: var(--text-secondary);
    font-size: 1em;
}

.error {
    background: var(--red-bg);
    border: 1px solid var(--red);
    padding: 16px 20px;
    border-radius: 6px;
    color: var(--red);
    margin: 20px 0;
}

/* Footer */
footer {
    text-align: center;
    color: var(--text-muted);
    margin-top: 40px;
    padding: 20px;
    font-size: 0.85em;
}

footer a {
    color: var(--accent-primary);
    text-decoration: none;
}

footer a:hover {
    text-decoration: underline;
}

footer .disclaimer {
    margin-top: 10px;
    font-size: 0.85em;
}

/* Tooltip Styles */
.tooltip-term {
    position: relative;
    cursor: help;
    border-bottom: 1px dotted var(--accent-primary);
    color: var(--text-primary);
}

.tooltip-term:hover {
    color: var(--accent-primary);
}

.tooltip-term .tooltip-content {
    visibility: hidden;
    opacity: 0;
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: var(--bg-primary);
    color: var(--text-primary);
    padding: 12px 16px;
    border-radius: 6px;
    font-size: 0.85em;
    line-height: 1.5;
    width: 280px;
    z-index: 1000;
    box-shadow: var(--shadow);
    border: 1px solid var(--border-color);
    transition: opacity 0.15s, visibility 0.15s;
    margin-bottom: 8px;
}

.tooltip-term .tooltip-content::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 8px solid transparent;
    border-top-color: var(--border-color);
}

.tooltip-term:hover .tooltip-content {
    visibility: visible;
    opacity: 1;
}

.tooltip-title {
    font-weight: 600;
    color: var(--accent-primary);
    margin-bottom: 6px;
    display: block;
}

.tooltip-link {
    display: inline-block;
    margin-top: 8px;
    color: var(--accent-secondary);
    text-decoration: none;
    font-size: 0.9em;
}

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

/* Explanation Section (shared across layer pages) */
.explanation-section {
    background: var(--bg-secondary);
    border-radius: 10px;
    padding: 25px;
    border: 1px solid var(--border-color);
    margin-top: 20px;
}

.explanation-section h3 {
    color: var(--text-primary);
    margin-bottom: 15px;
}

.explanation-section h3:not(:first-child) {
    margin-top: 24px;
}

.explanation-section p {
    color: var(--text-secondary);
    line-height: 1.8;
    margin-bottom: 12px;
}

.explanation-section .threshold-list {
    list-style: none;
    padding: 0;
}

.explanation-section .threshold-list li {
    padding: 8px 0;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-secondary);
}

.explanation-section .threshold-list li:last-child {
    border-bottom: none;
}

.threshold-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.85em;
    font-weight: 600;
    margin-right: 8px;
}

.threshold-badge.green { background: var(--green-bg); color: var(--green); }
.threshold-badge.yellow { background: var(--yellow-bg); color: var(--yellow); }
.threshold-badge.orange { background: var(--orange-bg); color: var(--orange); }
.threshold-badge.red { background: var(--red-bg); color: var(--red); }
.threshold-badge.blue { background: var(--blue-bg); color: var(--blue); }

/* Scrollbar styling */
::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

::-webkit-scrollbar-track {
    background: var(--bg-primary);
}

::-webkit-scrollbar-thumb {
    background: var(--bg-hover);
    border-radius: 5px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* Selection */
::selection {
    background: var(--accent-primary);
    color: var(--bg-primary);
}

/* Responsive Design */
@media (max-width: 768px) {
    .nav-container {
        flex-direction: column;
        height: auto;
        padding: 12px;
        gap: 10px;
    }

    .nav-links {
        flex-wrap: wrap;
        justify-content: center;
    }

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

    h1 {
        font-size: 1.5em;
    }

    .status-bar {
        flex-direction: column;
    }

    .alert-tiers {
        grid-template-columns: 1fr;
    }

    .container {
        padding: 16px 12px;
    }

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

@media (max-width: 500px) {
    .tooltip-term .tooltip-content {
        width: 220px;
        left: 0;
        transform: translateX(0);
    }

    .tooltip-term .tooltip-content::after {
        left: 20px;
        transform: none;
    }
}
