/* ============================================================
   Dega.UI — global stylesheet entry point
   ------------------------------------------------------------
   This is the ONE stylesheet a consuming app links to pull in
   the Dega design system:

     <link rel="stylesheet"
           href="_content/Dega.UI/css/dega-ui.css" />

   It loads the design tokens (the single source of truth for
   colors, type scale, spacing, and semantic roles) plus the
   element defaults. Per-component styles ship as scoped CSS and
   are bundled automatically into the consumer's
   {AssemblyName}.styles.css — link that too.
   ============================================================ */

@import './tokens.css';
@import './grid.css';

/* Global box-sizing reset — the design system sizes everything border-box
   (ported from the mockup's base.css `* { box-sizing: border-box }`). Without
   this, component padding adds to declared widths and layouts drift. */
*, *::before, *::after {
    box-sizing: border-box;
}

/* Visually-hidden but screen-reader-accessible and focusable. Gives icon-only or custom
   controls (e.g. an editable section heading) a programmatic name/heading without changing
   the visual layout. */
.dega-sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Zero the browser's default body margin (ported from base.css
   `html, body { margin:0; padding:0 }`) — otherwise an 8px white frame
   shows around the full-height app shell. */
html, body {
    margin: 0;
    padding: 0;
}

/* ============================================================
   Chart primitives (DegaPieChart / DegaLineChart / DegaBarChart /
   DegaCategoryBarChart). Ships with Dega.UI so the components are
   self-contained. Ported from the FBOLinx analytics chart styles.
   ============================================================ */
.dega-pie-wrap { display: flex; align-items: center; gap: 14px; width: 100%; justify-content: space-between; }
.dega-pie { flex-shrink: 0; }
.dega-pie-center-label { font-size: 10px; fill: var(--fg-3); font-family: var(--font-sans); font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; }
.dega-pie-center-val { font-size: 20px; fill: var(--fg-1); font-family: var(--font-display); font-weight: 700; }
.dega-pie-legend { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 5px; font-size: 12px; flex: 1; min-width: 0; }
.dega-pie-legend li { display: grid; grid-template-columns: 12px 1fr auto; gap: 8px; align-items: center; }
.dega-chart-dot { width: 10px; height: 10px; border-radius: 3px; display: inline-block; flex-shrink: 0; }
.dega-pie-name { font-size: 12px; color: var(--fg-2); white-space: normal; overflow-wrap: anywhere; }
.dega-pie-val { font-size: 12px; color: var(--fg-1); font-weight: 600; text-align: right; }

.dega-bar-wrap { display: flex; flex-direction: column; gap: 8px; }
.dega-bar-legend { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px 18px; justify-content: center; }
.dega-bar-legend li { display: inline-flex; align-items: center; gap: 7px; font-size: 12px; color: var(--fg-2); }
.dega-bar-legend-dot { width: 11px; height: 11px; border-radius: 3px; flex-shrink: 0; }

.dega-line-wrap { display: flex; gap: 14px; align-items: center; width: 100%; }
.dega-line-plot { flex: 1; min-width: 0; position: relative; }
.dega-line-legend { background: var(--gray-50); border: 1px solid var(--border-1); border-radius: var(--radius-sm); padding: 8px 10px; display: flex; flex-direction: column; gap: 4px; flex-shrink: 0; min-width: 100px; }
.dega-line-legend-title { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--fg-3); margin-bottom: 2px; }
.dega-line-legend-item { display: inline-flex; align-items: center; gap: 6px; font-size: 11.5px; color: var(--fg-2); }

/* Interactive charts: the hover tooltip anchors to the plot, and every node inside the plotting surface is
   pointer-transparent so the <svg> itself stays the event target — that keeps PointerEventArgs.OffsetX
   measured against the viewBox rather than against whichever bar or gridline happened to be under the cursor. */
.dega-bar-plot { position: relative; }
.dega-chart-hit * { pointer-events: none; }
.dega-chart-hit rect,
.dega-chart-hit g { transition: opacity 0.12s ease; }
.dega-chart-tip { position: absolute; top: 4px; transform: translateX(-50%); pointer-events: none; z-index: 2; min-width: 140px; background: var(--bg-surface); border: 1px solid var(--border-1); border-radius: var(--radius-sm); box-shadow: var(--shadow-md); padding: 7px 9px; }
.dega-chart-tip-label { font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; color: var(--fg-3); margin-bottom: 4px; }
.dega-chart-tip-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; font-size: 11.5px; color: var(--fg-2); line-height: 1.7; }
.dega-chart-tip-dot { width: 8px; height: 8px; border-radius: 2px; display: inline-block; margin-right: 6px; flex-shrink: 0; }
.dega-chart-tip-val { font-family: var(--font-mono); font-weight: 600; color: var(--fg-1); }

