/*
 * Trend display primitives: badges, sparklines, percentile chips, +
 * the date-range selector that drives the as-of view.
 *
 * Owned by SC_Hub_Trend_Display + SC_Hub_Broker_Reporting.
 */

/* ── Trend badge ────────────────────────────────────────────────── */

.sc-trend-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 11px;
    line-height: 1;
    font-weight: 600;
    padding: 3px 7px;
    border-radius: 999px;
    white-space: nowrap;
    vertical-align: middle;
    border: 1px solid transparent;
}

.sc-trend-badge__arrow {
    font-size: 12px;
    line-height: 1;
}

.sc-trend-badge__pct {
    letter-spacing: 0.01em;
}

.sc-trend-badge__vs {
    font-weight: 500;
    opacity: 0.75;
    font-size: 10.5px;
    margin-left: 2px;
}

.sc-trend-badge--positive {
    background: #ecfdf5;
    color: #047857;
    border-color: #a7f3d0;
}

.sc-trend-badge--negative {
    background: #fef2f2;
    color: #b91c1c;
    border-color: #fecaca;
}

/* ── Sparkline ──────────────────────────────────────────────────── */

.sc-sparkline {
    display: inline-block;
    vertical-align: middle;
    overflow: visible;
}

.sc-sparkline__line {
    transition: stroke 0.15s ease;
}

.sc-sparkline--positive { color: #10b981; }
.sc-sparkline--negative { color: #ef4444; }
.sc-sparkline--neutral  { color: #94a3b8; }

/* ── Percentile chip ────────────────────────────────────────────── */

.sc-percentile-chip {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 11.5px;
    line-height: 1;
    font-weight: 600;
    padding: 5px 10px;
    border-radius: 999px;
    white-space: nowrap;
    vertical-align: middle;
    border: 1px solid transparent;
}

.sc-percentile-chip svg {
    flex: 0 0 auto;
    width: 12px;
    height: 12px;
}

.sc-percentile-chip--top {
    background: #ecfdf5;
    color: #047857;
    border-color: #a7f3d0;
}

.sc-percentile-chip--upper {
    background: #eff6ff;
    color: #1d4ed8;
    border-color: #bfdbfe;
}

.sc-percentile-chip--lower {
    background: #fef3c7;
    color: #92400e;
    border-color: #fde68a;
}

.sc-percentile-chip--bottom {
    background: #fef2f2;
    color: #b91c1c;
    border-color: #fecaca;
}

/* ── Date range selector ────────────────────────────────────────── */

.sc-broker-daterange {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 6px 10px 6px 14px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    font-size: 13px;
    line-height: 1.2;
    color: #334155;
}

.sc-broker-daterange__label {
    font-weight: 600;
    color: #1e293b;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.sc-broker-daterange__label svg {
    width: 14px;
    height: 14px;
    color: #64748b;
}

.sc-broker-daterange__noscript-list {
    list-style: none;
    margin: 8px 0 0;
    padding: 0;
    display: inline-flex;
    flex-wrap: wrap;
    gap: 6px;
}

.sc-broker-daterange__noscript-list a {
    text-decoration: none;
    background: #ffffff;
    border: 1px solid #cbd5e1;
    border-radius: 5px;
    padding: 4px 10px;
    font-size: 12px;
    color: #0f172a;
}

.sc-broker-daterange__select {
    appearance: none;
    background: #ffffff;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    padding: 5px 28px 5px 10px;
    font-size: 13px;
    font-weight: 500;
    color: #0f172a;
    line-height: 1.2;
    cursor: pointer;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 8px center;
}

.sc-broker-daterange__select:focus {
    outline: 2px solid #3b82f6;
    outline-offset: 1px;
}

.sc-broker-daterange__reset {
    text-decoration: none;
    color: #64748b;
    font-size: 12px;
    font-weight: 500;
    padding: 4px 8px;
    border-radius: 5px;
    background: transparent;
    border: 1px solid transparent;
    transition: background 0.15s ease, color 0.15s ease;
}

.sc-broker-daterange__reset:hover,
.sc-broker-daterange__reset:focus {
    background: #f1f5f9;
    color: #0f172a;
    text-decoration: none;
}

.sc-broker-daterange--inactive .sc-broker-daterange__reset {
    display: none;
}

.sc-broker-daterange__hint {
    font-size: 11.5px;
    color: #64748b;
}

/* As-of state banner — shown above the reporting block when ?as_of= set */

.sc-broker-asof-banner {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    margin: 0 0 16px;
    background: #fffbeb;
    border: 1px solid #fde68a;
    border-radius: 8px;
    color: #78350f;
    font-size: 13px;
    line-height: 1.4;
}

.sc-broker-asof-banner svg {
    flex: 0 0 auto;
    width: 16px;
    height: 16px;
}

.sc-broker-asof-banner strong {
    font-weight: 700;
}

.sc-broker-asof-banner a {
    color: #92400e;
    font-weight: 600;
    text-decoration: underline;
    margin-left: auto;
}

/* ── Reporting card additions ────────────────────────────────────── */

/* Allow trend badges to coexist nicely with table values */

.sc-portfolio-table__value {
    white-space: nowrap;
}

.sc-portfolio-table__value-wrap {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.sc-portfolio-table__value-wrap .sc-sparkline {
    margin-right: -2px;
}

/* ROI hero — percentile chip + sparkline below the value */

.sc-portfolio-roi__meta {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    margin-top: 10px;
}

/* ── Broker table additions ─────────────────────────────────────── */

.sc-broker-table td .sc-trend-badge {
    margin-left: 6px;
}

.sc-broker-table .sc-broker-table__value-wrap {
    display: inline-flex;
    align-items: baseline;
    gap: 6px;
    justify-content: flex-end;
    flex-wrap: nowrap;
}

/* Responsive — collapse the date selector cleanly on mobile */

@media (max-width: 600px) {
    .sc-broker-daterange {
        flex-wrap: wrap;
        gap: 6px;
    }

    .sc-broker-daterange__hint {
        flex-basis: 100%;
    }

    .sc-trend-badge__vs {
        display: none; /* keep the badge tight on phones */
    }
}
