/* Stock Analysis Dashboard Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: #f5f5f5;
    color: #333;
    line-height: 1.4;
    font-size: 13px;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 15px;
}

/* Header */
header {
    display: flex;
    justify-content: flex-start;
    align-items: center;
    margin-bottom: 20px;
    padding: 15px 20px;
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    gap: 15px;
}

.header-left {
    display: flex;
    flex-direction: column;
}

header h1 {
    font-size: 14px;
    color: #2c3e50;
    margin: 0;
}

header .toggle-buttons {
    display: flex;
    gap: 5px;
}

.header-info {
    display: flex;
    gap: 15px;
    font-size: 12px;
    margin-left: auto;
    color: #666;
}

/* Filters */
.filters {
    display: flex;
    gap: 15px;
    align-items: center;
    margin-bottom: 0;
    padding: 10px 15px;
    background: #fff;
    border-radius: 8px 8px 0 0;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.filter-checkboxes {
    display: flex;
    gap: 15px;
    align-items: center;
    margin-bottom: 15px;
    padding: 6px 15px;
    background: #fff;
    border-radius: 0 0 8px 8px;
    border-top: 1px solid #eee;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.filter-group {
    display: flex;
    align-items: center;
    gap: 8px;
}

.filter-group label {
    font-weight: 500;
    color: #555;
}

.filter-group select {
    padding: 6px 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 12px;
    background: #fff;
    cursor: pointer;
}

.filter-group select:focus {
    outline: none;
    border-color: #3498db;
}

/* Toggle buttons for Call/Put selection */
.toggle-buttons {
    display: flex;
    gap: 0;
}

.toggle-btn {
    padding: 5px 10px;
    background: #e9ecef;
    color: #555;
    border: 1px solid #ddd;
    border-left: none;
    font-size: 11px;
    cursor: pointer;
    transition: all 0.2s;
}

.toggle-btn:first-child {
    border-radius: 4px 0 0 4px;
    border-left: 1px solid #ddd;
}

.toggle-btn:last-child {
    border-radius: 0 4px 4px 0;
}

/* Middle buttons have no border-radius */
.toggle-btn:not(:first-child):not(:last-child) {
    border-radius: 0;
}

.toggle-btn:hover {
    background: #dee2e6;
}

.toggle-btn.active {
    background: #3498db;
    color: #fff;
    border-color: #3498db;
}

.toggle-btn.active:hover {
    background: #2980b9;
}

/* Gold Only filter checkbox */
.golden-filter {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 11px;
    font-weight: 600;
    color: #b8860b;
    margin-left: 8px;
    cursor: pointer;
    white-space: nowrap;
}

.golden-filter input[type="checkbox"] {
    cursor: pointer;
    accent-color: #FFD700;
}

.purple-filter {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 11px;
    font-weight: 600;
    color: #8B00FF;
    margin-left: 8px;
    cursor: pointer;
    white-space: nowrap;
}

.purple-filter input[type="checkbox"] {
    cursor: pointer;
    accent-color: #8B00FF;
}

.both-filter {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 11px;
    font-weight: 600;
    color: #555;
    margin-left: 8px;
    cursor: pointer;
    white-space: nowrap;
}

.both-filter input[type="checkbox"] {
    cursor: pointer;
    accent-color: #666;
}

/* Search filter */
.search-group {
    position: relative;
}

.search-group input {
    padding: 6px 28px 6px 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 12px;
    width: 180px;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.search-group input:focus {
    outline: none;
    border-color: #3498db;
    box-shadow: 0 0 0 2px rgba(52, 152, 219, 0.2);
}

.search-group input::placeholder {
    color: #999;
}

#clear-search {
    position: absolute;
    right: 4px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: #999;
    font-size: 16px;
    cursor: pointer;
    padding: 2px 6px;
    line-height: 1;
    border-radius: 2px;
}

#clear-search:hover {
    color: #333;
    background: #eee;
}

#refresh-btn {
    padding: 6px 16px;
    background: #3498db;
    color: #fff;
    border: none;
    border-radius: 4px;
    font-size: 12px;
    cursor: pointer;
    transition: background 0.2s;
}

#refresh-btn:hover {
    background: #2980b9;
}

#export-btn {
    padding: 6px 16px;
    background: #27ae60;
    color: #fff;
    border: none;
    border-radius: 4px;
    font-size: 12px;
    cursor: pointer;
    transition: background 0.2s;
}

#export-btn:hover {
    background: #219a52;
}

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

