/* ═══════════════════════════════════════
   ANALYST RATINGS — STYLING ONLY
   Layout is in feed/feed_analyst.css
   ═══════════════════════════════════════ */

/* ── Group Header ── */
.analyst-ticker-group {
    border-bottom: 1px solid var(--border);
}

/* ── Ticker Header ── */
.ticker-header {
    position: sticky;
    top: 0;
    background: var(--bg-raised);
    padding: 10px 16px;
    font-family: var(--font-mono);
    font-weight: 600;
    font-size: 13px;
    color: var(--text-primary);
    z-index: 10;
    border-bottom: 1px solid var(--border-light);
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    transition: background 0.15s ease;
}

.ticker-header:hover {
    background: var(--bg-hover);
}

.ticker-header-left {
    display: flex;
    align-items: center;
}

.ticker-logo {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    margin-right: 10px;
    object-fit: cover;
}

.ticker-symbol {
    color: var(--accent);
    font-size: 14px;
}

/* Coverage count pill */
.ticker-coverage {
    font-size: 10px;
    color: var(--text-primary);
    background: var(--bg-base);
    border: 1px solid var(--border);
    padding: 1px 6px;
    border-radius: var(--radius-full);  /* pill shape — token added to tokens.css */
    margin-left: 8px;
    font-family: var(--font-mono);
    font-weight: 600;
}

.ticker-name {
    margin-left: 10px;
    font-family: var(--font-ui);
    font-size: 12px;
    font-weight: 500;
    color: var(--text-muted);
}

.ticker-header .exchange {
    font-size: 11px;
    color: var(--text-muted);
    font-weight: 400;
}

/* ── Rating Item ── */
.rating-item {
    padding: 12px 16px 12px 44px;
    border-bottom: 1px solid var(--border-light);
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    transition: background 0.15s ease;
    position: relative;
}

/* Visual tree thread */
.rating-item::before {
    content: '';
    position: absolute;
    left: 24px;
    top: 0;
    bottom: 0;
    width: 1px;
    background: var(--border-light);
    opacity: 0.5;
}
.rating-item:last-child::before {
    bottom: 50%;
}
.rating-item::after {
    content: '';
    position: absolute;
    left: 24px;
    top: 50%;
    width: 8px;
    height: 1px;
    background: var(--border-light);
    opacity: 0.5;
}

.rating-item:last-child {
    border-bottom: none;
}

/* Intentional non-token: faint frost tint — no token maps to this subtle interactive highlight */
.rating-item:hover,
.rating-item.active {
    background: rgba(255, 255, 255, 0.05);
}

.rating-broker {
    flex: 1;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
}

.rating-badges {
    display: flex;
    align-items: center;
    gap: 8px;
}

.rating-arrow {
    font-size: 12px;
    color: var(--text-primary);
    font-weight: 500;
}

.rating-arrow-icon {
    opacity: 0.5;
}

/* ── Badges ── */
.badge {
    padding: 2px 6px;
    border-radius: var(--radius-full);
    font-size: 11px;
    font-family: var(--font-mono);
    font-weight: 600;
    text-transform: uppercase;
}

.badge-upgrade { background: var(--positive-dim); color: var(--positive); border: 1px solid var(--positive); }
.badge-downgrade { background: var(--negative-dim); color: var(--negative); border: 1px solid var(--negative); }
.badge-initiated { background: var(--purple-dim); color: var(--purple); border: 1px solid var(--purple); }
.badge-maintained { background: var(--accent-dim); color: var(--accent); border: 1px solid var(--accent); }
.badge-reiterated { background: var(--warning-dim); color: var(--warning); border: 1px solid var(--warning); }

/* ── Detail Placeholder ── */
/* flex:1 lets it self-center inside the detail pane without the parent needing justify-content */
.detail-placeholder {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    color: var(--text-muted);
    font-size: 14px;
    min-height: 120px;
    width: 100%;
}

.detail-placeholder svg {
    width: 48px;
    height: 48px;
    margin-bottom: 16px;
    opacity: 0.5;
}

/* ── Detail Content ── */
.detail-content {
    width: 100%;
    display: none;
    flex-direction: column;
    align-items: flex-start;
    text-align: left;
    flex: 1;
    min-height: 0;
}

.detail-header {
    width: 100%;
    margin-bottom: 24px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border);
}

