/* style.css -- custom styles for Stock Monitor */

/* ─────────────────────────────────────────────────────────────
   Watchlist row coloring
   The row gets a subtle background tint + a colored left border.
   ───────────────────────────────────────────────────────────── */
.row-green {
    background-color: rgba(34, 197, 94, 0.08);
    border-left: 4px solid rgb(34, 197, 94);
}
.row-red {
    background-color: rgba(239, 68, 68, 0.08);
    border-left: 4px solid rgb(239, 68, 68);
}
.row-yellow {
    background-color: rgba(234, 179, 8, 0.08);
    border-left: 4px solid rgb(234, 179, 8);
}
.row-neutral {
    background-color: rgba(148, 163, 184, 0.05);
    border-left: 4px solid rgb(100, 116, 139);
}

.pct-green  { color: rgb(74, 222, 128); }
.pct-red    { color: rgb(248, 113, 113); }
.pct-yellow { color: rgb(250, 204, 21);  }

/* ─────────────────────────────────────────────────────────────
   Tables
   ───────────────────────────────────────────────────────────── */
table.data-table {
    width: 100%;
    border-collapse: collapse;
}
table.data-table th {
    text-align: left;
    padding: 0.6rem 0.75rem;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: rgb(148, 163, 184);
    background: rgb(30, 41, 59);
    border-bottom: 1px solid rgb(51, 65, 85);
}
table.data-table th.sortable:hover {
    color: rgb(241, 245, 249);
    background: rgb(51, 65, 85);
}
table.data-table th.sort-active {
    color: rgb(96, 165, 250);
}
table.data-table th .sort-ind {
    color: rgb(96, 165, 250);
    font-size: 0.7rem;
}
table.data-table td {
    padding: 0.4rem 0.75rem;
    border-bottom: 1px solid rgb(51, 65, 85);
    font-size: 0.9rem;
}
table.data-table tbody tr:last-child td {
    border-bottom: none;
}
/* Modifier for narrow 3-column tables (Expected Moves, CVaR, VaR).
   Default data-table is full-width which leaves gaping space between
   columns when there are only 3. This caps the table to its content. */
table.data-table.data-table-compact {
    width: auto;
    min-width: 32rem;
    max-width: 56rem;
}
table.data-table.data-table-compact th,
table.data-table.data-table-compact td {
    padding-left: 1.25rem;
    padding-right: 1.25rem;
}
table.data-table.data-table-compact th:first-child,
table.data-table.data-table-compact td:first-child {
    padding-left: 0.75rem;
}
table.data-table.data-table-compact th.num,
table.data-table.data-table-compact td.num {
    min-width: 7rem;
}

/* Mobile-only column for net-delta on iron condor rows.
   ─ Default (desktop):       hidden -- desktop uses the wider col-delta
   ─ Inside @media (≤640px):  shown as table-cell (override below)
   Sits right after the P&L column on phones, so the user can see at
   a glance whether each iron condor is still neutral.
   IMPORTANT: this rule MUST come BEFORE the @media block so the
   mobile override wins on tied specificity. Earlier we had the
   "display: none" later in the file and it canceled out the
   mobile rule on phones. */
table.dashboard-table .col-mobile-delta {
    display: none;
}

/* On phones (below 640px = sm: breakpoint), shrink the compact tables
   to fit instead of horizontal-scrolling. The min-width and per-cell
   horizontal padding both relax so content fits in ~360px viewports. */
@media (max-width: 640px) {
    table.data-table.data-table-compact {
        min-width: 0;
        width: 100%;
    }
    table.data-table.data-table-compact th,
    table.data-table.data-table-compact td {
        padding-left: 0.5rem;
        padding-right: 0.5rem;
        font-size: 0.85rem;
    }
    table.data-table.data-table-compact th.num,
    table.data-table.data-table-compact td.num {
        min-width: 0;
    }
    /* Body cell padding tighter on phones */
    table.data-table td {
        padding: 0.35rem 0.5rem;
    }

    /* ── Dashboard-specific mobile rules ─────────────────────────
       Hide low-priority columns on phones to fit core info in the
       viewport. Tapping a row reveals the rest as a stacked card
       (handled in JS). */
    table.dashboard-table .col-rsi,
    table.dashboard-table .col-trend,
    table.dashboard-table .col-delta,
    table.dashboard-table .col-iv,
    table.dashboard-table .col-underlying,
    table.dashboard-table .col-updated {
        display: none;
    }
    /* Show the mobile-only delta column on phones. Tight width
       (just the value, no extra padding) so other columns get room. */
    table.dashboard-table .col-mobile-delta {
        display: table-cell;
        padding-left: 0.3rem;
        padding-right: 0.3rem;
        font-size: 0.8rem;
        white-space: nowrap;
        min-width: 2.6rem;
    }
    /* Tighten remaining column padding so 7 columns fit in ~360px */
    table.dashboard-table th,
    table.dashboard-table td {
        padding-left: 0.4rem;
        padding-right: 0.4rem;
        font-size: 0.85rem;
    }
    table.dashboard-table .col-toggle {
        padding-left: 0;
        padding-right: 0;
    }
}

/* Bigger tap target for expand toggles. Visual + sign stays the same
   size; the clickable area extends to 44×44px (Apple's minimum tap
   target). Applies on all viewports -- desktop also benefits from a
   more forgiving click zone. */
.expand-toggle {
    min-width: 44px;
    min-height: 44px;
    padding: 0;
    line-height: 44px;
    font-size: 1.25rem;
    font-weight: 600;
}

