/*
 * WMS — what this product adds on top of the common sheets: the plan and its
 * side panel. Buttons, cards, tables, badges and the frame are the common
 * ones (`common/styles/`), the same files SmartDecisions and SmartBilling load.
 */

:root {
    /* The plan's own colours, from the brand's blues. */
    --plan-floor:          #fbfcfe;
    --plan-grid:           #e7edf6;
    --plan-grid-major:     #cfdbea;
    --plan-warehouse:      #dceafa;
    --plan-warehouse-line: #2f6fb5;
    --plan-aisle:          #f3f0e2;
    --plan-aisle-stripe:   #e2d9b0;
    --plan-aisle-line:     #c9b97a;
    --plan-element-line:   rgba(13, 26, 49, 0.35);
    --plan-selected:       #12796f;
    --plan-blocked:        #b4373a;
    /* What a page wants seen at once (where a receipt went): apart from the blues of both looks. */
    --plan-highlight:      #f59e0b;
    --plan-highlight-text: #b45309;
}

.muted { color: var(--muted); }
.small { font-size: var(--fs-label); }

#view > div > :is(.card, section, div) + :is(.card, section, .plan-layout) { margin-top: var(--gap-block); }
#view > div > .sd-page-head + * { margin-top: 0; }

.warehouse-pick select { min-width: 16rem; }

/* ------------------------------------------------------------ Layout -- */

.plan-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 320px;
    gap: var(--gap-block);
    align-items: start;
}
.plan-card { min-width: 0; display: grid; gap: 1rem; }
/* Its one column never grows past the panel: long lists and fields wrap or shrink inside it. */
.plan-panel { position: sticky; top: calc(var(--topbar-height) + 1rem); display: grid; gap: 0.8rem;
              grid-template-columns: minmax(0, 1fr); }
.plan-panel > * { min-width: 0; }
.plan-panel .field input { width: 100%; min-width: 0; box-sizing: border-box; }
.plan-panel h3 { margin: 0; display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }

.plan-tools { display: grid; gap: 1.1rem; }
.tool-group { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 0.75rem; }
.tool-title { flex-basis: 100%; margin: 0; font-size: var(--fs-label); font-weight: 700; text-transform: uppercase;
              letter-spacing: 0.08em; color: var(--muted); }
.tool-group .field input { width: 6rem; }
.tool-group .field input[name="name"] { width: 12rem; }
.plan-tools .field input { width: 7rem; }
.plan-tools .field input[name="name"] { width: 14rem; }

.plan-legend { display: flex; flex-wrap: wrap; gap: 0.5rem 1.1rem; font-size: var(--fs-label); color: var(--muted); }
.plan-legend span { display: inline-flex; align-items: center; gap: 0.35rem; }
.plan-legend i { width: 0.9rem; height: 0.9rem; border-radius: 3px; border: 1px solid var(--plan-element-line); }
.plan-legend i.is-aisle { background: repeating-linear-gradient(45deg, var(--plan-aisle) 0 3px, var(--plan-aisle-stripe) 3px 5px); }

/* --------------------------------------------------------------- Plan -- */