.detail-ticker {
    font-size: 24px;
    font-family: var(--font-mono);
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.detail-name {
    font-size: 14px;
    color: var(--text-secondary);
}

.detail-section-title {
    font-size: 13px;
    color: var(--text-muted);
    text-transform: uppercase;
    margin-bottom: 12px;
    letter-spacing: 0.05em;
}

.detail-section-title.mt {
    margin-top: 8px;
}

/* ── Detail Grid Boxes ── */
.detail-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    width: 100%;
    margin-bottom: 24px;
}

.detail-box {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 16px;
}

.detail-box-wide {
    grid-column: span 2;
    display: flex;
    justify-content: space-between;
    padding: 16px 24px;
}

.detail-box-col {
    text-align: center;
}

.box-label {
    font-size: 11px;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-bottom: 8px;
    letter-spacing: 0.05em;
}

.box-value {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
}

.box-value.positive { color: var(--positive); }
.box-value.negative { color: var(--negative); }
.box-value.warning { color: var(--warning); }
.box-value.accent { color: var(--accent); }

/* ── History List ── */
.dt-history-list {
    width: 100%;
}

.history-empty {
    padding: 16px;
    text-align: center;
    color: var(--text-muted);
    font-size: 13px;
    background: var(--bg-surface);
    border-radius: var(--radius-md);
}

.history-item {
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    margin-bottom: 8px;
    background: var(--bg-surface);
}

.history-item-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 6px;
}

.history-item-date {
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--text-muted);
}

.history-item-broker {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.history-item-rating {
    font-size: 13px;
    color: var(--text-primary);
}

/* ── Empty State ── */
.analyst-stream-pane-empty {
    padding: 20px;
    text-align: center;
    color: var(--text-muted);
    font-size: 13px;
}

/* ── Date Badge ── */
.analyst-date-badge {
    background: var(--bg-surface);
    color: var(--text-muted);
    border: 1px solid var(--border);
}

/* ── Loader ── */
.detail-loader-container {
    width: 100%;
    padding: 20px 0;
    display: none;
}

.loading-spinner {
    width: 24px;
    height: 24px;
    border: 2px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ── Recent History Table (Compact) ── */
.dt-history-table-container {
    width: 100%;
    overflow-x: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--bg-surface);
}

.dt-history-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
    text-align: left;
}

.dt-history-table th {
    padding: 10px 12px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
    background: var(--bg-raised);
    white-space: nowrap;
}

.dt-history-table td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    color: var(--text-primary);
    vertical-align: middle;
}

.dt-history-table tr:last-child td {
    border-bottom: none;
}

/* Intentional non-token: near-invisible row highlight — fainter than --bg-hover by design */
.dt-history-table tbody tr:hover {
    background: rgba(255, 255, 255, 0.02);
}

.dt-history-table .td-date {
    width: 20%;
    color: var(--text-muted);
    font-family: var(--font-mono), monospace;
    font-size: 12px;
    white-space: nowrap;
}

.dt-history-table .td-broker {
    width: 35%;
    font-weight: 500;
}

.dt-history-table .td-action {
    width: 20%;
}

.dt-history-table .td-rating {
    width: 25%;
    white-space: nowrap;
}

.rating-old {
    color: var(--text-muted);
    font-size: 12px;
}

.rating-new {
    font-weight: 600;
}

/* ── Detail Chart Container ── */
.detail-chart-container {
    width: 100%;
    margin-bottom: 20px;
    flex-shrink: 0;
}

.chart-title {
    font-size: 11px;
    text-transform: uppercase;
    color: var(--text-muted);
    letter-spacing: 0.05em;
    margin-bottom: 6px;
    font-family: var(--font-mono);
    font-weight: 600;
}


/* ═══════════════════════════════════════
   RESPONSIVE LAYOUTS (ANALYST COMPONENTS)
═══════════════════════════════════════ */

/* ── 1440px: Laptops ── */
@media (max-width: 1440px) {
    .ticker-header        { font-size: 12px; padding: 9px 14px; }
    .ticker-symbol        { font-size: 13px; }
    .rating-item          { padding: 11px 14px 11px 40px; gap: 10px; }
    .rating-broker        { font-size: 12px; }
    .detail-ticker        { font-size: 22px; }
    .detail-name          { font-size: 13px; }
    .detail-grid          { gap: 14px; margin-bottom: 20px; }
    .detail-box           { padding: 14px; }
    .detail-box-wide      { padding: 14px 20px; }
    .box-value            { font-size: 15px; }
}

