/* ==========================================================================
   widgets.css — Form tabs, FO import zone, liquid panel, insurance fields,
                 side-gig items, calculator outputs, scenario table, FIRE
                 progress bar, CD stats
   ========================================================================== */

/* Unified add-form type tabs — organic fluid */
.ua-type-tabs {
    display: flex;
    gap: var(--space-xs);
    margin-bottom: var(--space-lg);
    background: rgba(255,255,255,0.04);
    border-radius: var(--border-radius);
    padding: var(--space-xs);
}

.ua-tab-btn {
    flex: 1;
    padding: var(--space-xs) var(--space-sm);
    font-size: var(--text-sm);
    font-family: var(--font-heading);
    font-weight: 600;
    border: none;
    border-radius: var(--border-radius-sm);
    cursor: pointer;
    background: transparent;
    color: rgba(255,255,255,0.45);
    transition: var(--transition-fast);
}
.ua-tab-btn.active {
    background: rgba(139,92,246,0.25);
    color: #c4b5fd;
    box-shadow: inset 0 -2px 0 var(--color-primary);
}
.ua-tab-btn:hover:not(.active) {
    background: rgba(255,255,255,0.06);
    color: rgba(255,255,255,0.7);
}

/* Inline form layout for FO add forms — fluid */
.fo-form-row {
    display: grid;
    gap: var(--space-md);
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 140px), 1fr));
}

.fo-form-row .form-group {
    margin-bottom: 0;
}

/* CD metrics inline in holdings card title row */
.cd-inline-metrics {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    font-size: var(--text-sm);
    font-weight: 600;
    flex-wrap: wrap;
}

/* FO import drop zone — organic */
.fo-import-drop {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-sm) var(--space-md);
    border: 1.5px dashed rgba(255,255,255,0.18);
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: var(--transition-fast);
    white-space: nowrap;
    flex-shrink: 0;
}
.fo-import-drop:hover,
.fo-import-drop.drag-over {
    border-color: rgba(139,92,246,0.7);
    background: rgba(139,92,246,0.08);
}

/* Disabled while Plaid transaction sync is active — see
   setFidelityImportDisabled() in app/lib/csv-import.js */
.fo-import-drop.disabled {
    cursor: not-allowed;
    opacity: 0.5;
    pointer-events: none;
}

.fo-upload-icon {
    width: 18px;
    height: 18px;
    color: rgba(255,255,255,0.5);
    flex-shrink: 0;
}

.fo-import-label {
    font-size: var(--text-sm);
    color: rgba(255,255,255,0.55);
}

.fo-import-files {
    flex: 1;
    overflow-x: auto;
}

.fo-import-table {
    font-size: var(--text-xs);
    width: 100%;
}
.fo-import-table th, .fo-import-table td {
    padding: 4px 8px;
}

/* FO import card (right panel) */
.fo-import-card .fo-import-drop {
    padding: 10px 14px;
    gap: 8px;
    justify-content: flex-start;
}
.fo-import-card .fo-upload-icon {
    width: 16px;
    height: 16px;
}
.fo-import-card .fo-import-label {
    font-size: 11px;
}

/* Cash & Fixed Income dashboard panel */
.liquid-section-label {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: rgba(255,255,255,0.35);
    margin: 4px 0 6px;
}
.liquid-section-label.mt-2 { margin-top: 12px; }

.liquid-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 8px;
    padding: 5px 0;
    border-bottom: 1px solid rgba(255,255,255,0.04);
    font-size: 12px;
}
.liquid-row:last-child { border-bottom: none; }

