/* PanelAlpha Connect - Design Tokens (PanelAlpha 2.0 Design System restyle, 2026-11-01)
 *
 * The look comes from the PanelAlpha 2.0 Design System: every value points at a DS ROLE
 * (--pui-*, defined in ./ds-tokens.css). Layout is unchanged - the GEOMETRY tokens that carry
 * structure (nav height, container width, control sizes, blur radii) keep the product's values;
 * type sizes, weights and radii map onto the DS scale. The same mapping is applied in every
 * component's scoped styles (approved design: DS catalog family "Propozycja 2.0 - Hub").
 *
 * COLOR tokens below are kept for inline styles and scripts that read them (e.g. MetricChart);
 * components read the DS roles directly. They are re-declared on every [data-theme] element so a
 * nested theme root (the order wizard) resolves them against its own roles.
 *
 * Dark theme = the DS dark context (ds-tokens.css applies it to data-theme="dark"); the block at
 * the end fills the roles the DS dark context does not switch.
 *
 * All component colors MUST use variables only - never hardcode hex.
 */

/* ── Geometry (shared by both themes) ─────────────────────────────────── */
:root {

  /* === GEOMETRY (shared - consumed identically by both themes) === */

  /* Radius by box type, on the DS component roles: card / panel / tile -> the DS card, field /
     control -> the DS small field, button -> the DS small button */
  --radius-card: var(--pui-blog-card-latest-update-body-radius);
  --radius-panel: var(--pui-blog-card-latest-update-body-radius);
  --radius-tile: var(--pui-blog-card-latest-update-body-radius);
  --radius-input: var(--pui-form-sm-radius);
  --radius-control: var(--pui-form-sm-radius);
  --radius-pill: var(--pui-ui-radius-rounded);
  /* Legacy alias: existing components reference --radius-button; keep until Phases 23/24 migrate */
  --radius-button: var(--pui-button-sm-radius);

  /* DS-05: Typography scale on the DS type roles (nearest DS step to the previous scale):
   * H1 29 -> h5 · H2 20 -> h7 · H3 17 -> h8 · table-name 15 -> p-base · body 14.5 -> p-sm
   * muted / col-label / version-label 13-12 -> p-xs · sub-text 10 -> p-xxs · timer 27 -> h5.
   * Weights: 800/900 -> bold (700 is the heaviest DS weight). */
  --fs-h1: var(--pui-text-h5-font-size);
  --fw-h1: var(--pui-font-weight-bold);
  --ls-h1: var(--pui-text-h5-letter-spacing);

  --fs-h2: var(--pui-text-h7-font-size);
  --fw-h2: var(--pui-font-weight-bold);

  --fs-h3: var(--pui-text-h8-font-size);
  --fw-h3: var(--pui-font-weight-semi-bold);

  --fs-table-name: var(--pui-text-p-base-font-size);
  --fw-table-name: var(--pui-font-weight-bold);

  /* Table rhythm tokens (mockup: airy rows, quiet uppercase headers) */
  --table-row-height: 60px;
  --table-cell-pad-y: var(--pui-table-cell-padding-v);
  --table-cell-pad-x: var(--pui-table-cell-padding-h);

  --fs-body: var(--pui-text-p-sm-font-size);
  --fw-body: var(--pui-font-weight-regular);
  --lh-body: var(--pui-text-p-sm-line-height);

  --fs-muted: var(--pui-text-p-xs-font-size);

  --fs-sub-text: var(--pui-text-p-xxs-font-size);

  --fs-version-label: var(--pui-text-p-xs-font-size);

  --fs-nav: var(--pui-text-p-base-font-size);
  --fw-nav: var(--pui-font-weight-bold);

  --fs-col-label: var(--pui-text-p-xs-font-size);
  --fw-col-label: var(--pui-font-weight-medium);
  --ls-col-label: 0;

  /* DS-05: Named token for action/management grid card labels (UI-SPEC FLAG 2).
   * Use var(--fw-card-label) instead of inlining 700 in card component styles. */
  --fw-card-label: var(--pui-font-weight-bold);

  --fs-timer: var(--pui-text-h5-font-size);
  --fw-timer: var(--pui-font-weight-bold);

  /* DS-06: Spacing scale - 4px base ladder matching mockup padding clusters
   * --space-1: 4px   (tight icon gap, pill vertical pad)
   * --space-2: 8px   (pill horizontal pad, small gap)
   * --space-3: 12px  (field icon left, card inner gap)
   * --space-4: 16px  (table cell, form input pad)
   * --space-5: 20px  (section gap small)
   * --space-6: 24px  (nav gutter, section gap)
   * --space-8: 30px  (container top pad)
   * --space-10: 40px (section vertical rhythm)
   * --space-12: 48px (page section gap)
   * --space-16: 70px (container bottom pad, = --nav-height) */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 30px;
  --space-10: 40px;
  --space-12: 48px;
  --space-16: 70px;

  /* DS-06: Layout vars, on the DS frame: the DS container, and the DS main navigation
     (its 12px top and bottom padding around a 64px bar = 88px) */
  --container-max: var(--pui-container-width-max);
  /* A narrow one-task page (the order form, "+ Add New" install / connect steps):
     its width with the container padding included. */
  --page-narrow-max: 980px;
  --nav-height: calc(var(--pui-navigation-main-padding-top) + 64px + var(--pui-navigation-main-padding-bottom));
  --control-h: var(--pui-form-sm-height);
  /* The PanelAlpha Hub lockup is wider than the DS logo (HUB under the wordmark), so, like Go's
     GO lockup, it stands 44px high instead of the DS's 56 (36 on phones; 40 in the footer). */
  --logo-height: 44px;

  /* FX-01: Glass blur radii (geometry only - shared, never in [data-theme]) */
  --blur-glass: 10px;     /* nav frosted-glass backdrop blur radius */
  --blur-scrim: 4px;      /* modal scrim backdrop blur radius */

  /* Phase 24: cards/boxes + buttons (CARD-01..04, BTN-01) - GEOMETRY
   * All purely numeric/positional values below. Color-bearing tokens (gradient
   * stops, shadow rgba, inset rgba, tonal-border rgba, glow rgba) are in the
   * COLOR sections of: root (light) and [data-theme='dark'] - see Task 2. */

  /* CARD-03: card padding = the DS card's */
  --card-pad: var(--pui-blog-card-latest-update-body-padding-v);

  /* CARD-01: diagonal gradient wash direction (color stops are per-theme) */
  --elevated-gradient-angle: 145deg;

  /* CARD-02: inset top-edge highlight position/spread (rgba color is per-theme)
   * NOTE: components use the per-theme --inset-highlight var (full box-shadow string).
   * This offset var is provided as a structural reference. */
  --inset-highlight-offset: inset 0 1px 0;

  /* CARD-04: hover-lift raise for clickable tiles (respect prefers-reduced-motion
   * in components) */
  --hover-lift-y: -3px;

  /* BTN-01: large/CTA button = the DS base button */
  --btn-h-lg: var(--pui-button-base-height);
  --btn-fs-lg: var(--pui-text-p-lg-font-size);
  /* Removed --btn-radius-lg (260628-n7m): all buttons share --radius-button (8px) so
     corner rounding matches the login "Continue with Google" button. */
}

