/* 2D Analysis Dashboard - scientific analysis workspace */

:root {
    --bg: #eef3f5;
    --surface: #ffffff;
    --surface-muted: #f7fafb;
    --surface-strong: #e8eef1;
    --nav: #172833;
    --nav-muted: #9eb0ba;
    --text: #20313d;
    --text-muted: #667985;
    --border: #d8e1e6;
    --border-strong: #c6d2d9;
    --accent: #2f7f9f;
    --accent-dark: #23627b;
    --accent-soft: #e2f1f6;
    --success: #27824f;
    --success-bg: #e6f5ed;
    --error: #bd3d35;
    --error-bg: #fae8e6;
    --warning: #d9831f;
    --shadow-sm: 0 1px 2px rgba(23, 40, 51, 0.06);
    --shadow-md: 0 16px 42px rgba(23, 40, 51, 0.10);
    --radius: 8px;
}

* {
    box-sizing: border-box;
}

html {
    background: var(--bg);
}

body {
    font-family: Aptos, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    margin: 0;
    padding: 0;
    color: var(--text);
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.88), rgba(238, 243, 245, 0.95) 280px),
        var(--bg);
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

button,
input,
select,
textarea {
    font: inherit;
}

a {
    color: var(--accent);
}

/* App Shell */
.main-container {
    background: transparent;
    border-radius: 0;
    box-shadow: none;
    margin: 0;
    min-height: 100vh;
}

.page-content {
    width: 100%;
    max-width: 100vw;
    margin: 0;
    padding: 0 28px 44px;
}

.content-section {
    width: 100%;
    max-width: 1500px;
    margin: 0 auto;
    padding: 28px 0;
}

/* Navigation */
.navigation-bar {
    position: sticky;
    top: 0;
    z-index: 50;
    background:
        linear-gradient(90deg, rgba(47, 127, 159, 0.18), transparent 38%),
        var(--nav);
    padding: 0 28px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: 0 12px 28px rgba(23, 40, 51, 0.16);
}

.nav-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: 1500px;
    margin: 0 auto;
    min-height: 72px;
    gap: 28px;
}

.nav-brand {
    display: flex;
    align-items: center;
    min-width: 0;
}

.nav-brand::before {
    content: "";
    display: inline-block;
    width: 10px;
    height: 34px;
    margin-right: 14px;
    border-radius: 999px;
    background: linear-gradient(180deg, #6dc3d7, #d9831f);
}

.nav-brand .nav-title {
    color: #f7fbfc;
    margin: 0;
    font-size: 1.55rem;
    line-height: 1.1;
    font-weight: 680;
    letter-spacing: 0;
    white-space: nowrap;
}

.nav-links {
    display: flex;
    gap: 6px;
    align-items: center;
    padding: 4px;
    border: 1px solid rgba(255, 255, 255, 0.10);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.06);
}

.nav-link {
    color: rgba(247, 251, 252, 0.82);
    text-decoration: none;
    padding: 9px 16px;
    border-radius: 999px;
    font-size: 0.94rem;
    font-weight: 650;
    line-height: 1;
    transition: color 160ms ease, background-color 160ms ease, box-shadow 160ms ease;
}

.nav-link:hover {
    color: #ffffff;
    background: rgba(255, 255, 255, 0.10);
    text-decoration: none;
}

.nav-link.active {
    color: var(--nav);
    background: #f8fbfc;
    box-shadow: var(--shadow-sm);
}

.nav-reset-button {
    border: 0;
    background: transparent;
    font-family: inherit;
    cursor: pointer;
}

/* Legacy header support */
.header-section {
    background: var(--nav);
    color: white;
    padding: 18px 30px;
    border-radius: 0;
    text-align: left;
}

.header-section::before {
    display: none;
}

.header-content {
    max-width: 1500px;
    margin: 0 auto;
}

.app-title {
    font-size: 1.9rem;
    font-weight: 700;
    margin: 0 0 4px;
    color: white;
}

.app-subtitle {
    font-size: 0.95rem;
    color: var(--nav-muted);
    font-weight: 400;
    margin: 0;
}

/* Panels */
.top-controls-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 310px;
    gap: 20px;
    align-items: start;
    margin-bottom: 22px;
}

.file-input-section,
.display-options-section {
    min-width: 0;
}

