/*
   NOTE ON site.css COMPATIBILITY:
   site.css is the shared design system (loaded globally) and is
   never modified here. This file only adds Yard-page-specific
   layout. Every selector below that could collide with a site.css
   selector of the same name (.stat-card, .legend-item) has been
   scoped under a page-specific parent class so it always wins
   regardless of stylesheet load order, without needing an
   !important or a markup change.
*/

.yard-page {
    width: 100%;
    height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ============================================================
   HEADER / TOOLBAR
   ============================================================ */

/*
   The page is a single flex column that fills the viewport.
   Header / stats / legend are fixed-height (flex-shrink: 0).
   <main> takes all remaining space (flex: 1) so canvas and
   details panels never rely on a hardcoded "100vh - Npx" value
   that breaks the moment the header wraps to two lines.
*/

.yard-page-v2 {
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: #f4f7fb;
    color: #1f2937;
}

.yard-toolbar-v2 {
    flex-shrink: 0;
    display: flex;
    justify-content: space-between;
    gap: 18px;
    align-items: center;
    padding: 14px 16px;
    background: #ffffff;
    border-bottom: 1px solid #dfe5ec;
    box-shadow: 0 1px 3px rgba(0, 0, 0, .05);
}

.yard-title-wrap h1 {
    margin: 0;
    font-size: 24px;
    line-height: 1.15;
}

.yard-title-wrap .sub-title {
    margin-top: 4px;
    color: #667085;
    font-size: 13px;
}

.yard-controls {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    align-items: center;
    gap: 8px;
}

    .yard-controls input,
    .yard-controls select,
    .yard-controls button {
        height: 36px;
        border: 1px solid #cbd5e1;
        border-radius: 6px;
        background: #ffffff;
        padding: 0 10px;
        font-size: 13px;
    }

    .yard-controls input {
        min-width: 220px;
    }

    .yard-controls button {
        cursor: pointer;
        font-weight: 600;
    }

        .yard-controls button:hover {
            background: #f1f5f9;
        }

        .yard-controls button.active {
            background: #e8f2ff;
            border-color: #7db3f4;
        }

.zoom-value {
    min-width: 58px;
    text-align: center;
    font-weight: 700;
    color: #344054;
}

/* Select2 sizing to match the rest of the toolbar controls */
.yard-controls .select2-container {
    min-width: 160px;
}

    .yard-controls .select2-container .select2-selection--single {
        height: 36px;
        border: 1px solid #cbd5e1;
        border-radius: 6px;
    }

    .yard-controls .select2-container .select2-selection__rendered {
        line-height: 34px;
        font-size: 13px;
    }

    .yard-controls .select2-container .select2-selection__arrow {
        height: 34px;
    }

/* ============================================================
   SUMMARY CARDS
   ============================================================ */

.stats-v2 {
    flex-shrink: 0;
    display: grid;
    grid-template-columns: repeat(5, minmax(120px, 1fr));
    gap: 10px;
    padding: 10px 16px;
}

    /*
   Scoped as ".stats-v2 .stat-card" (not bare ".stat-card") because
   site.css already defines a ".stat-card" component (dashboard
   icon+value card) with a different box model. This selector is
   more specific, so the Yard summary cards render correctly no
   matter which stylesheet loads first, and the dashboard's own
   .stat-card elsewhere in the app is left completely untouched.
*/
    .stats-v2 .stat-card {
        background: #ffffff;
        border: 1px solid #dfe5ec;
        border-radius: 8px;
        padding: 10px 12px;
        box-shadow: 0 1px 2px rgba(0, 0, 0, .03);
        display: block;
    }

        .stats-v2 .stat-card span {
            display: block;
            color: #667085;
            font-size: 12px;
            margin-bottom: 3px;
        }

        .stats-v2 .stat-card strong {
            font-size: 21px;
        }

/* ============================================================
   LEGEND / STATUS
   ============================================================ */

.yard-statusbar {
    flex-shrink: 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    padding: 0 16px 10px;
    color: #667085;
    font-size: 12px;
}

.yard-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 14px;
    align-items: center;
}

    /*
   Scoped as ".yard-legend .legend-item" (not bare ".legend-item")
   because site.css already defines ".legend-item" for the damage
   diagram (padding, border, cursor:pointer, hover/active states).
   Scoping guarantees the map legend renders as a plain inline
   chip regardless of load order, and never picks up the damage
   diagram's clickable/hover styling by accident.
*/
    .yard-legend .legend-item {
        display: inline-flex;
        gap: 6px;
        align-items: center;
    }

