/* UI Chart Component Styles */

/* Container */
.ui-chart {
    position: relative;
    width: 100%;
}

.ui-chart.chart-responsive {
    height: auto;
}

.ui-chart.chart-in-card {
    margin: 0;
}

/* Chart sizes */
.ui-chart.chart-extra-small {
    max-height: 200px;
}

.ui-chart.chart-small {
    max-height: 250px;
}

.ui-chart.chart-normal {
    max-height: 300px;
}

.ui-chart.chart-large {
    max-height: 400px;
}

.ui-chart.chart-extra-large {
    max-height: 500px;
}

.ui-chart.chart-huge {
    max-height: 600px;
}

/* Chart Canvas */
.chart-canvas-container {
    position: relative;
    width: 100%;
    height: 100%;
}

.chart-canvas {
    max-width: 100%;
    height: auto;
}

/* Specific chart type containers */
.ui-chart-pie .chart-canvas-container,
.ui-chart-doughnut .chart-canvas-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 300px;
}

.ui-chart-bar .chart-canvas-container,
.ui-chart-line .chart-canvas-container,
.ui-chart-area .chart-canvas-container {
    min-height: 300px;
}

.ui-chart-radar .chart-canvas-container,
.ui-chart-polararea .chart-canvas-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 300px;
}

/* Loading State */
.chart-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 300px;
    padding: 2rem;
    text-align: center;
}

.chart-loading .spinner-border {
    width: 3rem;
    height: 3rem;
    margin-bottom: 1rem;
}

.chart-loading p {
    margin: 0;
    color: #6c757d;
    font-size: 0.875rem;
}

/* Error State */
.chart-error {
    padding: 1rem;
    text-align: center;
}

