/* NP2 — Rate Price Grid Window (rate-grid-window.js)
   A movable, resizable, non-modal window over the rate editor. Sticky axes,
   sticky grow buttons, hatched refusal cells, external labels everywhere. */

.rgw {
    position: fixed;
    z-index: 1400;                      /* under the shared Modal overlay */
    display: flex;
    flex-direction: column;
    background: #fff;
    border: 1px solid #cbd2da;
    border-radius: 10px;
    box-shadow: 0 18px 50px rgba(15, 23, 42, 0.28);
    min-width: 420px;
    min-height: 260px;
    resize: both;                       /* cheap corner-drag resize */
    overflow: hidden;
}
/* Maximized: fill the space BELOW the NP2 header — the header stays visible and
   usable (the window is non-modal), and its chrome can never cover our buttons. */
.rgw.rgw-max {
    left: 12px !important; top: calc(var(--header-height, 52px) + 8px) !important;
    right: 12px; bottom: 12px;
    width: auto !important; height: auto !important;
    resize: none;
}
.rgw.rgw-sheet {
    left: 0 !important; top: 0 !important; right: 0; bottom: 0;
    width: auto !important; height: auto !important;
    border-radius: 0; border: none; min-width: 0; min-height: 0;
    resize: none;
}
.rgw.rgw-pulse { animation: rgw-pulse 0.5s ease; }
@keyframes rgw-pulse {
    0%   { box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.55), 0 18px 50px rgba(15, 23, 42, 0.28); }
    100% { box-shadow: 0 18px 50px rgba(15, 23, 42, 0.28); }
}