.plan-host {
    overflow: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--plan-floor);
}
/* The 3D view takes the plan's place, with its own height: a canvas has none. */
.plan-views { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.plan-3d { position: relative; overflow: hidden; height: clamp(420px, 68vh, 760px); }
.plan3d-canvas { display: block; width: 100%; height: 100%; touch-action: none; }
.plan3d-message { margin: 0; padding: 2rem; color: var(--muted); text-align: center; }
.plan3d-tools { position: absolute; top: 0.75rem; right: 0.75rem; display: flex; gap: 0.4rem; flex-wrap: wrap; }
.plan3d-tools .btn { background: var(--panel); }
.plan3d-tools .btn[aria-pressed="true"] { border-color: var(--plan-selected); color: var(--plan-selected); }
.plan3d-hint { position: absolute; left: 0.75rem; bottom: 0.75rem; margin: 0; max-width: calc(100% - 1.5rem);
               padding: 0.35rem 0.6rem; border-radius: var(--radius-sm); background: var(--panel);
               border: 1px solid var(--border); color: var(--muted); font-size: var(--fs-label); pointer-events: none; }
.plan3d-tip { position: absolute; z-index: 2; display: grid; gap: 0.15rem; max-width: 280px; padding: 0.5rem 0.7rem;
              border-radius: var(--radius-sm); background: var(--panel); border: 1px solid var(--border);
              box-shadow: 0 8px 24px rgba(13, 26, 49, 0.16); font-size: var(--fs-label); pointer-events: none; }
.plan3d-tip span { color: var(--muted); }
.plan3d-tip .plan3d-tip-sub { color: var(--plan-selected); font-weight: 700; }
@media (max-width: 640px) { .plan3d-hint { display: none; } }
.plan-svg { display: block; width: 100%; height: auto; touch-action: none; user-select: none; }
.plan-floor { fill: var(--plan-floor); }
/* A warehouse that is not a rectangle: outside its walls is not floor. */
.plan-floor.is-outside { fill: var(--plan-grid); }
.plan-walls { stroke: var(--plan-warehouse-line); stroke-width: 2px; vector-effect: non-scaling-stroke; }
.plan-grid line { stroke: var(--plan-grid); stroke-width: 0.05; }
.plan-grid line.is-major { stroke: var(--plan-grid-major); stroke-width: 0.1; }
.plan-ruler line { stroke: var(--text); stroke-width: 0.15; }
.plan-ruler text { font-size: 1.2px; fill: var(--muted); text-anchor: middle; font-family: var(--font); }

.plan-item { cursor: grab; outline: none; }
.plan-item:active { cursor: grabbing; }
.plan-item rect { stroke-width: 0.12; vector-effect: non-scaling-stroke; transition: filter 0.15s ease; }
.plan-item.is-warehouse rect { stroke-width: 2px; }
.plan-item.is-element rect { stroke-width: 1px; }
.plan-item.is-aisle rect { stroke-width: 1px; stroke-dasharray: 4 3; }
.plan-item text {
    fill: var(--text-strong);
    font-family: var(--font);
    font-weight: 700;
    text-anchor: middle;
    dominant-baseline: central;
    pointer-events: none;
}
/* On a light tone or on its fill: dark letters with a light edge read on both. */
.plan-item.is-element text { fill: var(--text-strong); font-weight: 600; paint-order: stroke;
                             stroke: rgba(255, 255, 255, 0.85); stroke-width: 0.12; stroke-linejoin: round; }
.plan-item.is-aisle text { fill: #8a7a3d; font-weight: 600; }
.plan-item text.plan-sub { font-weight: 500; fill: var(--muted); }
.plan-item:hover rect, .plan-item:focus-visible rect { filter: brightness(1.06) drop-shadow(0 0 0.3px rgba(13, 26, 49, 0.4)); }
.plan-item.is-selected rect { stroke: var(--plan-selected); stroke-width: 3px; stroke-dasharray: none; }
.plan-item.is-blocked rect { stroke: var(--plan-blocked); stroke-width: 3px; fill-opacity: 0.6; }
/* What the page wants seen at once (where a receipt went): a thick outline that pulses. */
.plan-item.is-glowing rect:not(.plan-fill) { stroke: var(--plan-highlight); stroke-width: 4px; stroke-dasharray: none;
                                             animation: plan-glow 1.3s ease-in-out infinite; }
@keyframes plan-glow {
    0%, 100% { filter: drop-shadow(0 0 0 transparent); stroke-opacity: 1; }
    50% { filter: drop-shadow(0 0 7px var(--plan-highlight)); stroke-opacity: 0.6; }
}
@media (prefers-reduced-motion: reduce) { .plan-item.is-glowing rect:not(.plan-fill) { animation: none; } }
.placed-in .code[data-label] { cursor: pointer; text-decoration: underline dotted; }
.plan-panel .is-placed { color: var(--plan-highlight-text); font-weight: 700; }
/* How full an element is: never outlined, never caught by the pointer. */
.plan-item rect.plan-fill { stroke: none; pointer-events: none; }

/* The handle that turns the selected item, and the aisle being drawn. */
.plan-rotate { cursor: grab; }
.plan-rotate line { stroke: var(--plan-selected); stroke-width: 1.5px; vector-effect: non-scaling-stroke; }
.plan-rotate circle { fill: #ffffff; stroke: var(--plan-selected); stroke-width: 2px; vector-effect: non-scaling-stroke; }
.plan-svg.is-drawing { cursor: crosshair; }
.plan-drawing { fill: var(--plan-aisle); fill-opacity: 0.7; stroke: var(--plan-aisle-line); stroke-width: 2px;
                stroke-dasharray: 5 3; vector-effect: non-scaling-stroke; pointer-events: none; }

/* -------------------------------------------------------------- Panel -- */

.panel-form { display: grid; gap: 0.8rem; }
.panel-form .field-row > .field { flex: 1 1 5rem; }
.panel-form .field input, .panel-form .field select { width: 100%; }
.panel-label { margin: 0.4rem 0 0; font-size: var(--fs-label); font-weight: 700; text-transform: uppercase;
               letter-spacing: 0.08em; color: var(--muted); }

.code {
    font-family: 'JetBrains Mono', ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
    font-size: var(--fs-table);
    font-weight: 600;
    color: var(--text-strong);
    /* A code is one word: a narrow column never breaks it at its separators. */
    white-space: nowrap;
}
.code.is-new { color: var(--plan-selected); }
.code-chips { display: flex; flex-wrap: wrap; gap: 0.35rem; }
.code-chips .code { padding: 0.15rem 0.45rem; border-radius: 6px; background: var(--bg-alt); }
/* Printing labels, under the data of what is selected. */
.labels-tool { display: grid; gap: 0.4rem; margin-top: 0.8rem; padding-top: 0.8rem; border-top: 1px solid var(--border); }

.recode-confirm { display: grid; gap: 0.6rem; }
.recode-confirm h3 { margin: 0; }
.recode-list, .change-list { margin: 0; padding: 0; list-style: none; display: grid; gap: 0.35rem;
                             max-height: 22rem; overflow: auto; }
.change-list li { display: flex; flex-wrap: wrap; align-items: center; gap: 0.4rem; font-size: var(--fs-text); }

/* The bar that says there is something to save, over the plan. */
.save-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.75rem;
    padding: 0.7rem 1rem;
    border: 1px solid var(--warning);
    border-radius: var(--radius-sm);
    background: var(--panel);
    box-shadow: var(--shadow-sm);
}
.save-count { font-weight: 700; color: var(--warning); margin-right: auto; }
.save-bar input { width: 18rem; max-width: 100%; }

/* --------------------------------------------------------------- Site -- */

/* The facility's map and what is measured from its outline. */
.site-status { margin: 0.6rem 0; font-weight: 600; color: var(--text-strong); }
.site-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 280px;
    gap: var(--gap-block);
    align-items: start;
    margin-bottom: 1rem;
}
.site-map { height: 480px; border: 1px solid var(--border); border-radius: var(--radius-sm); }
.site-measures { display: grid; gap: 0.6rem; }
.site-problem { margin: 0; font-weight: 600; color: var(--danger); }
.site-figures { margin: 0; display: grid; gap: 0.5rem; }
.site-figures div { display: grid; gap: 0.1rem; }
.site-figures dt { font-size: var(--fs-label); color: var(--muted); text-transform: uppercase; letter-spacing: 0.08em; }
.site-figures dd { margin: 0; font-weight: 700; color: var(--text-strong); }
.site-sides { margin: 0; padding: 0; list-style: none; display: grid; gap: 0.25rem; max-height: 14rem; overflow: auto;
              font-size: var(--fs-table); }
.site-sides li { display: flex; justify-content: space-between; gap: 0.5rem; }

/* A vertex on the map: its number in a round mark. */
.site-vertex span {
    display: grid;
    place-items: center;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    border: 2px solid #ffffff;
    background: var(--plan-selected);
    color: #ffffff;
    font: 700 12px var(--font);
    box-shadow: 0 1px 4px rgba(13, 26, 49, 0.5);
}
.site-map-tall { height: 620px; }
.leaflet-tooltip.site-label {
    padding: 2px 6px;
    border: none;
    background: rgba(255, 255, 255, 0.92);
    color: var(--text-strong);
    font: 700 12px var(--font);
    box-shadow: 0 1px 3px rgba(13, 26, 49, 0.4);
}
.plan-panel tr[data-id] { cursor: pointer; }
.plan-layout.is-site { grid-template-columns: minmax(0, 1fr) 380px; }
.plan-panel tr.is-selected td { background: var(--bg-alt); font-weight: 700; }
.panel-detail { display: grid; gap: 0.6rem; }
.leaflet-tooltip.site-side {
    padding: 1px 5px;
    border: none;
    background: rgba(13, 26, 49, 0.75);
    color: #ffffff;
    font: 600 11px var(--font);
    box-shadow: none;
}

/* ----------------------------------------------------------- Inbound -- */

/* The lines of a receipt: where each part was placed, or what it waits for. */
.inbound-lines { display: grid; gap: 0.5rem; margin: 1rem 0 0.5rem; }
.inbound-line {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.6rem;
    padding: 0.6rem 0.8rem;
    border: 1px solid var(--plan-warehouse-line);
    border-radius: var(--radius-sm);
    background: var(--plan-warehouse);
}
.inbound-line span:not(.badge) { color: var(--muted); margin-right: auto; }
.placed-in { flex-basis: 100%; margin: 0; font-size: var(--fs-table); color: var(--text); }
.inbound-line.is-done { border-color: var(--border); background: var(--bg-alt); }
/* What waits for the warehouse, with the call that runs it. */
.waiting-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 0.6rem; margin-top: 1rem; }
.waiting-bar p { margin: 0; margin-right: auto; }
.stock-lot { white-space: nowrap; }
.drag-grip { color: var(--muted); }
#receiptRows tr[data-id] { cursor: pointer; }
#receiptRows tr.is-selected td { background: var(--bg-alt); font-weight: 700; }