.chart-error .alert {
    margin: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.chart-error .alert i {
    font-size: 1.125rem;
}

/* No Data State */
.chart-no-data {
    padding: 1rem;
    text-align: center;
}

.chart-no-data .alert {
    margin: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.chart-no-data .alert i {
    font-size: 1.125rem;
}

/* Card styling overrides */
.ui-chart.chart-in-card .card {
    border: 1px solid #dee2e6;
    border-radius: 0.375rem;
    box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);
    overflow: hidden;
    background-color: #ffffff;
}

.ui-chart.chart-in-card .card-header {
    background-color: #f8f9fa;
    border-bottom: 1px solid #dee2e6;
    padding: 0.75rem 1rem;
}

.ui-chart.chart-in-card .card-header .card-title {
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
    color: #495057;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.ui-chart.chart-in-card .card-header .card-title i {
    font-size: 1.125rem;
    color: #6c757d;
}

.ui-chart.chart-in-card .card-body {
    padding: 1rem;
}

/* Chart legend customization */
.ui-chart .chart-canvas-container canvas {
    margin-bottom: 0;
}

/* Selectable Chart Legend */
.chart-legend-selectable {
    padding: 1rem;
    border: 1px solid #dee2e6;
    border-radius: 0.375rem;
    margin-top: 0.75rem;
    background-color: #f8f9fa;
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem 1rem;
    align-items: flex-start;
    position: relative;
}

.chart-legend-selectable .legend-item {
    display: flex;
    align-items: center;
    cursor: pointer;
    transition: all 0.2s ease;
    padding: 0.25rem 0.5rem;
    border-radius: 0.25rem;
    margin: 0;
    flex-shrink: 0;
    background-color: transparent;
}

.chart-legend-selectable .legend-item:hover {
    background-color: rgba(0, 123, 255, 0.1);
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.chart-legend-selectable .legend-item input[type="checkbox"] {
    cursor: pointer;
    margin: 0 0.4rem 0 0;
    flex-shrink: 0;
    width: 16px;
    height: 16px;
    accent-color: #007bff;
}

.chart-legend-selectable .legend-item input[type="checkbox"]:focus {
    outline: 2px solid #007bff;
    outline-offset: 2px;
}

.chart-legend-selectable .legend-color-box {
    width: 12px;
    height: 12px;
    border: 1px solid rgba(0, 0, 0, 0.15);
    border-radius: 2px;
    margin-right: 0.4rem;
    margin-left: 1.5rem;
    flex-shrink: 0;
    transition: opacity 0.2s ease;
}

.chart-legend-selectable .legend-item label {
    cursor: pointer;
    margin: 0;
    font-size: 0.875rem;
    font-weight: 500;
    color: #495057;
    transition: color 0.2s ease;
    user-select: none;
    white-space: nowrap;
}

.chart-legend-selectable .legend-item:hover label {
    color: #007bff;
}

/* Clear All Button */
.chart-legend-clear {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    padding: 0.25rem 0.75rem;
    font-size: 0.75rem;
    border: 1px solid #6c757d;
    background-color: transparent;
    color: #6c757d;
    border-radius: 0.25rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.chart-legend-clear:hover {
    background-color: #6c757d;
    color: #ffffff;
}

/* Remove the problematic Bootstrap margin classes */
.chart-legend-selectable .legend-item.d-inline-flex,
.chart-legend-selectable .legend-item.me-3,
.chart-legend-selectable .legend-item.mb-2 {
    margin: 0 !important;
}
/* Responsive adjustments */
@media (max-width: 768px) {
    .ui-chart.chart-large,
    .ui-chart.chart-extra-large,
    .ui-chart.chart-huge {
        max-height: 300px;
    }
    
    .ui-chart-pie .chart-canvas-container,
    .ui-chart-doughnut .chart-canvas-container,
    .ui-chart-bar .chart-canvas-container,
    .ui-chart-line .chart-canvas-container,
    .ui-chart-area .chart-canvas-container,
    .ui-chart-radar .chart-canvas-container,
    .ui-chart-polararea .chart-canvas-container {
        min-height: 250px;
    }
    
    .chart-loading {
        min-height: 250px;
        padding: 1rem;
    }
    
    .ui-chart.chart-in-card .card-header {
        padding: 0.5rem 0.75rem;
    }
    
    .ui-chart.chart-in-card .card-header .card-title {
        font-size: 0.875rem;
    }
    
    .ui-chart.chart-in-card .card-body {
        padding: 0.75rem;
    }
}

@media (max-width: 576px) {
    .ui-chart {
        margin-bottom: 1rem;
    }
    
    .ui-chart-pie .chart-canvas-container,
    .ui-chart-doughnut .chart-canvas-container,
    .ui-chart-bar .chart-canvas-container,
    .ui-chart-line .chart-canvas-container,
    .ui-chart-area .chart-canvas-container,
    .ui-chart-radar .chart-canvas-container,
    .ui-chart-polararea .chart-canvas-container {
        min-height: 200px;
    }
    
    .chart-loading {
        min-height: 200px;
        padding: 0.75rem;
    }
    
    .chart-loading .spinner-border {
        width: 2rem;
        height: 2rem;
    }
    
    .chart-loading p {
        font-size: 0.75rem;
    }
}

/* Accessibility improvements */
.chart-canvas:focus {
    outline: 2px solid #007bff;
    outline-offset: 2px;
}

/* Print styles */
@media print {
    .ui-chart {
        break-inside: avoid;
        page-break-inside: avoid;
    }
    
    .chart-loading,
    .chart-error,
    .chart-no-data {
        display: none !important;
    }
    
    .chart-canvas-container {
        display: block !important;
    }
}

/* Animation for state transitions */
.chart-loading,
.chart-error,
.chart-no-data,
.chart-canvas-container {
    transition: opacity 0.3s ease-in-out, transform 0.3s ease-in-out;
}

.chart-loading.fade-out,
.chart-error.fade-out,
.chart-no-data.fade-out {
    opacity: 0;
    transform: translateY(-10px);
}

.chart-canvas-container.fade-in {
    opacity: 1;
    transform: translateY(0);
}

/* Dark theme support */
[data-theme="dark"] .ui-chart.chart-in-card .card,
.dark .ui-chart.chart-in-card .card,
body.dark .ui-chart.chart-in-card .card,
body[data-theme="dark"] .ui-chart.chart-in-card .card {
    background-color: #2d3748 !important;
    border-color: #4a5568 !important;
}

[data-theme="dark"] .ui-chart.chart-in-card .card-header,
.dark .ui-chart.chart-in-card .card-header,
body.dark .ui-chart.chart-in-card .card-header,
body[data-theme="dark"] .ui-chart.chart-in-card .card-header {
    background-color: #4a5568 !important;
    border-color: #2d3748 !important;
}

[data-theme="dark"] .ui-chart.chart-in-card .card-header .card-title,
.dark .ui-chart.chart-in-card .card-header .card-title,
body.dark .ui-chart.chart-in-card .card-header .card-title,
body[data-theme="dark"] .ui-chart.chart-in-card .card-header .card-title {
    color: #e2e8f0 !important;
}

[data-theme="dark"] .ui-chart.chart-in-card .card-header .card-title i,
.dark .ui-chart.chart-in-card .card-header .card-title i,
body.dark .ui-chart.chart-in-card .card-header .card-title i,
body[data-theme="dark"] .ui-chart.chart-in-card .card-header .card-title i {
    color: #a0aec0 !important;
}

[data-theme="dark"] .chart-loading p,
.dark .chart-loading p,
body.dark .chart-loading p,
body[data-theme="dark"] .chart-loading p {
    color: #a0aec0 !important;
}

/* Dark mode for selectable legend */
[data-theme="dark"] .chart-legend-selectable,
.dark .chart-legend-selectable,
body.dark .chart-legend-selectable,
body[data-theme="dark"] .chart-legend-selectable {
    border-color: #4a5568 !important;
}

[data-theme="dark"] .chart-legend-selectable .legend-item:hover,
.dark .chart-legend-selectable .legend-item:hover,
body.dark .chart-legend-selectable .legend-item:hover,
body[data-theme="dark"] .chart-legend-selectable .legend-item:hover {
    background-color: rgba(99, 179, 237, 0.1) !important;
}

[data-theme="dark"] .chart-legend-selectable .legend-item label,
.dark .chart-legend-selectable .legend-item label,
body.dark .chart-legend-selectable .legend-item label,
body[data-theme="dark"] .chart-legend-selectable .legend-item label {
    color: #e2e8f0 !important;
}

[data-theme="dark"] .chart-legend-selectable .legend-item:hover label,
.dark .chart-legend-selectable .legend-item:hover label,
body.dark .chart-legend-selectable .legend-item:hover label,
body[data-theme="dark"] .chart-legend-selectable .legend-item:hover label {
    color: #63b3ed !important;
}

[data-theme="dark"] .chart-legend-selectable.legend-left,
.dark .chart-legend-selectable.legend-left,
body.dark .chart-legend-selectable.legend-left,
body[data-theme="dark"] .chart-legend-selectable.legend-left {
    border-right-color: #4a5568 !important;
}

[data-theme="dark"] .chart-legend-selectable.legend-right,
.dark .chart-legend-selectable.legend-right,
body.dark .chart-legend-selectable.legend-right,
body[data-theme="dark"] .chart-legend-selectable.legend-right {
    border-left-color: #4a5568 !important;
}

[data-theme="dark"] .chart-legend-selectable.legend-top,
.dark .chart-legend-selectable.legend-top,
body.dark .chart-legend-selectable.legend-top,
body[data-theme="dark"] .chart-legend-selectable.legend-top {
    border-bottom-color: #4a5568 !important;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .ui-chart.chart-in-card .card {
        border-width: 2px;
    }
    
    .chart-canvas:focus {
        outline-width: 3px;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    .chart-loading,
    .chart-error,
    .chart-no-data,
    .chart-canvas-container {
        transition: none;
    }
}
 