/* Phones: Go's 72px bar (the DS navigation padding around a 48px row) */
@media (max-width: 767.98px) {
  :root {
    --nav-height: calc(var(--pui-navigation-main-padding-top) + 48px + var(--pui-navigation-main-padding-bottom));
    --logo-height: 36px;
  }
}

/* ── Brand: the Hub logo's teal (like Go's forest green) ─────────────────
   The PanelAlpha Hub logo's teals (its gradient's stops; the HUB word is the dark one on light
   grounds, the main one on dark grounds). They take the place of the DS's green primary scale,
   so every primary role follows the logo, on the base teal #009A84 (a shade deeper than the
   logo's main #1FB09C): the buttons (600, 650 on hover; 550 on hover in dark), the green text and
   labels (600 on a 50 tint; 400 / 350 in dark), the accents (500), the light ones (100-400).
   Steps between the stops are mixed from them. */
:root {
  --logo-teal-d1: #0C7468;
  --logo-teal: #1FB09C;
  --logo-teal-l1: #63E5D3;
  --primary-base: #009A84;

  --static-primary-50: #E4F6F3;
  --static-primary-100: #C0E9E3;
  --static-primary-150: #B0E8E0;
  --static-primary-200: #A1E8DE;
  --static-primary-250: #92E7DB;
  --static-primary-300: #82E6D8;
  --static-primary-350: #72E6D6;
  --static-primary-400: var(--logo-teal-l1);
  --static-primary-450: #41CAB8;
  --static-primary-500: var(--primary-base);
  --static-primary-550: #37C3AF;
  --static-primary-600: var(--primary-base);
  --static-primary-650: var(--logo-teal-d1);
  --static-primary-700: #0B665C;
  --static-primary-750: #09574E;
  --static-primary-800: #074840;
  --static-primary-850: #063832;
  --static-primary-900: #042723;
  --static-primary-950: #02100F;
}

/* and the fields' hover and focus borders and their icons, not the DS's orange (both themes;
   the selector matches the DS dark context's so it wins there too) */
:root,
:root[data-theme='dark'],
[data-theme='dark'],
[data-context="on-dark"] {
  --pui-form-border-hover: var(--primary-base);
  --pui-form-border-active: var(--primary-base);
  --pui-form-icon: var(--primary-base);
}