/* ---------------------------------------------------------- Outbound -- */

/* An order's guide: each product, where it is taken from, numbered as the route walks. */
.pick-list { margin: 0; padding: 0; list-style: none; display: grid; gap: 0.8rem; }
.pick-list > li { padding: 0.7rem 0.8rem; border: 1px solid var(--border); border-radius: var(--radius-sm);
                 min-width: 0; }
.pick-list > li.is-done { background: var(--bg-alt); }
.pick-head { display: flex; flex-wrap: wrap; align-items: center; gap: 0.4rem 0.6rem; }
.pick-head span:not(.badge) { color: var(--muted); font-size: var(--fs-table); }
.pick-spots { margin: 0.5rem 0 0; padding: 0; list-style: none; display: grid; gap: 0.25rem; font-size: var(--fs-table); }
.pick-spots li { display: flex; flex-wrap: wrap; align-items: center; gap: 0.3rem 0.5rem; }
.pick-spots li.is-chosen { font-weight: 700; }
/* The route's stop a location is on, as the plan numbers it. */
.stop-number {
    display: inline-grid;
    place-items: center;
    min-width: 1.4rem;
    height: 1.4rem;
    border-radius: 50%;
    background: var(--plan-selected);
    color: #ffffff;
    font-size: var(--fs-label);
    font-weight: 700;
}
/* The suggested walk over the plan: drawn on top, never in the way of a click. */
.plan-route { pointer-events: none; }
.plan-route polyline { fill: none; stroke: var(--plan-selected); stroke-width: 2px; stroke-dasharray: 6 4;
                       vector-effect: non-scaling-stroke; }
