/* Invoice Settings > Equation Builder (Pages/EquationBuilder.razor, wwwroot/scripts/equationbuilder.js).
 *
 * Everything is scoped to .eqb: the builder's short class names (.pop, .tok, .form ...) would
 * otherwise meet the app's own. The page shell around it -- top bar, search, Save / Cancel -- is
 * the app's shared look; the Value box and its pickers keep Miracle's User Field Equation Entry
 * look on purpose (approved as Demo/EquationBuilderDemo.html).
 */

/* Pinned under the shared .top-btns-container, at the Account Master pages' edges. */
.eqb-container {
    position: fixed;
    top: 7rem;
    bottom: 1rem;
    left: 14.5rem;
    right: 1rem;
    overflow: auto;
    transition: left 0.2s ease;
}

.eqb-container.sidebar-collapsed {
    left: 5.5rem;
}

@media (max-width: 700px) {
    .eqb-container { left: 0.5rem; right: 0.5rem; top: 9rem; }
}

.eqb { font-size: 13px; color: #1f2937; }
.eqb .custom-modal-footer { position: static; padding: 14px; }
.eqb .custom-modal-footer .btn { width: 160px; }

.eqb .eq-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr); gap: 10px; align-items: stretch; }

@media (max-width: 1000px) { .eqb .eq-layout { grid-template-columns: minmax(0, 1fr); }  }

