/*
================================================================================
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;
}

/* 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;
}

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

/* Signal cells (4H, 6H, 8H) */
.signal-cell {
    font-weight: 600;
    color: #fff;
    padding: 2px 5px;
    border-radius: 3px;
    display: inline-block;
    min-width: 30px;
    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);
}

.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;
}

/* 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;
}

/* 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;
}

/* 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;
    }
}

/* 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;
    }
}
