/* Sheets charts (static/js/sheets_charts.js): the chart box over the grid, the chart editor sidebar and its
   popups. Every class starts with shc-. The charts themselves are SVG with their own colours (light / dark). */

:root { --shc-handle: #ffffff; --shc-ring: rgba(0, 0, 0, .14); }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { --shc-handle: #1d2025; --shc-ring: rgba(255, 255, 255, .22); }
}
:root[data-theme="dark"] { --shc-handle: #1d2025; --shc-ring: rgba(255, 255, 255, .22); }

/* ---------------------------------------------------------------- the chart box over the grid */
.shc-overlay { position: absolute; z-index: 6; box-sizing: border-box; border-radius: 2px; background: var(--surface);
  box-shadow: 0 0 0 1px var(--border); cursor: default; touch-action: none; user-select: none; -webkit-user-select: none; }
.shc-overlay:hover { box-shadow: 0 0 0 1px var(--border-strong); }
.shc-overlay:not(.shc-readonly) { cursor: move; }
.shc-overlay.selected { z-index: 8; box-shadow: 0 0 0 2px var(--accent); }
.shc-overlay:focus { outline: none; }
.shc-overlay:focus-visible { box-shadow: 0 0 0 2px var(--accent), 0 0 0 5px var(--sel-strong); }
.shc-overlay.shc-moving, .shc-overlay.shc-resizing { z-index: 9; opacity: .92; box-shadow: 0 0 0 2px var(--accent), var(--shadow-2); }
.shc-overlay.shc-moving { cursor: grabbing; }
.shc-frame { position: absolute; inset: 0; overflow: hidden; border-radius: inherit; }
.shc-frame .shc-svg { display: block; width: 100%; height: 100%; }

.shc-menu-btn { position: absolute; top: 6px; right: 6px; z-index: 2; display: grid; place-items: center; width: 30px; height: 30px; padding: 0;
  border: 1px solid var(--border); border-radius: 50%; background: var(--surface); color: var(--text-2); cursor: pointer;
  box-shadow: var(--shadow-1); opacity: 0; transition: opacity .12s; }
.shc-menu-btn .icon { width: 18px; height: 18px; }
.shc-menu-btn:hover { background: var(--surface-2); color: var(--text); }
.shc-menu-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; opacity: 1; }
.shc-overlay:hover .shc-menu-btn, .shc-overlay.selected .shc-menu-btn, .shc-overlay:focus-within .shc-menu-btn,
.shc-menu-btn[aria-expanded="true"] { opacity: 1; }
.shc-overlay.shc-moving .shc-menu-btn, .shc-overlay.shc-resizing .shc-menu-btn { opacity: 0; }
@media (hover: none) { .shc-menu-btn { opacity: 1; } }

.shc-handle { position: absolute; z-index: 3; display: none; width: 10px; height: 10px; margin: -5px 0 0 -5px; border: 1.5px solid var(--accent);
  border-radius: 2px; background: var(--shc-handle); }
.shc-overlay.selected .shc-handle { display: block; }
.shc-overlay.shc-moving .shc-handle { display: none; }
.shc-h-nw { left: 0; top: 0; cursor: nwse-resize; }
.shc-h-n { left: 50%; top: 0; cursor: ns-resize; }
.shc-h-ne { left: 100%; top: 0; cursor: nesw-resize; }
.shc-h-e { left: 100%; top: 50%; cursor: ew-resize; }
.shc-h-se { left: 100%; top: 100%; cursor: nwse-resize; }
.shc-h-s { left: 50%; top: 100%; cursor: ns-resize; }
.shc-h-sw { left: 0; top: 100%; cursor: nesw-resize; }
.shc-h-w { left: 0; top: 50%; cursor: ew-resize; }
@media (pointer: coarse) { .shc-handle { width: 18px; height: 18px; margin: -9px 0 0 -9px; } }

