/**
 * Charts Styling
 * Migration-ready: Pure CSS, no WordPress dependencies
 */

/* =============================================
   HOLDINGS DISTRIBUTION CHART
   ============================================= */

.cpt-holdings-chart {
    position: relative;
}

.cpt-holdings-chart canvas {
    max-width: 100%;
    height: auto !important;
}

/* Top Holdings Legend */
.cpt-top-holdings {
    margin-top: 20px;
}

.cpt-top-holdings > div {
    transition: background 0.2s ease;
}

.cpt-top-holdings > div:hover {
    background: #f9fafb;
    border-radius: 6px;
    margin: 0 -8px;
    padding-left: 8px !important;
    padding-right: 8px !important;
}

body.dark-mode .cpt-top-holdings > div:hover {
    background: #374151;
}

/* Loading State */
.cpt-holdings-chart.loading {
    opacity: 0.6;
    pointer-events: none;
}

.cpt-holdings-chart.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 40px;
    height: 40px;
    border: 3px solid #e5e7eb;
    border-top-color: #667eea;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: translate(-50%, -50%) rotate(360deg); }
}

/* =============================================
   PERFORMANCE CHART
   ============================================= */

.cpt-performance-chart {
    position: relative;
}

.cpt-performance-chart canvas {
    max-width: 100%;
    height: auto !important;
}

/* Time Range Buttons */
.chart-time-range {
    display: flex;
    gap: 8px;
}

.chart-time-range button {
    padding: 6px 12px !important;
    border-radius: 6px !important;
    font-size: 12px !important;
    height: auto !important;
    border: 1px solid #e5e7eb !important;
    background: white !important;
    color: #6b7280 !important;
    transition: all 0.2s !important;
    cursor: pointer;
}

.chart-time-range button:hover {
    background: #f9fafb !important;
    border-color: #667eea !important;
}

.chart-time-range button.active {
    background: #667eea !important;
    color: white !important;
    border-color: #667eea !important;
}

body.dark-mode .chart-time-range button {
    background: #374151 !important;
    border-color: #4b5563 !important;
    color: #d1d5db !important;
}

body.dark-mode .chart-time-range button:hover {
    background: #4b5563 !important;
    border-color: #667eea !important;
}

body.dark-mode .chart-time-range button.active {
    background: #667eea !important;
    color: white !important;
}

/* =============================================
   RESPONSIVE
   ============================================= */

@media (max-width: 768px) {
    .cpt-holdings-chart,
    .cpt-performance-chart {
        padding: 16px !important;
    }
    
    .chart-time-range {
        flex-wrap: wrap;
    }
    
    .chart-time-range button {
        flex: 1;
        min-width: 60px;
    }
}

/* =============================================
   ANIMATIONS
   ============================================= */

.cpt-holdings-chart,
.cpt-performance-chart {
    animation: fadeIn 0.4s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}