/*
 * Shared components for the reworked dashboard: snapshot bars, freshness chips, lane badges,
 * tiles, state blocks, data tables, desk overview, research tabs, metric glossary markers.
 * Uses the ICE & CARBON tokens defined in styles.css.
 */

/* ---- Snapshot provenance bar ---- */
.snapshot-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 18px;
    align-items: center;
    padding: 10px 14px;
    margin-bottom: 16px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 12px;
}

.snapshot-item { display: inline-flex; align-items: center; gap: 6px; }
.snapshot-label { color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.4px; font-size: 10.5px; font-weight: 600; }
.snapshot-value, .snapshot-source { font-family: var(--font-mono); color: var(--text-primary); }
.snapshot-source { color: var(--text-muted); }
.snapshot-diagnostic { color: var(--accent-red); font-weight: 500; flex-basis: 100%; }
.snapshot-diagnostic:empty { display: none; }

/* ---- Freshness chips (fixed allowlist of statuses) ---- */
.fresh-chip {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 600;
    font-family: var(--font-mono);
    border: 1px solid transparent;
    white-space: nowrap;
}
.fresh-fresh { background: rgba(0, 135, 90, 0.10); color: var(--accent-green); border-color: rgba(0, 135, 90, 0.30); }
.fresh-closed { background: rgba(8, 145, 178, 0.10); color: var(--accent-cyan); border-color: rgba(8, 145, 178, 0.30); }
.fresh-warn { background: rgba(180, 83, 9, 0.10); color: var(--accent-yellow); border-color: rgba(180, 83, 9, 0.30); }
.fresh-stale { background: rgba(222, 55, 48, 0.10); color: var(--accent-red); border-color: rgba(222, 55, 48, 0.30); }
.fresh-unknown, .fresh-unverified { background: var(--bg-secondary); color: var(--text-muted); border-color: var(--border-color); }

/* ---- Lane badges ---- */
.lane-badge {
    display: inline-block;
    padding: 1px 7px;
    border-radius: 4px;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.5px;
    font-family: var(--font-mono);
    vertical-align: middle;
    border: 1px solid transparent;
}
.lane-production { background: rgba(0, 102, 255, 0.10); color: var(--accent-blue); border-color: rgba(0, 102, 255, 0.35); }
.lane-paper { background: rgba(0, 135, 90, 0.10); color: var(--accent-green); border-color: rgba(0, 135, 90, 0.35); }
.lane-simulated { background: rgba(180, 83, 9, 0.10); color: var(--accent-yellow); border-color: rgba(180, 83, 9, 0.35); }
.lane-research { background: rgba(107, 33, 168, 0.10); color: var(--accent-purple); border-color: rgba(107, 33, 168, 0.35); }
.lane-shadow { background: var(--bg-secondary); color: var(--text-secondary); border-color: var(--border-color); }
.lane-restricted { background: rgba(222, 55, 48, 0.08); color: var(--accent-red); border-color: rgba(222, 55, 48, 0.35); }
.lane-structure { background: rgba(8, 145, 178, 0.10); color: var(--accent-cyan); border-color: rgba(8, 145, 178, 0.35); }

/* ---- Tiles ---- */
.tile-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
    gap: 12px;
    margin-bottom: 16px;
}
.tile-grid.compact { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 8px; }
.tile {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 12px 14px;
    box-shadow: var(--shadow-sm);
    min-width: 0;
}
.tile-label { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; font-weight: 600; display: flex; align-items: center; gap: 6px; }
.tile-value { font-family: var(--font-mono); font-size: 20px; font-weight: 600; margin-top: 4px; color: var(--text-primary); overflow-wrap: anywhere; }
.tile-note { font-size: 11.5px; color: var(--text-secondary); margin-top: 4px; }
.tone-positive { color: var(--accent-green); }
.tone-negative { color: var(--accent-red); }
.tone-warn { color: var(--accent-yellow); }
.tone-muted { color: var(--text-muted); }
.tone-info { color: var(--accent-blue); }
.tone-neutral { color: inherit; }

/* ---- Metric glossary marker ---- */
.metric-info {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    border: 1px solid var(--border-hover);
    color: var(--text-muted);
    font-size: 9px;
    font-family: var(--font-mono);
    font-style: italic;
    cursor: help;
    line-height: 1;
}

