/* Common Styles for Data Explorer Dashboard - Sonar Theme */

@font-face {
    font-family: "Inter";
    font-style: normal;
    font-weight: 100 900;
    src: url("../fonts/Inter/Inter-VariableFont_opsz,wght.ttf") format("truetype");
    font-display: swap;
}

@font-face {
    font-family: "Inter";
    font-style: italic;
    font-weight: 100 900;
    src: url("../fonts/Inter/Inter-Italic-VariableFont_opsz,wght.ttf") format("truetype");
    font-display: swap;
}

@font-face {
    font-family: "Poppins";
    src: url("../fonts/Poppins/Poppins-Regular.ttf") format("truetype");
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: "Poppins";
    src: url("../fonts/Poppins/Poppins-Medium.ttf") format("truetype");
    font-weight: 500;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: "Poppins";
    src: url("../fonts/Poppins/Poppins-SemiBold.ttf") format("truetype");
    font-weight: 600;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: "Poppins";
    src: url("../fonts/Poppins/Poppins-Bold.ttf") format("truetype");
    font-weight: 700;
    font-style: normal;
    font-display: swap;
}

:root {
    /* Light theme - Sonar branded */
    --bg-primary: #eef4fc;
    --bg-secondary: #ffffff;
    --bg-tertiary: #ddeaf9;
    --bg-card: #ffffff;
    --border-color: #e1e5eb;
    --text-primary: #290042;
    --text-secondary: #5a6f87;
    --text-muted: #506070;

    /* Sonar brand colors */
    --sonar-blue: #126ed3;
    --sonar-blue-light: #0e5ab8;
    --sonar-red: #d3121d;
    --accent-blue: #0271e3;
    --accent-purple: #7c4dff;
    --accent-best: #22c55e;

    /* Status colors */
    --color-success: #2e7d32;
    --color-danger: #c62828;
    --color-warning: #b45309;
    --color-orange: #db6d28;

    /* Brand UI state colors */
    --hover-blue: #0c5db5;
    --hover-purple: #4f3e5a;
    --disabled-purple: #d4cdd9;
    --uranium-blue: #b7d3f2;

    /* Data visualization palette */
    --bubblegum: #fbacbe;
    --sour-apple: #1b998b;
    --lemon-zest: #ffe156;
}

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

body {
    font-family:
        "Inter",
        ui-sans-serif,
        system-ui,
        -apple-system,
        BlinkMacSystemFont,
        "Segoe UI",
        sans-serif;
    font-optical-sizing: auto;
    background: var(--bg-secondary);
    color: var(--text-primary);
    line-height: 1.5;
    min-height: 100vh;
    scrollbar-gutter: stable;
}

h1,
h2,
h3,
h4,
h5,
h6 {
    font-family:
        "Poppins",
        ui-sans-serif,
        system-ui,
        -apple-system,
        BlinkMacSystemFont,
        "Segoe UI",
        sans-serif;
}

/* Fixed Header Wrapper */
app-header {
    display: block;
    min-height: var(--header-height, 240px);
}

.fixed-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
}

/* Sonar Top Bar */
.sonar-topbar {
    background: var(--bg-secondary);
    padding: 12px 24px;
    border-bottom: 1px solid var(--border-color);
}

.sonar-logo {
    display: flex;
    align-items: center;
    text-decoration: none;
}

.sonar-logo img {
    height: 32px;
    width: auto;
}

/* Hero Banner */
.hero-banner {
    background: var(--sonar-blue);
    padding: 20px 24px;
    color: white;
}

.hero-content {
    max-width: fit-content;
    margin: 0 auto;
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 20px;
}

.hero-icon {
    width: 64px;
    height: 64px;
    flex-shrink: 0;
    opacity: 0.95;
}