table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
}

thead {
    background: #f8f9fa;
    position: sticky;
    top: 0;
    z-index: 10;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

thead th {
    position: sticky;
    top: 0;
    background: #f8f9fa;
    z-index: 10;
}

th {
    padding: 8px 10px;
    text-align: left;
    font-weight: 600;
    font-size: 12px;
    color: #2c3e50;
    border-bottom: 2px solid #dee2e6;
    white-space: nowrap;
    background: #f8f9fa;
}

th.sortable {
    cursor: pointer;
    user-select: none;
}

th.sortable:hover {
    background: #e9ecef !important;
}

th.sortable::after {
    content: '';
    display: inline-block;
    margin-left: 5px;
    width: 0;
    height: 0;
}

th.sort-asc::after {
    border-left: 5px solid transparent;
    border-right: 5px solid transparent;
    border-bottom: 5px solid #2c3e50;
}

th.sort-desc::after {
    border-left: 5px solid transparent;
    border-right: 5px solid transparent;
    border-top: 5px solid #2c3e50;
}

td {
    padding: 6px 10px;
    border-bottom: 1px solid #dee2e6;
    font-size: 12px;
}

tbody tr:hover {
    background: #f8f9fa;
}

/* Ticker column styling */
.ticker {
    font-weight: 600;
    color: #2c3e50;
    white-space: nowrap;
}

/* Ticker links (X and TradingView icons) */
.ticker-links {
    display: inline-flex;
    gap: 6px;
    margin-left: 8px;
    vertical-align: middle;
}

.ticker-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    border-radius: 4px;
    text-decoration: none;
    transition: all 0.2s ease;
    opacity: 0.7;
}

.ticker-icon:hover {
    opacity: 1;
    transform: scale(1.1);
}

/* X (Twitter) icon */
.ticker-icon.x-icon {
    color: #000;
    background-color: #f0f0f0;
}

.ticker-icon.x-icon:hover {
    background-color: #000;
    color: #fff;
}

/* TradingView icon */
.ticker-icon.tv-icon {
    color: #2962ff;
    background-color: #e8f0fe;
}

.ticker-icon.tv-icon:hover {
    background-color: #2962ff;
    color: #fff;
}

/* StockTwits icon */
.ticker-icon.st-icon {
    color: #fff;
    background-color: #1da1f2;
    font-weight: bold;
}

.ticker-icon.st-icon:hover {
    background-color: #0d8bd9;
    color: #fff;
}

/* Company info icon */
.company-info-icon {
    color: #6c757d;
    opacity: 0.6;
    cursor: pointer;
    margin-right: 4px;
    vertical-align: middle;
}

.company-info-icon:hover {
    opacity: 1;
    color: #3498db;
}

/* Company info modal */
.company-modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 2000;
    justify-content: center;
    align-items: center;
}

.company-modal {
    background: #fff;
    border-radius: 10px;
    width: 90%;
    max-width: 500px;
    max-height: 80vh;
    box-shadow: 0 8px 30px rgba(0,0,0,0.25);
    display: flex;
    flex-direction: column;
}

.company-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid #e0e0e0;
}

.company-modal-title {
    font-size: 16px;
    font-weight: 600;
    color: #2c3e50;
}

.company-modal-close {
    background: none;
    border: none;
    font-size: 24px;
    color: #888;
    cursor: pointer;
    padding: 0 4px;
    line-height: 1;
}

.company-modal-close:hover {
    color: #333;
}

.company-modal-body {
    padding: 20px;
    font-size: 14px;
    line-height: 1.6;
    color: #444;
    overflow-y: auto;
}

/* Price column styling */
.price {
    font-weight: 500;
    color: #2c3e50;
    text-align: left;
}

/* Percentage columns styling */
.pct-col {
    text-align: right;
    color: #555;
}

/* Narrow columns for % and Days headers */
th.narrow-col {
    text-align: center;
    line-height: 1.3;
    padding: 6px 6px;
    min-width: 55px;
    max-width: 70px;
}

td.pct-col,
td.days-col {
    text-align: center;
    padding: 6px 6px;
    min-width: 55px;
}

/* Category column styling */
.category {
    text-align: left !important;
    color: #555;
}

/* Type column styling */
.type {
    text-align: center !important;
    color: #555;
    font-size: 11px;
}

/* Signal cells - Green highlighting like Excel mockup */
.signal-active {
    background-color: #c6efce !important;
    color: #006100;
    font-weight: 600;
    text-align: center;
}