/* DegaChartHeader — live legend + value + trend above a chart */
.dega-chart-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 6px; }
.dega-chart-head-stats { display: flex; align-items: flex-start; gap: 22px; flex-wrap: wrap; }
.dega-chart-head-stat { display: inline-flex; align-items: center; gap: 8px; }
.dega-chart-head-dot { width: 10px; height: 10px; border-radius: 3px; flex-shrink: 0; }
.dega-chart-head-body { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.dega-chart-head-name { font-size: 11px; color: var(--fg-3); white-space: nowrap; }
.dega-chart-head-val { font-size: 15px; font-weight: 700; color: var(--fg-1); font-family: var(--font-mono); }
.dega-chart-head-delta { display: inline-flex; align-items: center; gap: 2px; font-size: 11px; font-weight: 600; }
.dega-chart-head-delta.is-up { color: var(--success-600); }
.dega-chart-head-delta.is-down { color: var(--danger-600); }
.dega-chart-head-ctx { font-size: 11px; color: var(--fg-3); font-family: var(--font-mono); white-space: nowrap; }

/* ============================================================
   DegaMoneyInput — bare decimal/price input (chrome from wrapper)
   ============================================================ */
.dega-money-input {
  border: 0; outline: 0; background: transparent;
  font-family: var(--font-mono); font-size: 14px;
  color: var(--fg-1);
  font-variant-numeric: tabular-nums;
  width: 100%; min-width: 0;
  padding: 0;
}
.dega-money-input::placeholder { color: var(--fg-4); }
.dega-money-input::-webkit-outer-spin-button,
.dega-money-input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

/* ============================================================
   DegaDatePicker — month-grid calendar panel
   ============================================================ */
.dega-datepicker {
  position: absolute; z-index: 60; top: calc(100% + 6px); left: 0;
  width: 240px; padding: 12px;
  background: var(--bg-surface);
  border: 1px solid var(--border-1);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
}
.dega-dp-head {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 13px; font-weight: 700; color: var(--fg-1);
  margin-bottom: 8px;
}
.dega-dp-head button {
  background: transparent; border: 0; cursor: pointer;
  width: 22px; height: 22px;
  display: flex; align-items: center; justify-content: center;
  color: var(--fg-2); border-radius: var(--radius-sm);
}
.dega-dp-head button:hover { background: var(--gray-100); color: var(--fg-1); }
.dega-dp-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; font-size: 11.5px; }
.dega-dp-dow { text-align: center; color: var(--fg-3); font-weight: 700; font-size: 10.5px; padding: 4px 0; }
.dega-dp-day {
  background: transparent; border: 0; cursor: pointer;
  width: 28px; height: 28px; border-radius: var(--radius-sm);
  font-family: var(--font-mono); font-size: 12px; font-weight: 500;
  color: var(--fg-1);
  display: flex; align-items: center; justify-content: center;
}
.dega-dp-day:hover { background: var(--gray-100); }
.dega-dp-day.is-other { color: var(--fg-4); }
.dega-dp-day.is-today { color: var(--brand-500); font-weight: 700; }
.dega-dp-day.is-selected { background: var(--brand-500); color: white; }
.dega-dp-day.is-disabled { color: var(--fg-4); cursor: not-allowed; opacity: 0.4; }
.dega-dp-day.is-disabled:hover { background: transparent; }

/* ============================================================
   DegaDateField — labelled chip that opens a DegaDatePicker popover
   ============================================================ */
.dega-date-field-wrap { position: relative; display: inline-flex; }
.dega-date-field {
  display: inline-flex; align-items: center; gap: 5px;
  background: var(--gray-50);
  border: 1px solid var(--border-1);
  border-radius: var(--radius-sm);
  padding: 4px 8px;
  font-size: 11px;
  color: var(--fg-2);
  cursor: pointer;
}
.dega-date-field:hover { background: var(--gray-100); }
.dega-date-field-label { color: var(--fg-3); font-weight: 600; }
.dega-date-field-val { font-family: var(--font-mono); }
.dega-date-field svg { color: var(--fg-3); }
.dega-date-field-wrap.is-align-end .dega-datepicker { left: auto; right: 0; }

/* ============================================================
   DegaFocusSentinel — shared focus-trap sentinel (any bespoke expand/overlay, not
   just DegaModalShell): tabbable but visually hidden; on focus it bounces to the
   opposite edge, keeping Tab/Shift+Tab inside the container. Pair with
   data-focus-sentinel (fboFocusEdge already filters it out) and an @onfocus handler
   that calls fboFocusEdge(container, "first"/"last").
   ============================================================ */
.dega-focus-sentinel {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  opacity: 0;
}

/* ============================================================
   DegaProportionBar — segmented composition bar
   ============================================================ */
.dega-proportion-bar {
  display: flex; height: 14px; border-radius: 999px; overflow: hidden;
  background: var(--gray-100);
}
.dega-proportion-bar-mini { height: 8px; min-width: 56px; }
.dega-proportion-seg { height: 100%; }
.dega-proportion-seg + .dega-proportion-seg { box-shadow: inset 1px 0 0 rgba(255,255,255,.65); }