.liquid-name {
    display: flex;
    flex-direction: column;
    gap: 1px;
    flex: 1;
    min-width: 0;
    font-weight: 600;
    color: rgba(255,255,255,0.85);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.liquid-type {
    font-size: 10px;
    font-weight: 500;
    color: rgba(255,255,255,0.35);
}

.liquid-maturity {
    font-size: 10px;
    font-weight: 600;
}

.liquid-val {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 2px;
    font-weight: 700;
    color: #10b981;
    white-space: nowrap;
    flex-shrink: 0;
}

.liquid-rate {
    font-size: 10px;
    font-weight: 600;
    color: #f59e0b;
}

/* Asset Allocation drill-down (charts/allocation.js) */
.alloc-back-btn {
    background: none;
    border: 1px solid var(--border-divider);
    color: rgba(255,255,255,0.7);
    border-radius: var(--border-radius-sm);
    font-size: 11px;
    font-weight: 600;
    padding: 4px 10px;
    cursor: pointer;
    transition: var(--transition-smooth);
}
.alloc-back-btn:hover {
    color: #fff;
    border-color: var(--card-hover-border);
}

.alloc-detail-list {
    margin-top: 8px;
    max-height: 160px;
    overflow-y: auto;
}

.alloc-detail-row {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    padding: 5px 0;
    border-bottom: 1px solid rgba(255,255,255,0.04);
    font-size: 12px;
}
.alloc-detail-row:last-child { border-bottom: none; }

.alloc-detail-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
    margin-top: 4px;
}

.alloc-detail-name {
    flex: 1;
    min-width: 0;
    font-weight: 600;
    color: rgba(255,255,255,0.85);
    overflow: hidden;
    text-overflow: ellipsis;
}

.alloc-detail-val {
    font-weight: 700;
    color: rgba(255,255,255,0.9);
    white-space: nowrap;
    flex-shrink: 0;
}

/* Insurance fields in Expenses tab */
.insurance-section {
    border-top: 1px solid rgba(255,255,255,0.08);
    padding-top: 16px;
}

.section-sub-title {
    font-size: 13px;
    font-weight: 700;
    color: rgba(255,255,255,0.75);
    margin: 0 0 4px 0;
    font-family: 'Outfit', sans-serif;
}

.insurance-field-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.insurance-field-group label {
    font-size: 12px;
    color: rgba(255,255,255,0.6);
    font-weight: 600;
}

.insurance-row {
    display: flex;
    gap: 8px;
    align-items: center;
}

.insurance-amt-input {
    flex: 1;
    min-width: 80px;
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(255,255,255,0.12);
    border-radius: 8px;
    padding: 8px 12px;
    color: #fff;
    font-size: 13px;
    font-family: 'Outfit', sans-serif;
}
.insurance-amt-input:focus {
    outline: none;
    border-color: rgba(139,92,246,0.6);
}

.insurance-freq-select {
    flex: 1.4;
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(255,255,255,0.12);
    border-radius: 8px;
    padding: 8px 10px;
    color: rgba(255,255,255,0.8);
    font-size: 12px;
    font-family: 'Outfit', sans-serif;
    cursor: pointer;
}
.insurance-freq-select:focus {
    outline: none;
    border-color: rgba(139,92,246,0.6);
}

/* Side hustles tips items */
.hustle-tips-container {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.hustle-item {
    background-color: rgba(255,255,255,0.01);
    border-radius: 8px;
    padding: 12px;
    border-left: 2px solid var(--color-primary);
}

.hustle-item h4 {
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 4px;
}

.hustle-item p {
    font-size: 11px;
    color: var(--text-muted);
}

/* eBay Profit Calculator Outputs — organic fluid */
.calculator-results-box {
    background-color: rgba(15, 22, 36, 0.9);
    border: 1px solid var(--border-divider);
    border-radius: var(--border-radius);
    padding: var(--space-lg);
}

.results-grid {
    display: grid;
    gap: var(--space-md);
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 140px), 1fr));
}

.result-box {
    display: flex;
    flex-direction: column;
}

.result-label {
    font-size: var(--text-xs);
    color: var(--text-muted);
    margin-bottom: var(--space-xs);
}

.result-value {
    font-family: var(--font-heading);
    font-size: var(--text-xl);
    font-weight: 700;
}