.eqb .eq-card { background: #fff; border: 1px solid #e5e9f0; border-radius: 12px; box-shadow: 0 6px 18px rgba(16,24,40,.06); overflow: hidden; min-width: 0; display: flex; flex-direction: column; }

.eqb .eq-card-head { padding: 10px 14px; border-bottom: 1px solid #eef0f3; display: flex; align-items: center; justify-content: space-between; gap: 10px; }

.eqb .eq-card-title { font-size: 14px; font-weight: 700; }

.eqb .eq-card-sub { font-size: 12px; color: #6b7280; }

/* field list, drawn like .master-content-table1 */
.eqb .eq-table-scroll { height: 560px; overflow: auto; scrollbar-width: thin; scrollbar-color: #99c2ff #f1f1f1; }

.eqb .eq-table { border-collapse: collapse; width: 100%; table-layout: fixed; font-size: 12px; }

.eqb .eq-table th, .eqb .eq-table td { text-align: left; padding: 8px 12px; border-bottom: 1px solid #eef0f3; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.eqb .eq-table thead th { position: sticky; top: 0; z-index: 1; background: #fff; border-bottom: 1px solid #e5e9f0; color: #6b7280; font-size: 9px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; }

.eqb .eq-table tr.vch td { background: #f8fafc; color: #007BFF; font-weight: 700; font-size: 12px; padding: 7px 12px; }

.eqb .eq-table tr.vch td:last-child { text-align: left; }

.eqb .eq-table tr.fld { cursor: pointer; }

.eqb .eq-table tr.fld:hover td { background: #f1f5ff; }

.eqb .eq-table tr.fld.sel td { background: #e8f2ff; }

.eqb .eq-table tr.fld.sel td:first-child { box-shadow: inset 3px 0 0 #007BFF; }

.eqb .eq-table td.eqtext { font-family: Consolas, 'Courier New', monospace; color: #374151; }

.eqb .eq-table td.none { color: #9ca3af; font-style: italic; }

.eqb .eq-table th:last-child, .eqb .eq-table td:last-child { text-align: center; }

.eqb .edit-icon, .eqb .delete-icon { width: 18px; height: 18px; fill: #6b7280; cursor: pointer; margin: 0 4px; vertical-align: middle; }

.eqb .edit-icon:hover { fill: #2563eb; }

.eqb .delete-icon:hover { fill: #dc2626; }

.eqb .delete-icon.off { opacity: .3; pointer-events: none; }

.eqb .eq-value-body { padding: 12px 14px; flex: 1; display: flex; flex-direction: column; gap: 8px; }

.eqb .eq-hint { font-size: 12px; color: #6b7280; line-height: 1.5; }

.eqb .eq-status { font-size: 12px; min-height: 18px; display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; color: #6b7280; }

.eqb .eq-status .bad { color: #dc2626; font-weight: 600; }

.eqb .eq-status .ok { color: #16a34a; font-weight: 600; }

/* ===== Value box and its pickers: kept exactly as Miracle's User Field Equation Entry draws them ===== */
.eqb .value-wrap {
        --win: #f0f0f0; --frame: #a9a9a9; --white: #ffffff; --text: #000000; --muted: #6b6b6b;
        --grid-head: #e3e3e3; --grid-line: #e6e6e6; --grid-sel: #dcdcdc; --group: #e00000;
        --chip: #e3ecf7; --pick: #f7d4f7; --title: #c4c4c4; --btn: #e1e1e1; --btn-b: #adadad;
        --green: #b8f2b8; --err: #e00000;
        font: 13px Verdana, Tahoma, 'Segoe UI', sans-serif; color: #000;
    }

.eqb .value-wrap button { min-width: 92px; height: 22px; padding: 0 10px; background: var(--btn); border: 1px solid var(--btn-b); color: #000; font: 13px Verdana, Tahoma, sans-serif; cursor: pointer; border-radius: 0; }

.eqb .value-wrap button:hover { background: #e5f1fb; border-color: #0078d7; }

.eqb .xbtn { width: 18px; height: 18px; background: #e04040; border: 1px solid #fff; color: #fff; font: 700 12px/14px Arial, sans-serif; text-align: center; cursor: pointer; }

.eqb .editor { min-height: 400px !important; }

/* ---- Value: the token editor ---- */
.eqb .value-wrap { border: 1px solid var(--frame); background: var(--white); }

.eqb .editor { min-height: 420px; padding: 4px; display: flex; flex-wrap: wrap; align-content: flex-start; gap: 3px 0; outline: none; cursor: text; }

.eqb .tok { display: inline-flex; align-items: center; height: 22px; padding: 0 9px; margin-right: 4px; background: var(--chip); white-space: nowrap; user-select: none; cursor: default; }

.eqb .tok.err { background: #ffd6d6; outline: 1px solid var(--err); }

/* the cursor: Miracle's small hollow box, blinking while the box has focus */
.eqb .caret { width: 9px; height: 22px; border: 1px solid transparent; margin-right: 4px; flex: 0 0 auto; }

.eqb .caret.on { border-color: #555; border-left-width: 2px; }

.eqb .editor:focus .caret.on { animation: blink 1.05s step-end infinite; }

@keyframes blink { 50% { border-color: transparent; } }

.eqb .flat { padding: 2px 2px; white-space: pre-wrap; word-break: break-all; }

.eqb .valstrip { background: var(--win); border-top: 1px solid var(--frame); display: flex; justify-content: center; gap: 2px; padding: 3px; }

.eqb .status { padding: 4px 10px 6px; min-height: 22px; font-size: 12px; color: var(--muted); display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; }

.eqb .status .bad { color: var(--err); }

.eqb .status .ok { color: #0a7a2a; }

/* A clicked chip: selected for Delete (a function's whole call lights up together). */
.eqb .tok.sel { background: #b9d7ff; outline: 1px solid #1a73e8; }

/* ---- The Value box's pickers: drawn like the app's VirtualDropdown (VirtualDropdown.css) ---- */
.eqb .pop {
    position: fixed; z-index: 50; display: none; flex-direction: column; outline: none;
    min-width: 240px; max-width: min(380px, calc(100vw - 16px));
    background: #fff; border: 1px solid #ccc; border-radius: 4px; box-shadow: 0 8px 24px rgba(16, 24, 40, .15);
    font: 12px 'Inter', -apple-system, 'Segoe UI', Roboto, sans-serif; color: #323130; overflow: hidden;
}
.eqb .pop.types { min-width: 200px; }
.eqb .pop .gh { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 7px 10px; font-weight: bold; font-size: 12px; border-bottom: 1px solid #ddd; }
.eqb .pop .gh .cnt { font-weight: normal; color: #6b7280; }
.eqb .pop .gh .x { border: 0; background: transparent; font-size: 18px; line-height: 1; color: #6b7280; cursor: pointer; padding: 0 2px; }
.eqb .pop .gh .x:hover { color: #dc2626; }
.eqb .pop .pf { padding: 6px; border-bottom: 1px solid #ddd; }
.eqb .pop .pf input { display: block; box-sizing: border-box; width: 100%; height: 28px; padding: 0 8px; border: 1px solid #c8c6c4; border-radius: 4px; font: inherit; color: #323130; background: #fff; outline: none; }
.eqb .pop .pf input:focus { border-color: #0078d4; }
.eqb .pop .pl { overflow: auto; flex: 0 1 auto; min-height: 40px; }
.eqb .pop .grp { padding: 6px 8px 4px; font-size: 11px; font-weight: 700; color: #007BFF; text-transform: uppercase; letter-spacing: .03em; white-space: nowrap; background: #f8fafc; }
.eqb .pop .it { display: flex; align-items: center; gap: 10px; height: 34px; padding: 0 10px; cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.eqb .pop .it .lb { flex: 1 1 auto; overflow: hidden; text-overflow: ellipsis; }
.eqb .pop .it small { color: #6b7280; flex: 0 0 auto; }
.eqb .pop .it.hi { background: #0078d4; color: #fff; }
.eqb .pop .it.hi small { color: #dbeafe; }
.eqb .pop .mk { width: 14px; flex: 0 0 auto; font-weight: 700; color: #0078d4; }
.eqb .pop .it.hi .mk { color: #fff; }
.eqb .pop .none { padding: 10px; color: #888; font-style: italic; }
.eqb .pop .help { display: none; padding: 8px 10px; border-top: 1px solid #ddd; background: #f8fafc; color: #374151; white-space: normal; line-height: 1.45; }
.eqb .pop .help.on { display: block; }
.eqb .pop .foot { display: flex; gap: 6px; padding: 6px; border-top: 1px solid #ddd; }
.eqb .pop .foot button { flex: 1; height: 30px; border: 1px solid #c8c6c4; border-radius: 4px; background: #fff; font: bold 12px 'Inter', 'Segoe UI', sans-serif; color: #323130; cursor: pointer; }
.eqb .pop .foot button:hover { border-color: #0078d4; }
.eqb .pop .foot button.primary { background: #007BFF; border-color: #007BFF; color: #fff; }
/* Select Value, laid out like the app's floating-label form items */
.eqb .pop.win { min-width: 280px; }
.eqb .pop.win .vform { display: flex; flex-direction: column; gap: 12px; padding: 14px 12px 6px; }
.eqb .pop.win .fl { position: relative; display: block; }
.eqb .pop.win .fl > .cap { position: absolute; top: -7px; left: 8px; padding: 0 4px; background: #fff; font-size: 10px; font-weight: 600; color: #0078d4; z-index: 1; }
.eqb .pop.win select, .eqb .pop.win input { display: block; box-sizing: border-box; width: 100%; height: 32px; padding: 0 8px; border: 1px solid #c8c6c4; border-radius: 4px; font: inherit; color: #323130; background: #fff; outline: none; }
.eqb .pop.win select:focus, .eqb .pop.win input:focus { border-color: #0078d4; }
.eqb .pop.win input.v { text-align: right; }
.eqb .pop.win input.v.txt { text-align: left; }
.eqb .pop.win input.bad { border-color: #dc2626; }
.eqb .pop.win .foot { border-top: 0; padding: 8px 12px 12px; }
.eqb .pop.win .vin { display: block; }
.eqb .pop.win .vform, .eqb .pop.win .fl { box-sizing: border-box; min-width: 0; }
