/**
 * trai-brain.css — TRAIBrain Panel Styling
 *
 * Glass-box treatment with gold underglow. Sentiment-colored accents for news.
 * Monospace fonts throughout. Pulsing ML-active indicator in header.
 * Smooth animations for narrator line append and response expand/collapse.
 *
 * All class names prefixed tb- (TraiBrain).
 * Depends on CSS variables from unified-dashboard-v2.html root block:
 *   --text-primary, --text-secondary, --ml-color, --profit-color,
 *   --loss-color, --border-color, --core-color, --glass-bg, --glass-border,
 *   --glass-underglow, etc.
 *
 * @file public/css/panels/trai-brain.css
 */

/* ========================================================================
   CONTAINER & LAYOUT
   ======================================================================== */

#traiBrain {
    display: flex;
    flex-direction: column;
    gap: 0;
    min-height: 100%;
    background: var(--glass-bg, rgba(15, 15, 18, 0.55));
    border: 1px solid var(--glass-border, rgba(255, 215, 0, 0.18));
    border-radius: 8px;
    backdrop-filter: blur(14px) saturate(160%);
    box-shadow: var(--glass-underglow, 0 6px 24px -8px rgba(255, 215, 0, 0.25), 0 1px 0 0 rgba(255, 215, 0, 0.08) inset);
    font-family: 'JetBrains Mono', monospace;
    font-size: 11px;
    color: var(--text-primary, #ffffff);
    overflow: hidden;
}

/* ========================================================================
   HEADER
   ======================================================================== */

.tb-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 12px;
    border-bottom: 1px solid var(--border-color, rgba(255, 255, 255, 0.1));
    flex-shrink: 0;
    background: rgba(0, 0, 0, 0.2);
}

