/* ============================================================================
   Terminal Page - customizable module workspace
   Dark terminal theme: near-black bg, gold accent, mono numerals
   ============================================================================ */

/* Full-height flex when terminal page is active */
.page-content-wrapper:has(#page-terminal.active) {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
}

#page-terminal {
    padding: 0 !important;
    background: #0b0d10;
    color: #dfe3e8;
}

#page-terminal.active {
    display: flex !important;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    height: 100% !important;
    overflow: hidden;
}

#page-terminal, #page-terminal * {
    box-sizing: border-box;
}

/* ---------------------------------------------------------------- toolbar */
.tp-toolbar {
    height: 42px;
    flex: none;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 12px;
    background: #101318;
    border-bottom: 1px solid #232830;
}

.tp-toolbar-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 700;
    font-size: 12px;
    letter-spacing: 0.12em;
    color: #e8eaed;
}

.tp-toolbar-badge {
    font: 600 9px Consolas, monospace;
    letter-spacing: 0.1em;
    color: #d7a94f;
    border: 1px solid rgba(215, 169, 79, 0.4);
    border-radius: 3px;
    padding: 2px 5px;
}

.tp-toolbar-hint {
    font-size: 10.5px;
    color: #4a515c;
}

.tp-toolbar-right {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 8px;
    position: relative;
}

.tp-add-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    background: #d7a94f;
    color: #14161a;
    font-weight: 600;
    font-size: 11.5px;
    padding: 6px 12px;
    border-radius: 5px;
    border: none;
    cursor: pointer;
}

