/* Page Designer — Charts Block | Namespace: pd-blk-charts-* */
/* v1.0.0 (introduced in PAGE_DESIGNER_VERSION 2.9.404)       */
/*                                                            */
/* Container styles for Charts blocks in BOTH the editor      */
/* canvas and the published page output. Keeps no shared      */
/* selectors with the legacy `chart` block (pd-blk-chart-*).  */

/* Default container height — fixed 300px so every chart type
   (Bar / Line / Pie / Donut / Polar / Radar) renders at the same
   height by default. Chart.js's responsive sizing for radial types
   would otherwise inflate the parent to a 1:1 aspect ratio. The
   Size panel writes an inline `height: <Npx>` override on user
   change, which beats this CSS rule due to inline-style precedence. */
[data-pd-block="charts"] {
    position: relative;
    width: 100%;
    height: 300px;
    box-sizing: border-box;
}

/* Pin the canvas to fill the container exactly. Chart.js's responsive
   logic respects this when maintainAspectRatio is false. */
[data-pd-block="charts"] canvas.pd-blk-charts-canvas {
    display: block;
    width: 100%;
    height: 100%;
    max-width: 100%;
}

/* Editor-canvas-only chrome — `[data-gjs-type]` attributes are
   stripped at save time, so these rules never reach the public
   page. They give the user a hover/selection ring and a small
   badge identifying dynamic-mode blocks at a glance. */
[data-gjs-type="pd-charts"] {
    padding: 4px;
    margin: 2px 0;
}

[data-gjs-type="pd-charts"][data-pd-charts-mode="dynamic"]::before {
    content: 'Dynamic data — preview shows placeholder until refreshed';
    position: absolute;
    top: 6px;
    right: 6px;
    z-index: 5;
    font-size: 10px;
    line-height: 1;
    padding: 4px 7px;
    border-radius: 3px;
    background: rgba(137, 180, 250, 0.16);
    color: var(--at-color-primary);
    border: 1px solid rgba(137, 180, 250, 0.45);
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.18s ease;
}

[data-gjs-type="pd-charts"][data-pd-charts-mode="dynamic"]:hover::before {
    opacity: 1;
}

/* Dynamic-mode source chip stamped by the panel when a source is
   chosen — visible on the published page too as a subtle caption.
   Authors can hide it via Design panel → display:none if not wanted. */
[data-pd-block="charts"] .pd-blk-charts-caption {
    font-size: 11px;
    color: inherit; /* v3.7.19 — General Text colour, not admin token */
    margin-top: 6px;
    text-align: center;
    line-height: 1.3;
}

/* Loading + error states for the public runtime. The runtime swaps
   the .pd-blk-charts-state class to show one of these. */
[data-pd-block="charts"].pd-blk-charts-state-loading::after,
[data-pd-block="charts"].pd-blk-charts-state-error::after {
    content: 'Loading chart…';
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: inherit; /* v3.7.19 — General Text colour */
    font-size: 12px;
    pointer-events: none;
}
[data-pd-block="charts"].pd-blk-charts-state-error::after {
    content: 'Chart could not load.';
    color: #dc2626; /* v3.7.19 — error red, not admin token */
}

/* Responsive height suggestions — authors override via Design panel. */
@media (max-width: 768px) {
    [data-pd-block="charts"] {
        min-height: 200px;
    }
}
