/* Scale Summary — layout + sidebar styles
   Auto-served by Dash from /assets/. */

/* === Height plumbing ===================================================
   On desktop (>= lg) we plumb height through Dash's nested page-container
   chain so the sidebar can fill the viewport.

   On mobile we DELIBERATELY drop this chain — letting .ss-page take its
   natural height — so the page can scroll the whole way down through the
   stacked sidebar + plots. Without this, the natural sidebar height
   collapses the content area (and therefore the plots) to ~0.

   DOM chain (top → down):
     #page-content-wrapper  (style: flex:1, overflow-y:auto)
       > div                ← dash.page_container outer, no id/class
         > #_pages_content  (Dash internal)
           > .ss-page       ← us
   */
@media (min-width: 992px) {
    #page-content-wrapper:has(.ss-page) {
        display: flex;
        flex-direction: column;
    }
    #page-content-wrapper:has(.ss-page) > div {
        flex: 1;
        min-height: 0;
        display: flex;
        flex-direction: column;
    }
    #_pages_content:has(.ss-page) {
        flex: 1;
        min-height: 0;
        display: flex;
        flex-direction: column;
    }
    .ss-page {
        flex: 1;
        min-height: 0;
    }
    .ss-layout {
        flex: 1;
        min-height: 0;
    }
}

.ss-page {
    width: 100%;
    background-color: #ffffff;
    display: flex;
    flex-direction: column;
}

.ss-layout {
    display: flex;
    flex-direction: row;
    align-items: stretch;
}

/* === Sidebar =========================================================== */
.ss-sidebar {
    flex: 0 0 240px;
    width: 240px;
    background-color: #f8f9fa;
    border-right: 1px solid #dee2e6;
    padding: 1rem 1rem 1.5rem 1rem;
    overflow-y: auto;
}

.ss-sidebar-header {
    font-weight: 600;
    font-size: 0.85rem;
    color: #6c757d;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 0.75rem;
}

.ss-label {
    display: block;
    font-weight: 500;
    font-size: 0.8rem;
    color: #495057;
    margin-bottom: 0.25rem;
    margin-top: 0.5rem;
}

.ss-sep {
    border-top: 1px solid #dee2e6;
    margin: 1rem 0 0.5rem 0;
}

.ss-endpoint-list {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

.ss-endpoint-input {
    margin-right: 0.4rem;
}

.ss-endpoint-label {
    font-size: 0.85rem;
    color: #212529;
    display: inline-block;
    cursor: pointer;
}

.ss-radio {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

.ss-radio-input {
    margin-right: 0.4rem;
}

.ss-radio-label {
    font-size: 0.85rem;
    color: #212529;
    cursor: pointer;
}

.ss-dropdown {
    font-size: 0.85rem;
    margin-bottom: 0.5rem;
}

.ss-overlay-toggle {
    margin-top: 0.25rem;
}

/* === Content =========================================================== */
.ss-content {
    flex: 1 1 auto;
    min-width: 0;
    padding: 1rem 1.25rem 2rem 1.25rem;
    overflow-y: auto;
}

.ss-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 0.75rem;
}

.ss-y-mode {
    display: flex;
    gap: 1rem;
}

.ss-refresh-btn {
    font-size: 0.8rem;
}

.ss-message {
    font-size: 0.85rem;
    color: #6c757d;
    margin-bottom: 0.5rem;
    min-height: 1rem;
}

.ss-empty {
    padding: 2rem 1rem;
    color: #6c757d;
    font-size: 0.9rem;
    border: 1px dashed #dee2e6;
    border-radius: 4px;
    text-align: center;
    background-color: #fafbfc;
}

.ss-plots-area {
    display: flex;
    flex-direction: row;
    align-items: flex-start;
    gap: 1rem;
}

.ss-plots {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.ss-graph {
    border: 1px solid #e9ecef;
    border-radius: 4px;
    background-color: #ffffff;
    /* Anchor a min height; Plotly's autosize otherwise collapses the
       canvas on react() updates when there's no explicit height. */
    min-height: 280px;
}

/* One legend for all panels, on the right of the plot stack. */
.ss-legend {
    flex: 0 0 200px;
    width: 200px;
    background-color: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 4px;
    padding: 0.75rem 0.9rem;
    position: sticky;
    top: 0.75rem;
    font-size: 0.85rem;
    color: #212529;
}

.ss-legend-title {
    font-size: 0.75rem;
    font-weight: 600;
    color: #6c757d;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 0.5rem;
}

.ss-legend-item {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    margin-bottom: 0.3rem;
}

.ss-legend-swatch {
    display: inline-block;
    flex: 0 0 16px;
    width: 16px;
    height: 3px;
    border-radius: 2px;
}

.ss-legend-overlay-swatch {
    background-image: linear-gradient(
        to right, #6c757d 50%, transparent 50%
    );
    background-size: 6px 3px;
    background-color: transparent;
}

.ss-legend-empty {
    color: #6c757d;
    font-size: 0.8rem;
}

/* === Mobile (< lg) ===================================================== */
/* Sidebar stacks above content; legend collapses below plots; tighter
   padding so the limited width is mostly content; the page-content
   wrapper's overflow-y handles the vertical scroll for the whole stack. */
@media (max-width: 991.98px) {
    .ss-layout {
        flex-direction: column;
    }
    .ss-sidebar {
        flex: 0 0 auto;
        width: 100%;
        border-right: none;
        border-bottom: 1px solid #dee2e6;
        padding: 0.75rem 1rem;
        max-height: none;  /* let it grow with content; outer wrapper scrolls */
        overflow-y: visible;
    }
    .ss-content {
        padding: 0.75rem 1rem 2rem 1rem;
        overflow-y: visible;
    }
    .ss-plots-area {
        flex-direction: column;
        /* Override the desktop `align-items: flex-start` (which there
           controls the legend's *vertical* alignment beside the plots).
           On mobile the cross-axis is horizontal — flex-start would
           then pin children to their min-content width, and Plotly's
           SVG default of 700px would lock the canvas at that width
           even on narrower viewports. Stretch lets the plots + legend
           fill the column. */
        align-items: stretch;
    }
    .ss-legend {
        flex: 0 0 auto;
        width: 100%;
        position: static;
    }
    .ss-graph {
        min-height: 240px;
    }
}

/* Phone-portrait extra-tight tweaks. */
@media (max-width: 575.98px) {
    .ss-sidebar {
        padding: 0.5rem 0.75rem;
    }
    .ss-content {
        padding: 0.5rem 0.75rem 1.5rem 0.75rem;
    }
    .ss-graph {
        min-height: 220px;
    }
}