.info-card,
.control-card,
.graph-container,
.analysis-section {
    background: rgba(255, 255, 255, 0.92);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
}

.info-card,
.control-card {
    padding: 18px;
}

.info-card {
    margin-bottom: 16px;
}

.control-card {
    transition: border-color 160ms ease, box-shadow 160ms ease, background-color 160ms ease;
}

.control-card:hover {
    border-color: var(--border-strong);
    box-shadow: 0 10px 28px rgba(23, 40, 51, 0.08);
}

.graph-container {
    padding: 18px 20px 20px;
    margin: 0;
    box-shadow: var(--shadow-md);
}

.control-label {
    display: block;
    margin-bottom: 10px;
    color: var(--text);
    font-size: 0.92rem;
    font-weight: 700;
}

.info-card h4,
.control-card h4,
.analysis-section h4,
.analysis-chart-container h5 {
    color: var(--text) !important;
    letter-spacing: 0;
}

/* Inputs and Uploads */
.file-input {
    width: 70%;
    min-width: 0;
    padding: 10px 12px;
    color: var(--text);
    background: #ffffff;
    border: 1px solid var(--border-strong);
    border-radius: 7px;
    font-size: 0.92rem;
    box-shadow: inset 0 1px 1px rgba(23, 40, 51, 0.03);
    transition: border-color 160ms ease, box-shadow 160ms ease;
}

.file-input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(47, 127, 159, 0.16);
}

.load-button,
.analysis-button,
.btn-primary {
    background: var(--accent) !important;
    color: #ffffff !important;
    border: 1px solid var(--accent) !important;
    border-radius: 7px;
    cursor: pointer;
    font-size: 0.92rem;
    font-weight: 700;
    line-height: 1;
    transition: background-color 160ms ease, border-color 160ms ease, box-shadow 160ms ease, transform 120ms ease;
}

.load-button {
    padding: 0 18px;
    min-height: 42px;
}

.analysis-button {
    padding: 12px 18px;
    margin-right: 8px;
    margin-bottom: 8px;
}

.load-button:hover,
.analysis-button:hover,
.btn-primary:hover {
    background: var(--accent-dark) !important;
    border-color: var(--accent-dark) !important;
    box-shadow: 0 10px 24px rgba(47, 127, 159, 0.22);
}

.load-button:active,
.analysis-button:active,
.btn-primary:active {
    transform: translateY(1px);
}

.load-button:focus-visible,
.analysis-button:focus-visible,
.btn-primary:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px rgba(47, 127, 159, 0.20);
}

.upload-area {
    width: 100%;
    min-height: 68px;
    line-height: 1.35;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    border: 1px dashed var(--border-strong);
    border-radius: var(--radius);
    text-align: center;
    margin: 10px 0;
    cursor: pointer;
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.78), rgba(247, 250, 251, 0.95)),
        var(--surface-muted);
    color: var(--text-muted);
    font-size: 0.92rem;
    transition: border-color 160ms ease, background-color 160ms ease, color 160ms ease, box-shadow 160ms ease;
}

.upload-area:hover,
.upload-area.dragover {
    background: var(--accent-soft);
    border-color: var(--accent);
    color: var(--accent-dark);
    box-shadow: 0 0 0 3px rgba(47, 127, 159, 0.10);
}

input[type="checkbox"] {
    accent-color: var(--accent);
}

/* Slider */
.rc-slider {
    margin: 14px 10px 26px;
}

.rc-slider-track {
    background: linear-gradient(90deg, var(--accent), var(--warning)) !important;
    height: 5px !important;
}

.rc-slider-handle {
    border: 2px solid var(--accent) !important;
    background: white !important;
    width: 18px !important;
    height: 18px !important;
    margin-top: -7px !important;
    box-shadow: 0 4px 12px rgba(47, 127, 159, 0.24) !important;
    opacity: 1 !important;
}

.rc-slider-handle:focus,
.rc-slider-handle:hover {
    border-color: var(--accent-dark) !important;
    box-shadow: 0 0 0 5px rgba(47, 127, 159, 0.14) !important;
}

.rc-slider-rail {
    background: #dfe7eb !important;
    height: 5px !important;
}

.rc-slider-mark-text {
    color: #7e8f9a !important;
    font-size: 0.78rem;
}

.rc-slider-tooltip-inner {
    background: var(--nav) !important;
    border-radius: 6px !important;
    box-shadow: var(--shadow-sm) !important;
}

