/**
 * Thematic Intelligence Styles
 * Extends the main dashboard theme with thematic-specific components
 */

/* =====================================================
   THEME STATE BADGES
   ===================================================== */

.theme-state-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.theme-state-emerging {
    background: var(--accent-cyan);
    color: #000;
}

.theme-state-confirmed {
    background: var(--accent-green);
    color: #000;
}

.theme-state-crowded {
    background: var(--accent-yellow);
    color: #000;
}

.theme-state-fading {
    background: var(--accent-red);
    color: #fff;
}

.theme-state-neutral {
    background: var(--text-muted);
    color: #fff;
}

/* =====================================================
   SETUP TYPE BADGES
   ===================================================== */

.setup-badge {
    display: inline-block;
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 0.75rem;
    font-weight: 500;
    text-transform: uppercase;
}

.setup-breakout {
    background: rgba(34, 197, 94, 0.2);
    color: var(--accent-green);
    border: 1px solid rgba(34, 197, 94, 0.3);
}

.setup-pullback {
    background: rgba(59, 130, 246, 0.2);
    color: var(--accent-blue);
    border: 1px solid rgba(59, 130, 246, 0.3);
}

.setup-compression {
    background: rgba(168, 85, 247, 0.2);
    color: var(--accent-purple);
    border: 1px solid rgba(168, 85, 247, 0.3);
}

.setup-mr {
    background: rgba(249, 115, 22, 0.2);
    color: var(--accent-orange);
    border: 1px solid rgba(249, 115, 22, 0.3);
}

.setup-default {
    background: var(--bg-hover);
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
}

/* =====================================================
   SCORE COLORING
   ===================================================== */

.score-strong {
    color: var(--accent-green) !important;
    font-weight: 600;
}

.score-neutral {
    color: var(--accent-yellow) !important;
}

.score-weak {
    color: var(--accent-red) !important;
}

.score-mini {
    font-size: 0.85em;
}

/* =====================================================
   FLAG BADGES
   ===================================================== */

.flag-badge {
    display: inline-block;
    padding: 2px 5px;
    border-radius: 2px;
    font-size: 0.7rem;
    font-weight: 600;
    margin-left: 4px;
}

.flag-rs-high {
    background: rgba(34, 197, 94, 0.3);
    color: var(--accent-green);
}

.flag-bottoming {
    background: rgba(59, 130, 246, 0.3);
    color: var(--accent-blue);
}

.flag-divergence {
    background: rgba(249, 115, 22, 0.3);
    color: var(--accent-orange);
}

/* =====================================================
   THEMATIC CONTAINER
   ===================================================== */

#thematic-page {
    padding: 20px;
    height: 100%;
    overflow-y: auto;
}

.thematic-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 1px solid var(--border-color);
}

.thematic-header h2 {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
}

.thematic-header .last-update {
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* =====================================================
   THEMATIC NAVIGATION TABS
   ===================================================== */

.thematic-nav {
    display: flex;
    gap: 4px;
    margin-bottom: 20px;
    background: var(--bg-secondary);
    padding: 4px;
    border-radius: 8px;
}

.thematic-nav-tab {
    flex: 1;
    padding: 10px 16px;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    border-radius: 6px;
    transition: all var(--transition-fast);
}

.thematic-nav-tab:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.thematic-nav-tab.active {
    background: var(--accent-primary);
    color: #fff;
}

/* =====================================================
   THEMATIC SUBPAGES
   ===================================================== */

.thematic-subpage {
    display: none;
}

.thematic-subpage.active {
    display: block;
}

.thematic-empty {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
    font-size: 1rem;
}

/* =====================================================
   THEMATIC TABLES
   ===================================================== */

.thematic-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

.thematic-table th {
    text-align: left;
    padding: 12px 10px;
    background: var(--bg-secondary);
    color: var(--text-secondary);
    font-weight: 500;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 10;
}

.thematic-table td {
    padding: 10px;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-primary);
}

.thematic-table tbody tr:hover {
    background: var(--bg-hover);
    cursor: pointer;
}

.thematic-table .theme-name-cell {
    min-width: 200px;
}

.thematic-table .theme-name {
    font-weight: 500;
    color: var(--text-primary);
}

.thematic-table .theme-desc {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 2px;
}

.thematic-table .score-cell {
    font-weight: 600;
    font-size: 1.1rem;
}

.thematic-table .rank-cell {
    color: var(--text-muted);
    font-weight: 500;
}

.thematic-table .symbol-cell .symbol {
    font-weight: 600;
    color: var(--accent-blue);
}

.thematic-table .date-cell {
    color: var(--text-muted);
    font-size: 0.8rem;
}

/* Positive/Negative coloring */
.positive {
    color: var(--accent-green);
}

.negative {
    color: var(--accent-red);
}

