/* ==========================================================================
   Budget Workspace — shared entry-grid table styles (global, NOT scoped).
   Used by both BudgetWorkspace.razor and the WsGridCard.razor child component,
   so they must render identically. v2 light theme.
   ========================================================================== */

/* card shell + header (title left, + Add Line right, on one bordered row) */
.ws-card { background: var(--bc-surface); border: 1px solid var(--bc-border); border-radius: 14px; overflow: hidden; margin-bottom: 16px; }
.ws-card-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 15px; border-bottom: 1px solid var(--bc-border-faint); }
.ws-card-title-row { display: flex; align-items: center; gap: 7px; font-size: 13px; font-weight: 600; }
.ws-card-dot { font-size: 10px; }
.ws-card-add { height: 30px; padding: 0 12px; font-size: 11px; font-weight: 600; border-radius: var(--bc-r-md); border: 0; background: var(--bc-primary); color: #fff; cursor: pointer; font-family: inherit; }
.ws-empty { padding: 40px 16px; text-align: center; color: var(--bc-text-faint); font-size: 12.5px; line-height: 1.6; }
.ws-empty b { color: var(--bc-text-2); }
.ws-empty-actions { display: flex; gap: 8px; justify-content: center; margin-top: 14px; }

/* parent rollup card (one per child) */
.ws-rc-dot { width: 9px; height: 9px; border-radius: 3px; flex-shrink: 0; margin-right: 3px; background: var(--bc-text-faint); }
.ws-rc-dot.t-t1 { background: var(--bc-tier1-fg); }
.ws-rc-dot.t-t2 { background: var(--bc-tier2-fg); }
.ws-rc-dot.t-t3 { background: var(--bc-tier3-fg); }
.ws-rc-type { font-family: var(--bc-font-mono); font-size: 8.5px; letter-spacing: .06em; text-transform: uppercase; color: var(--bc-text-faint); margin-left: 4px; padding: 2px 6px; border-radius: 5px; background: var(--bc-chip-bg); }
.ws-rc-total { font-family: var(--bc-font-mono); font-size: 12px; font-weight: 700; color: var(--bc-text); }
.ws-rc-label { font-size: 11.5px; font-weight: 600; color: var(--bc-text); }
.ws-ro.strong { color: var(--bc-text); font-weight: 500; }

/* Resizable frozen-column widths (shared across all cards via :root; updated by drag).
   Left offsets are computed from these so sticky columns stay aligned. */
:root {
    --ws-col-name: 200px;
    --ws-col-py: 84px;
    --ws-col-annual: 96px;
    --ws-col-month: 84px;   /* fits up to $99,999,999.99 with cents; 12 fit in full-screen alongside name+PY+annual frozen cols. Single-month billions are unrealistic — those live in annual/rollup totals ($1.0B compact). */
}

.ws-grid-wrap { overflow-x: auto; }
.ws-grid-wrap::-webkit-scrollbar { height: 10px; }
.ws-grid-wrap::-webkit-scrollbar-thumb { background: #D6DCE4; border-radius: 999px; }

/* Excel-style: vertical + horizontal grid lines on every cell, tight padding. */
.ws-grid { border-collapse: separate; border-spacing: 0; width: max-content; min-width: 100%; }
.ws-grid th { padding: 8px 8px; font-size: 9px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--bc-text-faint); background: var(--bc-surface-muted); border-bottom: 1px solid var(--bc-border); border-right: 1px solid var(--bc-border-faint); position: sticky; top: 0; z-index: 3; }
.ws-grid th.l, .ws-grid td.l { text-align: left; }
.ws-grid th.r, .ws-grid td.r { text-align: right; }
.ws-grid th.c, .ws-grid td.c { text-align: center; }
.ws-grid th.mo, .ws-grid td.mo { width: var(--ws-col-month); min-width: var(--ws-col-month); max-width: var(--ws-col-month); }
/* month cells host a full-width input; trim the td gutter so the input keeps the column's width */
.ws-grid td.mo { padding-left: 1px; padding-right: 1px; }
.ws-grid td { padding: 3px 5px; border-bottom: 1px solid var(--bc-border-cell); border-right: 1px solid var(--bc-border-cell); font-size: 11px; }
.ws-grid th:last-child, .ws-grid td:last-child { border-right: 0; }

/* sticky left columns — widths + offsets driven by CSS vars so they can be resized.
   No overflow:hidden here (it would clip the resize handle); inner content ellipsizes. */
.ws-sticky-name { position: sticky; left: 0; z-index: 2; width: var(--ws-col-name); min-width: var(--ws-col-name); max-width: var(--ws-col-name); background: var(--bc-surface); }
.ws-sticky-py { position: sticky; left: var(--ws-col-name); z-index: 2; width: var(--ws-col-py); min-width: var(--ws-col-py); max-width: var(--ws-col-py); background: var(--bc-surface); font-family: var(--bc-font-mono); color: var(--bc-text-muted); }
.ws-sticky-annual { position: sticky; left: calc(var(--ws-col-name) + var(--ws-col-py)); z-index: 2; width: var(--ws-col-annual); min-width: var(--ws-col-annual); max-width: var(--ws-col-annual); background: var(--bc-surface); font-family: var(--bc-font-mono); font-weight: 500; color: var(--bc-text); border-right: 2px solid var(--bc-border); }
/* rollup card has no PY column → Annual sits right after the name column */
.ws-grid.no-py .ws-sticky-annual { left: var(--ws-col-name); }
.ws-grid thead .ws-sticky-name, .ws-grid thead .ws-sticky-py, .ws-grid thead .ws-sticky-annual { z-index: 4; background: var(--bc-surface-muted); }
.ws-actcol { position: sticky; right: 0; background: var(--bc-surface-muted); border-left: 1px solid var(--bc-border-faint); width: 40px; }

/* drag-resize handle on the header cells (sits just inside the right edge) */
.ws-th-resizable { position: relative; }
.ws-resize-handle { position: absolute; top: 0; right: 0; width: 9px; height: 100%; cursor: col-resize; z-index: 6; user-select: none; touch-action: none; }
.ws-resize-handle::after { content: ""; position: absolute; top: 18%; bottom: 18%; right: 2px; width: 2px; border-radius: 2px; background: transparent; transition: background .12s; }
.ws-resize-handle:hover::after, .ws-resize-handle.dragging::after { background: var(--bc-primary); }
body.ws-resizing, body.ws-resizing * { cursor: col-resize !important; user-select: none !important; }

.ws-name-indent { display: inline-flex; align-items: center; }
.ws-line-arrow { width: 16px; height: 16px; display: inline-flex; align-items: center; justify-content: center; border: 0; background: transparent; color: var(--bc-text-faint); cursor: pointer; border-radius: 4px; flex-shrink: 0; margin-right: 2px; transition: transform .15s, background .12s, color .12s; padding: 0; }
.ws-line-arrow:hover { background: var(--bc-border-faint); color: var(--bc-text); }
.ws-line-arrow.open { transform: rotate(90deg); }
.ws-sub-glyph { color: var(--bc-text-faint); font-size: 11px; flex-shrink: 0; margin-right: 5px; }
.ws-line-dot { display: inline-block; width: 7px; height: 7px; border-radius: 2px; margin-right: 7px; vertical-align: middle; }
.ws-line-name { width: calc(100% - 16px); background: transparent; border: 1px solid transparent; color: var(--bc-text); font-family: var(--bc-font-ui); font-size: 11.5px; font-weight: 500; padding: 5px 6px; border-radius: 6px; vertical-align: middle; }
.ws-line-name.rollup { font-weight: 600; }
.ws-line-name:hover { border-color: var(--bc-border); background: var(--bc-hover-bg); }
.ws-line-name:focus { border-color: var(--bc-primary); background: var(--bc-surface); outline: none; box-shadow: 0 0 0 2px var(--bc-primary-ring); }

.ws-addsub { width: 20px; height: 20px; border-radius: 5px; border: 1px solid var(--bc-border); background: var(--bc-surface); color: var(--bc-text-muted); cursor: pointer; font-size: 13px; line-height: 1; display: none; align-items: center; justify-content: center; margin-left: 4px; flex-shrink: 0; }
.ws-sticky-name:hover .ws-addsub { display: inline-flex; }
.ws-addsub:hover { border-color: var(--bc-primary); color: var(--bc-primary-strong); }
.ws-ro { display: inline-block; padding: 5px 3px; font-family: var(--bc-font-mono); font-size: 10.5px; letter-spacing: -.2px; color: var(--bc-text-faint); }

.ws-py-input, .ws-annual-input { width: 100%; box-sizing: border-box; background: transparent; border: 1px solid transparent; font-family: var(--bc-font-mono); font-size: 10.5px; letter-spacing: -.2px; text-align: right; padding: 4px 4px; border-radius: 5px; }
.ws-py-input { color: var(--bc-text-muted); }
.ws-annual-input { color: var(--bc-text); font-weight: 500; font-size: 11.5px; }
.ws-py-input:hover, .ws-annual-input:hover { border-color: var(--bc-border); background: var(--bc-hover-bg); }
.ws-py-input:focus, .ws-annual-input:focus { border-color: var(--bc-primary); background: var(--bc-surface); color: var(--bc-text); outline: none; box-shadow: 0 0 0 2px var(--bc-primary-ring); }

.ws-cell { width: 100%; min-width: 0; background: transparent; border: 1px solid transparent; color: var(--bc-text-2); font-family: var(--bc-font-mono); font-size: 10px; letter-spacing: -.3px; text-align: right; padding: 4px 2px; border-radius: 5px; box-sizing: border-box; }
.ws-cell:hover { border-color: var(--bc-border); background: var(--bc-hover-bg); }
.ws-cell:focus { border-color: var(--bc-primary); background: var(--bc-surface); color: var(--bc-text); outline: none; box-shadow: 0 0 0 2px var(--bc-primary-ring); }

.ws-del { width: 22px; height: 22px; border-radius: 6px; border: 1px solid var(--bc-border); background: var(--bc-surface); color: var(--bc-text-muted); cursor: pointer; display: inline-flex; align-items: center; justify-content: center; }
.ws-del:hover { border-color: var(--bc-danger-border); color: var(--bc-danger); background: var(--bc-danger-bg); }

.ws-total-row td { font-weight: 700; color: var(--bc-text); font-size: 11.5px; background: var(--bc-primary-wash); border-top: 2px solid var(--bc-border); border-bottom: none; font-family: var(--bc-font-mono); }
.ws-total-row td.l { font-family: var(--bc-font-ui); }
.ws-total-row .ws-sticky-name, .ws-total-row .ws-sticky-py, .ws-total-row .ws-sticky-annual { background: var(--bc-primary-wash); }