/* ── 1100px: Tablets / iPads ── */
@media (max-width: 1100px) {
    .ticker-header        { font-size: 11px; padding: 8px 12px; }
    .ticker-logo          { width: 16px; height: 16px; margin-right: 8px; }
    .ticker-symbol        { font-size: 12px; }
    .ticker-coverage      { font-size: 9px; padding: 1px 5px; }

    .rating-item          { padding: 10px 12px 10px 36px; gap: 8px; }
    .rating-item::before  { left: 20px; }
    .rating-item::after   { left: 20px; }
    .rating-broker        { font-size: 11px; }
    .badge                { font-size: 10px; padding: 2px 5px; }

    .detail-ticker        { font-size: 20px; }
    .detail-name          { font-size: 12px; }
    .detail-header        { margin-bottom: 16px; padding-bottom: 12px; }
    .detail-section-title { font-size: 12px; margin-bottom: 10px; }
    .detail-grid          { gap: 12px; margin-bottom: 16px; }
    .detail-box           { padding: 12px; }
    .detail-box-wide      { padding: 12px 16px; }
    .box-label            { font-size: 10px; margin-bottom: 6px; }
    .box-value            { font-size: 14px; }
    .detail-chart-container { margin-bottom: 16px; }

    .dt-history-table     { font-size: 12px; }
    .dt-history-table th  { padding: 8px 10px; font-size: 10px; }
    .dt-history-table td  { padding: 8px 10px; }
}

/* ── 768px: Mobile Phones ── */
@media (max-width: 768px) {
    /* Hide company name in stream — ticker + exchange is enough at this width */
    .ticker-name          { display: none; }

    .ticker-header        { font-size: 11px; padding: 8px 10px; }
    .ticker-logo          { width: 15px; height: 15px; }
    .rating-item          { padding: 9px 10px 9px 32px; gap: 6px; }
    .rating-item::before  { left: 17px; }
    .rating-item::after   { left: 17px; }
    .rating-badges        { gap: 6px; }
    .badge                { font-size: 9px; padding: 1px 4px; }

    .detail-ticker        { font-size: 18px; }
    .detail-header        { margin-bottom: 12px; padding-bottom: 10px; }
    .detail-grid          { gap: 10px; margin-bottom: 12px; }
    .detail-box           { padding: 10px; }
    /* Wrap the 5 consensus columns (Buy/Outperform/Hold/Underperform/Sell) on narrow phones */
    .detail-box-wide      { flex-wrap: wrap; gap: 8px 6px; padding: 10px 12px; }
    .detail-box-col       { flex: 1 1 28%; min-width: 60px; }
    .box-value            { font-size: 13px; }
    .box-label            { font-size: 9px; margin-bottom: 4px; }

    .detail-chart-container { margin-bottom: 12px; }
    .chart-title          { font-size: 10px; margin-bottom: 4px; }

    .dt-history-table     { font-size: 11px; }
    .dt-history-table th  { padding: 7px 8px; font-size: 9px; }
    .dt-history-table td  { padding: 7px 8px; }
}

/* ── 480px: Small Mobile ── */
@media (max-width: 480px) {
    .ticker-header        { font-size: 10px; padding: 7px 8px; }
    .ticker-coverage      { font-size: 8px; padding: 1px 4px; margin-left: 6px; }
    .rating-item          { padding: 8px 8px 8px 28px; gap: 4px; }
    .rating-item::before  { left: 15px; }
    .rating-item::after   { left: 15px; width: 6px; }
    .rating-broker        { font-size: 10px; }
    .badge                { font-size: 8px; padding: 1px 3px; }

    .detail-ticker        { font-size: 16px; }
    .detail-name          { font-size: 11px; }
    .detail-grid          { gap: 8px; margin-bottom: 10px; }
    .detail-box           { padding: 8px; }
    .detail-box-wide      { padding: 8px 10px; gap: 6px 4px; }
    .detail-box-col       { flex: 1 1 40%; }
    .box-value            { font-size: 12px; }

    .dt-history-table th  { padding: 6px 6px; }
    .dt-history-table td  { padding: 6px 6px; }
    .dt-history-table .td-date { font-size: 10px; }
}

/* Detail pane error message (non-OK API responses, demo whitelist) */
.analyst-detail-error { font-size: 13px; }
