/* Distribution Compare — page + per-side panel + stats table */

/* === Height plumbing ===================================================
   Same pattern as Scale Summary: chain the viewport height down to .dc-page
   on desktop, but DROP the chain on mobile so the stacked sides + plots
   scroll naturally via the parent's overflow-y. */
@media (min-width: 992px) {
    #page-content-wrapper:has(.dc-page) {
        display: flex;
        flex-direction: column;
    }
    #page-content-wrapper:has(.dc-page) > div {
        flex: 1;
        min-height: 0;
        display: flex;
        flex-direction: column;
    }
    #_pages_content:has(.dc-page) {
        flex: 1;
        min-height: 0;
        display: flex;
        flex-direction: column;
    }
    .dc-page {
        flex: 1;
        min-height: 0;
    }
    .dc-panes {
        flex: 1;
        min-height: 0;
    }
}

.dc-page {
    width: 100%;
    background-color: #ffffff;
    display: flex;
    flex-direction: column;
    padding: 0.75rem 1.25rem 2rem 1.25rem;
    overflow-y: auto;
}

/* Two side-by-side panes */
.dc-panes {
    display: flex;
    flex-direction: row;
    gap: 1rem;
}

.dc-side {
    flex: 1 1 0;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

/* === Per-side controls — 3-col grid (2 rows of 3 cells) ================
   Row 1: Scale | Y-axis | Visit
   Row 2: Site  | Bin width | Randomized only

   align-items: stretch (default) makes every cell in a row fill the row's
   height; combined with margin: auto 0 on the actual control, that
   centers controls of differing natural heights on a shared baseline. */
.dc-controls {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    column-gap: 0.75rem;
    row-gap: 0.5rem;
    padding: 0.5rem 0.7rem;
    background-color: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 4px;
}

.dc-cell {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.dc-cell > .dc-label {
    margin-bottom: 0.2rem;
}

.dc-cell > .dc-dropdown,
.dc-cell > .dc-radio,
.dc-cell > .dc-slider,
.dc-cell > .dc-randomized {
    margin-top: auto;
    margin-bottom: auto;
}

.dc-cell-slider {
    padding-bottom: 0.4rem;
}

.dc-label {
    display: block;
    font-size: 0.7rem;
    font-weight: 600;
    color: #6c757d;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    line-height: 1.1;
    margin: 0;
}

.dc-dropdown {
    font-size: 0.82rem;
}

.dc-radio {
    display: flex;
    flex-wrap: nowrap;
    gap: 0.75rem;
    padding-top: 0.15rem;
}

.dc-radio-input {
    margin-right: 0.35rem;
}

.dc-radio-label {
    font-size: 0.82rem;
    color: #212529;
    cursor: pointer;
    white-space: nowrap;
}

.dc-randomized {
    font-size: 0.82rem;
}

.dc-graph {
    border: 1px solid #e9ecef;
    border-radius: 4px;
    background-color: #ffffff;
}

.dc-stats {
    border: 1px solid #e9ecef;
    border-radius: 4px;
    padding: 0.5rem 0.75rem;
    background-color: #ffffff;
}

.dc-stats-table {
    width: 100%;
    font-size: 0.85rem;
    table-layout: fixed;
}

.dc-stats-table th {
    font-size: 0.7rem;
    font-weight: 600;
    color: #6c757d;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    text-align: right;
    padding: 0.15rem 0.5rem;
    border-bottom: 1px solid #e9ecef;
}

.dc-stats-table td {
    text-align: right;
    padding: 0.25rem 0.5rem;
    color: #212529;
    font-variant-numeric: tabular-nums;
}

/* === Mobile (< lg) ===================================================== */
/* Stack the two sides vertically; controls grid collapses to 2 cols then
   1; tighter page padding; smaller graph footprint via !important since
   the dcc.Graph anchor uses an inline style. */
@media (max-width: 991.98px) {
    .dc-page {
        padding: 0.75rem 1rem 2rem 1rem;
    }
    .dc-panes {
        flex-direction: column;
    }
    .dc-side {
        flex: 0 0 auto;
    }
    .dc-controls {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
    .dc-graph {
        height: 280px !important;
    }
}

/* Phone-portrait extra-tight tweaks. */
@media (max-width: 575.98px) {
    .dc-page {
        padding: 0.5rem 0.75rem 1.5rem 0.75rem;
    }
    .dc-controls {
        grid-template-columns: 1fr;
        padding: 0.4rem 0.5rem;
    }
    .dc-cell > .dc-dropdown,
    .dc-cell > .dc-radio,
    .dc-cell > .dc-slider,
    .dc-cell > .dc-randomized {
        /* On 1-col layout, the auto-margin centring stops making sense;
           reset to natural flow so labels sit right above controls. */
        margin-top: 0;
        margin-bottom: 0;
    }
    .dc-graph {
        height: 240px !important;
    }
}
