/*
================================================================================
NASDAQ/NYSE Strategy Watchlist - Dashboard Styles
================================================================================
*/

/* Base styles */
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background-color: #f8f9fa;
    font-size: 0.85rem;
}

/* Header */
header h1 {
    color: #2c3e50;
    font-weight: 600;
    font-size: 1.3rem;
}

/* Signal Type Filter */
.signal-type-filter {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.filter-label {
    font-weight: 600;
    color: #495057;
    font-size: 0.85rem;
}

.filter-buttons {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.filter-btn {
    padding: 4px 10px;
    border: 2px solid #dee2e6;
    border-radius: 4px;
    background-color: #f8f9fa;
    color: #6c757d;
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    opacity: 0.5;
}

.filter-btn:hover {
    border-color: #adb5bd;
}

.filter-btn.active {
    opacity: 1;
    border-color: #495057;
}

.filter-btn[data-type="all"].active {
    background-color: #495057;
    color: #fff;
    border-color: #495057;
}

.filter-btn.type-5-btn.active {
    background-color: #FFD700;
    color: #000;
    border-color: #B8860B;
}

.filter-btn.type-4-btn.active {
    background-color: #27AE60;
    color: #fff;
    border-color: #1e8449;
}

.filter-btn.type-3-btn.active {
    background-color: #E67E22;
    color: #fff;
    border-color: #ca6f1e;
}

.filter-btn.type-2-btn.active {
    background-color: #3498DB;
    color: #fff;
    border-color: #2980b9;
}

.filter-btn.type-1-btn.active {
    background-color: #9B59B6;
    color: #fff;
    border-color: #7d3c98;
}

.filter-btn.type-0-btn.active {
    background-color: #95a5a6;
    color: #fff;
    border-color: #7f8c8d;
}

/* Legend Section */
.legend-section {
    background-color: #fff;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    padding: 8px 12px;
}

.legend-row {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
}

.legend-title {
    font-weight: 600;
    color: #495057;
    min-width: 80px;
    font-size: 0.75rem;
}

.legend-items {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 0.7rem;
    color: #6c757d;
}

.legend-color {
    width: 14px;
    height: 14px;
    border-radius: 3px;
    border: 1px solid rgba(0, 0, 0, 0.15);
}

/* Signal Type Colors */
.type-1 {
    background-color: #9B59B6 !important;  /* Purple - Divergence Only */
}

.type-2 {
    background-color: #3498DB !important;  /* Blue - Div + HTF Oversold */
}

.type-3 {
    background-color: #E67E22 !important;  /* Orange - Div + Double Bottom */
}

.type-4 {
    background-color: #27AE60 !important;  /* Green - All Three (Strongest) */
}

.type-5 {
    background-color: #FFD700 !important;  /* Gold - Optimized Double Bottom (Best) */
    color: #000 !important;
}

/* % from Low Colors (lower = better = greener) */
.pct-0-5 {
    background-color: #4CAF50 !important;  /* Green - at or near the low */
    color: #fff !important;
}

.pct-5-10 {
    background-color: #8BC34A !important;  /* Light Green - good */
    color: #000 !important;
}

.pct-10-15 {
    background-color: #CDDC39 !important;  /* Yellow-Green - acceptable */
    color: #000 !important;
}

.pct-15-25 {
    background-color: #FFEB3B !important;  /* Yellow - neutral */
    color: #000 !important;
}

.pct-25-40 {
    background-color: #FF9800 !important;  /* Orange - caution */
    color: #000 !important;
}

.pct-40plus {
    background-color: #F44336 !important;  /* Red - far from low */
    color: #fff !important;
}

/* 1M Oversold indicator */
.oversold-1m-cell {
    font-weight: 600;
    text-align: center;
}

.oversold-1m-yes {
    background-color: #4CAF50 !important;  /* Green - monthly oversold (favorable) */
    color: #fff !important;
}

.oversold-1m-no {
    color: #999 !important;
}

/* MA Count Colors (1-3 = good, 0 or 4 = filtered out by default) */
.ma-cell {
    font-weight: 500;
    font-size: 0.7rem;
}

.ma-0 {
    background-color: #F44336 !important;  /* Red - below all MAs (filtered) */
    color: #fff !important;
}

.ma-1 {
    background-color: #FFEB3B !important;  /* Yellow - 1 MA above */
    color: #000 !important;
}

.ma-2 {
    background-color: #8BC34A !important;  /* Light Green - 2 MAs above (sweet spot) */
    color: #000 !important;
}

.ma-3 {
    background-color: #4CAF50 !important;  /* Green - 3 MAs above (strong) */
    color: #fff !important;
}

.ma-4 {
    background-color: #FF9800 !important;  /* Orange - above all 4 MAs (overextended) */
    color: #000 !important;
}

.ma-none {
    color: #999 !important;
    font-style: italic;
}

/* % from 90D High Colors (higher = better pullback = greener) */
.high-0-15 {
    background-color: #F44336 !important;  /* Red - near highs */
    color: #fff !important;
}

.high-15-30 {
    background-color: #FF9800 !important;  /* Orange - small pullback */
    color: #000 !important;
}

.high-30-45 {
    background-color: #FFEB3B !important;  /* Yellow - moderate pullback */
    color: #000 !important;
}

.high-45-60 {
    background-color: #8BC34A !important;  /* Light Green - good pullback */
    color: #000 !important;
}

.high-60plus {
    background-color: #4CAF50 !important;  /* Green - deep pullback */
    color: #fff !important;
}

/* Table Container */
.table-container {
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* Table Styles */
#signals-table {
    font-size: 0.75rem;
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
}

/* Sticky Header */
#signals-table thead {
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

#signals-table thead th {
    position: sticky;
    top: 0;
    z-index: 100;
    background-color: #212529 !important;
    color: #fff;
    white-space: nowrap;
    font-weight: 600;
    text-align: center;
    vertical-align: middle;
    padding: 4px 6px;
    font-size: 0.7rem;
}

/* Allow line breaks in specific headers */
#signals-table thead th:nth-child(n+9) {
    white-space: normal;
    line-height: 1.2;
}