.shc-live { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

/* the drawn chart (also used outside the overlay) */
.shc-svg { overflow: hidden; }
.shc-svg:focus { outline: none; }
.shc-svg:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.shc-svg text { user-select: none; -webkit-user-select: none; }
.shc-svg .shc-legend-item { cursor: default; }
.shc-svg .shc-series { transition: opacity .12s; }
.shc-svg .shc-marks path.shc-mark { transition: transform .12s ease-out; }
@media (prefers-reduced-motion: reduce) {
  .shc-svg .shc-series, .shc-svg .shc-marks path.shc-mark, .shc-menu-btn { transition: none; }
}
@media (forced-colors: active) {
  .shc-overlay.selected { outline: 2px solid Highlight; }
  .shc-handle { forced-color-adjust: none; background: Canvas; border-color: Highlight; }
}

/* ---------------------------------------------------------------- the editor sidebar */
.side-panel.shc-side .body { padding: 0; overflow: hidden; display: flex; flex-direction: column; }
.shc-root { position: relative; flex: 1; min-height: 0; display: flex; flex-direction: column; }
.shc-tabs { flex: none; display: flex; padding: 0 12px; border-bottom: 1px solid var(--border); }
.shc-tab { flex: 1; height: 42px; border: 0; border-bottom: 3px solid transparent; background: none; cursor: pointer;
  font-size: 13.5px; font-weight: 600; color: var(--text-2); }
.shc-tab:hover { color: var(--text); }
.shc-tab[aria-selected="true"] { color: var(--accent); border-bottom-color: var(--accent); }
.shc-tab:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; border-radius: 4px 4px 0 0; }
.shc-view { flex: 1; min-height: 0; overflow-y: auto; padding: 8px 20px 28px; }
.shc-view [hidden] { display: none !important; }

.shc-field { display: flex; flex-direction: column; min-width: 0; margin-top: 14px; }
.shc-label { display: block; margin: 0 0 6px; font-size: 12.5px; font-weight: 600; color: var(--text-2); }
.shc-hint { margin: 6px 0 0; font-size: 12.5px; line-height: 1.45; color: var(--text-3); }
.shc-error { margin: 6px 0 0; font-size: 12.5px; color: var(--danger); }
.shc-view .input, .shc-view .select { height: 36px; font-size: 13.5px; }
.shc-view .input[aria-invalid="true"] { border-color: var(--danger); }
.shc-view .input[aria-invalid="true"]:focus { box-shadow: 0 0 0 3px color-mix(in srgb, var(--danger) 18%, transparent); }
.shc-view textarea.input.shc-textarea { height: auto; min-height: 72px; font-size: 13px; line-height: 1.4; }
.shc-mono { font-family: var(--mono); font-size: 12.5px !important; }
.shc-select { min-width: 0; text-overflow: ellipsis; }
.shc-range-row { display: flex; align-items: center; gap: 4px; }
.shc-range-row .input { flex: 1; min-width: 0; }
.shc-pick { flex: none; }
.shc-checks { display: flex; flex-direction: column; gap: 10px; margin-top: 18px; }
.shc-check { align-items: flex-start; line-height: 1.35; }
.shc-check input { flex: none; width: 16px; height: 16px; margin: 1px 0 0; accent-color: var(--accent); }
.shc-field + .shc-check, .shc-acc-body > .shc-check { margin-top: 12px; }
.shc-check:has(input:disabled) { opacity: .55; cursor: default; }
.shc-pair { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 10px; }

/* chart type field */
.shc-type-btn { display: flex; align-items: center; gap: 10px; width: 100%; height: 44px; padding: 0 10px 0 8px; border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm); background: var(--surface); color: var(--text); text-align: left; cursor: pointer; font-size: 13.5px; }
.shc-type-btn:hover { background: var(--surface-2); }
.shc-type-btn:focus-visible { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--sel); }
.shc-type-btn > .icon { color: var(--text-2); }
.shc-type-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.shc-type-icon { flex: none; width: 28px; height: 28px; color: var(--accent); fill: none; stroke: currentColor; stroke-width: 1.6;
  stroke-linecap: round; stroke-linejoin: round; }
.shc-type-icon .ax { stroke: var(--text-3); stroke-width: 1.3; }
.shc-type-icon .ln { stroke-width: 2; }
.shc-type-icon .thin { stroke-width: 1.5; }
.shc-type-icon .f1 { fill: currentColor; stroke: none; }
.shc-type-icon .f2 { fill: currentColor; fill-opacity: .45; stroke: none; }
.shc-type-icon .ring { stroke-width: 3.2; stroke-opacity: .45; }
.shc-type-icon .ring2 { stroke-width: 3.2; }
.shc-type-icon .sep { stroke: var(--surface); stroke-width: 1.2; }
.shc-type-icon .box { stroke: var(--text-3); stroke-width: 1.3; }