.plan-route circle { fill: var(--plan-selected); }
.plan-route text { fill: #ffffff; font-weight: 700; text-anchor: middle; dominant-baseline: central;
                   font-family: var(--font); pointer-events: none; }
#orderRows tr[data-id] { cursor: pointer; }
#orderRows tr.is-selected td { background: var(--bg-alt); font-weight: 700; }

/* --------------------------------------------------------- Movements -- */

.move-spot { display: grid; gap: 0.35rem; padding-bottom: 0.6rem; border-bottom: 1px solid var(--border); }
.move-item { display: flex; flex-wrap: wrap; align-items: center; gap: 0.4rem; padding: 0.35rem 0.5rem;
.move-item .move { margin-left: auto; }
             border: 1px dashed var(--plan-warehouse-line); border-radius: var(--radius-sm);
             background: var(--plan-warehouse); font-size: var(--fs-table); cursor: grab; }

/* ------------------------------------------------------------- Narrow -- */

@media (max-width: 1100px) {
    .plan-layout, .plan-layout.is-site { grid-template-columns: 1fr; }
    .plan-panel { position: static; }
    .site-layout { grid-template-columns: 1fr; }
    .site-map, .site-map-tall { height: 380px; }
}

/* ------------------------------------------------------------ Inicio -- */