.legend-box {
    width: 13px;
    height: 13px;
    border: 1px solid #64748b;
    border-radius: 2px;
    display: inline-block;
}

.legend-empty {
    background: #ffffff;
}

.legend-20 {
    background: #42a5f5;
}

.legend-40 {
    background: #ff9800;
}

.legend-stack {
    background: #8b5cf6;
}

.legend-selected {
    background: #ef4444;
}

.last-update strong {
    color: #344054;
}

/* ============================================================
   MAIN LAYOUT
   ============================================================ */

.yard-layout-v2 {
    /*
       flex:1 + min-height:0 lets this element consume exactly
       whatever vertical space is left inside the flex-column
       page, regardless of how tall the header/stats/legend end
       up being (e.g. when the toolbar wraps on narrow screens).
    */
    flex: 1;
    min-height: 0;
    display: grid;
    grid-template-columns: minmax(0, 1fr) 310px;
    gap: 10px;
    padding: 0 16px 16px;
}

.yard-canvas-v2 {
    position: relative;
    height: 100%;
    min-height: 0;
    background: #ffffff;
    border: 1px solid #dfe5ec;
    border-radius: 8px;
    overflow: hidden;
}

#yardSvgContainer {
    width: 100%;
    height: 100%;
    overflow: hidden;
    cursor: grab;
    user-select: none;
}

    #yardSvgContainer.panning {
        cursor: grabbing;
    }

    #yardSvgContainer svg {
        width: 100%;
        height: 100%;
        display: block;
    }

/* ============================================================
   MAXIMIZE OVERLAY

   When toggled, the yard canvas expands to fill the viewport
   in a fixed-position overlay above everything else on the
   page. The details panel/grid layout is untouched underneath,
   so restoring simply removes the class.
   ============================================================ */

.yard-canvas-v2.is-maximized {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100vw;
    height: 100vh;
    z-index: 1050;
    border-radius: 0;
    border: none;
}

.exit-maximize-btn {
    display: none;
    position: absolute;
    top: 12px;
    right: 12px;
    z-index: 1060;
    width: 34px;
    height: 34px;
    border: none;
    border-radius: 50%;
    background: rgba(15, 23, 42, .65);
    color: #ffffff;
    font-size: 16px;
    line-height: 34px;
    text-align: center;
    cursor: pointer;
    padding: 0;
}

    .exit-maximize-btn:hover {
        background: rgba(15, 23, 42, .85);
    }

.yard-canvas-v2.is-maximized .exit-maximize-btn {
    display: block;
}

body.yard-maximized-active {
    overflow: hidden;
}

/* ============================================================
   LOCATION PANEL
   ============================================================ */

.details-panel-v2 {
    background: #ffffff;
    border: 1px solid #dfe5ec;
    border-radius: 8px;
    padding: 14px;
    overflow: auto;
    height: 100%;
    min-height: 0;
}

    .details-panel-v2 h2 {
        margin: 0 0 12px;
        font-size: 21px;
    }

.location-heading {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
}

    .location-heading h3 {
        margin: 0;
        font-size: 18px;
        overflow-wrap: anywhere;
    }

.size-badge {
    border-radius: 999px;
    padding: 4px 8px;
    font-size: 11px;
    font-weight: 700;
    background: #eef2f6;
    white-space: nowrap;
}

