/* FloodMapp admin overlay — panel styling.
   Mirrors the Wind ARI (tg) panel in climateData.css: it occupies the same
   .LoopControlsPanel slot and should be indistinguishable from the panels it
   swaps with. */

@media only screen and (max-width:6000px) {

    /* .LoopControlsPanel is a fixed grid slot (rows 8-10 of the desktop grid =
       290px). Unlike the panels this swaps with, the layer list has no fixed
       length — FloodMapp can publish any number of layers — so the panel has
       to constrain itself and scroll internally rather than spilling over the
       Layers and Functions panels below it.

       height:100% is what gives the inner flex column something definite to
       resolve against; without it .ClimateControls' own height:100% collapses
       to content height and the box grows unbounded. */
    .FloodmappLoopControls {
        display: none;
        height: 100%;
        box-sizing: border-box;
        overflow: hidden;
        /* Match .LoopControlsPanel so the clip follows its rounded corners
           rather than squaring them off. */
        border-radius: 16px;
    }

    .FloodmappLoopControls .ClimateControls {
        display: flex;
        flex-direction: column;
        height: 100%;
        box-sizing: border-box;
        padding-bottom: 8px;
        overflow: hidden;
    }

    .FloodmappLoopControls .headers {
        flex: 0 0 auto;
        margin: 6px 0 2px;
    }

    #floodmappStatus {
        flex: 0 0 auto;
        margin: 0 14px 4px;
        font-size: 11px;
        font-family: 'Open Sans', 'Roboto', Arial, sans-serif;
        color: rgba(255, 255, 255, 0.75);
        text-align: center;
        min-height: 14px;
    }

    /* min-height:0 is required — a flex child defaults to min-height:auto,
       which refuses to shrink below its content and so never scrolls. */
    #floodmappLayerList {
        flex: 1 1 auto;
        min-height: 0;
        overflow-y: auto;
        margin: 0 10px;
        padding-right: 4px;
        scrollbar-width: thin;
        scrollbar-color: rgba(255, 255, 255, 0.35) transparent;
    }

    .floodmappGroup {
        font-size: 11px;
        font-family: 'Open Sans', 'Roboto', Arial, sans-serif;
        color: rgba(255, 255, 255, 0.6);
        text-transform: uppercase;
        letter-spacing: 0.4px;
        margin: 6px 0 2px 6px;
    }

    .floodmappRow {
        margin-bottom: 2px;
    }

    .floodmappItem {
        display: flex;
        align-items: flex-start;
        gap: 6px;
        padding: 3px 6px;
        border-radius: 5px;
        font-size: 12px;
        line-height: 1.25;
        font-family: 'Open Sans', 'Roboto', Arial, sans-serif;
        color: white;
        cursor: pointer;
        transition-duration: 0.2s;
    }

    .floodmappItem:hover {
        background-color: rgba(255, 255, 255, 0.1);
    }

    .floodmappCheck {
        /* Nudge the box onto the first line of a title that wraps. */
        margin-top: 2px;
        flex: 0 0 auto;
        cursor: pointer;
    }

    /* Legends come straight from FloodMapp's own GetLegendGraphic, so they
       always match what is actually drawn — including when they restyle a
       layer. White background because they are rendered with black label text
       on transparent. Capped because they are authored at up to 164x120, which
       would swallow the whole panel. */
    .floodmappLegend {
        display: block;
        max-width: calc(100% - 24px);
        max-height: 54px;
        width: auto;
        margin: 1px 0 4px 24px;
        padding: 2px 4px;
        background-color: rgba(255, 255, 255, 0.9);
        border-radius: 4px;
    }

    #floodmappValueControls {
        flex: 0 0 auto;
    }

    .FloodmappLoopControls .ClimateDropDownDiv {
        justify-content: space-between;
        gap: 0;
        margin-top: 5px;
        margin-left: 14px;
        margin-right: 14px;
    }

    .FloodmappLoopControls .ClimateControls label {
        flex: 0 0 42%;
        box-sizing: border-box;
        text-align: right;
        padding-right: 10px;
        font-size: 12px;
        white-space: nowrap;
    }

    .FloodmappLoopControls .ClimateControls select {
        flex: 0 0 55%;
        width: 55%;
        box-sizing: border-box;
        font-size: 12px;
        text-align: left;
    }

    /* Min and max share one row — vertical space in this slot is the scarce
       resource, and they are read as a pair anyway. */
    .floodmappRangePair {
        flex: 0 0 55%;
        display: flex;
        gap: 4px;
    }

    .floodmappRangePair input {
        flex: 1 1 0;
        min-width: 0;
        box-sizing: border-box;
        font-size: 12px;
        text-align: left;
    }

    /* .floodmappItem is also a label, but it lays out its own row — keep the
       form-row label rules above from reaching it. */
    .FloodmappLoopControls .ClimateControls label.floodmappItem {
        flex: 1 1 auto;
        text-align: left;
        padding-right: 0;
        white-space: normal;
    }

    .floodmappButtons {
        flex: 0 0 auto;
        display: flex;
        justify-content: center;
        gap: 6px;
        margin-top: 8px;
    }

    #floodmappRefreshBtn,
    #floodmappClearBtn,
    #floodmappAutoRangeBtn {
        position: relative;
        /* sit above the layers panel that overlaps this slot */
        z-index: 1000;
        padding: 4px 9px;
        font-size: 12px;
        font-family: 'Open Sans', 'Roboto', Arial, sans-serif;
        color: white;
        background-color: rgb(29, 52, 76);
        border: 1px solid rgb(29, 52, 76);
        border-radius: 6px;
        cursor: pointer;
        white-space: nowrap;
        transition-duration: 0.2s;
    }

    #floodmappRefreshBtn:hover,
    #floodmappClearBtn:hover,
    #floodmappAutoRangeBtn:hover {
        background-color: rgb(22, 39, 56);
    }

    /* ── FloodMapp depth colour bar — mirrors the IFD/tg scale layout ──────── */
    #divFloodmappScale {
        display: none;
    }

    #floodmappScaleContainer {
        display: flex;
        align-items: flex-start;
        margin: 10px;
    }

    #floodmappColorScaleBar {
        display: flex;
        flex-direction: column-reverse;
        /* min at bottom, max at top */
        width: 30px;
        height: 347px;
        border: 1px solid black;
        margin-right: 10px;
        margin-top: 9px;
    }

    #floodmappLabels {
        display: flex;
        flex-direction: column-reverse;
        justify-content: space-between;
        /* Matches the bar's content height so each label lines up with the
           tick drawn by .color-segment::before at the same fraction. */
        height: 366px;
        font-size: 13px;
        font-family: 'Open Sans', 'Roboto', Arial, sans-serif;
        color: white;
    }

    #floodmappScaleUnits {
        text-align: center;
        font-size: 13px;
        font-family: 'Open Sans', 'Roboto', Arial, sans-serif;
        color: white;
        margin-top: -5px;
    }

    #floodmappScaleReadout {
        font-size: 14px;
        font-family: 'Open Sans', 'Roboto', Arial, sans-serif;
        text-align: center;
        margin-top: 2px;
        min-height: 18px;
        color: white;
    }
}
