/* Crypto 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;
    align-items: center;
    gap: 20px;
    margin-bottom: 15px;
    padding: 10px 15px;
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

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

header h1 {
    font-size: 16px;
    color: #2c3e50;
    line-height: 1.2;
}

.header-source {
    font-size: 10px;
    color: #e67e22;
    font-weight: 600;
}

.header-toggles {
    flex: 1;
}

.header-stats {
    display: flex;
    gap: 16px;
    white-space: nowrap;
}

.stat-item {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.stat-label {
    font-size: 10px;
    color: #999;
}

.stat-value {
    font-size: 12px;
    color: #333;
    font-weight: 600;
}

/* Filters */
.filters {
    display: flex;
    gap: 15px;
    align-items: center;
    margin-bottom: 15px;
    padding: 10px 15px;
    background: #fff;
    border-radius: 8px;
    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;
}

.filter-group input[type="text"] {
    padding: 6px 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 12px;
    background: #fff;
    width: 120px;
}

.filter-group input[type="text"]:focus {
    outline: none;
    border-color: #3498db;
}

/* Toggle buttons for signal type selection */
.toggle-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 0;
}

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

.toggle-btn {
    border-radius: 3px;
    margin: 1px;
}

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

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

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

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

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

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

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

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

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

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

/* Golden border for signals near daily MA */
.signal-golden {
    outline: 3px solid #FFD700;
    outline-offset: -3px;
    box-shadow: inset 0 0 6px rgba(255, 215, 0, 0.6);
}

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

/* Stacked gold + purple border */
.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;
}

/* Listed column styling */
.listed-col {
    white-space: nowrap;
    font-size: 0.9em;
    color: #666;
}

/* Empty/no signal cells */
td:nth-child(n+5):not(.signal-active):not(.listed-col) {
    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;
}

/* === Div Trend Visualization === */

/* Header */
.div-trend-header { margin-bottom: 24px; }
.div-trend-header-label {
    font-size: 11px; letter-spacing: 3px; color: #64748b;
    text-transform: uppercase; margin-bottom: 6px;
}
.div-trend-header-title {
    font-size: 22px; font-weight: 600; color: #0f172a;
    letter-spacing: -0.5px; margin: 0;
    font-family: 'JetBrains Mono', 'Fira Code', 'Courier New', monospace;
}
.div-trend-header-sub { font-size: 12px; color: #64748b; margin-top: 4px; }

/* Stat Cards */
.div-trend-stats { display: flex; gap: 12px; margin-bottom: 24px; }
.trend-stat-card {
    flex: 1; padding: 14px 16px; background: #f8fafc; border: 1px solid #e2e8f0;
    border-radius: 8px; text-align: left;
    font-family: 'JetBrains Mono', 'Fira Code', 'Courier New', monospace;
}
.trend-stat-label {
    font-size: 10px; color: #475569; text-transform: uppercase;
    letter-spacing: 1.5px; margin-bottom: 6px;
}
.trend-stat-value { font-size: 20px; font-weight: 700; margin-top: 0; }
.trend-stat-sub { font-size: 10px; color: #64748b; margin-top: 2px; }
.color-green { color: #047857; }
.color-red { color: #b91c1c; }
.color-amber { color: #b45309; }

/* Chart Panel */
.div-trend-chart-panel {
    background: #f8fafc; border: 1px solid #e2e8f0; border-radius: 10px;
    padding: 20px 16px 12px; margin-bottom: 20px;
}
.chart-panel-header {
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: 16px;
}
.chart-panel-title { font-size: 15px; font-weight: 700; color: #000000; }
.chart-legend { display: flex; gap: 16px; font-size: 13px; font-weight: 600; color: #000000; }
.legend-entry { display: flex; align-items: center; gap: 6px; }
.legend-swatch { width: 10px; height: 10px; border-radius: 2px; display: inline-block; }
.legend-line { width: 18px; height: 2px; border-radius: 2px; display: inline-block; }

/* Chart SVG area */
.chart-wrapper { position: relative; min-height: 400px; }
.svg-bar { transition: fill 0.15s; }

/* Tooltip (light theme, fixed top-right) */
.chart-tooltip {
    display: none; position: absolute; z-index: 20; top: 8px; right: 8px;
    background: #ffffff; color: #334155;
    border: 1px solid #e2e8f0; border-radius: 6px;
    padding: 10px 14px; font-size: 11px; line-height: 1.7;
    pointer-events: none; min-width: 160;
    font-family: 'JetBrains Mono', 'Fira Code', 'Courier New', monospace;
    box-shadow: 0 4px 12px rgba(0,0,0,0.08); white-space: nowrap;
}

/* Breakdown Toggle */
.breakdown-toggle {
    display: block; width: auto; padding: 8px 16px;
    background: none; border: 1px solid #e2e8f0; border-radius: 6px;
    cursor: pointer; font-size: 12px; color: #1e293b; font-weight: 600;
    margin-bottom: 12px;
    font-family: 'JetBrains Mono', 'Fira Code', 'Courier New', monospace;
    transition: all 0.15s;
}
.breakdown-toggle:hover { border-color: #cbd5e1; color: #0f172a; }

/* Breakdown Table */
.breakdown-table-wrap {
    background: #ffffff; border: 1px solid #e2e8f0;
    border-radius: 10px; overflow: hidden;
}
.breakdown-table {
    width: 100%; border-collapse: collapse;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    font-size: 14px;
}
.breakdown-table th {
    padding: 12px 16px; border-bottom: 2px solid #e2e8f0;
    font-size: 13px; color: #0f172a; text-transform: uppercase;
    letter-spacing: 1px; font-weight: 700;
}
.breakdown-table td { padding: 10px 16px; border-bottom: 1px solid #f1f5f9; color: #0f172a; font-size: 14px; }
.breakdown-table tbody tr:nth-child(even) { background: #f8fafc; }
.breakdown-table tbody tr:hover, .breakdown-table tbody tr.highlight {
    background: #f1f5f9; transition: background 0.1s;
}

/* Responsive - Tablet (iPad) */
@media (max-width: 1024px) {
    .container {
        padding: 10px;
    }

    th, td {
        padding: 6px 6px;
        font-size: 11px;
    }

    table {
        min-width: 1100px;
    }
}

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

    header h1 {
        font-size: 16px;
    }

    .filters {
        flex-wrap: wrap;
        gap: 10px;
    }

    .table-container {
        -webkit-overflow-scrolling: touch;
    }

    table {
        min-width: 950px;
    }

    th, td {
        padding: 5px 4px;
        font-size: 10px;
    }

    .legend {
        padding: 10px;
    }

    .legend h3 {
        font-size: 12px;
    }

    .legend-item {
        font-size: 10px;
    }
}

/* Responsive - Small Mobile */
@media (max-width: 480px) {
    .container {
        padding: 5px;
    }

    header {
        padding: 10px;
    }

    header h1 {
        font-size: 14px;
    }

    .header-info {
        font-size: 10px;
        flex-direction: column;
        gap: 5px;
    }

    .filters {
        padding: 8px;
    }

    .toggle-btn, #refresh-btn {
        padding: 5px 10px;
        font-size: 11px;
    }

    table {
        min-width: 850px;
    }

    th, td {
        padding: 4px 3px;
        font-size: 9px;
    }
}
