/* =============================================================================
   차트 전용 스타일
   ============================================================================= */

/* 차트 컨테이너 기본 설정 */
.chart-wrapper {
    position: relative;
    width: 100%;
    min-height: 300px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.chart-wrapper canvas {
    max-width: 100%;
    height: auto !important;
}

/* 차트 로딩 상태 */
.chart-loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    color: var(--text-muted);
}

.chart-loading .spinner {
    width: 32px;
    height: 32px;
    margin-bottom: var(--spacing-sm);
}

.chart-loading-text {
    font-size: var(--font-size-sm);
}

/* 차트 오버레이 */
.chart-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(255, 255, 255, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--border-radius-lg);
    z-index: 10;
}

/* 범례 커스텀 스타일 */
.chart-legend {
    display: flex;
    flex-wrap: wrap;
    gap: var(--spacing-md);
    margin-top: var(--spacing-md);
    padding-top: var(--spacing-md);
    border-top: 1px solid var(--border-light);
}

.chart-legend-item {
    display: flex;
    align-items: center;
    gap: var(--spacing-xs);
    font-size: var(--font-size-sm);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition-fast);
    padding: var(--spacing-xs) var(--spacing-sm);
    border-radius: var(--border-radius-sm);
}

.chart-legend-item:hover {
    background-color: var(--bg-tertiary);
    color: var(--text-primary);
}

.chart-legend-item.disabled {
    opacity: 0.5;
}

.chart-legend-color {
    width: 14px;
    height: 14px;
    border-radius: var(--border-radius-sm);
    flex-shrink: 0;
    border: 2px solid transparent;
    transition: all var(--transition-fast);
}

.chart-legend-item:hover .chart-legend-color {
    border-color: var(--border-medium);
}

.chart-legend-label {
    font-weight: 500;
    white-space: nowrap;
}

.chart-legend-value {
    font-weight: 600;
    color: var(--text-primary);
    margin-left: auto;
    padding-left: var(--spacing-sm);
}

/* 차트별 특화 스타일 */

/* 라인 차트 (일별 트렌드) */
.daily-trend-chart {
    height: 320px;
}

/* 파이 차트 (분류별 비중) */
.category-pie-chart {
    height: 280px;
}

/* 바 차트 (상품 순위) */
.product-ranking-chart {
    height: 400px;
}

/* 도넛 차트 */
.chart-wrapper.donut-chart {
    position: relative;
}

.chart-center-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    pointer-events: none;
}

.chart-center-value {
    font-size: var(--font-size-xl);
    font-weight: 700;
    color: var(--text-primary);
    display: block;
    margin-bottom: var(--spacing-xs);
}

.chart-center-label {
    font-size: var(--font-size-sm);
    color: var(--text-secondary);
    font-weight: 500;
}

/* 차트 툴팁 커스텀 (Chart.js 커스텀) */
.chartjs-tooltip {
    opacity: 1;
    position: absolute;
    background: var(--bg-primary);
    color: var(--text-primary);
    border: 1px solid var(--border-light);
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-lg);
    padding: var(--spacing-sm) var(--spacing-md);
    pointer-events: none;
    transform: translate(-50%, -100%);
    font-size: var(--font-size-sm);
    font-family: var(--font-family);
    z-index: 100;
}

.chartjs-tooltip-header {
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: var(--spacing-xs);
    padding-bottom: var(--spacing-xs);
    border-bottom: 1px solid var(--border-light);
}

.chartjs-tooltip-body {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-xs);
}

.chartjs-tooltip-item {
    display: flex;
    align-items: center;
    gap: var(--spacing-xs);
}

.chartjs-tooltip-color {
    width: 12px;
    height: 12px;
    border-radius: 2px;
    flex-shrink: 0;
}

.chartjs-tooltip-label {
    color: var(--text-secondary);
    flex: 1;
}

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

/* 차트 상호작용 */
.chart-wrapper:hover {
    cursor: default;
}

/* 차트 없음 상태 */
.chart-no-data {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 300px;
    color: var(--text-muted);
}

.chart-no-data-icon {
    font-size: var(--font-size-4xl);
    margin-bottom: var(--spacing-md);
    opacity: 0.5;
}

.chart-no-data-title {
    font-size: var(--font-size-lg);
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: var(--spacing-sm);
}

.chart-no-data-description {
    font-size: var(--font-size-sm);
    text-align: center;
    line-height: var(--line-height-loose);
    max-width: 300px;
}

/* 차트 애니메이션 */
@keyframes chartFadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.chart-wrapper.loaded {
    animation: chartFadeIn 0.5s ease-out forwards;
}

/* 반응형 차트 조정 */
@media (max-width: 768px) {
    .chart-wrapper {
        min-height: 250px;
    }
    
    .daily-trend-chart {
        height: 280px;
    }
    
    .category-pie-chart {
        height: 240px;
    }
    
    .product-ranking-chart {
        height: 350px;
    }
    
    .chart-legend {
        flex-direction: column;
        gap: var(--spacing-sm);
    }
    
    .chart-legend-item {
        justify-content: space-between;
        width: 100%;
    }
}

@media (max-width: 480px) {
    .chart-wrapper {
        min-height: 200px;
    }
    
    .chart-center-value {
        font-size: var(--font-size-lg);
    }
    
    .chart-center-label {
        font-size: var(--font-size-xs);
    }
    
    .chartjs-tooltip {
        font-size: var(--font-size-xs);
        padding: var(--spacing-xs) var(--spacing-sm);
    }
}

/* 차트 로딩 애니메이션 */
.chart-container {
    position: relative !important;
    overflow: hidden !important;
}

.chart-loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 200px;
    height: 150px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(2px);
    z-index: 10;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.loading-spinner {
    text-align: center;
}

.loading-spinner .spinner {
    width: 40px;
    height: 40px;
    margin: 0 auto 12px;
    border: 3px solid #e2e8f0;
    border-top-color: #3b82f6;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.loading-spinner p {
    color: #64748b;
    font-size: 14px;
    margin: 0;
    font-weight: 500;
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}