/* Custom styles - Pico CSS handles most styling via CDN */

/* ── Color utilities ── */
.positive { color: #22c55e; }
.negative { color: #ef4444; }

/* ── Portfolio tab bar ── */
.pf-tabs {
    display: flex;
    gap: 0.5rem;
    margin: 2rem 0 0;
    padding: 0;
    border-bottom: 2px solid var(--pico-muted-border-color);
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.pf-tab {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.7rem 1.2rem;
    border: none;
    border-bottom: 3px solid transparent;
    background: none;
    color: var(--pico-muted-color);
    cursor: pointer;
    font-size: 0.95rem;
    font-weight: 600;
    white-space: nowrap;
    transition: all 0.2s ease;
    border-radius: 8px 8px 0 0;
    margin-bottom: -2px;
}

.pf-tab:hover {
    background: var(--pf-color-bg);
    color: var(--pf-color);
}

.pf-tab--active {
    color: var(--pf-color);
    border-bottom-color: var(--pf-color);
    background: var(--pf-color-bg);
}

.pf-tab-icon {
    font-size: 1.15em;
    line-height: 1;
}

.pf-tab-name {
    letter-spacing: 0.02em;
}

.pf-tab-pnl {
    font-size: 0.82em;
    font-weight: 700;
    padding: 0.1rem 0.45rem;
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.06);
}

/* ── Portfolio panels ── */
.pf-panel {
    display: none;
    padding: 1.5rem 0 0;
    animation: pf-fade-in 0.25s ease;
    position: relative;
}

.pf-panel--active {
    display: block;
}

.pf-panel::before {
    content: attr(data-icon);
    position: absolute;
    top: 1.5rem;
    right: 0;
    font-size: 8rem;
    opacity: 0.03;
    pointer-events: none;
    z-index: 0;
    line-height: 1;
}

@keyframes pf-fade-in {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0); }
}

.pf-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1.25rem;
    padding: 1rem 1.2rem;
    background: var(--pf-color-bg);
    border: 1px solid var(--pf-color-border);
    border-left: 4px solid var(--pf-color);
    border-radius: 8px;
}

.pf-header-icon {
    font-size: 2.5rem;
    line-height: 1;
    flex-shrink: 0;
}

.pf-header-text {
    flex: 1;
    min-width: 0;
}

.pf-header h2 {
    margin-bottom: 0.15rem;
}

.pf-description {
    opacity: 0.65;
    font-size: 0.9rem;
    margin: 0;
}

/* ── Stats grid ── */
.pf-stats-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
    margin-bottom: 1.5rem;
}

@media (max-width: 700px) {
    .pf-stats-grid { grid-template-columns: 1fr; }
}

.pf-stat-card {
    background: var(--pico-card-background-color);
    border: 1px solid var(--pf-color-border, var(--pico-muted-border-color));
    border-radius: 8px;
    padding: 1rem 1.2rem;
    border-top: 3px solid var(--pf-color);
    transition: border-color 0.2s, box-shadow 0.2s;
}

.pf-stat-card:hover {
    border-color: var(--pf-color);
    box-shadow: 0 0 12px var(--pf-color-bg);
}

.pf-stat-label {
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    opacity: 0.6;
    margin-bottom: 0.3rem;
}

.pf-stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    line-height: 1.2;
}

.pf-stat-value small {
    font-size: 0.6em;
    font-weight: 400;
    opacity: 0.7;
}

.pf-stat-sub {
    font-size: 0.82rem;
    opacity: 0.6;
    margin-top: 0.3rem;
}

/* ── Cards (holdings, reasoning, thoughts, reco) ── */
.pf-card {
    background: var(--pico-card-background-color);
    border: 1px solid var(--pf-color-border, var(--pico-muted-border-color));
    border-radius: 8px;
    padding: 1rem 1.2rem;
    margin-bottom: 1rem;
    position: relative;
    z-index: 1;
}

.pf-card-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 600;
    margin-bottom: 0.75rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--pf-color-border, var(--pico-muted-border-color));
}