/* ── Color (product tokens -> DS roles) ───────────────────────────────── */
:root,
[data-theme] {
  --bg: var(--pui-table-bg-muted);
  --surface: var(--pui-surface-solid-main);
  --surface-2: var(--pui-table-bg-muted);
  --surface-3: var(--pui-label-default-faded-bg);
  --primary: var(--pui-text-primary);
  --primary-dark: var(--pui-button-primary-solid-bg-hover);
  --primary-soft: var(--pui-label-primary-faded-bg);
  --text-on-primary: var(--pui-button-primary-solid-fg);
  --text-on-error: var(--pui-label-red-solid-fg);
  --text: var(--pui-text-heading);
  --muted: var(--pui-text-lighter);
  --dim: var(--pui-text-faded);
  --border: var(--pui-panel-border);
  --border-2: var(--pui-form-border);
  --ok: var(--pui-text-primary);
  --ok-soft: var(--pui-label-primary-faded-bg);
  --ok-glow: transparent;
  --error: var(--pui-text-red);
  --error-soft: var(--pui-label-red-faded-bg);
  --error-glow: transparent;
  --warn: var(--pui-text-orange);
  --warn-soft: var(--pui-label-orange-faded-bg);
  --info: var(--pui-text-blue);
  --info-soft: var(--pui-label-default-faded-bg);
  --idle: var(--pui-text-faded);
  --idle-soft: var(--pui-label-default-faded-bg);
  --usage-low: var(--pui-label-primary-solid-bg);
  --usage-med: var(--pui-label-orange-solid-bg);
  --usage-high: var(--pui-label-orange-solid-bg);
  --usage-crit: var(--pui-label-red-solid-bg);
  --card-shadow: 0 0 0 var(--pui-ui-border-outline-border-width) var(--pui-panel-border);
  --nav-shadow: 0 var(--pui-ui-border-divider-width) 0 0 var(--pui-navigation-separator);
  --surface-input: var(--pui-form-bg);
  --focus-ring: var(--pui-label-primary-faded-bg);
  --cta-gradient: none;
  --login-gradient: none;
  --add-new-gradient: none;
  --add-new-glow: transparent;
  --login-glow-1: transparent;
  --login-glow-2: transparent;
  --surface-elevated: var(--pui-surface-solid-main);
  --shadow-elevated: 0 14px 30px 0 var(--pui-sub-navigation-shadow-black);
  --inset-highlight: 0 0 transparent;
  --border-tonal-lava: var(--pui-button-primary-outline-border);
  --border-tonal-magenta: var(--pui-text-blue);
  --border-tonal-amber: var(--pui-text-orange);
  --border-tonal-green: var(--pui-button-primary-outline-border);
  --glow-selected: 0 0 0 var(--pui-ui-border-outline-border-width) var(--pui-button-primary-outline-border);
  --glow-hover-tile: 0 14px 30px 0 var(--pui-sub-navigation-shadow-black);
  --glass-nav-bg: var(--pui-navigation-bg-scroll);
  --glass-scrim-bg: var(--static-overlay-dark-300);
  --success: var(--pui-text-primary);
  --primary-light: var(--pui-text-primary);
  --btn-glow: 0 0 transparent;
  color-scheme: light;
}

/* ── Dark theme: roles the DS dark context does not switch ───────────────
   Missing in the DS (proposal from the design, built from DS palette steps the way the
   neighbouring dark roles are): page / table backgrounds, dropdown panels, tooltips; the
   navigation bar after scroll is white in the DS. */
:root[data-theme='dark'],
[data-theme='dark'] {
  --pui-table-bg-muted: var(--static-gray-950);
  --pui-table-border: var(--static-overlay-light-100);
  --pui-table-divider: var(--static-overlay-light-100);
  /* footer copyright separator: the DS keeps its light gray-100 on dark (a bright line) */
  --pui-footer-separator: var(--static-overlay-light-100);
  --pui-table-hover: var(--static-overlay-light-50);
  --pui-navigation-bg-scroll: var(--static-gray-1000);
  --pui-sub-navigation-bg: var(--static-gray-950);
  --pui-sub-navigation-border: var(--static-overlay-light-100);
  --pui-tooltip-bg: var(--static-gray-950);
  --pui-label-red-faded-bg: var(--static-overlay-light-100);
  --pui-label-info-solid-bg: var(--static-blue-500);
  color-scheme: dark;
}

/* ── PanelAlpha GO order route (`.order-page--go`) ─────────────────────────
 * Same order layout; the GO route stays dark (OrderLayout forces it) and, in the DS restyle,
 * uses the DS palette and the Hub logotype like every other page (decision 2026-11-01). */