.rc-slider-tooltip-placement-bottom .rc-slider-tooltip-arrow {
    border-bottom-color: var(--nav) !important;
}

/* Statistics */
.stats-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
    margin-top: 12px;
}

.stat-item {
    background:
        linear-gradient(135deg, rgba(255, 255, 255, 0.96), rgba(247, 250, 251, 0.96));
    padding: 18px 14px;
    border-radius: 7px;
    text-align: center;
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
}

.stat-value {
    font-family: "Cascadia Mono", "SFMono-Regular", Consolas, monospace;
    font-size: 1.65rem;
    line-height: 1.05;
    font-weight: 700;
    color: var(--text);
    margin: 0;
    letter-spacing: 0;
    font-variant-numeric: tabular-nums;
}

.stat-label {
    font-size: 0.82rem;
    color: var(--text-muted);
    margin: 7px 0 0;
    font-weight: 600;
}

/* Status Messages */
.status-success {
    max-width: 100%;
    color: var(--success);
    font-weight: 600;
    overflow-wrap: anywhere;
}

.status-error {
    display: inline-flex;
    align-items: center;
    max-width: 100%;
    min-height: 28px;
    padding: 4px 9px;
    border-radius: 999px;
    color: var(--error);
    background: var(--error-bg);
    font-weight: 700;
    overflow-wrap: anywhere;
    white-space: normal;
}

/* Page Header */
.page-header {
    width: 100%;
    max-width: 1500px;
    margin: 0 auto;
    padding: 26px 0 0;
    border-bottom: 0;
}

.page-header .page-title {
    color: var(--text);
    margin: 0;
    font-size: 1.45rem;
    font-weight: 720;
}

/* Analysis Pages */
.analysis-content {
    display: grid;
    gap: 18px;
    grid-template-columns: minmax(0, 1fr);
    width: 100%;
    max-width: 1500px;
    margin: 20px auto 0;
}

.analysis-section {
    width: 100%;
    max-width: 100%;
    padding: 20px;
}

.analysis-section h4 {
    margin: 0 0 14px;
    font-size: 1.12rem;
    font-weight: 720;
}

.analysis-status {
    margin-top: 12px;
}

.placeholder-text {
    color: var(--text-muted);
    font-style: normal;
    text-align: center;
    padding: 34px;
    background: var(--surface-muted);
    border-radius: var(--radius);
    border: 1px dashed var(--border-strong);
}

.analysis-results-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(480px, 1fr));
    gap: 18px;
    margin-top: 18px;
    width: 100%;
    max-width: 100%;
    overflow: hidden;
}

.analysis-chart-container {
    background: #ffffff;
    border-radius: var(--radius);
    padding: 14px;
    border: 1px solid var(--border);
    max-width: 100%;
    overflow: hidden;
    box-sizing: border-box;
    box-shadow: var(--shadow-sm);
}

.analysis-chart-container h5,
.analysis-chart-title,
.chart-title {
    margin: 0 0 10px;
    color: var(--text);
    font-size: 1rem;
    font-weight: 700;
    text-align: left;
}

#analysis-charts-container,
#analysis-charts-container .js-plotly-plot {
    width: 100%;
    max-width: 100%;
    overflow: hidden;
}

#data-table-container {
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
    margin-top: 14px;
}

#data-table-container .dash-table-container,
#data-table-container .dash-table-container .dash-spreadsheet-container {
    max-width: 100%;
    overflow-x: auto;
}

.control-buttons {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 14px;
}

.analysis-chart-container .js-plotly-plot .plotly {
    height: 400px !important;
    max-height: 400px !important;
}

.analysis-section .js-plotly-plot .plotly {
    height: 500px !important;
    max-height: 500px !important;
}

/* MEV × AFM workspace */
.mevafm-page .content-section {
    padding-top: 18px;
}

.mevafm-command-panel {
    padding: 18px 20px 20px;
}

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

.mevafm-section-header h4 {
    margin: 0;
}

.mevafm-section-note {
    color: var(--text-muted);
    font-size: 0.88rem;
    font-weight: 600;
}

.mevafm-workflow {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--surface-muted);
}

.mevafm-step {
    padding: 5px 10px;
    border-radius: 999px;
    color: var(--text-muted);
    font-size: 0.78rem;
    font-weight: 750;
    white-space: nowrap;
}