#signals-table tbody td {
    vertical-align: middle;
    text-align: center;
    padding: 3px 5px;
}

#signals-table tbody td:nth-child(2) {
    text-align: left;  /* Name column left-aligned */
    white-space: nowrap;
    max-width: 320px;
    overflow: hidden;
    text-overflow: ellipsis;
}

#signals-table tbody td:nth-child(3) {
    text-align: center;  /* Sector column centered */
    white-space: nowrap;
}

/* Narrow 4H/6H/8H columns */
#signals-table th:nth-child(6),
#signals-table th:nth-child(7),
#signals-table th:nth-child(8),
#signals-table td:nth-child(6),
#signals-table td:nth-child(7),
#signals-table td:nth-child(8) {
    width: 36px;
    max-width: 36px;
    padding: 3px 2px;
}

/* Signal cells (4H, 6H, 8H) */
.signal-cell {
    font-weight: 600;
    color: #fff;
    padding: 2px 3px;
    border-radius: 3px;
    display: inline-block;
    min-width: 26px;
    font-size: 0.7rem;
    text-shadow: 1px 1px 1px rgba(0, 0, 0, 0.3);
}

.signal-cell.type-1 {
    background-color: #9B59B6;
}

.signal-cell.type-2 {
    background-color: #3498DB;
}

.signal-cell.type-3 {
    background-color: #E67E22;
}

.signal-cell.type-4 {
    background-color: #27AE60;
}

.signal-cell.type-5 {
    background-color: #FFD700;
    color: #000;
    font-weight: 700;
    border: 2px solid #B8860B;
    box-shadow: 0 0 6px rgba(255, 215, 0, 0.5);
}

/* Empty signal cell */
.signal-cell-empty {
    color: #dee2e6;
}

/* Exception indicator - signals that bypassed MA filter */
.signal-cell.exception {
    border: 2px solid #FFD700;  /* Gold border */
    box-shadow: 0 0 4px rgba(255, 215, 0, 0.6);
}

/* Near MA indicator - price within 6% above a moving average */
.signal-cell.near-ma {
    border: 3px solid #000000;
    box-shadow: 0 0 6px rgba(0, 0, 0, 0.6);
}

/* Repeated oversold exit indicator - purple border (takes priority over near-ma) */
.signal-cell.repeated-exit {
    border: 3px solid #6A0DAD;
    box-shadow: 0 0 6px rgba(106, 13, 173, 0.6);
}