/* ── DS-05: Typography utility classes ────────────────────────────────────
   Apply these classes to elements instead of per-component font-size/weight.
   All values reference the vars above; no literal px in the class bodies. */
.t-h1 {
  font-size: var(--pui-text-h5-font-size);
  font-weight: var(--pui-font-weight-bold);
  letter-spacing: var(--pui-text-h5-letter-spacing);
}

.t-h2 {
  font-size: var(--pui-text-h7-font-size);
  font-weight: var(--pui-font-weight-bold);
}

.t-h3 {
  font-size: var(--pui-text-h8-font-size);
  font-weight: var(--pui-font-weight-semi-bold);
}

.t-table-name {
  font-size: var(--pui-text-p-base-font-size);
  font-weight: var(--pui-font-weight-bold);
}

.t-body {
  font-size: var(--pui-text-p-sm-font-size);
  font-weight: var(--pui-font-weight-regular);
  line-height: var(--pui-text-p-sm-line-height); /* TYPE-02: airier body rhythm for prose */
}

.t-muted {
  font-size: var(--pui-text-p-xs-font-size);
  color: var(--pui-text-lighter);
}

.t-nav {
  font-size: var(--pui-text-p-base-font-size);
  font-weight: var(--pui-font-weight-bold);
}

/* Column label: normal-case muted (reference: pa-styles2.png table headers) */
.t-col-label {
  font-size: var(--pui-text-p-xs-font-size);
  font-weight: var(--pui-font-weight-medium);
  letter-spacing: 0;
  color: var(--pui-text-lighter);
}

/* Timer: tabular-nums for stable digit widths */
.t-timer {
  font-size: var(--pui-text-h5-font-size);
  font-weight: var(--pui-font-weight-bold);
  font-variant-numeric: tabular-nums;
}

/* ── Auth input affordances: leading icon + password eye toggle ───────────
   Shared by all auth views so the markup stays consistent without per-view CSS.
   These match on element class, so they apply to scoped `.field-input` too. */
.field-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.field-wrap > .field-input {
  flex: 1;
  min-width: 0;
}

.field-icon {
  position: absolute;
  left: 12px;
  color: var(--pui-text-faded);
  pointer-events: none;
}

.field-input--icon {
  padding-left: var(--pui-layout-padding-xl);
}

.field-input--password {
  padding-right: var(--pui-layout-padding-xl);
}

.field-eye {
  position: absolute;
  right: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border: none;
  background: transparent;
  color: var(--pui-text-faded);
  cursor: pointer;
  border-radius: var(--pui-ui-radius-md);
  transition: color 0.15s;
}

.field-eye:hover {
  color: var(--pui-text-lighter);
}

/* ── HOVER-ON-HOVER convention (touch-safe hover) ─────────────────────────
   On touch devices a tap synthesizes a :hover that "sticks" until the next
   tap elsewhere, leaving rows/buttons visually stuck in their hover state.
   To prevent this, scope every component :hover rule behind a
   `@media (hover: hover)` query so hover styles only apply to devices that
   have a true hover-capable pointer (mouse / trackpad), never to touch taps.

   Convention for ALL components (scoped CSS):
     .thing:hover { ... }            ->   wrap it:
     @media (hover: hover) {
       .thing:hover { ... }
     }

   Keep non-hover interaction states (:active, :focus-visible, :disabled)
   OUTSIDE the query so they still work on touch. Colors stay token-only. */

/* ── Base reset using tokens ──────────────────────────────────────────── */
*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: 'Figtree', system-ui, sans-serif;
  background-color: var(--pui-table-bg-muted);
  color: var(--pui-text-heading);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Form controls do NOT inherit font-family by default - native <button>/<input>/
   <select>/<textarea> fall back to the browser UA font. Force them to inherit so
   every button in the system (kebab triggers, dropdown items, etc.) renders in
   Figtree, not the UA default. */
button,
input,
select,
textarea {
  font-family: inherit;
}

/* ── Item 12: shared copy green-flash utility ─────────────────────────────
   Consumers (CopyableIp, license-key copy) toggle the `.copy-flash--active`
   class via useCopyFlash().flashing on a successful copy. A short green pulse
   (background + outline) using --ok / --ok-soft. Reduced-motion safe: the
   keyframe is disabled under prefers-reduce-motion (no flash, no throw). */
@keyframes copy-flash-pulse {
  0% {
    background-color: var(--pui-label-primary-faded-bg);
    box-shadow: 0 0 0 2px var(--pui-button-primary-outline-border);
  }
  100% {
    background-color: transparent;
    box-shadow: 0 0 0 2px transparent;
  }
}

.copy-flash--active {
  animation: copy-flash-pulse 0.6s ease-out;
}

@media (prefers-reduced-motion: reduce) {
  .copy-flash--active {
    animation: none;
  }
}