.hero-text {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.hero-banner h1 {
    font-size: 1.75rem;
    font-weight: 700;
    margin: 0;
}

.hero-banner .subtitle {
    font-size: 0.9375rem;
    color: rgba(255, 255, 255, 0.95);
    margin: 0;
    font-weight: 400;
}

/* Tab Navigation */
.tab-nav {
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    padding: 0 24px;
}

.tab-nav-inner {
    max-width: 1400px;
    margin: 0 auto;
    display: flex;
    gap: 0;
}

.tab-link {
    display: inline-block;
    padding: 16px 24px;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.9375rem;
    font-weight: 500;
    border-bottom: 2px solid transparent;
    transition: all 0.15s;
}

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

.tab-link.active {
    color: var(--sonar-blue);
    border-bottom-color: var(--sonar-blue);
}

.tab-link-right {
    margin-left: auto;
}

.tab-beta-badge {
    font-size: 0.5625rem;
    font-weight: 600;
    color: #0a4e9a;
    background: #f2f8ff;
    padding: 1px 5px;
    border-radius: 4px;
    margin-left: 6px;
    vertical-align: super;
    letter-spacing: 0.5px;
}

/* Model Icons */
.model-icon {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    object-fit: contain;
    border-radius: 3px;
}

.model-icon-lg {
    width: 32px;
    height: 32px;
    flex-shrink: 0;
    object-fit: contain;
    border-radius: 4px;
}

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

/* Spacer to offset fixed header height */
.header-spacer {
    height: var(--header-height, 240px);
}

/* Legacy Header (for pages that need it) */
.header {
    text-align: center;
}

.header h1 {
    font-size: 1.75rem;
    font-weight: 700;
    margin-bottom: 8px;
    color: var(--text-primary);
}

.header .subtitle {
    font-size: 1rem;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.header .date {
    font-size: 0.875rem;
    color: var(--text-muted);
}

/* Chart Container */
.chart-wrapper {
    display: flex;
    gap: 24px;
    margin-bottom: 32px;
    align-items: flex-start;
}

.chart-container {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 24px;
    overflow-x: auto;
    flex-shrink: 0;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    min-height: 500px;
}

.chart-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 20px;
}

/* Tooltip */
.tooltip {
    position: absolute;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 16px;
    font-size: 13px;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.15s;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
    max-width: 400px;
    z-index: 100;
}

.tooltip .model-name {
    font-weight: 600;
    font-size: 14px;
    color: var(--text-primary);
    margin-bottom: 2px;
}

.tooltip .org-name {
    color: var(--text-muted);
    font-size: 12px;
    margin-bottom: 12px;
}

.tooltip .metric-section {
    margin: 10px 0;
    padding: 8px 0;
    border-top: 1px solid var(--border-color);
}

.tooltip .metric-section:first-of-type {
    border-top: none;
    padding-top: 0;
}

.tooltip .metric-label {
    font-weight: 500;
    font-size: 12px;
    margin-bottom: 4px;
}

.tooltip .metric-values {
    font-size: 11px;
    color: var(--text-secondary);
    line-height: 1.6;
}

.tooltip .metric-row {
    display: flex;
    justify-content: space-between;
    margin: 4px 0;
    font-size: 12px;
}

.tooltip .metric-value {
    color: var(--text-primary);
    font-weight: 500;
}

/* Legend Container */
.legend-container {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.legend-title {
    font-size: 0.6875rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 16px;
}

.legend-grid {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.legend-item {
    display: flex;
    align-items: flex-start;
    gap: 10px;
}

.legend-color {
    width: 3px;
    height: 32px;
    border-radius: 2px;
    flex-shrink: 0;
}

.legend-color.correctness {
    background: var(--accent-blue);
}
.legend-color.security {
    background: var(--color-danger);
}
.legend-color.reliability {
    background: var(--color-warning);
}
.legend-color.maintainability {
    background: var(--color-success);
}

.legend-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    flex-shrink: 0;
}

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

.legend-content h4 {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 2px;
}

.legend-content p {
    font-size: 0.6875rem;
    color: var(--text-muted);
    line-height: 1.4;
}

/* Color Scales */
.color-scales {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--border-color);
}

.severity-note {
    font-size: 0.625rem;
    color: var(--text-muted);
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--border-color);
    line-height: 1.5;
}