/* series list */
.shc-series-list { display: flex; flex-direction: column; gap: 2px; margin: 0 -8px; padding: 0; list-style: none; }
.shc-series-item { display: flex; align-items: center; gap: 10px; min-height: 44px; padding: 4px 4px 4px 10px; border-radius: 8px; }
.shc-series-item:hover, .shc-series-item:focus-within { background: var(--surface-2); }
.shc-dot { flex: none; width: 12px; height: 12px; border-radius: 3px; box-shadow: inset 0 0 0 1px var(--shc-ring); }
.shc-series-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.shc-series-name, .shc-series-range { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.shc-series-name { font-size: 13.5px; color: var(--text); }
.shc-series-range { font-size: 12px; color: var(--text-3); font-family: var(--mono); }
.shc-series-item .select { flex: none; width: 104px; height: 30px; padding-left: 8px; font-size: 12.5px; }
.shc-series-empty { padding: 8px 10px; font-size: 13px; color: var(--text-3); }
.shc-add { align-self: flex-start; margin-top: 8px; }
.shc-add .icon { width: 16px; height: 16px; }

/* customise: collapsible sections */
.shc-acc { margin: 0 -20px; border-bottom: 1px solid var(--border); }
.shc-acc-h { margin: 0; font: inherit; }
.shc-acc-btn { display: flex; align-items: center; gap: 8px; width: 100%; min-height: 48px; padding: 0 20px; border: 0; background: none; color: var(--text);
  font-size: 14px; font-weight: 600; text-align: left; cursor: pointer; }
.shc-acc-btn > span { flex: 1; }
.shc-acc-btn:hover { background: var(--surface-2); }
.shc-acc-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.shc-acc-btn .icon { color: var(--text-2); transition: transform .15s; }
.shc-acc-btn[aria-expanded="true"] .icon { transform: rotate(180deg); }
.shc-acc-body { padding: 0 20px 18px; }
.shc-acc-body > .shc-select:first-child { margin-top: 2px; }
.shc-acc-body > .shc-field:first-child { margin-top: 2px; }
@media (prefers-reduced-motion: reduce) { .shc-acc-btn .icon { transition: none; } }

/* colour field */
.shc-color-btn { display: flex; align-items: center; gap: 8px; width: 100%; height: 36px; padding: 0 8px 0 10px; border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm); background: var(--surface); color: var(--text); cursor: pointer; font-size: 13px; text-align: left; }
.shc-color-btn:hover { background: var(--surface-2); }
.shc-color-btn:focus-visible { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--sel); }
.shc-color-btn .icon { color: var(--text-2); }
.shc-swatch { flex: none; width: 18px; height: 18px; border-radius: 50%; box-shadow: inset 0 0 0 1px var(--shc-ring); }
.shc-color-text { flex: 1; min-width: 0; font-family: var(--mono); font-size: 12.5px; color: var(--text-2); }

/* ---------------------------------------------------------------- popups (inside ui.popover's .menu) */
.menu.shc-pop { padding: 10px; max-width: calc(100vw - 16px); }
.shc-types { display: flex; flex-direction: column; width: 196px; max-height: min(460px, 70vh); overflow-y: auto; }
.shc-types-head { margin: 8px 2px 4px; font-size: 11.5px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--text-3); }
.shc-types-head:first-child { margin-top: 0; }
.shc-types-row { display: grid; grid-template-columns: repeat(3, 56px); gap: 8px; }
.shc-type-opt { display: grid; place-items: center; width: 56px; height: 44px; padding: 0; border: 1px solid var(--border); border-radius: 8px;
  background: var(--surface); cursor: pointer; }
.shc-type-opt:hover { background: var(--surface-2); }
.shc-type-opt:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.shc-type-opt.on { border-color: var(--accent); background: var(--accent-weak); }
.shc-type-opt .shc-type-icon { width: 28px; height: 28px; }

.shc-colors { display: flex; flex-direction: column; gap: 10px; width: 236px; }
.shc-auto { width: 100%; }
.shc-swatches { display: grid; grid-template-columns: repeat(8, 22px); justify-content: space-between; row-gap: 8px; }
.shc-swatch-opt { width: 22px; height: 22px; padding: 0; border: 0; border-radius: 50%; box-shadow: inset 0 0 0 1px var(--shc-ring); cursor: pointer; }
.shc-swatch-opt:hover { transform: scale(1.12); }
.shc-swatch-opt.on, .shc-swatch-opt:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.shc-custom { display: flex; align-items: center; gap: 6px; }
.shc-pop .input.shc-hex { flex: 1; min-width: 0; height: 32px; padding: 0 8px; font-family: var(--mono); font-size: 12.5px; }
.shc-hex[aria-invalid="true"] { border-color: var(--danger); }
@media (prefers-reduced-motion: reduce) { .shc-swatch-opt:hover { transform: none; } }