.pf-card-header small {
    font-weight: 400;
    opacity: 0.6;
}

.pf-table-wrap {
    overflow-x: auto;
}

/* ── Chart wrapper ── */
.pf-chart-wrap {
    background: var(--pico-card-background-color);
    border: 1px solid var(--pf-color-border, var(--pico-muted-border-color));
    border-radius: 8px;
    padding: 1rem 1.2rem;
    margin-bottom: 1.5rem;
}

.pf-chart-header {
    font-weight: 600;
    margin-bottom: 0.75rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.pf-chart-header small {
    opacity: 0.6;
    font-weight: 400;
}

.portfolio-chart {
    max-height: 400px;
}

.metrics-row {
    display: flex;
    gap: 1.5rem;
    justify-content: center;
    margin-top: 0.5rem;
    font-size: 0.85rem;
    color: var(--pico-muted-color);
}

/* ── Details (rules, feeds) ── */
.pf-details {
    border-left: 3px solid var(--pf-color, var(--pico-muted-border-color));
}

/* ── Trade reasoning ── */
.trade-reasoning {
    background: rgba(255, 255, 255, 0.03);
    padding: 1rem;
    border-radius: var(--pico-border-radius);
    margin-top: 0.5rem;
    font-size: 0.9em;
    white-space: pre-wrap;
}

/* ── Trade chips ── */
.trade-chip {
    display: inline-block;
    padding: 0.1rem 0.55rem;
    border-radius: 10px;
    font-size: 0.78em;
    font-weight: 600;
    letter-spacing: 0.04em;
}
.trade-chip-buy  { background: rgba(34, 197, 94, 0.18);  color: #22c55e; }
.trade-chip-sell { background: rgba(239, 68, 68, 0.18);  color: #ef4444; }

.badge-offline {
    display: inline-block;
    padding: 0.1rem 0.5rem;
    margin-left: 0.5rem;
    border-radius: 10px;
    background: rgba(245, 158, 11, 0.18);
    color: #f59e0b;
    font-size: 0.72em;
    font-weight: 600;
    letter-spacing: 0.03em;
    vertical-align: middle;
}

/* ── Recommendation 3-panel grid ── */
.reco-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
    margin-bottom: 1rem;
}
@media (max-width: 900px) {
    .reco-grid { grid-template-columns: 1fr; }
}
.reco-panel {
    margin: 0;
}
@media (max-width: 375px) {
    .reco-panel { padding: 0.7rem 0.8rem; }
    .reco-item  { padding: 0.45rem 0; }
}
.reco-list {
    list-style: none;
    padding: 0;
    margin: 0;
}
.reco-item {
    padding: 0.6rem 0;
    border-top: 1px solid var(--pico-muted-border-color);
}
.reco-item:first-child {
    border-top: 0;
    padding-top: 0;
}
.reco-head {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}
.reco-rationale {
    margin-top: 0.25rem;
    font-size: 0.88em;
    opacity: 0.9;
    line-height: 1.4;
}
.reco-meta {
    display: block;
    margin-top: 0.25rem;
    opacity: 0.65;
    font-size: 0.78em;
}
.reco-empty {
    opacity: 0.55;
    font-style: italic;
    padding: 0.5rem 0;
}
.reco-chip {
    display: inline-block;
    padding: 0.05rem 0.45rem;
    border-radius: 8px;
    font-size: 0.72em;
    font-weight: 700;
    letter-spacing: 0.05em;
}
.reco-chip-buy  { background: rgba(34, 197, 94, 0.18);  color: #22c55e; }
.reco-chip-sell { background: rgba(239, 68, 68, 0.18);  color: #ef4444; }
.reco-badge-executed {
    margin-left: auto;
    padding: 0.05rem 0.4rem;
    border-radius: 8px;
    background: rgba(96, 165, 250, 0.18);
    color: #60a5fa;
    font-size: 0.68em;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

/* ── Portfolio dots ── */
.portfolio-dots {
    display: inline-flex;
    gap: 0.3rem;
    margin-left: 0.6rem;
    vertical-align: middle;
}

.portfolio-dot {
    width: 0.7rem;
    height: 0.7rem;
    border-radius: 50%;
    display: inline-block;
    border: 1px solid rgba(0, 0, 0, 0.15);
    cursor: help;
    position: relative;
}

.portfolio-dot[data-tooltip]:hover::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    background: #1e1e2e;
    color: #e0e0e0;
    font-size: 0.75rem;
    font-weight: 400;
    line-height: 1.4;
    padding: 0.45rem 0.7rem;
    border-radius: 6px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    white-space: nowrap;
    z-index: 100;
    pointer-events: none;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
    animation: tooltip-in 0.15s ease;
}

.portfolio-dot[data-tooltip]:hover::before {
    content: '';
    position: absolute;
    bottom: calc(100% + 3px);
    left: 50%;
    transform: translateX(-50%);
    border: 5px solid transparent;
    border-top-color: #1e1e2e;
    z-index: 100;
    pointer-events: none;
}

@keyframes tooltip-in {
    from { opacity: 0; transform: translateX(-50%) translateY(4px); }
    to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}

.portfolio-dot--claude    { background: #d97706; }
.portfolio-dot--ollama    { background: #a855f7; }
.portfolio-dot--yahoo     { background: #60a5fa; }
.portfolio-dot--fred      { background: #16a34a; }
.portfolio-dot--fng       { background: #f59e0b; }
.portfolio-dot--reddit    { background: #ef4444; }
.portfolio-dot--wsb       { background: #ec4899; }
.portfolio-dot--benchmark { background: #6b7280; }

.portfolio-dot--stale {
    opacity: 0.3;
    animation: dot-pulse 2s ease-in-out infinite;
}

@keyframes dot-pulse {
    0%, 100% { opacity: 0.3; }
    50% { opacity: 0.6; }
}

/* ── Feed status ── */
.feed-status {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 0.5rem;
    margin: 1rem 0 1.5rem;
}

.feed-status-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem 0.7rem;
    background: var(--pico-card-background-color);
    border: 1px solid var(--pico-muted-border-color);
    border-radius: 6px;
    font-size: 0.85em;
}

.feed-status-dot {
    width: 0.6rem;
    height: 0.6rem;
    border-radius: 50%;
    flex-shrink: 0;
}

.feed-status-dot--ok   { background: #22c55e; }
.feed-status-dot--stale { background: #ef4444; }

.feed-status-name {
    font-weight: 600;
    white-space: nowrap;
}

.feed-status-ago {
    opacity: 0.7;
    margin-left: auto;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

.portfolio-feeds {
    margin: -0.5rem 0 1rem;
    padding: 0.5rem 0.9rem;
    background: var(--pico-card-background-color);
    border: 1px solid var(--pico-muted-border-color);
    border-radius: 6px;
    font-size: 0.9rem;
}

.portfolio-feeds summary {
    cursor: pointer;
    opacity: 0.8;
    font-weight: 500;
}

.portfolio-feeds summary:hover,
.portfolio-feeds summary:focus-visible {
    opacity: 1;
    outline: none;
}

.portfolio-feeds summary:focus-visible {
    text-decoration: underline;
}

.portfolio-feeds ul {
    margin: 0.5rem 0 0;
    padding-left: 1.2rem;
    opacity: 0.85;
}

.portfolio-feeds li {
    margin: 0.2rem 0;
}

/* ── AI activity ticker ── */
.ai-ticker {
    overflow: hidden;
    border: 1px solid var(--pico-muted-border-color);
    border-radius: 6px;
    background: var(--pico-card-background-color);
    margin: 1rem 0 1.5rem;
    padding: 0.55rem 0;
    position: relative;
    mask-image: linear-gradient(
        to right,
        transparent 0,
        #000 40px,
        #000 calc(100% - 40px),
        transparent 100%
    );
    -webkit-mask-image: linear-gradient(
        to right,
        transparent 0,
        #000 40px,
        #000 calc(100% - 40px),
        transparent 100%
    );
}

.ai-ticker-track {
    display: inline-flex;
    gap: 2.5rem;
    white-space: nowrap;
    animation: ai-ticker-scroll 90s linear infinite;
    will-change: transform;
    padding-left: 2.5rem;
}

.ai-ticker:hover .ai-ticker-track {
    animation-play-state: paused;
}

@keyframes ai-ticker-scroll {
    from { transform: translateX(0); }
    to   { transform: translateX(-50%); }
}

.ai-ticker-item {
    display: inline-flex;
    align-items: baseline;
    gap: 0.6rem;
    padding: 0.1rem 0.75rem;
    border-left: 3px solid var(--pico-muted-border-color);
    font-size: 0.88em;
}

.ai-ticker-label {
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    font-size: 0.82em;
}

.ai-ticker-time {
    opacity: 0.6;
    font-variant-numeric: tabular-nums;
    font-family: ui-monospace, SFMono-Regular, monospace;
    font-size: 0.85em;
}

.ai-ticker-kind {
    opacity: 0.55;
    font-size: 0.75em;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.ai-ticker-text {
    opacity: 0.95;
}

@media (max-width: 600px) {
    .ai-ticker-kind { display: none; }
    .ai-ticker-track { animation-duration: 60s; }
    .pf-tabs { gap: 0.25rem; }
    .pf-tab { padding: 0.5rem 0.8rem; font-size: 0.85rem; }
}

@media (prefers-reduced-motion: reduce) {
    .ai-ticker-track { animation: none; }
    .ai-ticker { overflow-x: auto; }
    .pf-panel { animation: none; }
}

/* ── Live agent thoughts feed ── */
.thoughts-feed {
    max-height: 420px;
    overflow-y: auto;
    padding-right: 0.25rem;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

.thoughts-empty {
    opacity: 0.6;
    font-style: italic;
    padding: 1rem 0;
}

.thought-item {
    border-left: 3px solid var(--pico-muted-border-color);
    padding: 0.55rem 0.75rem;
    background: rgba(255, 255, 255, 0.02);
    border-radius: 4px;
    font-size: 0.88em;
}

.thought-head {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem 0.75rem;
    align-items: baseline;
    margin-bottom: 0.3rem;
    font-size: 0.8em;
    opacity: 0.85;
}

.thought-type {
    text-transform: uppercase;
    letter-spacing: 0.04em;
    font-weight: 600;
}

.thought-time {
    opacity: 0.7;
    font-variant-numeric: tabular-nums;
}

.thought-model {
    opacity: 0.6;
    font-family: ui-monospace, SFMono-Regular, monospace;
    font-size: 0.9em;
}

.thought-content {
    white-space: pre-wrap;
    word-wrap: break-word;
    line-height: 1.4;
}

.thought-tickers {
    margin-top: 0.35rem;
    display: flex;
    flex-wrap: wrap;
    gap: 0.3rem;
}

.ticker-chip {
    display: inline-block;
    padding: 0.1rem 0.45rem;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.08);
    font-size: 0.78em;
    font-family: ui-monospace, SFMono-Regular, monospace;
}

/* Color-code by thought type */
.thought-research     { border-left-color: #60a5fa; }
.thought-trade_pre    { border-left-color: #22c55e; }
.thought-trade_post   { border-left-color: #9ca3af; }
.thought-hold         { border-left-color: #eab308; }
.thought-claude_review{ border-left-color: #a855f7; }

.thought-research     .thought-type { color: #60a5fa; }
.thought-trade_pre    .thought-type { color: #22c55e; }
.thought-trade_post   .thought-type { color: #9ca3af; }
.thought-hold         .thought-type { color: #eab308; }
.thought-claude_review.thought-type,
.thought-claude_review .thought-type { color: #a855f7; }

@media (max-width: 600px) {
    .thoughts-feed { max-height: 360px; }
    .thought-head { gap: 0.35rem 0.6rem; }
    .thought-model { display: none; }
}