/* Multi-Scenario FIRE Date Comparison Table */
.scenario-compare-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}
.scenario-compare-table th {
    text-align: left;
    font-family: var(--font-heading);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    color: var(--text-dimmed);
    padding: 0 12px 10px 12px;
    border-bottom: 1px solid var(--border-divider);
}
.scenario-compare-table td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--border-divider);
    vertical-align: middle;
}
.scenario-compare-table tbody tr:last-child td {
    border-bottom: none;
}
.scenario-compare-table tbody tr:hover td {
    background: rgba(255, 255, 255, 0.02);
}
.scen-base-row td {
    background: rgba(139, 92, 246, 0.06);
}
.scen-label-cell {
    font-weight: 500;
    color: var(--text-main);
}
.scen-delta-better {
    color: var(--color-success);
    font-weight: 600;
    font-size: 12px;
}
.scen-delta-worse {
    color: var(--color-danger);
    font-weight: 600;
    font-size: 12px;
}
.scen-delta-neutral {
    color: var(--text-dimmed);
    font-size: 12px;
}

/* Header: income sub-line */
.income-sub-line {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 2px;
}

/* Header: FIRE progress bar */
.fire-prog-wrap {
    margin-top: 4px;
    background: rgba(255,255,255,0.06);
    border-radius: 20px;
    height: 20px;
    overflow: hidden;
    position: relative;
}

.fire-prog-bar {
    height: 100%;
    background: linear-gradient(90deg, #8b5cf6, #a78bfa);
    border-radius: 20px;
    min-width: 20px;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    transition: width 0.5s ease;
}

.fire-prog-pct {
    font-size: 11px;
    font-weight: 700;
    color: #fff;
    padding-right: 6px;
    white-space: nowrap;
}

.fire-prog-target {
    font-size: var(--text-xs);
    color: var(--text-muted);
    margin-top: 3px;
}

/* CD Stats Container */
.cd-stats-container {
    display: flex;
    flex-direction: column;
}

.cd-stat-box {
    background-color: rgba(255,255,255,0.015);
    border: 1px solid var(--border-divider);
    border-radius: 8px;
    padding: 12px;
    display: flex;
    flex-direction: column;
}

.cd-stat-label {
    font-size: 10px;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-bottom: 2px;
}

.cd-stat-value {
    font-size: 18px;
    font-family: var(--font-heading);
    font-weight: 700;
}

/* ==========================================================================
   ENS / crypto wallet lookup widget
   ========================================================================== */
.ens-lookup-form {
    display: flex;
    gap: var(--space-sm);
    flex-wrap: wrap;
}

.ens-lookup-form input {
    flex: 1;
    min-width: 180px;
    background: var(--input-bg);
    border: 1px solid var(--card-border);
    border-radius: var(--border-radius-sm);
    color: var(--text-main);
    padding: var(--space-sm) var(--space-md);
    font-size: var(--text-sm);
}

.ens-lookup-result {
    margin-top: var(--space-md);
}

.ens-lookup-total {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    padding: var(--space-sm) 0;
    border-bottom: 1px solid var(--border-divider);
    margin-bottom: var(--space-sm);
}

.ens-lookup-total .val {
    font-family: var(--font-heading);
    font-size: var(--text-xl);
    font-weight: 700;
    color: var(--color-success);
}

.chain-balance-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 0;
    font-size: var(--text-sm);
    border-bottom: 1px solid var(--border-divider);
}

.chain-balance-row:last-child {
    border-bottom: none;
}

.chain-balance-row .chain-name {
    color: var(--text-muted);
}

.chain-balance-row .chain-val {
    font-weight: 600;
}

/* ==========================================================================
   Crypto wallet manager widget
   ========================================================================== */
.wallet-add-form {
    display: flex;
    gap: var(--space-sm);
    flex-wrap: wrap;
}

.wallet-add-form input,
.wallet-add-form select {
    flex: 1;
    min-width: 140px;
    background: var(--input-bg);
    border: 1px solid var(--card-border);
    border-radius: var(--border-radius-sm);
    color: var(--text-main);
    padding: var(--space-sm) var(--space-md);
    font-size: var(--text-sm);
}

.wallet-row {
    align-items: flex-start;
}

