/*
 ==============================================================================
 Project Name    : Esyasoft.BlazorKit
 File Name       : charts.css
 File Purpose    : Token-driven stylesheet for chart components (Line, Area, Column, Bar,
                   Pie, Treemap, DualAxes) and the shared chart tooltip.
 Created By      : Shreya Reddy A
 Created Date    : 2026-11-06
 ==============================================================================
 MODIFICATION HISTORY:
 Date (YYYY-MM-DD) | Modified By       | Task / CR #  | Description of Changes
 ------------------------------------------------------------------------------
 ------------------------------------------------------------------------------
*/

:root {
    --uuc-chart-font: var(--uuc-font-primary, 'Inter', -apple-system, 'Segoe UI', Roboto, sans-serif);
    --uuc-chart-text: rgba(0, 0, 0, 0.88);
    --uuc-chart-text-secondary: rgba(0, 0, 0, 0.45);
    --uuc-chart-axis-label: rgba(0, 0, 0, 0.45);
    --uuc-chart-axis-line: rgba(0, 0, 0, 0.15);
    --uuc-chart-grid: rgba(0, 0, 0, 0.06);
    --uuc-chart-band-hover: rgba(0, 0, 0, 0.04);
    --uuc-chart-crosshair: rgba(0, 0, 0, 0.25);
    --uuc-chart-bg: #ffffff;
    --uuc-chart-border: #f0f0f0;
    --uuc-chart-radius: 8px;
    --uuc-chart-tooltip-bg: #ffffff;
    --uuc-chart-tooltip-shadow: 0 6px 16px 0 rgba(0, 0, 0, 0.08), 0 3px 6px -4px rgba(0, 0, 0, 0.12), 0 9px 28px 8px rgba(0, 0, 0, 0.05);
    --uuc-chart-primary: var(--uuc-color-primary, #1677ff);
}

/* ---------------------------------------------------------------- frame */

.uuc-chart {
    position: relative;
    width: 100%;
    min-width: 0;
    font-family: var(--uuc-chart-font);
    color: var(--uuc-chart-text);
    box-sizing: border-box;
}

/* Fill the row when the chart sits directly in a flex container. */
.uuc-chart:not(.uuc-chart--fixed) {
    flex: 1 1 100%;
}

.uuc-chart--fixed {
    width: auto;
    display: inline-block;
}

.uuc-chart--bordered {
    background: var(--uuc-chart-bg);
    border: 1px solid var(--uuc-chart-border);
    border-radius: var(--uuc-chart-radius);
    padding: 16px 20px;
}

.uuc-chart-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 12px;
}

.uuc-chart-title {
    font-size: 16px;
    font-weight: 600;
    line-height: 1.5;
}

.uuc-chart-subtitle {
    font-size: 13px;
    color: var(--uuc-chart-text-secondary);
    line-height: 1.5;
}