.tb-header-title {
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: var(--text-primary, #ffffff);
}

.tb-pulse {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--ml-color, #ffd700);
    box-shadow: 0 0 8px var(--ml-color, #ffd700),
                inset 0 0 2px rgba(255, 215, 0, 0.5);
    animation: tb-pulse-keyframes 1.5s ease-in-out infinite;
    flex-shrink: 0;
}

@keyframes tb-pulse-keyframes {
    0%, 100% {
        opacity: 0.6;
        transform: scale(1);
    }
    50% {
        opacity: 1;
        transform: scale(1.15);
    }
}

.tb-header-status {
    font-size: 10px;
    color: var(--text-secondary, #a0a0a0);
    margin-left: auto;
    text-align: right;
    flex-shrink: 0;
}

/* ========================================================================
   SECTIONS CONTAINER & SECTION BASE
   ======================================================================== */

.tb-sections {
    display: flex;
    flex-direction: column;
    gap: 0;
    flex: 1;
    overflow-y: auto;
    padding: 0;
    min-height: 0;
}

.tb-section {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 10px 12px;
    border-bottom: 1px solid var(--border-color, rgba(255, 255, 255, 0.1));
    flex-shrink: 0;
}

.tb-section:last-child {
    border-bottom: none;
}

.tb-section-title {
    font-size: 9px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--ml-color, #ffd700);
}

/* ========================================================================
   NEWS ITEMS
   ======================================================================== */

.tb-news-item {
    padding: 6px 8px;
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.04);
    border-left: 2px solid var(--neutral-color, #8b8b8b);
    font-size: 10px;
    line-height: 1.3;
    color: var(--text-primary, #ffffff);
    cursor: pointer;
    transition: all 0.2s ease;
}

.tb-news-item:hover {
    background: rgba(255, 255, 255, 0.08);
    border-left-color: var(--ml-color, #ffd700);
}

.tb-news-item.bullish {
    border-left-color: var(--profit-color, #00ff88);
}

.tb-news-item.neutral {
    border-left-color: var(--ml-color, #ffd700);
}

.tb-news-item.defensive {
    border-left-color: var(--loss-color, #ff3366);
}

.tb-news-time {
    font-size: 9px;
    color: var(--text-secondary, #a0a0a0);
    display: block;
    margin-bottom: 2px;
}

.tb-news-headline {
    display: block;
    font-weight: 500;
}

.tb-news-source {
    font-size: 9px;
    color: var(--text-secondary, #a0a0a0);
    display: block;
    margin-top: 2px;
}

.tb-news-muted {
    padding: 6px 8px;
    font-size: 10px;
    color: var(--text-secondary, #a0a0a0);
    font-style: italic;
}

/* ========================================================================
   WHALE ALERTS
   ======================================================================== */

.tb-whale-item {
    padding: 6px 8px;
    border-radius: 4px;
    background: rgba(255, 215, 0, 0.06);
    border-left: 2px solid var(--ml-color, #ffd700);
    font-size: 10px;
    line-height: 1.3;
    color: var(--text-primary, #ffffff);
}

.tb-whale-muted {
    padding: 6px 8px;
    font-size: 10px;
    color: var(--text-secondary, #a0a0a0);
    font-style: italic;
}

/* ========================================================================
   NARRATOR LINES
   ======================================================================== */

.tb-narrator-lines {
    display: flex;
    flex-direction: column;
    gap: 4px;
    max-height: 100px;
    overflow-y: auto;
}

.tb-narrator-line {
    padding: 4px 6px;
    border-radius: 3px;
    background: rgba(255, 255, 255, 0.03);
    border-left: 1px solid var(--core-color, #00ccff);
    font-size: 9px;
    line-height: 1.3;
    color: var(--text-secondary, #a0a0a0);
    animation: tb-narrator-fade-in 0.3s ease-out;
}

.tb-narrator-line.new {
    color: var(--text-primary, #ffffff);
    background: rgba(0, 204, 255, 0.08);
}

@keyframes tb-narrator-fade-in {
    from {
        opacity: 0;
        transform: translateY(-2px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ========================================================================
   ESCALATION QUEUE
   ======================================================================== */

.tb-escalation-item {
    padding: 6px 8px;
    border-radius: 4px;
    background: rgba(255, 51, 102, 0.08);
    border-left: 2px solid var(--loss-color, #ff3366);
    font-size: 10px;
    line-height: 1.3;
    color: var(--text-primary, #ffffff);
}

.tb-escalation-item.warning {
    background: rgba(255, 215, 0, 0.08);
    border-left-color: var(--ml-color, #ffd700);
}

.tb-escalation-title {
    font-weight: 600;
    display: block;
    margin-bottom: 2px;
}

.tb-escalation-detail {
    font-size: 9px;
    color: var(--text-secondary, #a0a0a0);
}

.tb-escalation-muted {
    padding: 6px 8px;
    font-size: 10px;
    color: var(--text-secondary, #a0a0a0);
    font-style: italic;
}

/* ========================================================================
   ASK TRAI INPUT SECTION
   ======================================================================== */

.tb-ask-section {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 10px 12px;
    border-top: 1px solid var(--border-color, rgba(255, 255, 255, 0.1));
    flex-shrink: 0;
    background: rgba(0, 0, 0, 0.3);
}

.tb-ask-input {
    width: 100%;
    padding: 8px 10px;
    background: rgba(0, 0, 0, 0.6);
    border: 1px solid var(--border-color, rgba(255, 255, 255, 0.1));
    border-radius: 4px;
    color: var(--text-primary, #ffffff);
    font-family: 'JetBrains Mono', monospace;
    font-size: 10px;
    outline: none;
    transition: all 0.2s ease;
}

.tb-ask-input:focus {
    border-color: var(--ml-color, #ffd700);
    box-shadow: 0 0 8px rgba(255, 215, 0, 0.2);
}

.tb-ask-input::placeholder {
    color: var(--text-secondary, #a0a0a0);
}

/* ========================================================================
   RESPONSE PANEL
   ======================================================================== */

.tb-response-header {
    font-size: 9px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--ml-color, #ffd700);
    cursor: pointer;
    user-select: none;
    padding: 4px 8px;
    background: rgba(255, 215, 0, 0.08);
    border-radius: 3px;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: background 0.2s ease;
}

.tb-response-header:hover {
    background: rgba(255, 215, 0, 0.12);
}

.tb-response-arrow {
    display: inline-block;
    font-size: 8px;
    transform: rotate(0deg);
    transition: transform 0.2s ease;
}

.tb-response-header.expanded .tb-response-arrow {
    transform: rotate(90deg);
}

.tb-response-body {
    display: none;
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease, opacity 0.3s ease;
    opacity: 0;
}

.tb-response-body.expanded {
    display: block;
    max-height: 200px;
    opacity: 1;
    overflow-y: auto;
    padding: 8px 10px;
    background: rgba(0, 204, 255, 0.05);
    border-radius: 4px;
    margin-top: 4px;
    border-left: 2px solid var(--core-color, #00ccff);
    font-size: 9px;
    line-height: 1.4;
    color: var(--text-secondary, #a0a0a0);
    word-break: break-word;
}

/* ========================================================================
   "SEE MORE" TOGGLE
   ======================================================================== */

.tb-see-more {
    font-size: 9px;
    color: var(--ml-color, #ffd700);
    cursor: pointer;
    padding: 4px 6px;
    border-radius: 3px;
    background: rgba(255, 215, 0, 0.08);
    border: 1px solid rgba(255, 215, 0, 0.2);
    text-align: center;
    transition: all 0.2s ease;
    user-select: none;
}

.tb-see-more:hover {
    background: rgba(255, 215, 0, 0.12);
    border-color: rgba(255, 215, 0, 0.3);
}

/* ========================================================================
   SCROLLBARS
   ======================================================================== */

.tb-sections::-webkit-scrollbar,
.tb-narrator-lines::-webkit-scrollbar,
.tb-response-body::-webkit-scrollbar {
    width: 4px;
}

.tb-sections::-webkit-scrollbar-track,
.tb-narrator-lines::-webkit-scrollbar-track,
.tb-response-body::-webkit-scrollbar-track {
    background: transparent;
}

.tb-sections::-webkit-scrollbar-thumb,
.tb-narrator-lines::-webkit-scrollbar-thumb,
.tb-response-body::-webkit-scrollbar-thumb {
    background: rgba(255, 215, 0, 0.2);
    border-radius: 2px;
}

.tb-sections::-webkit-scrollbar-thumb:hover,
.tb-narrator-lines::-webkit-scrollbar-thumb:hover,
.tb-response-body::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 215, 0, 0.4);
}

/* ========================================================================
   RESPONSIVE & MEDIA QUERIES
   ======================================================================== */

@media (prefers-reduced-motion: reduce) {
    .tb-pulse,
    .tb-narrator-line,
    .tb-news-item,
    .tb-response-header,
    .tb-response-body {
        animation: none;
        transition: none;
    }
}