/* Green-Yellow-Red Color Scale Bar */
.color-scale-bar {
    width: 100%;
    height: 16px;
    border-radius: 4px;
    background: linear-gradient(
        90deg,
        rgb(215, 48, 39) 0%,
        rgb(244, 109, 67) 15%,
        rgb(253, 174, 97) 30%,
        rgb(254, 224, 139) 45%,
        rgb(255, 255, 191) 50%,
        rgb(217, 239, 139) 55%,
        rgb(166, 217, 106) 70%,
        rgb(102, 189, 99) 85%,
        rgb(57, 187, 87) 100%
    );
    margin-bottom: 8px;
    border: 1px solid var(--border-color);
}

.scale-labels {
    display: flex;
    justify-content: space-between;
    font-size: 0.6875rem;
    color: var(--text-secondary);
    margin-bottom: 12px;
}

.scale-description {
    font-size: 0.6875rem;
    color: var(--text-muted);
    line-height: 1.5;
}

/* Filters & Controls */
.filters,
.controls {
    display: flex;
    align-items: center;
    gap: 16px;
    padding-top: 8px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.controls {
    gap: 24px;
    margin-bottom: 24px;
}

.filter-group,
.control-group {
    display: flex;
    align-items: center;
    gap: 8px;
}

.filter-label,
.control-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    font-weight: 500;
    position: relative;
}

.filter-select,
.control-select {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-primary);
    font-size: 0.8125rem;
    font-family: inherit;
    padding: 8px 32px 8px 12px;
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%235a6f87' d='M2.5 4.5L6 8l3.5-3.5'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    min-width: 180px;
}

.filter-input {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-primary);
    font-size: 0.8125rem;
    font-family: inherit;
    padding: 8px 12px;
    min-width: 180px;
}

.filter-input::placeholder {
    color: var(--text-muted);
}

.filter-input:hover {
    border-color: var(--text-muted);
}

.filter-input:focus {
    outline: none;
    border-color: var(--accent-blue);
    box-shadow: 0 0 0 2px rgba(2, 113, 227, 0.2);
}

#year-filter {
    min-width: 90px;
}

#pass-rate-filter {
    min-width: 120px;
}

#lang-filter {
    min-width: 90px;
}

#size-filter {
    min-width: 140px;
}

.filter-hint {
    position: relative;
    cursor: help;
    font-size: 0.7rem;
    opacity: 0.6;
    margin-left: 3px;
    display: inline-block;
}

.filter-hint::after {
    content: attr(aria-label);
    visibility: hidden;
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    margin-top: 6px;
    background: rgba(30, 41, 59, 0.95);
    color: #fff;
    padding: 6px 10px;
    border-radius: 6px;
    font-size: 11px;
    white-space: nowrap;
    pointer-events: none;
    z-index: 1000;
}

.filter-hint:hover::after {
    visibility: visible;
}

.filter-select:hover,
.control-select:hover {
    border-color: var(--text-muted);
}

.filter-select:focus,
.control-select:focus {
    outline: none;
    border-color: var(--accent-blue);
    box-shadow: 0 0 0 2px rgba(2, 113, 227, 0.2);
}