.uuc-chart-extra {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.uuc-chart-body {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.uuc-chart-body--legend-left,
.uuc-chart-body--legend-right {
    flex-direction: row;
    align-items: center;
}

.uuc-chart-plot {
    position: relative;
    flex: 1 1 auto;
    min-width: 0;
    width: 100%;
}

.uuc-chart-svg {
    display: block;
    overflow: visible;
    font-family: var(--uuc-chart-font);
    user-select: none;
}

/* ---------------------------------------------------------------- legend */

.uuc-chart-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 4px 16px;
    font-size: 12px;
}

.uuc-chart-body--legend-left .uuc-chart-legend,
.uuc-chart-body--legend-right .uuc-chart-legend {
    flex-direction: column;
    flex-wrap: nowrap;
    flex: 0 0 auto;
    max-width: 40%;
    max-height: 100%;
    overflow-y: auto;
    gap: 8px;
}

.uuc-chart-legend-item {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 2px 0;
    border: 0;
    background: none;
    font: inherit;
    color: var(--uuc-chart-text);
    cursor: pointer;
    text-align: left;
    transition: opacity 0.2s ease, color 0.2s ease;
}

.uuc-chart-legend-item:hover {
    opacity: 0.75;
}

.uuc-chart-legend-item:focus-visible {
    outline: 2px solid var(--uuc-chart-primary);
    outline-offset: 2px;
    border-radius: 2px;
}

.uuc-chart-legend-item.is-inactive {
    color: rgba(0, 0, 0, 0.25);
}

.uuc-chart-legend-item.is-static,
.uuc-chart-legend-item:disabled {
    cursor: default;
    opacity: 1;
    color: var(--uuc-chart-text);
}

.uuc-chart-legend-marker {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.uuc-chart-legend-text {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 180px;
}

/* ---------------------------------------------------------------- axes */

.uuc-chart-grid {
    stroke: var(--uuc-chart-grid);
    stroke-width: 1;
    shape-rendering: crispEdges;
}

.uuc-chart-axis-line {
    stroke: var(--uuc-chart-axis-line);
    stroke-width: 1;
    shape-rendering: crispEdges;
}

.uuc-chart-axis-label {
    font-size: 12px;
    fill: var(--uuc-chart-axis-label);
}

.uuc-chart-axis-title {
    font-size: 12px;
    font-weight: 500;
    fill: var(--uuc-chart-text-secondary);
}

.uuc-chart-reference {
    stroke-width: 1.5;
    shape-rendering: crispEdges;
}

.uuc-chart-reference-label {
    font-size: 11px;
    font-weight: 500;
}

.uuc-chart-value-label {
    font-size: 11px;
    fill: var(--uuc-chart-text-secondary);
    pointer-events: none;
}

.uuc-chart-value-label.is-inside {
    fill: #ffffff;
    font-weight: 500;
}

/* ---------------------------------------------------------------- shapes */

.uuc-chart-line {
    fill: none;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.uuc-chart-point,
.uuc-chart-line,
.uuc-chart-area {
    pointer-events: none;
}

.uuc-chart-hit rect {
    cursor: default;
}

.uuc-chart-crosshair {
    stroke: var(--uuc-chart-crosshair);
    stroke-width: 1;
    stroke-dasharray: 3 3;
    opacity: 0;
    pointer-events: none;
}

.uuc-chart-active-point {
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.15s ease;
}

.uuc-chart-hit:hover .uuc-chart-crosshair,
.uuc-chart-hit:hover .uuc-chart-active-point {
    opacity: 1;
}

.uuc-chart-band {
    fill: transparent;
    transition: fill 0.15s ease;
}

.uuc-chart-cat:hover .uuc-chart-band {
    fill: var(--uuc-chart-band-hover);
}

.uuc-chart-bar {
    transition: opacity 0.15s ease, filter 0.15s ease;
}

.uuc-chart-cat:hover .uuc-chart-bar {
    filter: brightness(1.06);
}

.uuc-chart-bar:hover {
    opacity: 0.85;
}

.is-clickable,
.is-clickable rect,
.is-clickable path {
    cursor: pointer;
}

/* Pie */

.uuc-pie-slice {
    stroke: #ffffff;
    stroke-width: 1;
    transition: transform 0.2s ease, opacity 0.2s ease;
}

.uuc-pie-slice:hover {
    transform: translate(var(--uuc-dx, 0), var(--uuc-dy, 0));
}

.uuc-pie-leader {
    fill: none;
    stroke-width: 1;
    opacity: 0.6;
}

.uuc-pie-label {
    fill: var(--uuc-chart-text);
    font-size: 12px;
}

.uuc-pie-center-title {
    font-size: 13px;
    fill: var(--uuc-chart-text-secondary);
}

.uuc-pie-center-value {
    font-size: 22px;
    font-weight: 600;
    fill: var(--uuc-chart-text);
}

.uuc-pie-center-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    pointer-events: none;
}

/* Treemap */

.uuc-treemap-tile rect {
    stroke: #ffffff;
    stroke-width: 1;
    transition: filter 0.15s ease;
}

.uuc-treemap-tile.is-leaf:hover rect {
    filter: brightness(1.1);
}

.uuc-treemap-tile.is-group {
    pointer-events: visiblePainted;
}

.uuc-treemap-label {
    font-size: 12px;
    font-weight: 500;
    fill: #ffffff;
    pointer-events: none;
}

.uuc-treemap-value {
    font-size: 11px;
    fill: rgba(255, 255, 255, 0.85);
    pointer-events: none;
}

.uuc-treemap-group-label {
    font-size: 12px;
    font-weight: 600;
    pointer-events: none;
}

.uuc-treemap-breadcrumb {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 4px;
    margin-bottom: 8px;
    font-size: 13px;
}

.uuc-treemap-crumb {
    border: 0;
    background: none;
    padding: 0 2px;
    font: inherit;
    color: var(--uuc-chart-text-secondary);
    cursor: pointer;
    border-radius: 4px;
}

.uuc-treemap-crumb:hover {
    color: var(--uuc-chart-primary);
}

.uuc-treemap-crumb.is-current {
    color: var(--uuc-chart-text);
    cursor: default;
}

.uuc-treemap-crumb-sep {
    color: rgba(0, 0, 0, 0.25);
}

/* ---------------------------------------------------------------- states */

.uuc-chart-empty {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    color: rgba(0, 0, 0, 0.25);
    font-size: 14px;
}

.uuc-chart-loading {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.6);
    z-index: 2;
}

.uuc-chart-spinner {
    width: 24px;
    height: 24px;
    border: 3px solid rgba(22, 119, 255, 0.2);
    border-top-color: var(--uuc-chart-primary);
    border-radius: 50%;
    animation: uuc-chart-spin 0.8s linear infinite;
}

.uuc-chart-sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
}