/* ---- Explicit states ---- */
.state-block {
    padding: 14px 16px;
    border-radius: 8px;
    border: 1px dashed var(--border-color);
    background: var(--bg-elevated);
    color: var(--text-secondary);
}
.state-title { font-weight: 600; color: var(--text-primary); font-size: 13px; }
.state-detail { font-size: 12px; margin-top: 4px; }
.state-empty { }
.state-loading { color: var(--text-muted); }
.state-error { border-color: rgba(222, 55, 48, 0.5); background: rgba(222, 55, 48, 0.05); }
.state-error .state-title { color: var(--accent-red); }
.state-unverified { border-color: rgba(180, 83, 9, 0.5); background: rgba(180, 83, 9, 0.05); }
.state-unverified .state-title { color: var(--accent-yellow); }
.state-restricted { border-color: var(--border-hover); background: var(--bg-secondary); }
.state-restricted .state-title::before { content: 'RESTRICTED · '; font-family: var(--font-mono); font-size: 10px; color: var(--text-muted); }

/* ---- Data tables ---- */
.data-table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.data-table th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: 0.4px; color: var(--text-muted); padding: 8px 10px; border-bottom: 1px solid var(--border-color); white-space: nowrap; }
.data-table td { padding: 7px 10px; border-bottom: 1px solid var(--bg-secondary); font-family: var(--font-mono); vertical-align: top; }
.data-table tr:hover td { background: var(--bg-hover); }
.data-table .empty-cell { text-align: center; color: var(--text-muted); font-family: var(--font-primary); padding: 18px; }
.asof-line { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; font-size: 12px; margin: 6px 0 10px; }

.two-col-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(360px, 1fr)); gap: 16px; margin-bottom: 16px; }
.research-card { margin-bottom: 16px; }
.research-card .section-header-inline { flex-wrap: wrap; gap: 8px; }

/* ---- Desk overview ---- */
.desk-overview {
    background: var(--gradient-card);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 18px 20px;
    margin-bottom: 18px;
    box-shadow: var(--shadow-sm);
}
.desk-overview-header { display: flex; justify-content: space-between; gap: 16px; align-items: flex-start; flex-wrap: wrap; margin-bottom: 14px; }
.desk-kicker { font-size: 10.5px; letter-spacing: 1px; color: var(--accent-blue); font-weight: 700; }
.desk-title { font-size: 26px; font-weight: 700; margin: 2px 0; font-family: var(--font-display); }
.desk-spot { font-family: var(--font-mono); font-weight: 500; }
.desk-subtitle { font-size: 12.5px; color: var(--text-secondary); max-width: 720px; }
.desk-freshness { display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; max-width: 420px; }
.desk-structure-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 10px; }
.desk-read { margin: 12px 0 4px; }
.desk-read-text { font-size: 13.5px; line-height: 1.5; color: var(--text-primary); }
.desk-actionable { margin-top: 14px; border-top: 1px solid var(--border-color); padding-top: 12px; }
.desk-actionable-header { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; margin-bottom: 10px; }
.desk-actionable-header h2 { font-size: 15px; font-weight: 700; }
.desk-actionable-note { font-size: 11.5px; color: var(--text-muted); }
.desk-actionable-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 10px; }
.desk-action-card { background: var(--bg-card); border: 1px solid var(--border-color); border-radius: 10px; padding: 10px 12px; }
.desk-action-header { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.desk-action-direction { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.4px; }
.desk-action-direction.dir-bullish { color: var(--accent-green); }
.desk-action-direction.dir-bearish { color: var(--accent-red); }
.desk-action-direction.dir-neutral { color: var(--text-muted); }
.desk-action-symbol { font-family: var(--font-mono); font-weight: 600; }
.desk-action-contract { font-family: var(--font-mono); font-size: 13px; }
.desk-action-meta { font-size: 11.5px; color: var(--text-secondary); margin-top: 3px; }
.desk-books { margin-top: 28px; border-top: 2px solid var(--border-color); padding-top: 16px; }
.desk-books-header { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.desk-books-header h2 { font-size: 16px; font-weight: 700; }

/* ---- Research tabs ---- */
.research-tabs { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }
.research-tab {
    padding: 6px 12px;
    border-radius: 999px;
    border: 1px solid var(--border-color);
    background: var(--bg-card);
    color: var(--text-secondary);
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
}
.research-tab:hover { border-color: var(--border-hover); }
.research-tab.active { background: var(--accent-primary); border-color: var(--accent-primary); color: #fff; }

@media (max-width: 720px) {
    .desk-freshness { justify-content: flex-start; max-width: none; }
    .snapshot-bar { gap: 6px 12px; }
    .tile-value { font-size: 17px; }
}

/* Keep immutable evidence IDs readable on narrow screens. */
.nf-history-event { margin: 1rem 0; padding-top: .75rem; border-top: 1px solid var(--border-color, #cbd5e1); overflow-wrap: anywhere; }