.exception-star {
    color: #FFD700;
    font-weight: bold;
    margin-left: 1px;
    text-shadow: 0 0 2px #000;
}

/* Legend exception indicator */
.legend-color.exception-indicator {
    background: linear-gradient(135deg, #FFD700 0%, #FFA500 100%);
    border: 2px solid #FFD700;
}

/* Legend near-MA indicator */
.legend-color.near-ma-indicator {
    background: linear-gradient(135deg, #000000 0%, #333333 100%);
    border: 2px solid #000000;
}

/* Legend repeated exit indicator */
.legend-color.repeated-exit-indicator {
    background: linear-gradient(135deg, #6A0DAD 0%, #4B0082 100%);
    border: 2px solid #6A0DAD;
}

/* Price metrics cells - full cell background */
td.metric-cell {
    font-weight: 500;
    text-align: center;
}

/* TradingView Link */
.tv-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 20px;
    height: 18px;
    padding: 0 3px;
    margin-right: 4px;
    background-color: #2962FF;
    border-radius: 3px;
    vertical-align: middle;
    transition: background-color 0.2s ease;
    color: #fff !important;
    font-size: 9px;
    font-weight: 700;
    text-decoration: none !important;
}

.tv-link:hover {
    background-color: #1E88E5;
    color: #fff !important;
}

/* StockTwits Link */
.st-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 20px;
    height: 18px;
    padding: 0 3px;
    margin-right: 6px;
    background-color: #1DA1F2;
    border-radius: 3px;
    vertical-align: middle;
    transition: background-color 0.2s ease;
    color: #fff !important;
    font-size: 9px;
    font-weight: 700;
    text-decoration: none !important;
}

.st-link:hover {
    background-color: #0d8de0;
    color: #fff !important;
}

/* X (Twitter) Link */
.x-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    margin-right: 6px;
    background-color: #000;
    border-radius: 3px;
    vertical-align: middle;
    transition: background-color 0.2s ease;
}

.x-link:hover {
    background-color: #333;
}

.x-icon {
    width: 12px;
    height: 12px;
    fill: #fff;
}

/* Info icon */
.info-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    margin-right: 3px;
    background-color: #6c757d;
    border-radius: 50%;
    vertical-align: middle;
    cursor: pointer;
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    font-style: italic;
    font-family: Georgia, serif;
    text-decoration: none;
    transition: background-color 0.2s ease;
    line-height: 1;
}

.info-icon:hover {
    background-color: #495057;
}

/* Ticker tooltip */
.ticker-name {
    cursor: help;
    border-bottom: 1px dotted #6c757d;
}

/* Loading and status */
#loading-spinner {
    min-height: 200px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

#status-message {
    margin-bottom: 1rem;
}

/* DataTables customization */
.dataTables_wrapper .dataTables_length,
.dataTables_wrapper .dataTables_filter {
    margin-bottom: 1rem;
}

.dataTables_wrapper .dataTables_info,
.dataTables_wrapper .dataTables_paginate {
    margin-top: 1rem;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .legend-row {
        flex-direction: column;
        align-items: flex-start;
    }

    .legend-items {
        margin-left: 0;
    }

    #signals-table {
        font-size: 0.8rem;
    }
}

/* =============================================================================
   NAV TOGGLE
   ============================================================================= */
.nav-toggle {
    display: flex;
    gap: 4px;
}

.nav-toggle .nav-link {
    display: inline-block;
    padding: 4px 14px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
    color: #6c757d;
    text-decoration: none;
    border: 2px solid transparent;
    transition: all 0.2s ease;
}

.nav-toggle .nav-link:hover {
    color: #495057;
    background-color: #e9ecef;
}

.nav-toggle .nav-link.active {
    color: #fff;
    background-color: #2c3e50;
    border-color: #2c3e50;
}

/* =============================================================================
   TOP MOVERS — Summary Cards
   ============================================================================= */