/* ---------------------------------------------------------------- tooltip (appended to body by charts.js) */

.uuc-chart-tooltip {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 1080;
    min-width: 120px;
    max-width: 320px;
    padding: 8px 12px;
    border-radius: 6px;
    background: var(--uuc-chart-tooltip-bg);
    box-shadow: var(--uuc-chart-tooltip-shadow);
    font-family: var(--uuc-chart-font);
    font-size: 12px;
    color: var(--uuc-chart-text);
    pointer-events: none;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.12s ease, visibility 0.12s ease;
}

.uuc-chart-tooltip.is-visible {
    opacity: 1;
    visibility: visible;
}

.uuc-chart-tooltip-title {
    margin-bottom: 6px;
    font-weight: 500;
    color: var(--uuc-chart-text-secondary);
}

.uuc-chart-tooltip-row {
    display: flex;
    align-items: center;
    gap: 8px;
    line-height: 20px;
}

.uuc-chart-tooltip-marker {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.uuc-chart-tooltip-name {
    flex: 1 1 auto;
    color: var(--uuc-chart-text-secondary);
}

.uuc-chart-tooltip-value {
    margin-left: 16px;
    font-weight: 500;
    font-variant-numeric: tabular-nums;
}

/* ---------------------------------------------------------------- animation */

.uuc-chart--animate .uuc-chart-line {
    stroke-dasharray: 1;
    stroke-dashoffset: 1;
    animation: uuc-chart-draw 1s ease-out forwards;
}

.uuc-chart--animate .uuc-chart-area,
.uuc-chart--animate .uuc-chart-point,
.uuc-chart--animate .uuc-chart-labels {
    animation: uuc-chart-fade 0.8s ease-out both;
}

.uuc-chart--animate .uuc-chart-bar {
    transform-box: fill-box;
    animation: uuc-chart-grow-y 0.6s cubic-bezier(0.23, 1, 0.32, 1) both;
}

.uuc-chart--animate .uuc-chart-bar--up { transform-origin: 50% 100%; }
.uuc-chart--animate .uuc-chart-bar--down { transform-origin: 50% 0; }

.uuc-chart--animate .uuc-chart-bar--right,
.uuc-chart--animate .uuc-chart-bar--left {
    animation-name: uuc-chart-grow-x;
}

.uuc-chart--animate .uuc-chart-bar--right { transform-origin: 0 50%; }
.uuc-chart--animate .uuc-chart-bar--left { transform-origin: 100% 50%; }

.uuc-chart--animate .uuc-pie-slices {
    animation: uuc-chart-pop 0.6s cubic-bezier(0.23, 1, 0.32, 1) both;
    transform-box: view-box;
    transform-origin: 50% 50%;
}

.uuc-chart--animate .uuc-treemap-tile {
    animation: uuc-chart-fade 0.5s ease-out both;
}

@keyframes uuc-chart-draw { to { stroke-dashoffset: 0; } }
@keyframes uuc-chart-fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes uuc-chart-grow-y { from { transform: scaleY(0); } to { transform: scaleY(1); } }
@keyframes uuc-chart-grow-x { from { transform: scaleX(0); } to { transform: scaleX(1); } }
@keyframes uuc-chart-pop { from { transform: scale(0.6); opacity: 0; } to { transform: scale(1); opacity: 1; } }
@keyframes uuc-chart-spin { to { transform: rotate(360deg); } }

@media (prefers-reduced-motion: reduce) {
    .uuc-chart--animate .uuc-chart-line,
    .uuc-chart--animate .uuc-chart-area,
    .uuc-chart--animate .uuc-chart-point,
    .uuc-chart--animate .uuc-chart-labels,
    .uuc-chart--animate .uuc-chart-bar,
    .uuc-chart--animate .uuc-pie-slices,
    .uuc-chart--animate .uuc-treemap-tile {
        animation: none;
        stroke-dasharray: none;
        stroke-dashoffset: 0;
    }
}

@media (max-width: 576px) {
    .uuc-chart-body--legend-left,
    .uuc-chart-body--legend-right {
        flex-direction: column;
        align-items: stretch;
    }

    .uuc-chart-body--legend-left .uuc-chart-legend,
    .uuc-chart-body--legend-right .uuc-chart-legend {
        flex-direction: row;
        flex-wrap: wrap;
        max-width: none;
    }
}