.filter-select option,
.control-select option {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

.model-count {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.filter-status {
    display: flex;
    align-items: center;
    gap: 8px;
}

.reset-filters-btn {
    font-size: 0.75rem;
    color: var(--text-muted);
    background: none;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 4px 10px;
    cursor: pointer;
    transition:
        color 0.15s,
        border-color 0.15s;
}
.reset-filters-btn:hover {
    color: var(--accent-blue);
    border-color: var(--accent-blue);
}

/* Footer */
.footer {
    text-align: center;
    padding: 24px;
    border-top: 1px solid var(--border-color);
    margin-top: 40px;
    background: var(--bg-secondary);
}

.footer p {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-bottom: 4px;
}

.footer .copyright {
    font-size: 0.6875rem;
    color: var(--text-muted);
}

.footer .footer-attribution {
    font-size: 0.625rem;
    color: var(--text-muted);
    opacity: 0.7;
}

.footer .footer-attribution a {
    color: var(--text-muted);
    text-decoration: underline;
}

/* SVG Styles */
.category-header {
    font-size: 12px;
    font-weight: 600;
    fill: var(--text-primary);
}

.unit-label {
    font-size: 9px;
    fill: var(--text-muted);
}

.severity-label {
    font-size: 9px;
    fill: var(--text-secondary);
}

.model-label {
    font-size: 11px;
    fill: var(--text-secondary);
    cursor: pointer;
    transition: fill 0.15s;
    text-decoration: underline;
}

.model-label:hover {
    fill: var(--accent-blue);
}

.axis-label {
    font-size: 13px;
    fill: var(--text-muted);
}

/* Chart axis styles */
.axis text {
    fill: var(--text-secondary);
    font-size: 13px;
}

.axis line,
.axis path {
    stroke: var(--border-color);
}

.grid line {
    stroke: var(--border-color);
    stroke-opacity: 0.5;
}

/* Timeline specific */
.data-point {
    cursor: pointer;
    transition: r 0.15s;
}

.data-point:hover {
    r: 10;
}

.trend-line {
    fill: none;
    stroke: var(--accent-purple);
    stroke-width: 2;
    stroke-dasharray: 5, 5;
    opacity: 0.6;
}

/* ─────────────────────────────────────────────────────────────────────
   Legend Overlay (shared by quadrant, correlate, timeline)
   ───────────────────────────────────────────────────────────────────── */

.legend-overlay {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    right: 15px;
    background: rgba(255, 255, 255, 0.95);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 12px 16px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    max-width: 180px;
    z-index: 10;
}

.legend-overlay .legend-title {
    font-size: 0.625rem;
    margin-bottom: 10px;
}

.legend-overlay .legend-grid {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.legend-overlay .legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    padding: 4px 6px;
    margin: -4px -6px;
    border-radius: 4px;
    transition:
        opacity 0.15s,
        background-color 0.15s;
}

.legend-overlay .legend-item:hover {
    background-color: rgba(0, 0, 0, 0.05);
}

.legend-overlay .legend-item:not(.active) {
    opacity: 0.4;
}

.legend-overlay .legend-item:not(.active) .legend-dot {
    background-color: #ccc !important;
}

.legend-overlay .legend-dot {
    width: 10px;
    height: 10px;
}

.legend-overlay .legend-label {
    font-size: 0.6875rem;
    white-space: nowrap;
}

/* ─────────────────────────────────────────────────────────────────────
   Leader Line Labels (shared by quadrant, correlate, timeline)
   ───────────────────────────────────────────────────────────────────── */

.leader-labels .point-label {
    font-size: 11px;
    fill: #57606a;
    pointer-events: none;
}

.leader-labels .leader-line {
    stroke: #c0c0c0;
    stroke-width: 1;
    stroke-dasharray: 2, 2;
    fill: none;
}

/* ─────────────────────────────────────────────────────────────────────
   Section Header & Icon (shared by model domain sections, compare)
   ───────────────────────────────────────────────────────────────────── */

.section-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 20px;
    background: var(--bg-primary);
    border-bottom: 1px solid var(--border-color);
}

.section-icon {
    width: 8px;
    height: 24px;
    border-radius: 2px;
}

.section-icon.correctness {
    background: var(--accent-blue);
}
.section-icon.security {
    background: var(--color-danger);
}
.section-icon.reliability {
    background: var(--color-warning);
}
.section-icon.maintainability {
    background: var(--color-success);
}
.section-icon.complexity {
    background: var(--accent-purple);
}
.section-icon.volumetric {
    background: #64748b;
}
.section-icon.token-usage {
    background: #0ea5e9;
}

.section-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
}

.section-subtitle {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-left: auto;
}

/* ─────────────────────────────────────────────────────────────────────
   Radar Chart (shared by model and compare)
   ───────────────────────────────────────────────────────────────────── */

.radar-container {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 24px;
}

.radar-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 16px;
    text-align: center;
}

.radar-chart {
    display: flex;
    justify-content: center;
    position: relative;
}

.radar-legend {
    display: flex;
    justify-content: center;
    gap: 24px;
    margin-top: 16px;
}

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

