/* Portfolio DCA Simulator - additions layered on top of ../style.css */

/* Toggle switch (re-declared so this tool is self-sufficient if loaded alone) */
.toggle-switch{position:relative;display:inline-flex;align-items:center}
.toggle-switch input{position:absolute;opacity:0;width:0;height:0}
.toggle-track{width:38px;height:21px;background:var(--input-bg);border:1px solid var(--border);border-radius:999px;position:relative;transition:background .15s,border-color .15s}
.toggle-knob{position:absolute;top:2px;left:2px;width:15px;height:15px;border-radius:50%;background:var(--muted);transition:transform .15s,background .15s}
.toggle-switch input:checked + .toggle-track{background:var(--accent);border-color:var(--accent)}
.toggle-switch input:checked + .toggle-track .toggle-knob{transform:translateX(17px);background:#fff}

/* Drag-to-reorder handle on each asset card. The asset order sets the stacking
   order in Composition Over Time (top of the list = top of the chart). */
.drag-handle{display:inline-flex;align-items:center;justify-content:center;flex-shrink:0;color:var(--muted);font-size:1.05rem;line-height:1;cursor:grab;padding:0 2px;margin-left:-2px;letter-spacing:-1px;user-select:none;touch-action:none;transition:color .15s}
.drag-handle:hover{color:var(--text)}
.drag-handle:active{cursor:grabbing}
.sec-card.dragging{opacity:.5}
.sec-card.drag-over{border-color:var(--accent);box-shadow:inset 0 2px 0 var(--accent)}

/* Read-only asset row (Assets subtab): assets are defined in the Data tab, so a row
   can only be dragged to reorder or removed via the ✕ button — no inline editing. */
.sec-row-item{display:flex;align-items:center;gap:8px;padding:9px 11px}
.sec-row-item .sec-name{flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.sec-del-x{flex-shrink:0;width:26px;height:26px;display:inline-flex;align-items:center;justify-content:center;font-size:1.2rem;line-height:1;padding:0;border:1px solid rgba(230,57,57,.25);background:rgba(230,57,57,.12);color:#FF8B8B;border-radius:7px;cursor:pointer;font-family:inherit;transition:background .15s,border-color .15s}
.sec-del-x:hover{background:rgba(230,57,57,.28);border-color:rgba(230,57,57,.5)}

/* Target-weight pie + editable table (Rebalancing subtab).
   Pie and table sit side by side; the pie is kept compact (a fixed 120px so its
   flex item has a definite width — a responsive Chart.js canvas collapses to 0
   without one) so the table gets the rest of the room, even on narrow phones. */
.weight-main{display:flex;align-items:center;gap:12px;margin:8px 0 2px}
.weight-pie-wrap{flex:0 0 120px;width:120px;margin:0;display:flex;justify-content:center}
.weight-table-wrap{flex:1 1 auto;min-width:0}
/* Flex rows (not a <table>) so each asset's name and its input box stay
   vertically centred on one line with a clean full-width separator — a table
   aligns the short label and the taller input on different baselines. */
.weight-table{font-size:.84rem}
.weight-row{display:flex;align-items:center;justify-content:space-between;gap:8px;padding:6px 0;border-bottom:1px solid var(--border)}
.weight-row .wt-name{display:flex;align-items:center;gap:7px;min-width:0;color:var(--text)}
.weight-row .wt-label{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.weight-row .wt-input{display:flex;align-items:center;gap:4px;flex-shrink:0;white-space:nowrap}
.weight-row .wt-input .num-input{width:60px;max-width:60px;min-width:56px;text-align:right;-moz-appearance:textfield}
.weight-row .wt-input .num-input::-webkit-inner-spin-button,
.weight-row .wt-input .num-input::-webkit-outer-spin-button{-webkit-appearance:none;margin:0}
.weight-row .wt-pct{color:var(--muted)}
.weight-row.wt-total{border-bottom:none;font-weight:800;color:var(--text);padding-top:8px}
.weight-row.wt-total .wt-input{font-family:'DM Mono',monospace}
.weight-row.wt-total.bad .wt-name,.weight-row.wt-total.bad .wt-input{color:#FFD28C}
body.light .weight-row.wt-total.bad .wt-name,body.light .weight-row.wt-total.bad .wt-input{color:#7A4A00}

/* Schedule editor */
.sched-box{margin-top:4px}
.weekday-grid{display:flex;gap:5px;flex-wrap:wrap}
.weekday-chip{flex:1 1 0;min-width:38px;padding:6px 4px;font-size:.74rem;font-weight:700;border:1px solid var(--border);background:var(--input-bg);color:var(--muted);border-radius:8px;cursor:pointer;text-align:center;transition:all .15s;font-family:inherit;user-select:none;white-space:nowrap}
.weekday-chip.wp-chip{flex:0 0 auto;padding:6px 14px}
.weekday-chip:hover{border-color:var(--accent);color:var(--text)}
.weekday-chip.active{background:var(--accent);color:#fff;border-color:var(--accent)}
.sched-inline{display:flex;gap:8px;align-items:center;flex-wrap:wrap}
.sched-inline .num-input,.sched-inline .txt-input{max-width:120px}
.sched-inline label{font-size:.8rem;color:var(--muted)}

/* Composition table: tint the cash column */
#compTable td.cash-cell,#compTable th.cash-cell{color:var(--gold)}

/* Portfolio bar - the scenario selector. Wrapped in its own panel and given a
   distinct accent (--accent2, teal) so it reads as separate from the blue-accented
   #pfEditSection sub-tabs below it. */
.pf-bar{display:flex;align-items:flex-start;gap:8px;margin-bottom:14px;padding:9px;border:1px solid var(--border);border-radius:12px;background:var(--input-bg)}
.pf-tabs{display:flex;gap:6px;flex-wrap:wrap;flex:1;min-width:0;align-items:center}
.pf-tab{display:flex;align-items:center;gap:6px;padding:6px 11px;border:1px solid var(--border);border-radius:8px;background:var(--panel);color:var(--muted);font-weight:600;font-size:.82rem;cursor:pointer;user-select:none;max-width:170px;white-space:nowrap;transition:all .15s}
.pf-tab:hover{border-color:var(--accent2);color:var(--text)}
.pf-tab.active{background:var(--accent2);color:#fff;border-color:var(--accent2);font-weight:700}
.pf-tab-name{overflow:hidden;text-overflow:ellipsis}
.pf-tab-dot{width:13px;height:13px;padding:0;border:none;border-radius:50%;background:none;cursor:pointer;flex-shrink:0;-webkit-appearance:none;-moz-appearance:none;appearance:none}
.pf-tab-dot::-webkit-color-swatch-wrapper{padding:0}
.pf-tab-dot::-webkit-color-swatch{border:1px solid rgba(0,0,0,.25);border-radius:50%}
.pf-tab-dot::-moz-color-swatch{border:1px solid rgba(0,0,0,.25);border-radius:50%}
.pf-tab-rename{width:92px;font:inherit;font-size:.82rem;padding:1px 4px;border:1px solid var(--border);border-radius:5px;background:var(--panel);color:var(--text)}

/* Inline + Add button - sits directly beside the last portfolio tab and wraps with them */
.pf-add-btn{display:inline-flex;align-items:center;justify-content:center;width:32px;height:32px;font-size:1.2rem;line-height:1;border:1px dashed var(--accent2);border-radius:8px;background:transparent;color:var(--accent2);cursor:pointer;font-family:inherit;padding:0;flex-shrink:0;transition:all .15s}
.pf-add-btn:hover{background:var(--accent2);color:#fff;border-style:solid}

/* Copy & Delete grouped on the side, stacked vertically and divided from the tabs */
.pf-bar-actions{display:flex;flex-direction:column;gap:5px;flex-shrink:0;padding-left:9px;border-left:1px solid var(--border)}
.pf-act-btn{width:30px;height:30px;display:inline-flex;align-items:center;justify-content:center;font-size:.95rem;border:1px solid var(--border);border-radius:8px;background:var(--panel);color:var(--text);cursor:pointer;font-family:inherit;padding:0;transition:all .15s}
.pf-act-btn:hover{border-color:var(--accent2);color:var(--accent2)}
.pf-act-btn.pf-act-del:hover{border-color:#ef4444;color:#ef4444}

/* Portfolio chooser on the Detailed Breakdown header (drives every subsection) */
.pf-view-select{font-size:.8rem;padding:5px 10px;min-width:130px;max-width:200px}

/* Detailed Breakdown subsections (Security Prices / Composition / Breakdown Table)
   share one card and one portfolio selector; a divider separates each block. */
.detail-subsection{margin-top:26px;padding-top:22px;border-top:1px solid var(--border)}
.detail-subsection:first-of-type{margin-top:10px;padding-top:0;border-top:none}
.detail-subsection .section-title{margin-bottom:10px}
.detail-subtitle{margin:0;font-size:1rem;font-weight:700;color:var(--text);text-transform:none;letter-spacing:normal}
.detail-subtitle .muted-note{color:var(--muted);font-size:.85rem;font-weight:400}

/* Sub-tabs for editing the selected portfolio (Assets / Top-Ups / Rebalancing) */
.sub-tabs{display:flex;gap:4px;margin-bottom:12px;background:var(--input-bg);border:1px solid var(--border);border-radius:10px;padding:3px}
.sub-tab{flex:1 1 0;padding:7px 4px;text-align:center;font-weight:700;font-size:.78rem;cursor:pointer;color:var(--muted);background:transparent;border:none;border-radius:7px;transition:all .15s;white-space:nowrap;font-family:inherit}
.sub-tab:hover{color:var(--text)}
.sub-tab.active{background:var(--accent);color:#fff}
.sub-panel{display:none}
.sub-panel.active{display:block}

/* Segmented view toggle (Composition chart: $ value / % of portfolio) */
.seg-toggle{display:inline-flex;gap:2px;background:var(--input-bg);border:1px solid var(--border);border-radius:9px;padding:3px;flex-shrink:0}
.seg-btn{padding:4px 11px;font-size:.78rem;font-weight:700;border:none;background:transparent;color:var(--muted);border-radius:6px;cursor:pointer;font-family:inherit;white-space:nowrap;transition:all .15s}
.seg-btn:hover{color:var(--text)}
.seg-btn.active{background:var(--accent);color:#fff}

/* Keep chart export buttons grouped so they don't orphan-wrap onto a new line */
.btn-cluster{display:inline-flex;align-items:center;gap:8px;flex-shrink:0}

/* Collapsed Method summary (Rebalancing subtab): shows the chosen method with a
   "Change Method" button so the long five-option list does not crowd the panel. */
.method-collapsed{display:flex;align-items:flex-start;gap:10px;padding:10px 12px;border:1px solid var(--accent);background:rgba(141,187,255,.08);border-radius:9px;margin-top:6px}
.method-collapsed-text{flex:1;min-width:0;font-size:.8rem;line-height:1.4;color:var(--muted)}
.method-collapsed-text strong{display:block;color:var(--text);font-weight:700;font-size:.86rem;margin-bottom:1px}
/* Pencil edit button to re-open the full method list; compact square icon. */
.method-change-btn{flex-shrink:0;font-size:.95rem;line-height:1;padding:6px 9px;white-space:nowrap}

/* Rule-Based deploy triggers: one compact card per asset (Rebalancing subtab) */
#triggerTableWrap{display:flex;flex-direction:column;gap:8px;margin-top:4px}
.trigger-card{border:1px solid var(--border);border-radius:10px;padding:8px 10px;background:var(--input-bg)}
.trigger-head{display:flex;align-items:center;gap:7px;font-size:.84rem;font-weight:700;color:var(--text);margin-bottom:2px}
.trigger-head .wt-label{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;min-width:0;flex:1}
.trigger-head .tip-icon{flex-shrink:0}
.trigger-reserve-tag{margin-left:auto;font-size:.7rem;font-weight:700;color:var(--gold);border:1px solid var(--gold);border-radius:6px;padding:1px 7px;flex-shrink:0}
/* Collapsible trigger config: header toggles, chevron rotates, body + summary swap. */
.trigger-toggle{cursor:pointer;user-select:none}
.trig-chevron{flex-shrink:0;font-size:.7rem;color:var(--muted);transition:transform .15s}
.trigger-card.is-collapsed .trig-chevron{transform:rotate(-90deg)}
.trigger-summary{display:none;font-size:.76rem;color:var(--muted);padding:2px 0 1px}
.trigger-card.is-collapsed .trigger-summary{display:block}
.trigger-card.is-collapsed .trigger-body{display:none}
/* Keep each control on its own line; let selects grow so long option labels
   (e.g. "Price % move", "Falls by", "Month open") are no longer clipped, while
   number inputs stay compact. */
.trigger-card .param-row{padding:3px 0;flex-wrap:nowrap}
.trigger-card .param-row>label{min-width:66px}
.trigger-card .param-row input.num-input{max-width:78px}
.trigger-card .param-row select.num-input{flex:1 1 auto;min-width:0;width:auto;max-width:none}
.trigger-card .tech-eom{padding:6px 0 2px}