.mevafm-step.is-active {
    color: var(--accent-dark);
    background: var(--accent-soft);
}

.mevafm-step.is-complete {
    color: #2e7d55;
    background: #e8f4ec;
}

.mevafm-step.is-complete.is-active {
    color: var(--accent-dark);
    background: var(--accent-soft);
}

.mevafm-upload-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
}

.mevafm-upload-card {
    min-width: 0;
    padding: 16px;
}

.mevafm-upload-card .upload-area {
    min-height: 54px;
    margin-bottom: 10px;
}

.mevafm-field-note {
    color: var(--text-muted);
    font-size: 0.82rem;
    font-weight: 600;
    margin: -2px 0 8px;
}

.mevafm-file-state {
    min-height: 30px;
}

.mevafm-file-chip {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
    width: fit-content;
    max-width: 100%;
    padding: 5px 9px;
    border: 1px solid var(--border);
    border-radius: 999px;
    color: var(--text-muted);
    background: var(--surface-muted);
    font-size: 0.82rem;
}

.mevafm-file-chip.is-loaded {
    color: var(--success);
    border-color: rgba(39, 130, 79, 0.20);
    background: var(--success-bg);
}

.mevafm-file-kind {
    flex: 0 0 auto;
    font-weight: 750;
}

.mevafm-file-name {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.mevafm-action-row {
    display: grid;
    grid-template-columns: minmax(250px, 320px) minmax(0, 1fr);
    gap: 12px;
    align-items: start;
    margin-top: 12px;
}

.mevafm-blend-card {
    padding: 15px 16px 18px;
}

.mevafm-blend-card .rc-slider {
    margin: 12px 4px 10px;
}

.mevafm-blend-card .rc-slider-dot {
    display: none;
}

.mevafm-blend-card .rc-slider-mark,
.mevafm-blend-card .rc-slider-step,
.mevafm-blend-card .dash-slider-mark,
.mevafm-blend-card .dash-slider-tooltip {
    display: none !important;
}

.mevafm-blend-labels {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    color: var(--text-muted);
    font-size: 0.78rem;
    font-weight: 800;
    line-height: 1;
    text-transform: uppercase;
}

.mevafm-blend-labels span:nth-child(2) {
    text-align: center;
}

.mevafm-blend-labels span:nth-child(3) {
    text-align: right;
}

.mevafm-action-stack {
    display: flex;
    align-items: flex-start;
    flex-wrap: wrap;
    gap: 10px;
    padding-top: 2px;
}

.mevafm-action-stack .analysis-button {
    margin: 0;
}

.mevafm-action-stack .analysis-status {
    flex-basis: 100%;
    margin-top: 6px;
}

.mevafm-results-section {
    margin-top: 0;
}

.mevafm-results-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.08fr) minmax(0, 1fr);
    gap: 16px;
}

.mevafm-chart-panel {
    padding: 16px;
}

.mevafm-chart-panel h5 {
    margin-bottom: 8px;
}

.mevafm-chart-panel .js-plotly-plot,
.mevafm-chart-panel .plot-container,
.mevafm-chart-panel .svg-container {
    max-width: 100% !important;
}

.mevafm-corr-card {
    min-height: 260px;
}

.mevafm-empty-corr {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 180px;
    padding: 20px;
    color: var(--text-muted);
    background: var(--surface-muted);
    border: 1px dashed var(--border-strong);
    border-radius: var(--radius);
    text-align: center;
    font-size: 0.9rem;
    font-weight: 650;
}

.mevafm-corr-summary {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
}

.mevafm-metric-card,
.mevafm-model-card {
    border: 1px solid var(--border);
    border-radius: 7px;
    background: var(--surface-muted);
    padding: 12px;
}

.mevafm-metric-label,
.mevafm-model-label {
    color: var(--text-muted);
    font-size: 0.76rem;
    font-weight: 800;
    text-transform: uppercase;
}

.mevafm-metric-value {
    margin-top: 7px;
    color: var(--text);
    font-family: "Cascadia Mono", "SFMono-Regular", Consolas, monospace;
    font-size: 1.15rem;
    font-weight: 760;
    font-variant-numeric: tabular-nums;
}

.mevafm-metric-note {
    margin-top: 5px;
    color: var(--text-muted);
    font-size: 0.78rem;
    font-weight: 650;
}

