/* ==========================================================================
   PollsCafe Charts Stylesheet
   Styles for chart visualizations including time series charts
   ========================================================================== */

/* ==========================================================================
   CSS Custom Properties (Chart-specific)
   ========================================================================== */
:root {
    /* Chart colors */
    --chart-bg: #FFFFFF;
    --chart-border: #E3E6EA;
    --chart-text: #212529;
    --chart-text-muted: #6C757D;
    
    /* Mini chart specific */
    --mini-chart-bg: #FFFFFF;
    --mini-chart-radius: 12px;
    --mini-chart-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    --mini-chart-padding: 1rem;
}

/* ==========================================================================
   Hero Chart Full Width Styling
   ========================================================================== */

/* Hero chart wrapper - fills entire width of container */
.hero-chart-wrapper {
    width: 100%;
    padding: 0;
    margin: 0;
}

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

/* Featured chart card - use flexbox to fill space */
.featured-chart {
    display: flex;
    flex-direction: column;
    max-height: 210px;
}

/* Featured chart card body - minimal padding, flex to fill */
.featured-chart .card-body {
    padding: 0.5rem;
    display: flex;
    flex-direction: column;
    flex: 1;
    overflow: hidden;
}

/* Timeseries mini charts need more height for the legend */
.featured-chart.timeseries-mini-container {
    max-height: 230px;
}

/* Chart wrapper in featured section - expand to fill available space */
.featured-chart .chart-wrapper {
    flex: 1;
    min-height: 0;
}

/* Ensure timeseries mini charts in hero section fill width */
.featured-chart.timeseries-mini-container .chart-wrapper {
    width: 100%;
}

/* Timeseries mini in hero section needs taller chart wrapper for legend */
.featured-chart.timeseries-mini-container .hero-chart-wrapper {
    height: 160px !important;
}

/* Sidebar chart cards - reduce bottom padding */
.chart-card .card-body {
    padding-bottom: 0.5rem;
}

.chart-card .chart-wrapper {
    margin-bottom: 0;
}

/* ==========================================================================
   Time Series Mini Chart Container
   Requirements: 4.8 - White background with rounded corners
   ========================================================================== */

/* Mini chart container wrapper */
.timeseries-mini-container,
.chart-mini-container {
    background-color: var(--mini-chart-bg);
    border-radius: var(--mini-chart-radius);
    box-shadow: var(--mini-chart-shadow);
    padding: var(--mini-chart-padding);
    overflow: hidden;
}

/* Chart wrapper inside mini container */
.timeseries-mini-container .chart-wrapper,
.chart-mini-container .chart-wrapper {
    padding: 0.5rem;
    min-height: 150px;
    position: relative;
}

/* Canvas element styling */
.timeseries-mini-container canvas,
.chart-mini-container canvas {
    max-width: 100%;
    height: auto !important;
}

/* ==========================================================================
   Endpoint Value Labels
   Requirements: 4.6 - Display endpoint value (percentage) next to endpoint marker
   ========================================================================== */

/* Endpoint value label styling (for custom rendering if needed) */
.endpoint-value-label {
    font-weight: 700;
    font-size: 0.875rem;
    line-height: 1;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    background-color: rgba(255, 255, 255, 0.9);
    white-space: nowrap;
}

/* Endpoint label positioned to the right of the marker */
.endpoint-value-label--right {
    margin-left: 0.5rem;
}

/* Endpoint label positioned above the marker */
.endpoint-value-label--top {
    margin-bottom: 0.25rem;
}

/* Series-specific endpoint colors (inherit from series color) */
.endpoint-value-label[data-series-color] {
    color: attr(data-series-color);
}

/* ==========================================================================
   Mini Chart Legend Styling
   Requirements: 4.7 - Simple legend below the chart
   ========================================================================== */

/* Legend container for mini charts */
.timeseries-mini-container .chart-legend,
.chart-mini-container .chart-legend {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 1rem;
    padding-top: 0.75rem;
    margin-top: 0.5rem;
    border-top: 1px solid var(--chart-border);
}

/* Individual legend item */
.chart-legend-item {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    font-size: 0.8125rem;
    color: var(--chart-text);
}

/* Legend color indicator */
.chart-legend-color {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    flex-shrink: 0;
}

/* Legend label text */
.chart-legend-label {
    font-weight: 500;
}

/* ==========================================================================
   Mini Chart Title (Optional)
   ========================================================================== */

.timeseries-mini-container .chart-title,
.chart-mini-container .chart-title {
    font-size: 0.9375rem;
    font-weight: 600;
    color: var(--chart-text);
    margin-bottom: 0.75rem;
    text-align: center;
}

/* ==========================================================================
   Mini Chart Responsive Styles
   ========================================================================== */

/* Tablet */
@media (max-width: 991.98px) {
    .timeseries-mini-container,
    .chart-mini-container {
        padding: 0.875rem;
    }
    
    .timeseries-mini-container .chart-wrapper,
    .chart-mini-container .chart-wrapper {
        min-height: 130px;
    }
}

/* Mobile */
@media (max-width: 768px) {
    :root {
        --mini-chart-radius: 8px;
        --mini-chart-padding: 0.75rem;
    }
    
    .timeseries-mini-container,
    .chart-mini-container {
        border-radius: var(--mini-chart-radius);
        padding: var(--mini-chart-padding);
    }
    
    .timeseries-mini-container .chart-wrapper,
    .chart-mini-container .chart-wrapper {
        min-height: 120px;
        padding: 0.25rem;
    }
    
    .endpoint-value-label {
        font-size: 0.75rem;
        padding: 0.125rem 0.375rem;
    }
    
    .timeseries-mini-container .chart-legend,
    .chart-mini-container .chart-legend {
        gap: 0.75rem;
        padding-top: 0.5rem;
    }
    
    .chart-legend-item {
        font-size: 0.75rem;
    }
    
    .chart-legend-color {
        width: 10px;
        height: 10px;
    }
}

/* Small Mobile */
@media (max-width: 576px) {
    .timeseries-mini-container .chart-legend,
    .chart-mini-container .chart-legend {
        flex-direction: column;
        align-items: center;
        gap: 0.5rem;
    }
}

/* ==========================================================================
   High Contrast Mode Support
   ========================================================================== */
@media (prefers-contrast: high) {
    .timeseries-mini-container,
    .chart-mini-container {
        border: 2px solid #000;
        box-shadow: none;
    }
    
    .endpoint-value-label {
        background-color: #fff;
        border: 1px solid #000;
    }
    
    .timeseries-mini-container .chart-legend,
    .chart-mini-container .chart-legend {
        border-top: 2px solid #000;
    }
}

/* ==========================================================================
   Reduced Motion Support
   ========================================================================== */
@media (prefers-reduced-motion: reduce) {
    .timeseries-mini-container,
    .chart-mini-container,
    .endpoint-value-label {
        transition: none;
    }
}

/* ==========================================================================
   Print Styles
   ========================================================================== */
@media print {
    .timeseries-mini-container,
    .chart-mini-container {
        box-shadow: none;
        border: 1px solid #ccc;
        page-break-inside: avoid;
    }
    
    .endpoint-value-label {
        background-color: transparent;
        border: none;
    }
}
