/**
 * Market Overview Page Styles
 * D3.js treemap visualizations and sentiment widgets
 */

.market-overview-page {
    padding: 0;
}

.page-header-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    flex-wrap: wrap;
    gap: 16px;
}

.view-selector {
    display: flex;
    gap: 4px;
    background: var(--bg-secondary);
    padding: 4px;
    border-radius: 8px;
}

.view-btn {
    padding: 8px 16px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s;
}

.view-btn:hover {
    color: var(--text-primary);
    background: var(--bg-tertiary);
}

.view-btn.active {
    background: var(--accent-primary);
    color: white;
}

/* Sentiment Widget */
.sentiment-widget {
    display: grid;
    grid-template-columns: 1.3fr 1fr 1fr 1fr 1fr;
    gap: 12px;
    margin-bottom: 24px;
}

.sentiment-card {
    background: var(--bg-secondary);
    border-radius: 10px;
    padding: 14px 12px;
    border: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
}

.sentiment-card.fear-greed {
    position: relative;
}

.sentiment-gauge {
    width: 100px;
    height: 58px;
    margin-bottom: 6px;
}

.sentiment-stat {
    font-size: 26px;
    font-weight: 700;
    color: var(--text-primary);
}

.sentiment-stat.positive {
    color: var(--positive);
}

.sentiment-stat.negative {
    color: var(--negative);
}

.sentiment-label {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 2px;
}

.sentiment-sublabel {
    font-size: 12px;
    color: var(--text-tertiary);
}

/* Chart Section */
.chart-section {
    background: var(--bg-secondary);
    border-radius: 12px;
    padding: 24px;
    margin-bottom: 24px;
    border: 1px solid var(--border-color);
}

.chart-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
}

/* Treemap Section */
.treemap-section {
    min-height: 500px;
}

.chart-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    flex-wrap: wrap;
    gap: 12px;
}

.treemap-legend {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
}

.legend-label {
    color: var(--text-secondary);
    font-weight: 500;
    margin-right: 2px;
}

.legend-item {
    padding: 4px 8px;
    border-radius: 4px;
    font-weight: 500;
}

.legend-item.negative-strong {
    background: #dc2626;
    color: white;
}

.legend-item.negative {
    background: #f87171 !important;
    color: black !important;
}

.legend-item.neutral {
    background: #6b7280 !important;
    color: white !important;
}

.legend-item.positive {
    background: #4ade80 !important;
    color: black !important;
}

.legend-item.positive-strong {
    background: #22c55e;
    color: white;
}

.treemap-wrapper {
    height: 450px;
    background: var(--bg-tertiary);
    border-radius: 8px;
    overflow: hidden;
    position: relative;
}

.treemap-loading {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-tertiary);
    font-size: 14px;
}

/* D3 Treemap Cells */
.treemap-cell {
    stroke: var(--bg-primary);
    stroke-width: 1px;
    transition: opacity 0.15s;
}

.treemap-cell:hover {
    opacity: 0.85;
    cursor: pointer;
}

.treemap-label {
    font-weight: 600;
    fill: white;
    pointer-events: none;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.7);
}

.treemap-value {
    fill: rgba(255, 255, 255, 0.9);
    pointer-events: none;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.7);
}

/* Treemap Tooltip */
.treemap-tooltip {
    position: absolute;
    padding: 12px 16px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    box-shadow: 0 4px 12px var(--shadow-lg);
    pointer-events: none;
    z-index: 100;
    font-size: 13px;
    min-width: 180px;
    opacity: 0;
    transition: opacity 0.15s;
}

.treemap-tooltip.visible {
    opacity: 1;
}

.treemap-tooltip .tooltip-ticker {
    font-weight: 700;
    font-size: 14px;
    margin-bottom: 8px;
    color: var(--text-primary);
}

.treemap-tooltip .tooltip-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 4px;
    color: var(--text-secondary);
}

.treemap-tooltip .tooltip-row:last-child {
    margin-bottom: 0;
}

.treemap-tooltip .tooltip-value {
    font-weight: 500;
    color: var(--text-primary);
}

.treemap-tooltip .tooltip-value.positive {
    color: var(--positive);
}

.treemap-tooltip .tooltip-value.negative {
    color: var(--negative);
}

/* DEX Volume Section */
.dex-volume-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
    align-items: start;
}

.chart-wrapper-half {
    height: 250px;
    position: relative;
}

.dex-volume-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.dex-volume-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background: var(--bg-tertiary);
    border-radius: 8px;
}

.dex-volume-item .dex-info {
    flex: 1;
    min-width: 0;
}

.dex-name {
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.dex-bar {
    height: 4px;
    background: var(--bg-primary);
    border-radius: 2px;
    overflow: hidden;
}

.dex-bar-fill {
    height: 100%;
    border-radius: 2px;
    transition: width 0.3s ease;
}

.dex-volume {
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 500;
    margin-left: 16px;
    white-space: nowrap;
}

/* Responsive */
@media (max-width: 1200px) {
    .sentiment-widget {
        grid-template-columns: repeat(2, 1fr);
    }

    .sentiment-card.fear-greed {
        grid-column: span 2;
    }
}

@media (max-width: 768px) {
    .sentiment-widget {
        grid-template-columns: 1fr;
    }

    .sentiment-card.fear-greed {
        grid-column: span 1;
    }

    .dex-volume-grid {
        grid-template-columns: 1fr;
    }

    .treemap-wrapper {
        height: 350px;
    }

    .view-selector {
        width: 100%;
        justify-content: center;
    }

    .chart-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .treemap-legend {
        flex-wrap: wrap;
    }
}

@media (max-width: 480px) {
    .sentiment-stat {
        font-size: 22px;
    }

    .treemap-wrapper {
        height: 300px;
    }

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