/* Mobile tap-to-expand: card-style row showing the hidden columns
   stacked with their labels. Inserted by JS as the next sibling of
   any tapped parent row. */
tr.mobile-detail-row > td {
    background: rgba(30, 41, 59, 0.7);
    padding: 0.5rem 0.75rem;
    border-bottom: 1px solid rgb(51, 65, 85);
}
.mobile-detail-card {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.4rem 1rem;
}
.mobile-detail-pair {
    display: flex;
    flex-direction: column;
    font-size: 0.8rem;
    line-height: 1.2;
}
.mobile-detail-label {
    color: rgb(148, 163, 184);
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 0.15rem;
}
.mobile-detail-value {
    color: rgb(226, 232, 240);
}
/* When a parent row's detail is open, give a subtle visual cue */
tr.mobile-detail-open > td {
    border-bottom-color: transparent;
}
table.data-table tbody tr:hover td {
    background-color: rgba(30, 41, 59, 0.5);
}
table.data-table .num {
    font-variant-numeric: tabular-nums;
    text-align: right;
}

/* ─────────────────────────────────────────────────────────────
   Badges
   ───────────────────────────────────────────────────────────── */
.badge {
    display: inline-block;
    padding: 0.15rem 0.55rem;
    border-radius: 9999px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}
.badge-uptrend   { background: rgba(34, 197, 94, 0.2);  color: rgb(74, 222, 128); }
.badge-downtrend { background: rgba(239, 68, 68, 0.2);  color: rgb(248, 113, 113); }
.badge-sideways  { background: rgba(234, 179, 8, 0.2);  color: rgb(250, 204, 21); }
.badge-call      { background: rgba(34, 197, 94, 0.2);  color: rgb(74, 222, 128); }
.badge-put       { background: rgba(239, 68, 68, 0.2);  color: rgb(248, 113, 113); }
.badge-stock     { background: rgba(99, 102, 241, 0.2); color: rgb(165, 180, 252); }

/* ─────────────────────────────────────────────────────────────
   Forms
   ───────────────────────────────────────────────────────────── */
.input {
    background: rgb(15, 23, 42);
    border: 1px solid rgb(51, 65, 85);
    color: rgb(241, 245, 249);
    border-radius: 0.375rem;
    padding: 0.5rem 0.75rem;
    width: 100%;
}
.input:focus {
    outline: none;
    border-color: rgb(59, 130, 246);
    box-shadow: 0 0 0 1px rgb(59, 130, 246);
}
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.5rem 0.9rem;
    border-radius: 0.375rem;
    font-weight: 500;
    font-size: 0.875rem;
    cursor: pointer;
    border: none;
}
.btn-primary { background: rgb(37, 99, 235); color: white; }
.btn-primary:hover { background: rgb(29, 78, 216); }
.btn-danger  { background: rgb(220, 38, 38);  color: white; }
.btn-danger:hover  { background: rgb(185, 28, 28); }
.btn-ghost   { background: transparent;       color: rgb(148, 163, 184); }
.btn-ghost:hover   { color: white; }

/* Card-ish container */
.panel {
    background: rgb(30, 41, 59);
    border: 1px solid rgb(51, 65, 85);
    border-radius: 0.5rem;
    padding: 1rem 1.25rem;
}

.flash-success { background: rgba(34, 197, 94, 0.15); border: 1px solid rgb(34, 197, 94); color: rgb(187, 247, 208); padding: 0.65rem 1rem; border-radius: 0.375rem; margin-bottom: 1rem; }
.flash-error   { background: rgba(239, 68, 68, 0.15); border: 1px solid rgb(239, 68, 68); color: rgb(254, 202, 202); padding: 0.65rem 1rem; border-radius: 0.375rem; margin-bottom: 1rem; }
.flash-warning { background: rgba(234, 179, 8, 0.15); border: 1px solid rgb(234, 179, 8); color: rgb(254, 240, 138); padding: 0.65rem 1rem; border-radius: 0.375rem; margin-bottom: 1rem; }

/* ─────────────────────────────────────────────────────────────
   Tooltips: <span class="tip" data-tip="...">?</span>
   Pure CSS, works on hover and on focus (so tap works on touch).
   ───────────────────────────────────────────────────────────── */
.tip {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1rem;
    height: 1rem;
    margin-left: 0.35rem;
    border-radius: 9999px;
    background: rgb(51, 65, 85);
    color: rgb(203, 213, 225);
    font-size: 0.7rem;
    font-weight: 700;
    cursor: help;
    user-select: none;
    position: relative;
    outline: none;
}
.tip:hover, .tip:focus {
    background: rgb(59, 130, 246);
    color: white;
}
.tip::after {
    content: attr(data-tip);
    position: absolute;
    left: 50%;
    bottom: calc(100% + 0.5rem);
    transform: translateX(-50%);
    background: rgb(15, 23, 42);
    color: rgb(241, 245, 249);
    border: 1px solid rgb(59, 130, 246);
    padding: 0.5rem 0.75rem;
    border-radius: 0.375rem;
    font-size: 0.75rem;
    font-weight: 400;
    line-height: 1.4;
    white-space: normal;
    width: max-content;
    max-width: 18rem;
    text-align: left;
    box-shadow: 0 4px 6px rgba(0,0,0,0.3);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.15s;
    z-index: 50;
}
.tip:hover::after, .tip:focus::after {
    opacity: 1;
}