.tp-add-btn:hover { background: #e6c37a; }

.tp-reset-btn {
    background: transparent;
    color: #8b92a0;
    border: 1px solid #232830;
    font-size: 11px;
    padding: 6px 10px;
    border-radius: 5px;
    cursor: pointer;
}

.tp-reset-btn:hover { color: #dfe3e8; border-color: #3a4250; }

/* --------------------------------------------------------- module palette */
.tp-palette {
    position: absolute;
    top: 36px;
    right: 0;
    width: 300px;
    background: #12151a;
    border: 1px solid #2c333d;
    border-radius: 7px;
    box-shadow: 0 12px 34px rgba(0, 0, 0, 0.6);
    z-index: 3000;
    overflow: hidden;
    display: none;
}

.tp-palette.open { display: block; }

.tp-palette-header {
    padding: 9px 12px;
    font: 600 9.5px Consolas, monospace;
    letter-spacing: 0.1em;
    color: #9aa3b0;
    border-bottom: 1px solid #232830;
    background: #161a21;
}

.tp-palette-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    cursor: pointer;
    border-bottom: 1px solid #1a1f26;
}

.tp-palette-item:last-child { border-bottom: none; }
.tp-palette-item:hover { background: #1a2029; }

.tp-palette-icon {
    width: 28px;
    height: 28px;
    flex: none;
    display: grid;
    place-items: center;
    background: #1e242e;
    color: #d7a94f;
    border-radius: 5px;
    font: 700 10px Consolas, monospace;
}

.tp-palette-name { font-size: 12px; font-weight: 600; color: #e8eaed; }
.tp-palette-desc { font-size: 10px; color: #6a7280; margin-top: 1px; }

/* layouts menu (shares palette styling) */
.tp-layouts-menu { max-height: 60vh; overflow-y: auto; }

.tp-layout-del {
    margin-left: auto;
    flex: none;
    background: none;
    border: none;
    color: #4a515c;
    cursor: pointer;
    font-size: 11px;
    padding: 2px 5px;
    border-radius: 3px;
}

.tp-layout-del:hover { color: #f0506a; background: rgba(240, 80, 106, 0.1); }

/* ------------------------------------------------------------------- grid */
.tp-grid {
    flex: 1;
    position: relative;
    overflow-y: auto;
    overflow-x: hidden;
    background: #0b0d10;
    min-height: 0;
}

.tp-grid-inner {
    position: relative;
    width: 100%;
}

.tp-empty {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    color: #4a515c;
    font-size: 13px;
    pointer-events: none;
}

/* ----------------------------------------------------------------- module */
.tp-module {
    position: absolute;
    display: flex;
    flex-direction: column;
    background: #12151a;
    border: 1px solid #232830;
    border-radius: 3px;
    overflow: hidden;
    min-width: 120px;
    min-height: 80px;
}

.tp-module.tp-dragging,
.tp-module.tp-resizing {
    opacity: 0.92;
    box-shadow: 0 14px 40px rgba(0, 0, 0, 0.65);
    border-color: #d7a94f;
    transition: none;
    z-index: 2000 !important;
}

.tp-ghost {
    position: absolute;
    border: 1px dashed #d7a94f;
    background: rgba(215, 169, 79, 0.07);
    border-radius: 6px;
    z-index: 1500;
    pointer-events: none;
}

.tp-module-header {
    height: 28px;
    flex: none;
    display: flex;
    align-items: center;
    gap: 7px;
    padding: 0 8px;
    background: #161a21;
    border-bottom: 1px solid #232830;
    cursor: grab;
    user-select: none;
}

.tp-module-header:active { cursor: grabbing; }

.tp-module-grip {
    color: #4a515c;
    font: 10px Consolas, monospace;
    flex: none;
}

.tp-module-title {
    font: 600 9.5px Consolas, monospace;
    letter-spacing: 0.1em;
    color: #9aa3b0;
    white-space: nowrap;
    flex: none;
}

.tp-module-controls {
    display: flex;
    align-items: center;
    gap: 5px;
    min-width: 0;
    flex: 1;
    overflow: hidden;
}

.tp-module-close {
    flex: none;
    background: none;
    border: none;
    color: #4a515c;
    font-size: 13px;
    line-height: 1;
    cursor: pointer;
    padding: 3px 4px;
    border-radius: 3px;
}

.tp-module-close:hover { color: #f0506a; background: rgba(240, 80, 106, 0.1); }

.tp-module-body {
    flex: 1;
    min-height: 0;
    overflow: auto;
    position: relative;
    font-size: 11px;
}

/* resize handles: 4 edges + 4 corners */
.tp-rh {
    position: absolute;
    z-index: 6;
}

.tp-rh-n { top: 0; left: 10px; right: 10px; height: 5px; cursor: ns-resize; }
.tp-rh-s { bottom: 0; left: 10px; right: 10px; height: 5px; cursor: ns-resize; }
.tp-rh-e { right: 0; top: 10px; bottom: 10px; width: 5px; cursor: ew-resize; }
.tp-rh-w { left: 0; top: 10px; bottom: 10px; width: 5px; cursor: ew-resize; }

.tp-rh-nw { top: 0; left: 0; width: 10px; height: 10px; cursor: nwse-resize; }
.tp-rh-ne { top: 0; right: 0; width: 10px; height: 10px; cursor: nesw-resize; }
.tp-rh-sw { bottom: 0; left: 0; width: 10px; height: 10px; cursor: nesw-resize; }

/* subtle gold hint when hovering an edge */
.tp-rh-n:hover, .tp-rh-s:hover, .tp-rh-e:hover, .tp-rh-w:hover,
.tp-rh-nw:hover, .tp-rh-ne:hover, .tp-rh-sw:hover {
    background: rgba(215, 169, 79, 0.25);
}

/* SE corner keeps the striped grip visual */
.tp-resize-handle {
    right: 0;
    bottom: 0;
    width: 14px;
    height: 14px;
    cursor: nwse-resize;
    clip-path: polygon(100% 0, 100% 100%, 0 100%);
    background: repeating-linear-gradient(135deg, transparent 0 2px, #414a57 2px 3px);
}

.tp-resize-handle:hover {
    background: repeating-linear-gradient(135deg, transparent 0 2px, #d7a94f 2px 3px);
}

/* --------------------------------------------------------- shared widgets */
.tp-input, .tp-select {
    background: #0e1116;
    border: 1px solid #232830;
    color: #dfe3e8;
    border-radius: 4px;
    font: 500 11px Consolas, monospace;
    padding: 3px 6px;
    outline: none;
    min-width: 0;
}

.tp-input:focus, .tp-select:focus { border-color: #d7a94f; }

.tp-sym-input {
    width: 72px;
    text-transform: uppercase;
}

.tp-mini-btn {
    background: #1e242e;
    border: 1px solid #2c333d;
    color: #9aa3b0;
    font: 500 10px Consolas, monospace;
    padding: 3px 7px;
    border-radius: 4px;
    cursor: pointer;
}

.tp-mini-btn:hover { color: #e8eaed; border-color: #3a4250; }
.tp-mini-btn.active { background: #2a3140; color: #e8eaed; border-color: #d7a94f; }

.tp-table {
    width: 100%;
    border-collapse: collapse;
    font: 500 10.5px Consolas, monospace;
}

.tp-table th {
    position: sticky;
    top: 0;
    background: #161a21;
    color: #6a7280;
    font: 600 8.5px Consolas, monospace;
    letter-spacing: 0.08em;
    text-align: right;
    padding: 4px 8px;
    border-bottom: 1px solid #232830;
    white-space: nowrap;
    z-index: 2;
}

.tp-table th:first-child, .tp-table td:first-child { text-align: left; }

.tp-table td {
    padding: 4px 8px;
    text-align: right;
    border-bottom: 1px solid #1a1f26;
    color: #aeb6c2;
    white-space: nowrap;
}

.tp-table tr:hover td { background: rgba(255, 255, 255, 0.02); }

.tp-up { color: #2fbf7f !important; }
.tp-dn { color: #f0506a !important; }
.tp-gold { color: #d7a94f !important; }
.tp-muted { color: #5d6572 !important; }
.tp-strong { color: #e8eaed !important; font-weight: 600; }

@keyframes tpFlash {
    0% { background: rgba(215, 169, 79, 0.28); }
    100% { background: transparent; }
}

.tp-flash { animation: tpFlash 0.6s ease-out; }

.tp-row-btn {
    background: none;
    border: 1px solid #2c333d;
    color: #8b92a0;
    font-size: 9.5px;
    padding: 2px 7px;
    border-radius: 3px;
    cursor: pointer;
}

.tp-row-btn:hover { color: #f0506a; border-color: #f0506a; }

.tp-loading {
    padding: 18px;
    text-align: center;
    color: #4a515c;
    font: 500 10.5px Consolas, monospace;
}

/* ------------------------------------------------------------ order ticket */
.tp-ticket {
    padding: 10px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.tp-ticket-quote {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    font: 500 11px Consolas, monospace;
    color: #8b92a0;
}

.tp-field-label {
    font-size: 8.5px;
    font-weight: 600;
    letter-spacing: 0.06em;
    color: #6a7280;
    margin-bottom: 3px;
    text-transform: uppercase;
}

.tp-field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }

.tp-ticket .tp-input, .tp-ticket .tp-select { width: 100%; padding: 6px 8px; font-size: 12px; }

.tp-side-btns { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }

.tp-buy-btn, .tp-sell-btn {
    border: none;
    border-radius: 5px;
    font-weight: 700;
    font-size: 12px;
    padding: 9px 0;
    cursor: pointer;
    letter-spacing: 0.04em;
}

.tp-buy-btn { background: #2fbf7f; color: #0b0d10; }
.tp-buy-btn:hover { background: #3fd692; }
.tp-sell-btn { background: #f0506a; color: #fff; }
.tp-sell-btn:hover { background: #ff6a82; }
.tp-buy-btn:disabled, .tp-sell-btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* --------------------------------------------------------------------- DOM */
.tp-dom-row {
    display: grid;
    grid-template-columns: 1fr 76px 1fr;
    font: 500 10.5px Consolas, monospace;
    border-bottom: 1px solid #171c23;
    align-items: stretch;
}

.tp-dom-row > span { padding: 3px 8px; position: relative; }
.tp-dom-price { text-align: center; }
.tp-dom-size-bid { text-align: left; color: #aeb6c2; }
.tp-dom-size-ask { text-align: right; color: #aeb6c2; }

.tp-dom-bar {
    position: absolute;
    top: 2px;
    bottom: 2px;
    pointer-events: none;
}

.tp-dom-bar.bid { left: 0; background: rgba(47, 191, 127, 0.13); }
.tp-dom-bar.ask { right: 0; background: rgba(240, 80, 106, 0.13); }

.tp-dom-spread {
    display: grid;
    grid-template-columns: 1fr 76px 1fr;
    font: 600 10px Consolas, monospace;
    background: #161a21;
    border-top: 1px solid #232830;
    border-bottom: 1px solid #232830;
    color: #8b92a0;
}

.tp-dom-spread > span { padding: 5px 8px; }

/* ----------------------------------------------------------- options chain */
.tp-chain-underlying {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 5px 10px;
    border-bottom: 1px solid #1a2027;
    font: 500 11px Consolas, monospace;
    color: #8b92a0;
    flex: none;
}

.tp-chain-underlying .tp-und-price { color: #e8eaed; font-weight: 600; font-size: 13px; }

.tp-chain-expiries {
    display: flex;
    gap: 3px;
    padding: 5px 8px;
    border-bottom: 1px solid #1a2027;
    overflow-x: auto;
    flex: none;
    scrollbar-width: thin;
}

.tp-exp-tab {
    flex: none;
    font: 500 10px Consolas, monospace;
    color: #8b92a0;
    background: transparent;
    border: 1px solid transparent;
    padding: 3px 9px;
    border-radius: 4px;
    cursor: pointer;
    white-space: nowrap;
}

.tp-exp-tab:hover { color: #e8eaed; }
.tp-exp-tab.active { background: #232a35; color: #e8eaed; border-color: #2c333d; }

.tp-chain-scroller { flex: 1; overflow: auto; min-height: 0; }

.tp-chain-table { width: 100%; border-collapse: collapse; font: 500 10.5px Consolas, monospace; }

.tp-chain-table th {
    position: sticky;
    top: 0;
    background: #161a21;
    color: #6a7280;
    font: 600 8.5px Consolas, monospace;
    letter-spacing: 0.08em;
    padding: 4px 6px;
    text-align: right;
    border-bottom: 1px solid #232830;
    z-index: 2;
    white-space: nowrap;
}

.tp-chain-table td {
    padding: 3px 6px;
    text-align: right;
    border-bottom: 1px solid #1a1f26;
    color: #aeb6c2;
    white-space: nowrap;
}

.tp-chain-strike {
    background: #161a21 !important;
    color: #d7a94f !important;
    font-weight: 700;
    text-align: center !important;
    border-left: 1px solid #232830;
    border-right: 1px solid #232830;
    min-width: 62px;
}

.tp-chain-side { cursor: pointer; }
.tp-chain-side td { transition: background 0.1s; }
.tp-chain-itm td { background: rgba(215, 169, 79, 0.05); }

tr.tp-chain-row:hover .tp-chain-side-call td.tp-c,
tr.tp-chain-row:hover td.tp-c:hover { background: rgba(255, 255, 255, 0.03); }

/* strike selection highlight - applied to side cells */
td.tp-sel-buy { background: rgba(47, 191, 127, 0.18) !important; box-shadow: inset 0 1px 0 rgba(47,191,127,.35), inset 0 -1px 0 rgba(47,191,127,.35); }
td.tp-sel-sell { background: rgba(240, 80, 106, 0.18) !important; box-shadow: inset 0 1px 0 rgba(240,80,106,.35), inset 0 -1px 0 rgba(240,80,106,.35); }

.tp-chain-bid { color: #2fbf7f; }
.tp-chain-ask { color: #f0506a; }

/* ------------------------------------------ option ticket (floating, non-modal) */
.tp-order-float {
    position: fixed;
    top: 88px;
    right: 26px;
    width: 400px;
    max-width: 94vw;
    max-height: calc(100vh - 110px);
    background: #12151a;
    border: 1px solid #2c333d;
    border-radius: 8px;
    box-shadow: 0 24px 70px rgba(0, 0, 0, 0.7);
    z-index: 9000;
    display: none;
    flex-direction: column;
    overflow: hidden;
}

.tp-order-float.open { display: flex; }

.tp-order-float-header {
    flex: none;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 9px 12px;
    background: #161a21;
    border-bottom: 1px solid #232830;
    cursor: grab;
    user-select: none;
}

.tp-order-float-header:active { cursor: grabbing; }

.tp-order-float-title {
    font: 600 10px Consolas, monospace;
    letter-spacing: 0.1em;
    color: #9aa3b0;
}

.tp-order-float-strat {
    font: 600 11px Consolas, monospace;
    color: #d7a94f;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
}

.tp-order-modal-close {
    margin-left: auto;
    flex: none;
    background: none;
    border: none;
    color: #6a7280;
    font-size: 14px;
    cursor: pointer;
    padding: 2px 5px;
}

.tp-order-modal-close:hover { color: #f0506a; }

.tp-order-float-body {
    padding: 10px 12px;
    display: flex;
    flex-direction: column;
    gap: 9px;
    overflow-y: auto;
    min-height: 0;
}

/* leg rows */
.tp-ot-legs { display: flex; flex-direction: column; gap: 5px; }

.tp-leg-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 8px;
    background: #0e1116;
    border: 1px solid #232830;
    border-radius: 5px;
    font: 500 11px Consolas, monospace;
}

.tp-leg-pill {
    flex: none;
    cursor: pointer;
    font: 700 9.5px Consolas, monospace;
    letter-spacing: 0.06em;
    padding: 2px 8px;
    border-radius: 3px;
    border: 1px solid transparent;
}

.tp-leg-pill.buy { background: rgba(47, 191, 127, 0.18); color: #2fbf7f; }
.tp-leg-pill.sell { background: rgba(240, 80, 106, 0.18); color: #f0506a; }
.tp-leg-pill:hover { border-color: currentColor; }

.tp-leg-desc {
    flex: 1;
    color: #e8eaed;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.tp-leg-quote { flex: none; color: #8b92a0; font-size: 10px; white-space: nowrap; }

.tp-leg-ratio { width: 40px; text-align: center; flex: none; padding: 3px 4px; }

.tp-leg-del {
    flex: none;
    background: none;
    border: none;
    color: #4a515c;
    cursor: pointer;
    font-size: 11px;
    padding: 0 2px;
}

.tp-leg-del:hover { color: #f0506a; }

.tp-ticket-hint { font-size: 9.5px; color: #4a515c; text-align: center; }

.tp-order-float .tp-input, .tp-order-float .tp-select { width: 100%; padding: 7px 9px; font-size: 12.5px; }
.tp-order-float .tp-leg-ratio { padding: 3px 4px; font-size: 11px; }

.tp-order-summary {
    display: flex;
    justify-content: space-between;
    font: 500 10.5px Consolas, monospace;
    color: #8b92a0;
}

.tp-order-place-btn {
    border: none;
    border-radius: 5px;
    font-weight: 700;
    font-size: 12.5px;
    padding: 11px 0;
    cursor: pointer;
    letter-spacing: 0.03em;
}

.tp-order-place-btn.buy { background: #2fbf7f; color: #0b0d10; }
.tp-order-place-btn.sell { background: #f0506a; color: #fff; }
.tp-order-place-btn.net { background: #d7a94f; color: #14161a; }
.tp-order-place-btn:disabled { opacity: 0.55; cursor: wait; }

/* ------------------------------------------------------------ account tile */
.tp-acct-rows { padding: 4px 0; }

.tp-acct-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 5px 12px;
    font: 500 11px Consolas, monospace;
}

.tp-acct-row .k { color: #8b92a0; font-family: inherit; font-size: 10px; }
.tp-acct-row .v { color: #dfe3e8; }

/* --------------------------------------------------------------- watchlist */
.tp-wl-add {
    display: flex;
    gap: 6px;
    padding: 6px 8px;
    border-top: 1px solid #232830;
    background: #101318;
    position: sticky;
    bottom: 0;
}

.tp-wl-add .tp-input { flex: 1; }

.tp-wl-del {
    background: none;
    border: none;
    color: #4a515c;
    cursor: pointer;
    font-size: 11px;
    padding: 0 3px;
    visibility: hidden;
}

.tp-table tr:hover .tp-wl-del { visibility: visible; }
.tp-wl-del:hover { color: #f0506a; }

/* --------------------------------------------------------------- sections  */
.tp-section-label {
    padding: 5px 10px;
    font: 600 8.5px Consolas, monospace;
    letter-spacing: 0.1em;
    color: #6a7280;
    background: #14181f;
    border-bottom: 1px solid #232830;
    position: sticky;
    top: 0;
    z-index: 3;
}

/* scrollbars inside terminal */
#page-terminal ::-webkit-scrollbar { width: 8px; height: 8px; }
#page-terminal ::-webkit-scrollbar-track { background: #0e1116; }
#page-terminal ::-webkit-scrollbar-thumb { background: #2c333d; border-radius: 4px; }
#page-terminal ::-webkit-scrollbar-thumb:hover { background: #3a4250; }
