/**
 * ClimateScanner Charts Styles - D3.js Version
 * 
 * Estilos para os gráficos baseados no design do Figma
 * Utiliza variáveis CSS do tema ClimateScanner
 * Agora usando D3.js ao invés de Chart.js
 * 
 * @package ClimateScanner
 * @subpackage Charts
 * @version 2.0.0
 */

/* ================================================
   Chart Container Base
   ================================================ */

.cs-chart {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 6px;
}

.cs-chart svg {
    max-width: 100%;
    height: auto;
    padding: 10px;
}

/* Tooltip para D3.js */
.cs-chart-tooltip {
    position: absolute;
    visibility: hidden;
    background-color: rgba(3, 2, 23, 0.9);
    color: #ffffff;
    padding: 12px;
    border-radius: 8px;
    font-size: 12px;
    font-family: 'Poppins', sans-serif;
    pointer-events: none;
    z-index: 1000;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

/* ================================================
   Radar (Solar) Chart - D3.js Radial Stacked Bar
   ================================================ */

.cs-chart--radar {
    min-height: 600px;
    padding: 40px 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    overflow: visible;
}

.cs-chart--radar svg {
    width: 100% !important;
    max-width: 74vw !important;
    height: auto !important;
    overflow: visible;
}

/* D3 chart specific styles */
.cs-chart--radar path {
    transition: opacity 0.2s ease;
}

.cs-chart--radar path:hover {
    opacity: 0.8;
}

.cs-chart--radar text {
    font-family: 'Poppins', sans-serif;
    user-select: none;
}

.cs-chart--radar circle {
    pointer-events: none;
}

.cs-chart--radar line {
    pointer-events: none;
}
.cs-chart--radar text {
    pointer-events: none;
}

/* ================================================
   Pie (Donut) Chart - D3.js
   ================================================ */

.cs-chart--pie {
    margin: 0 auto;
}

.cs-chart__wrapper {
    position: relative;
    width: 200px;
    height: 200px;
}

.cs-chart__wrapper svg {
    width: 200px !important;
    height: 200px !important;
}

/* D3 pie chart specific styles */
.cs-chart--pie path {
    transition: all 0.2s ease;
    cursor: pointer;
}

.cs-chart--pie path:hover {
    filter: brightness(1.1);
}

.cs-chart--pie text {
    font-family: 'Open Sans', sans-serif;
    user-select: none;
}

/* Center content overlay */
.cs-chart__center-content {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    pointer-events: none;
}

.cs-chart__center-icon {
    width: 16px;
    height: 16px;
    margin-bottom: 4px;
}

.cs-chart__center-icon svg {
    width: 100%;
    height: 100%;
}

.cs-chart__center-value {
    font-family: 'Open Sans', sans-serif;
    font-size: 16px;
    font-weight: 600;
    line-height: 1.5;
    color: #010814;
    text-align: center;
}

.cs-chart__center-label {
    font-family: 'Open Sans', sans-serif;
    font-size: 12px;
    font-weight: 400;
    line-height: 1.5;
    color: #515052;
    text-align: center;
    max-width: 80px;
}

/* Center content overlay - HTML sobreposto ao SVG */
.full-evaluation__pie-info {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    pointer-events: none;
    font-family: 'Open Sans', sans-serif;
    z-index: 10;
    margin-top: -8px;
}

.full-evaluation__chart-container {
    display: flex;
    gap: var(--spacing-xl);
    align-items: center;
    justify-content: space-between;
}

.full-evaluation__pie-chart {
    margin: 16px auto;
}

.full-evaluation__pie-info .full-evaluation__pie-icon svg {
    width: 13px !important;
    height: 14px !important;
    padding: 0 !important;
}
.full-evaluation__pie-total {
    font-weight: 600;
    font-size: 16px;
    line-height: 1.5;
    text-align: center;
    color: #010814;
}

.full-evaluation__pie-label {
    font-weight: 400;
    font-size: 12px;
    line-height: 1.5;
    text-align: center;
    color: #515052;
}

/* Tooltip para pie chart */
.cs-chart-tooltip {
    position: absolute;
    background: rgba(0, 0, 0, 0.9);
    color: white;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 12px;
    font-family: 'Open Sans', sans-serif;
    pointer-events: none;
    opacity: 0;
    visibility: hidden;
    z-index: 9999;
    transition: opacity 0.2s ease;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
    white-space: nowrap;
}

.cs-chart-tooltip--pie {
    z-index: 9999 !important;
}

/* ================================================
   Chart Legend (Custom)
   ================================================ */

.cs-chart-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    margin-top: 24px;
    padding-top: 24px;
    border-top: 1px solid rgba(7, 22, 112, 0.1);
}

.cs-chart-legend__item {
    display: flex;
    align-items: center;
    gap: 8px;
}

.cs-chart-legend__color {
    width: 20px;
    height: 20px;
    border-radius: 4px;
    flex-shrink: 0;
}

.cs-chart-legend__label {
    font-family: 'Poppins', sans-serif;
    font-size: 14px;
    font-weight: 400;
    line-height: 1.4285714285714286;
    color: #030217;
}

/* ================================================
   Responsive Adjustments
   ================================================ */

@media screen and (max-width: 1010px) {
    .cs-chart--radar {
        padding: 20px 10px;
        min-height: 300px;
    }
    
    .cs-chart-legend {
        gap: 12px;
        margin-top: 16px;
        padding-top: 16px;
    }
}

@media screen and (max-width: 768px) {
    .cs-chart--radar {
        padding: 15px 5px;
        min-height: 250px;
    }
    
    .cs-chart-legend {
        flex-direction: column;
        gap: 8px;
    }
    
    .cs-chart-legend__label {
        font-size: 13px;
    }
}

/* ================================================
   Chart Integration with Full Evaluation
   ================================================ */

/* Quando usado no contexto de Full Evaluation */
.full-evaluation__sun-chart-container {
    width: 100%;
    max-width: 1228px;
    margin: 0 auto;
}

.full-evaluation__stages-chart-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 24px;
    padding: 32px 0;
}

/* ================================================
   Loading State
   ================================================ */

.cs-chart--loading {
    opacity: 0.5;
    pointer-events: none;
}

.cs-chart--loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 40px;
    height: 40px;
    border: 4px solid rgba(7, 22, 112, 0.1);
    border-top-color: #14528C;
    border-radius: 50%;
    animation: cs-chart-spin 0.8s linear infinite;
}

@keyframes cs-chart-spin {
    to {
        transform: translate(-50%, -50%) rotate(360deg);
    }
}

/* ================================================
   Error State
   ================================================ */

.cs-chart--error {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 200px;
    color: #D85959;
    font-family: 'Poppins', sans-serif;
    font-size: 14px;
}

/* ================================================
   Accessibility
   ================================================ */

.cs-chart:focus-within {
    outline: 2px solid #14528C;
    outline-offset: 4px;
}

/* Screen reader only text */
.cs-chart__sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