.wallet-row-actions {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 4px;
}

.wallet-row-btns {
    display: flex;
    gap: 6px;
}

.wallet-total-row {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    padding: var(--space-sm) 0;
    margin-top: var(--space-sm);
    border-top: 1px solid var(--border-divider);
}

/* ==========================================================================
   Expenses tab — spending CSV upload, transaction table, category mapping
   ========================================================================== */
.spending-tx-table {
    width: 100%;
    border-collapse: collapse;
    font-size: var(--text-sm);
}

.spending-tx-table th {
    text-align: left;
    font-size: var(--text-xs);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-dimmed);
    padding: 6px 8px;
    border-bottom: 1px solid var(--border-divider);
}

.spending-tx-table td {
    padding: 6px 8px;
    border-bottom: 1px solid var(--border-divider);
    vertical-align: middle;
}

.spending-cat-select {
    background: var(--input-bg);
    border: 1px solid var(--card-border);
    border-radius: var(--border-radius-sm);
    color: var(--text-main);
    font-size: var(--text-xs);
    padding: 4px 6px;
}

.spending-tx-delete {
    background: none;
    border: none;
    color: var(--text-dimmed);
    cursor: pointer;
    font-size: 14px;
    padding: 2px 6px;
    border-radius: 4px;
}

.spending-tx-delete:hover {
    color: var(--color-danger);
    background: var(--color-danger-bg);
}

.merchant-map-editor {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-top: var(--space-sm);
}

.merchant-map-row {
    display: grid;
    grid-template-columns: 1fr 1fr auto;
    gap: 6px;
    align-items: center;
}

.merchant-map-row input,
.merchant-map-row select {
    background: var(--input-bg);
    border: 1px solid var(--card-border);
    border-radius: var(--border-radius-sm);
    color: var(--text-main);
    padding: 5px 8px;
    font-size: var(--text-xs);
}

.alloc-cat-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: var(--space-sm);
}

.alloc-cat-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: var(--input-bg);
    border: 1px solid var(--card-border);
    border-radius: var(--border-radius-sm);
    color: var(--text-main);
    font-size: var(--text-xs);
    padding: 4px 8px;
    cursor: pointer;
}

.alloc-cat-btn:hover,
.alloc-cat-btn:focus-visible {
    border-color: var(--color-primary);
}

/* Top Investment Positions: narrow widths show symbol, value and PnL only;
   the hidden fields live behind a "+" in an otherwise empty column. */
.pos-expand-cell,
.position-detail-row {
    display: none;
}

.pos-expand-btn {
    background: none;
    border: 1px solid var(--card-border);
    border-radius: var(--border-radius-sm);
    color: var(--text-main);
    width: 24px;
    height: 24px;
    line-height: 1;
    cursor: pointer;
}

.pos-detail-list {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px 16px;
    margin: 0;
    font-size: var(--text-xs);
}

.pos-detail-list dt {
    color: var(--text-muted);
}

.pos-detail-list dd {
    margin: 0;
    overflow-wrap: anywhere;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
}

@media (max-width: 768px) {
    .pos-col-desc,
    .pos-col-qty,
    .pos-col-price,
    .pos-col-cost {
        display: none;
    }
    .pos-expand-cell {
        display: table-cell;
        width: 1%;
        padding-left: 4px;
        padding-right: 4px;
        text-align: center;
    }
    .position-detail-row:not([hidden]) {
        display: table-row;
    }
    /* Tighten and allow wrapping so symbol, value, PnL and + fit the card. */
    #table-dashboard-positions th,
    #table-dashboard-positions td {
        padding-left: 6px;
        padding-right: 6px;
        white-space: normal;
        overflow-wrap: anywhere;
        font-size: var(--text-xs);
    }
}

.hustle-item-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 8px;
}

.hustle-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 10px;
}

.hustle-mantra {
    text-align: center;
}

/* Vehicles: Estimate/Edit/Delete share the Actions cell. */
#table-vehicles td:last-child .action-btn {
    display: block;
    margin: 2px 0 2px auto;
}