/* ── Title bar ── */
.rgw-titlebar {
    display: flex; align-items: center; gap: 10px;
    padding: 9px 12px;
    background: #1f2937; color: #fff;
    cursor: move; user-select: none;
    flex: 0 0 auto;
}
.rgw-sheet .rgw-titlebar, .rgw-max .rgw-titlebar { cursor: default; }
.rgw-title {
    flex: 1; min-width: 0;
    font-size: 13px; font-weight: 600;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.rgw-titlebtns { display: flex; gap: 6px; }
.rgw-btn {
    border: none; background: rgba(255, 255, 255, 0.14); color: #fff;
    width: 26px; height: 24px; border-radius: 6px; cursor: pointer;
    font-size: 13px; line-height: 1;
}
.rgw-btn:hover { background: rgba(255, 255, 255, 0.28); }
.rgw-sheet .rgw-max-btn { display: none; }

/* ── Header band: the rate's name, big and bold, plus the axis choices ── */
.rgw-head {
    display: flex; flex-wrap: wrap; align-items: baseline; gap: 8px 20px;
    padding: 10px 14px 9px;
    border-bottom: 1px solid #e5e7eb;
    background: #fff;
    flex: 0 0 auto;
}
.rgw-ratename {
    font-size: 20px; font-weight: 800; color: #111827;
    min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
    max-width: 100%;
}
.rgw-axes { display: flex; flex-wrap: wrap; gap: 6px 16px; }
.rgw-axes label {
    display: inline-flex; align-items: center; gap: 6px;
    font-size: 12px; font-weight: 600; color: #374151; white-space: nowrap;
}
.rgw-axis {
    padding: 5px 8px; border: 1px solid #d1d5db; border-radius: 6px;
    font: inherit; font-size: 12.5px; background: #fff;
}
.rgw-axis:disabled { background: #f3f4f6; color: #9ca3af; }

/* ── Body / table ── */
.rgw-bodywrap { flex: 1; min-height: 0; display: flex; }
.rgw-body { flex: 1; overflow: auto; padding: 0; }

.rgw-table { border-collapse: separate; border-spacing: 0; min-width: 100%; }
.rgw-table th, .rgw-table td {
    border-bottom: 1px solid #e5e7eb;
    border-right: 1px solid #f0f2f5;
    padding: 7px 10px;
    vertical-align: top;
    text-align: left;
    background: #fff;
}

/* Sticky axes: header row on top, band column on the left, corner above both.
   Sticky grow buttons: + column pinned right, + row pinned bottom. */
.rgw-table thead th { position: sticky; top: 0; z-index: 3; background: #f8fafc; }
.rgw-corner { position: sticky; left: 0; top: 0; z-index: 5 !important; background: #f8fafc; }
.rgw-rowhead { position: sticky; left: 0; z-index: 2; background: #fbfcfe; white-space: nowrap; }
.rgw-addcol { position: sticky; right: 0; top: 0; z-index: 4; background: #f8fafc; vertical-align: middle; }
.rgw-addrowtr th, .rgw-addrowtr td { position: sticky; bottom: 0; z-index: 2; background: #f8fafc; border-top: 1px solid #e5e7eb; }
.rgw-addrowtr th { left: 0; z-index: 4; }

/* Row ✕ at the end of each row (shares the sticky-right column with + column);
   column ✕ at the bottom of each column (shares the sticky-bottom row with + row). */
.rgw-rowdel { position: sticky; right: 0; z-index: 1; background: #fbfcfe; text-align: center; vertical-align: middle; }
.rgw-coldel { text-align: center; vertical-align: middle; }

.rgw-axisname { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; color: #6b7280; }
.rgw-pairlabel { font-size: 12px; font-weight: 600; color: #374151; margin-top: 4px; }
.rgw-collabel { font-size: 12px; color: #6b7280; font-weight: 600; }

/* ── Bands ── */
.rgw-band {
    width: 58px; padding: 5px 7px;
    border: 1px solid #d1d5db; border-radius: 6px;
    font: inherit; font-size: 13px; text-align: right;
    background: #fff;
}
.rgw-band-named { width: 130px; text-align: left; }
.rgw-band[readonly] { background: #f3f4f6; color: #6b7280; }
.rgw-band:focus { outline: none; border-color: #2563eb; }
.rgw-band.rgw-err { border-color: #dc2626; background: #fef2f2; }

.rgw-pair { display: inline-flex; align-items: center; gap: 5px; flex-wrap: wrap; }
.rgw-colon { color: #9ca3af; font-weight: 700; }
.rgw-any { font-size: 12px; color: #6b7280; }
.rgw-andup { font-size: 11px; color: #6b7280; font-style: italic; }

/* Exact/range mode: a joined two-button pill — = (exact match) | ↔ (range). */
.rgw-mode {
    display: inline-flex;
    border: 1px solid #d1d5db; border-radius: 6px;
    overflow: hidden;
}
.rgw-mode-btn {
    border: none; background: #fff; color: #9ca3af;
    width: 24px; height: 24px; cursor: pointer;
    font-weight: 700; font-size: 12px; line-height: 1; padding: 0;
}
.rgw-mode-btn + .rgw-mode-btn { border-left: 1px solid #d1d5db; }
.rgw-mode-btn:hover { color: #2563eb; }
.rgw-mode-on, .rgw-mode-on:hover { background: #2563eb; color: #fff; }

.rgw-open { display: inline-flex; align-items: center; gap: 4px; font-size: 11px; color: #374151; white-space: nowrap; }

.rgw-x {
    border: none; background: none; cursor: pointer;
    color: #9ca3af; font-size: 13px; line-height: 1; padding: 2px 4px;
}
.rgw-x:hover { color: #b91c1c; }

.rgw-banderr { display: block; font-size: 11px; color: #b91c1c; margin-top: 3px; max-width: 240px; white-space: normal; }

/* Column headers: stacked labeled lines */
.rgw-colstack { display: flex; flex-direction: column; gap: 4px; min-width: 120px; }
.rgw-colline { display: flex; align-items: center; gap: 5px; }
.rgw-linelabel { font-size: 11px; font-weight: 600; color: #374151; width: 36px; flex: 0 0 auto; }
.rgw-colfoot { display: flex; align-items: center; gap: 6px; }

/* ── Cells ── */
.rgw-priced { display: flex; align-items: center; gap: 4px; }
.rgw-cell-val {
    width: 88px; padding: 5px 7px;
    border: 1px solid #d1d5db; border-radius: 6px;
    font: inherit; font-size: 13px; text-align: right;
}
.rgw-cell-val:focus { outline: none; border-color: #2563eb; }
.rgw-cell-blank { background: #fafbfc; }

/* Refusing cells: hatched so refusal regions read at a glance */
.rgw-cell-refusing {
    background: repeating-linear-gradient(45deg, #fef2f2, #fef2f2 6px, #fde8e8 6px, #fde8e8 12px) !important;
}
.rgw-refuselabel { font-size: 11px; font-weight: 600; color: #b91c1c; margin-bottom: 3px; }
.rgw-refuserow { display: flex; align-items: center; gap: 4px; }
.rgw-cell-msg {
    width: 140px; padding: 5px 7px;
    border: 1px solid #fca5a5; border-radius: 6px;
    font: inherit; font-size: 12px; background: #fff;
}
.rgw-cell-msg:focus { outline: none; border-color: #dc2626; }

/* Grow buttons */
.rgw-add {
    border: 1px dashed #9ca3af; background: #fff; color: #374151;
    border-radius: 6px; font-size: 12px; padding: 5px 10px; cursor: pointer;
    white-space: nowrap;
}
.rgw-add:hover { border-color: #2563eb; color: #2563eb; }