/* The warehouses of a facility: each one opens its summary below. */
.home-warehouses { display: grid; gap: 0.5rem; }
.home-warehouse {
    display: flex; align-items: center; gap: 0.5rem; width: 100%; padding: 0.6rem 0.8rem;
    border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--panel);
    color: var(--text); font: inherit; font-size: var(--fs-text); text-align: left; cursor: pointer;
}
.home-warehouse:hover { border-color: var(--accent); }
.home-warehouse.is-active { border-color: var(--accent); background: var(--accent-3); }
.home-warehouse .badge { margin-left: auto; }

/* What an element of the plan holds, level by level, over the page. */
.home-dialog {
    width: min(46rem, calc(100vw - 2rem)); max-height: calc(100vh - 4rem); padding: 1rem 1.2rem;
    border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--panel); color: var(--text);
}
.home-dialog::backdrop { background: rgb(0 0 0 / 0.45); }
.home-level { display: grid; gap: 0.35rem; padding: 0.6rem 0; border-top: 1px solid var(--border); }

/* A warehouse VENDER keeps not for sale: the same amber as its outline on the map. */
.sale-band {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    border-radius: var(--radius-sm, 6px);
    background: #fbe7c4;
    color: #7a4b07;
    font-weight: 600;
}

/* The stock alarm: soft backgrounds, so the text over them stays readable. */
.level-badge {
    display: inline-block;
    padding: 0.1rem 0.5rem;
    border-radius: var(--radius-sm, 8px);
    font-weight: 600;
    white-space: nowrap;
}
.level-below { background: #fde2e1; color: #9b1c1c; }
.level-near { background: #fff3c4; color: #7a5b00; }
.level-normal { background: #dcf3e3; color: #1d6b3a; }
.level-above { background: #e3f2fd; color: #1b5e8c; }

/* The match with VENDER's warehouse: amber while it is missing, since the
   warehouse cannot be put in use without it. */
.vender-match { margin: var(--gap-block, 1rem) 0; padding: 0.75rem 1rem; border-radius: var(--radius-sm, 8px);
    background: var(--surface-2, #f3f6fa); }
.vender-match.is-missing { background: #fbe7c4; color: #7a4b07; }