/* Overbought/Oversold */
.overbought {
    color: var(--accent-red);
    font-weight: 500;
}

.oversold {
    color: var(--accent-green);
    font-weight: 500;
}

/* Indicator above/below */
.indicator-above {
    color: var(--accent-green);
}

.indicator-below {
    color: var(--accent-red);
}

/* =====================================================
   THEME FILTER TABS
   ===================================================== */

.theme-filter-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 20px;
}

.theme-tab {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-secondary);
    font-size: 0.8rem;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.theme-tab:hover {
    background: var(--bg-hover);
    border-color: var(--border-hover);
}

.theme-tab.active {
    background: var(--accent-primary);
    border-color: var(--accent-primary);
    color: #fff;
}

.theme-tab .theme-state-badge {
    font-size: 0.6rem;
    padding: 1px 4px;
}

/* =====================================================
   CANDIDATES SECTION
   ===================================================== */

.candidates-container {
    max-height: calc(100vh - 300px);
    overflow-y: auto;
}

.theme-candidates-section {
    margin-bottom: 30px;
}

.theme-section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border-color);
}

.theme-section-header h3 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
}

.theme-section-header .candidate-count {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.candidates-table th,
.candidates-table td {
    padding: 8px 6px;
    font-size: 0.8rem;
}

/* =====================================================
   RADAR TABLE
   ===================================================== */

.radar-table .flags-cell {
    min-width: 120px;
}

/* =====================================================
   BACKTESTS TABLE
   ===================================================== */

.backtests-table .run-name {
    font-weight: 500;
}

.status-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
}

.status-queued {
    background: var(--text-muted);
    color: #fff;
}

.status-running {
    background: var(--accent-blue);
    color: #fff;
}

.status-completed {
    background: var(--accent-green);
    color: #000;
}

.status-failed {
    background: var(--accent-red);
    color: #fff;
}

.error-cell {
    color: var(--accent-red);
    font-size: 0.75rem;
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Backtest results summary */
.backtest-results-summary {
    margin-top: 20px;
    padding: 20px;
    background: var(--bg-card);
    border-radius: 8px;
    border: 1px solid var(--border-color);
}

.backtest-results-summary h4 {
    margin: 0 0 15px 0;
    font-size: 1rem;
    color: var(--text-primary);
}

.nav-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
}

.nav-stats .stat {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.nav-stats .label {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.nav-stats .value {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
}

.nav-stats .value.negative {
    color: var(--accent-red);
}

/* =====================================================
   LOADING & ERROR STATES
   ===================================================== */

.thematic-loading {
    text-align: center;
    padding: 40px;
    color: var(--text-muted);
}

.thematic-loading .spinner {
    display: inline-block;
    width: 24px;
    height: 24px;
    border: 3px solid var(--border-color);
    border-top-color: var(--accent-cyan);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-right: 10px;
    vertical-align: middle;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.thematic-error {
    text-align: center;
    padding: 40px;
    color: var(--accent-red);
    background: rgba(239, 68, 68, 0.1);
    border-radius: 8px;
    border: 1px solid var(--accent-red);
}

.thematic-empty {
    text-align: center;
    padding: 40px;
    color: var(--text-muted);
    background: var(--bg-secondary);
    border-radius: 8px;
    border: 1px dashed var(--border-color);
}

.loading {
    text-align: center;
    padding: 40px;
    color: var(--text-muted);
}

.error {
    text-align: center;
    padding: 40px;
    color: var(--accent-red);
}

.no-data {
    text-align: center;
    padding: 40px;
    color: var(--text-muted);
}

/* =====================================================
   METRICS DISPLAY
   ===================================================== */

.metric-cell {
    text-align: center;
    font-weight: 500;
}

.metric-strong {
    color: var(--accent-green);
}

.metric-neutral {
    color: var(--text-primary);
}

.metric-weak {
    color: var(--accent-red);
}

.metric-count {
    text-align: center;
    color: var(--text-muted);
}

.theme-name-cell {
    min-width: 150px;
}

.theme-name {
    font-weight: 600;
    color: var(--text-primary);
}

.theme-desc {
    font-size: 0.75rem;
    color: var(--text-muted);
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* =====================================================
   RESPONSIVE ADJUSTMENTS
   ===================================================== */

@media (max-width: 1200px) {
    .thematic-table {
        font-size: 0.8rem;
    }

    .thematic-table th,
    .thematic-table td {
        padding: 8px 6px;
    }
}

@media (max-width: 768px) {
    .thematic-nav {
        flex-wrap: wrap;
    }

    .thematic-nav-tab {
        flex: none;
        padding: 8px 12px;
    }

    .theme-filter-tabs {
        flex-direction: column;
    }

    .theme-tab {
        width: 100%;
        justify-content: flex-start;
    }
}