.detail-grid {
    display: grid;
    grid-template-columns: 90px 1fr;
    gap: 7px 10px;
    font-size: 13px;
}

    .detail-grid .label {
        color: #667085;
    }

    .detail-grid .value {
        font-weight: 600;
        overflow-wrap: anywhere;
    }

.stack-card {
    border: 1px solid #e2e8f0;
    border-radius: 7px;
    padding: 9px;
    margin-top: 8px;
    background: #f8fafc;
}

    .stack-card strong {
        display: block;
        margin-bottom: 5px;
    }

/* ============================================================
   LOADING
   ============================================================ */

#loading {
    position: absolute;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, .70);
    font-weight: 700;
    z-index: 20;
}

/* ============================================================
   SVG CONTAINER EFFECTS
   ============================================================ */

.yard-container-marker {
    transition: fill-opacity .15s ease, stroke-width .15s ease;
}

    .yard-container-marker:hover {
        fill-opacity: 1 !important;
    }

.yard-slot-occupied {
    fill: #ffd180 !important;
}

.yard-slot-selected {
    fill: #ff5722 !important;
    stroke: #b71c1c !important;
    stroke-width: 3 !important;
    filter: none;
}

.dimmed-container {
    opacity: .12 !important;
}

.hidden-container {
    display: none !important;
}

/* ============================================================
   HOVER TOOLTIP

   Single floating element, positioned near the mouse cursor,
   shown when hovering any element (original slot polygon or a
   rendered container marker) that carries a "data-tooltip"
   attribute. See setupTooltip() in yard.js.
   ============================================================ */

.yard-tooltip {
    position: fixed;
    z-index: 2000;
    pointer-events: none;
    background: rgba(15, 23, 42, .92);
    color: #ffffff;
    padding: 6px 10px;
    border-radius: 6px;
    font-size: 12px;
    line-height: 1.5;
    white-space: pre-line;
    box-shadow: 0 4px 10px rgba(0, 0, 0, .25);
    display: none;
    max-width: 240px;
}

/* ============================================================
   RESPONSIVE
   ============================================================ */

@media (max-width: 1000px) {

    /*
       Below this width the two panels stack vertically instead
       of sitting side-by-side, so the page can no longer rely on
       a fixed-height flex column that hides overflow — content
       needs to scroll instead.
    */
    html,
    body {
        overflow-y: auto;
    }

    .yard-page-v2 {
        height: auto;
        min-height: 100vh;
        overflow: visible;
    }

    .yard-toolbar-v2 {
        align-items: flex-start;
        flex-direction: column;
    }

    .yard-controls {
        justify-content: flex-start;
        width: 100%;
    }

        .yard-controls input {
            min-width: 0;
            flex: 1 1 160px;
        }

    .stats-v2 {
        grid-template-columns: repeat(2, minmax(120px, 1fr));
    }

    .yard-layout-v2 {
        flex: none;
        grid-template-columns: 1fr;
    }

    .yard-canvas-v2 {
        height: 60vh;
        min-height: 420px;
    }

    .details-panel-v2 {
        height: auto;
        max-height: 40vh;
    }
}

@media (max-width: 560px) {

    .yard-title-wrap h1 {
        font-size: 20px;
    }

    .stats-v2 {
        grid-template-columns: 1fr 1fr;
        padding: 8px 10px;
    }

    .yard-statusbar {
        padding: 0 10px 10px;
    }

    .yard-controls .select2-container {
        min-width: 130px;
        flex: 1 1 130px;
    }

    .yard-canvas-v2 {
        height: 50vh;
        min-height: 320px;
    }

    .details-panel-v2 {
        max-height: 35vh;
    }
}

/* ============================================================
   LABELS DISABLED — replaced by hover tooltip
   ============================================================ */

.yard-container-marker[data-yard-label] {
    display: none !important;
}

.yard-container-marker[data-yard-label],
.yard-40ft-label {
    display: none !important;
}