.mevafm-model-card {
    grid-column: 1 / -1;
}

.mevafm-model-text {
    margin-top: 8px;
    color: var(--text);
    font-family: "Cascadia Mono", "SFMono-Regular", Consolas, monospace;
    font-size: 0.92rem;
    line-height: 1.45;
    overflow-wrap: anywhere;
}

/* Dropdowns */
.Select-control,
.VirtualizedSelectFocusedOption {
    border-color: var(--border-strong) !important;
}

.Select-control {
    border-radius: 7px !important;
    min-height: 40px;
}

.is-focused:not(.is-open) > .Select-control {
    border-color: var(--accent) !important;
    box-shadow: 0 0 0 3px rgba(47, 127, 159, 0.14) !important;
}

/* Modal styles for band configuration */
.modal {
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(23, 40, 51, 0.52);
    backdrop-filter: blur(4px);
}

.modal-content {
    background-color: #ffffff;
    margin: 5% auto;
    padding: 0;
    border-radius: var(--radius);
    box-shadow: 0 24px 70px rgba(23, 40, 51, 0.30);
    width: 80%;
    max-width: 620px;
    max-height: 80%;
    overflow-y: auto;
    border: 1px solid var(--border);
}

.modal-header {
    padding: 18px 20px;
    border-bottom: 1px solid var(--border);
    background-color: var(--surface-muted);
    border-radius: var(--radius) var(--radius) 0 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-body {
    padding: 20px;
}

.modal-footer {
    padding: 15px 20px;
    border-top: 1px solid var(--border);
    background-color: var(--surface-muted);
    border-radius: 0 0 var(--radius) var(--radius);
    text-align: right;
}

.close-button:hover {
    background-color: rgba(23, 40, 51, 0.08) !important;
    border-radius: 5px;
}

.btn-secondary {
    border-radius: 7px !important;
}

.btn-secondary:hover {
    background-color: #e9eef1 !important;
}

.band-input-group {
    animation: fadeIn 180ms ease-in;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-6px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.001ms !important;
        animation-iteration-count: 1 !important;
        scroll-behavior: auto !important;
        transition-duration: 0.001ms !important;
    }
}

@media (max-width: 1200px) {
    .page-content {
        padding: 0 18px 36px;
    }

    .content-section {
        padding: 22px 0;
    }

    .top-controls-row {
        grid-template-columns: minmax(0, 1fr);
    }

    .display-options-section {
        width: 100%;
    }

    .analysis-results-grid {
        grid-template-columns: minmax(0, 1fr);
    }

    .analysis-chart-container {
        min-width: 0;
    }

    .mevafm-upload-grid,
    .mevafm-results-grid {
        grid-template-columns: minmax(0, 1fr);
    }

    .mevafm-action-row {
        grid-template-columns: minmax(0, 1fr);
    }
}

@media (max-width: 900px) {
    .viewer-main-row {
        flex-direction: column;
    }

    .viewer-main-row > * {
        width: 100% !important;
        flex: 1 1 auto !important;
    }
}

@media (max-width: 768px) {
    .navigation-bar {
        padding: 0 14px;
    }

    .nav-content {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
        padding: 14px 0;
        min-height: 0;
    }

    .nav-brand .nav-title {
        font-size: 1.28rem;
        white-space: normal;
    }

    .nav-links {
        justify-content: stretch;
        width: 100%;
        overflow-x: auto;
    }

    .nav-link {
        flex: 1 0 auto;
        text-align: center;
        padding: 9px 12px;
        font-size: 0.86rem;
    }

    .page-content {
        padding: 0 12px 30px;
    }

    .info-card,
    .control-card,
    .graph-container,
    .analysis-section {
        padding: 14px;
    }

    .page-header .page-title {
        font-size: 1.25rem;
    }

    .control-buttons {
        flex-direction: column;
    }

    .analysis-button {
        width: 100%;
        margin-right: 0;
    }

    .file-input {
        width: 100%;
    }

    .mevafm-section-header {
        align-items: flex-start;
        flex-direction: column;
    }

    .mevafm-workflow {
        width: 100%;
        justify-content: space-between;
    }

    .mevafm-step {
        flex: 1;
        text-align: center;
        padding-inline: 6px;
    }

    .mevafm-corr-summary {
        grid-template-columns: minmax(0, 1fr);
    }
}