.tm-summary-row {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.tm-summary-card {
    flex: 1 1 140px;
    background: #fff;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    padding: 12px 16px;
    text-align: center;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}

.tm-card-value {
    font-size: 1.6rem;
    font-weight: 700;
    color: #2c3e50;
    line-height: 1.2;
}

.tm-card-label {
    font-size: 0.72rem;
    color: #6c757d;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-top: 2px;
}

/* =============================================================================
   TOP MOVERS — Controls
   ============================================================================= */
.tm-controls {
    background: #fff;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    padding: 10px 16px;
}

/* =============================================================================
   TOP MOVERS — Legend
   ============================================================================= */
.tm-legend {
    background: #fff;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    padding: 8px 12px;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 14px;
}

.tm-legend-item {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 0.72rem;
    color: #6c757d;
}

.tm-legend-dot {
    width: 12px;
    height: 12px;
    border-radius: 3px;
    display: inline-block;
    border: 1px solid rgba(0,0,0,0.15);
}

/* =============================================================================
   TOP MOVERS — Match Indicators
   ============================================================================= */
.match-yes {
    color: #27AE60;
    font-weight: bold;
    font-size: 0.85rem;
    cursor: default;
}

.match-no {
    color: #ccc;
    font-size: 0.85rem;
}

/* =============================================================================
   TOP MOVERS — Gain % Color Gradient
   ============================================================================= */
.gain-15-25 {
    background-color: #C8E6C9 !important;
    color: #2E7D32 !important;
    font-weight: 600;
}

.gain-25-50 {
    background-color: #66BB6A !important;
    color: #fff !important;
    font-weight: 600;
}

.gain-50plus {
    background-color: #2E7D32 !important;
    color: #fff !important;
    font-weight: 700;
}

/* =============================================================================
   TOP MOVERS — Table tweaks
   ============================================================================= */
#tm-table {
    font-size: 0.75rem;
}

#tm-table thead th {
    white-space: nowrap;
    font-size: 0.7rem;
    text-align: center;
    vertical-align: middle;
    padding: 4px 6px;
}

#tm-table tbody td {
    text-align: center;
    vertical-align: middle;
    padding: 3px 5px;
}

#tm-table tbody td:first-child {
    text-align: left;
    white-space: nowrap;
    max-width: 320px;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Narrow signal match columns (T1-T5, Near MA, 1M OS, Rep Exit) */
#tm-table th:nth-child(n+7):nth-child(-n+14),
#tm-table td:nth-child(n+7):nth-child(-n+14) {
    width: 36px;
    max-width: 44px;
    padding: 3px 2px;
}

/* Dark mode support (optional) */
@media (prefers-color-scheme: dark) {
    body {
        background-color: #1a1a1a;
        color: #e0e0e0;
    }

    .legend-section {
        background-color: #2d2d2d;
        border-color: #404040;
    }

    .legend-title {
        color: #e0e0e0;
    }

    .legend-item {
        color: #b0b0b0;
    }

    header h1 {
        color: #e0e0e0;
    }

    #signals-table {
        color: #e0e0e0;
    }

    .table-striped > tbody > tr:nth-of-type(odd) > * {
        background-color: #2d2d2d;
        color: #e0e0e0;
    }

    .table-striped > tbody > tr:nth-of-type(even) > * {
        background-color: #262626;
        color: #e0e0e0;
    }

    .table-hover > tbody > tr:hover > * {
        background-color: #3d3d3d;
    }

    .signal-type-filter .filter-label {
        color: #e0e0e0;
    }

    .filter-btn {
        background-color: #2d2d2d;
        border-color: #404040;
        color: #b0b0b0;
    }

    .filter-btn:hover {
        border-color: #606060;
    }

    .filter-btn.active {
        border-color: #808080;
    }

    .tv-link {
        background-color: #2962FF;
    }

    .x-link {
        background-color: #fff;
    }

    .x-link:hover {
        background-color: #e0e0e0;
    }

    .x-icon {
        fill: #000;
    }

    /* Top Movers dark mode */
    .nav-toggle .nav-link {
        color: #b0b0b0;
    }

    .nav-toggle .nav-link:hover {
        color: #e0e0e0;
        background-color: #3d3d3d;
    }

    .nav-toggle .nav-link.active {
        background-color: #4a90d9;
        border-color: #4a90d9;
        color: #fff;
    }

    .tm-summary-card {
        background: #2d2d2d;
        border-color: #404040;
    }

    .tm-card-value {
        color: #e0e0e0;
    }

    .tm-controls {
        background: #2d2d2d;
        border-color: #404040;
    }

    .tm-legend {
        background: #2d2d2d;
        border-color: #404040;
    }

    .tm-legend-item {
        color: #b0b0b0;
    }

    .match-no {
        color: #555;
    }
}