.radar-legend-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
}

.radar-legend-line {
    width: 20px;
    height: 3px;
    border-radius: 2px;
}

.radar-legend-line.best {
    background-image: repeating-linear-gradient(
        90deg,
        var(--accent-best) 0px,
        var(--accent-best) 4px,
        transparent 4px,
        transparent 7px
    );
}

/* ─────────────────────────────────────────────────────────────────────
   Section Navigation (shared by model, compare, about)
   ───────────────────────────────────────────────────────────────────── */

[id^="section-"] {
    scroll-margin-top: calc(var(--header-height, 240px) + 20px);
}

.section-nav {
    position: fixed;
    left: 16px;
    top: calc(50% + 15px);
    transform: translateY(-50%);
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 8px 10px;
    display: flex;
    flex-direction: column;
    gap: 2px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    z-index: 100;
}

.section-nav-item {
    display: flex;
    align-items: center;
    gap: 6px;
    text-decoration: none;
    color: var(--text-secondary);
    font-size: 0.75rem;
    padding: 4px 6px;
    border-radius: 6px;
    transition: all 0.2s;
    white-space: nowrap;
}

.section-nav-item:hover {
    background: var(--bg-hover, rgba(0, 0, 0, 0.04));
    color: var(--text-primary);
}

.section-nav-item.active {
    color: var(--text-primary);
    font-weight: 600;
}

.section-nav-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--text-muted, #7d8b9e);
    flex-shrink: 0;
    transition: transform 0.2s;
}

.section-nav-item.active .section-nav-dot {
    transform: scale(1.5);
}

.section-nav-dot.correctness {
    background: var(--accent-blue);
}
.section-nav-dot.security {
    background: var(--color-danger);
}
.section-nav-dot.reliability {
    background: var(--color-warning);
}
.section-nav-dot.maintainability {
    background: var(--color-success);
}
.section-nav-dot.complexity {
    background: var(--accent-purple);
}
.section-nav-dot.volumetric {
    background: #64748b;
}
.section-nav-dot.token-usage {
    background: #0ea5e9;
}

.section-nav-separator {
    height: 1px;
    border-top: 1px dashed var(--border-color);
    margin: 4px 0;
}

/* ─────────────────────────────────────────────────────────────────────
   Language Pill Bar (shared by model, compare)
   ───────────────────────────────────────────────────────────────────── */

.nav-lang-section {
    padding: 0 0 2px;
}

.lang-pill-bar {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.lang-pill {
    padding: 8px;
    border: 1px solid var(--border-color);
    border-radius: 50%;
    background: transparent;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
}

.lang-pill:hover {
    border-color: var(--text-muted);
    background: var(--bg-tertiary);
}

.lang-pill-active {
    background: rgba(2, 113, 227, 0.12);
    border-color: var(--sonar-blue);
    box-shadow: 0 0 0 1px var(--sonar-blue);
}

.lang-pill-active:hover {
    background: rgba(2, 113, 227, 0.18);
    border-color: var(--sonar-blue);
}

.lang-pill-icon {
    width: 16px;
    height: 16px;
    vertical-align: middle;
}

/* ── Section nav links (prev / next) ────────────────────────── */
.section-nav-links {
    margin-left: auto;
    display: flex;
    gap: 8px;
    align-items: center;
}

.section-nav-links button {
    font-family: inherit;
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-muted);
    background: none;
    border: none;
    padding: 4px 8px;
    border-radius: 4px;
    cursor: pointer;
    transition:
        color 0.12s,
        background 0.12s;
}

.section-nav-links button:hover {
    color: var(--accent-blue);
    background: rgba(31, 111, 235, 0.06);
}

@media (max-width: 1400px) {
    .section-nav {
        display: none;
    }
    .container {
        padding-left: 24px;
    }
}

/* Feature flag: Poppins for content (activated via ?content_font=poppins) */
html.content-font-poppins body {
    font-family:
        "Poppins",
        ui-sans-serif,
        system-ui,
        -apple-system,
        BlinkMacSystemFont,
        "Segoe UI",
        sans-serif;
}