/* Strong divergence (YY - 3-point) styling */
.signal-strong {
    background-color: #81c784 !important;
    color: #1b5e20;
    font-weight: 700;
}

/* Golden border for MA Long signals within 14 days of weekly exit */
.signal-golden {
    border: 3px solid #FFD700 !important;
    box-shadow: 0 0 5px rgba(255, 215, 0, 0.5);
}

.signal-purple {
    border: 3px solid #8B00FF !important;
    box-shadow: 0 0 5px rgba(139, 0, 255, 0.5);
}

.signal-golden.signal-purple {
    border: 3px solid #8B00FF !important;
    box-shadow: 0 0 5px rgba(139, 0, 255, 0.5), inset 0 0 5px rgba(255, 215, 0, 0.6);
    outline: 2px solid #FFD700;
    outline-offset: -5px;
}

/* Dark red border for 1W RSI(7) < 30 */
.signal-darkred {
    border: 3px solid #8B0000 !important;
    box-shadow: 0 0 5px rgba(139, 0, 0, 0.5);
}

/* Dark red + golden combined */
.signal-darkred.signal-golden {
    border: 3px solid #8B0000 !important;
    box-shadow: 0 0 5px rgba(139, 0, 0, 0.5), inset 0 0 5px rgba(255, 215, 0, 0.6);
    outline: 2px solid #FFD700;
    outline-offset: -5px;
}

/* Dark red + purple combined */
.signal-darkred.signal-purple {
    border: 3px solid #8B0000 !important;
    box-shadow: 0 0 5px rgba(139, 0, 0, 0.5), inset 0 0 5px rgba(139, 0, 255, 0.4);
    outline: 2px solid #8B00FF;
    outline-offset: -5px;
}

/* Dark red + golden + purple combined */
.signal-darkred.signal-golden.signal-purple {
    border: 3px solid #8B0000 !important;
    box-shadow: 0 0 5px rgba(139, 0, 0, 0.5), inset 0 0 5px rgba(139, 0, 255, 0.4);
    outline: 2px solid #FFD700;
    outline-offset: -5px;
}

/* Empty/no signal cells */
td:nth-child(n+4):not(.signal-active) {
    text-align: center;
    color: #999;
}

/* Loading and error states */
.loading, .no-data, .error {
    text-align: center;
    padding: 40px;
    color: #666;
}

.error {
    color: #e74c3c;
}

/* Legend */
.legend {
    margin-top: 15px;
    padding: 12px 15px;
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.legend h3 {
    font-size: 14px;
    margin-bottom: 8px;
    color: #2c3e50;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
    font-size: 12px;
}

.legend-box {
    width: 20px;
    height: 20px;
    border: 1px solid #ddd;
    border-radius: 4px;
}

.legend-box.signal-active {
    background-color: #c6efce;
    border-color: #006100;
}

/* Top Movers signal match cells */
.sig-col { text-align: center; min-width: 28px; padding: 4px 2px; }
.sig-match { background-color: #c6efce; color: #006100; font-weight: 700; }
.sig-gold { background-color: #fff8e1; color: #b8860b; font-weight: 700; border: 2px solid #FFD700; }
.sig-purple { background-color: #f3e5f5; color: #6a1b9a; font-weight: 700; border: 2px solid #8B00FF; }
.sig-both { background-color: #f3e5f5; color: #6a1b9a; font-weight: 700; border: 2px solid #8B00FF; box-shadow: inset 0 0 4px rgba(255, 215, 0, 0.7); outline: 1px solid #FFD700; outline-offset: -3px; }
.sig-na { color: #bbb; font-style: italic; }
.sig-score { text-align: center; font-weight: 700; background-color: #e3f2fd; color: #1565c0; }

/* Top Movers compact table overrides */
.top-movers-active .container { max-width: 1600px; }
.top-movers-active table th,
.top-movers-active table td { padding: 4px 5px; font-size: 11px; }
.top-movers-active th.narrow-col { min-width: 36px; max-width: 50px; padding: 4px 3px; }
.top-movers-active .ticker-links { gap: 3px; margin-left: 4px; }
.top-movers-active .ticker-icon { width: 18px; height: 18px; }

/* Responsive */
@media (max-width: 768px) {
    header {
        flex-direction: column;
        gap: 10px;
    }

    .filters {
        flex-wrap: wrap;
    }

    .table-container {
        overflow-x: auto;
    }

    table {
        min-width: 1000px;
    }
}
