/* Connector design tokens.
   Audience: external customer admins. Tone: friendly, approachable, guided.
   Palette: warm ink-indigo brand, neutrals tinted toward hue 270. */

:root {
    /* Brand / accent ----------------------------------------------------- */
    --c-accent:            oklch(48% 0.14 270);
    --c-accent-hover:      oklch(43% 0.14 270);
    --c-accent-pressed:    oklch(38% 0.14 270);
    --c-accent-soft:       oklch(95% 0.03 270);
    --c-accent-soft-2:     oklch(90% 0.05 270);
    --c-accent-on:         oklch(99% 0.002 270);

    /* Surfaces (tinted toward brand hue for subtle cohesion) ------------- */
    --c-canvas:            oklch(98.5% 0.004 270);
    --c-surface:           oklch(100% 0 0);
    --c-surface-muted:     oklch(97% 0.006 270);
    --c-surface-sunken:    oklch(96% 0.008 270);

    /* Borders ------------------------------------------------------------- */
    --c-border:            oklch(92% 0.006 270);
    --c-border-strong:     oklch(86% 0.01 270);
    --c-divider:           oklch(94% 0.005 270);

    /* Text ---------------------------------------------------------------- */
    --c-text:              oklch(22% 0.01 270);
    --c-text-muted:        oklch(48% 0.01 270);
    --c-text-subtle:       oklch(62% 0.008 270);
    --c-text-on-accent:    oklch(99% 0.002 270);

    /* Semantic ------------------------------------------------------------ */
    --c-success:           oklch(55% 0.13 150);
    --c-success-soft:      oklch(96% 0.04 150);
    --c-warning:           oklch(70% 0.14 70);
    --c-warning-soft:      oklch(97% 0.05 85);
    --c-danger:            oklch(58% 0.18 25);
    --c-danger-soft:       oklch(96% 0.04 25);
    --c-info:              oklch(58% 0.12 240);
    --c-info-soft:         oklch(96% 0.03 240);

    /* Partner tints (from existing logo chips, re-keyed in OKLCH) -------- */
    --c-paradigm-soft:     oklch(96% 0.03 270);
    --c-hubspot-soft:      oklch(96% 0.04 45);

    /* Spacing scale (4pt) ------------------------------------------------- */
    --space-1:  4px;
    --space-2:  8px;
    --space-3:  12px;
    --space-4:  16px;
    --space-5:  24px;
    --space-6:  32px;
    --space-7:  48px;
    --space-8:  64px;
    --space-9:  96px;

    /* Radii --------------------------------------------------------------- */
    --radius-xs:   4px;
    --radius-sm:   6px;
    --radius-md:   10px;
    --radius-lg:   14px;
    --radius-pill: 9999px;

    /* Type scale --------------------------------------------------------- */
    /* Fixed rem scale for app UI — predictability for dense, container-
       based layouts. Only the hero display size is fluid via clamp. */
    --text-xs:      0.75rem;    /* 12px — tiny labels, captions */
    --text-sm:      0.8125rem;  /* 13px — secondary body, dense tables */
    --text-base:    0.9375rem;  /* 15px — default body */
    --text-md:      1rem;       /* 16px — emphasized body, small titles */
    --text-lg:      1.125rem;   /* 18px — card titles, section subheads */
    --text-xl:      1.375rem;   /* 22px — larger section headings */
    --text-2xl:     1.75rem;    /* 28px — major headings */
    --text-display: clamp(2.25rem, 1.75rem + 1.5vw, 2.75rem); /* 36–44px fluid */

    /* Line heights */
    --lh-display: 1.05;
    --lh-tight:   1.2;
    --lh-snug:    1.35;
    --lh-base:    1.5;
    --lh-prose:   1.6;

    /* Letter-spacing — tighter as type gets bigger (optical compensation) */
    --tracking-display: -0.032em;
    --tracking-heading: -0.01em;

    /* Weights (General Sans) */
    --fw-regular:  400;
    --fw-medium:   500;
    --fw-semibold: 600;
    --fw-bold:     700;

    /* Shadows — subtle, warm ink cast */
    --shadow-xs:  0 1px 2px -1px oklch(22% 0.05 270 / 0.08);
    --shadow-sm:  0 1px 3px -1px oklch(22% 0.05 270 / 0.10),
                  0 1px 2px -1px oklch(22% 0.05 270 / 0.06);
    --shadow-md:  0 4px 12px -4px oklch(22% 0.05 270 / 0.12),
                  0 2px 4px -2px oklch(22% 0.05 270 / 0.08);
    --shadow-lg:  0 12px 32px -8px oklch(22% 0.05 270 / 0.16),
                  0 4px 8px -4px oklch(22% 0.05 270 / 0.08);

    /* Motion */
    --ease-out:     cubic-bezier(0.22, 1, 0.36, 1);
    --ease-out-2:   cubic-bezier(0.16, 1, 0.3, 1);
    --dur-fast:     140ms;
    --dur-med:      220ms;
    --dur-slow:     360ms;

    /* Focus ring — brand-tinted, accessible */
    --ring:        0 0 0 3px oklch(48% 0.14 270 / 0.28);

    /* Sync-config shell width — centers header, content shell, and save
       footer on the same axis. Single source of truth. */
    --cfg-shell-max: 1440px;

    /* Approximate height of the sticky brand bar (.cfg-header). Used by
       sticky offsets, scroll-margins, and TOC max-height so that any
       change to the header chrome propagates without hand-tuning magic
       numbers. Buffer it with --space-* tokens at the call site. */
    --cfg-header-h: 64px;
}

/* Font base ---------------------------------------------------------------- */
html, body {
    font-family: 'General Sans', 'Söhne', 'Inter var', system-ui, -apple-system,
                 'Segoe UI', 'Helvetica Neue', sans-serif;
    font-feature-settings: 'cv11', 'ss01', 'ss03';
    font-optical-sizing: auto;
    color: var(--c-text);
    background-color: var(--c-canvas);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

/* Configuration-page scoped utilities --------------------------------------
   Used by SyncConfigurationLayout and its child pages. Keeps the shell
   consistent without fighting MudBlazor's own class surface. */

.cfg-canvas {
    background-color: var(--c-canvas);
    min-height: 100vh;
    padding-bottom: var(--space-9);
}

.cfg-shell {
    max-width: var(--cfg-shell-max);
    margin-inline: auto;
    display: flex;
    gap: var(--space-7);
    padding-block: var(--space-5) 0;
    padding-inline: clamp(var(--space-4), 4vw, var(--space-7));
    min-height: calc(100vh - 180px);
}

.cfg-nav {
    width: 320px;
    min-width: 320px;
    background-color: var(--c-surface);
    border: 1px solid var(--c-border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-xs);
    padding: var(--space-2);
    position: sticky;
    top: calc(var(--cfg-header-h) + var(--space-5));
    align-self: flex-start;
    overflow: hidden;
}

.cfg-nav .mud-nav-link {
    border-radius: var(--radius-sm);
    color: var(--c-text-muted);
    font-weight: var(--fw-medium);
    font-size: var(--text-sm);
    letter-spacing: 0.02em;
    transition: background-color var(--dur-fast) var(--ease-out),
                color var(--dur-fast) var(--ease-out);
}
.cfg-nav .mud-nav-link:hover {
    background-color: var(--c-surface-sunken);
    color: var(--c-text);
}
.cfg-nav .mud-nav-link.active {
    background-color: var(--c-accent-soft);
    color: var(--c-accent);
}
.cfg-nav .mud-nav-link.active .mud-icon-root {
    color: var(--c-accent);
}

.cfg-nav-group {
    padding: var(--space-3) var(--space-3) var(--space-2);
    font-size: var(--text-xs);
    font-weight: var(--fw-semibold);
    letter-spacing: 0.09em;
    text-transform: uppercase;
    color: var(--c-text-subtle);
}

.cfg-content {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    /* Query container so child layouts (e.g. SyncDocsPage's sticky TOC)
       adapt to actual content width, not the viewport. */
    container-type: inline-size;
}

/* Vertical rhythm — not every block is a peer. Related items cluster
   tight; major sections get more breath; the hero gets the biggest
   break to the next section. */
.cfg-content > * + *                            { margin-top: var(--space-6); }      /* 32px default */
.cfg-content > .cfg-page-header + *             { margin-top: var(--space-7); }      /* 48px after hero */
.cfg-content > .cfg-note + .cfg-note            { margin-top: var(--space-3); }      /* 12px — cluster */

/* Page header ------------------------------------------------------------
   Hero per sync-configuration page. Asymmetric top row (eyebrow left,
   meta right) breaks the symmetric stacked rhythm. Title does the heavy
   lifting — semibold-bold at 2.25–2.75rem with a tight 1.05 line-height.
   One accent moment lives on the eyebrow dot; everything else is type. */
.cfg-page-header {
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
    padding-top: var(--space-2);
}

.cfg-page-header-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3);
    min-height: 24px;
}

.cfg-page-header-eyebrow {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    font-size: 0.6875rem;
    font-weight: var(--fw-semibold);
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--c-text-subtle);
    line-height: 1;
}

.cfg-page-header-eyebrow-dot {
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background-color: var(--c-accent);
    box-shadow: 0 0 0 3px color-mix(in oklab, var(--c-accent) 18%, transparent);
}

.cfg-page-header-meta {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
}

.cfg-page-header-title {
    font-size: var(--text-display);
    font-weight: var(--fw-bold);
    color: var(--c-text);
    letter-spacing: var(--tracking-display);
    line-height: var(--lh-display);
    margin: 0;
}

.cfg-page-header-desc {
    font-size: var(--text-base);
    color: var(--c-text-muted);
    line-height: var(--lh-prose);
    max-width: 62ch;
    margin: 0;
}

/* Entrance reveal — scoped to the page hero only. Broad child selectors
   would also fire on in-page re-mounts (e.g. when a keyed component is
   re-created on a state change), which reads as lag. */
@media (prefers-reduced-motion: no-preference) {
    .cfg-content > .cfg-page-header {
        animation: cfgEntrance 440ms var(--ease-out-2) both;
    }
}

@keyframes cfgEntrance {
    from { opacity: 0; transform: translateY(10px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* Panel primitive --------------------------------------------------------- */
.cfg-panel {
    background-color: var(--c-surface);
    border: 1px solid var(--c-border);
    border-radius: var(--radius-md);
    overflow: hidden;
    box-shadow: var(--shadow-xs);
}

.cfg-panel-header {
    padding: var(--space-4) var(--space-5);
    display: flex;
    flex-direction: column;
    gap: var(--space-1);
}

.cfg-panel-title {
    font-size: var(--text-lg);
    font-weight: var(--fw-semibold);
    color: var(--c-text);
    letter-spacing: -0.01em;
    line-height: var(--lh-snug);
}

.cfg-panel-desc {
    font-size: var(--text-sm);
    color: var(--c-text-muted);
    line-height: var(--lh-base);
    max-width: 62ch;
}

.cfg-panel-divider {
    height: 1px;
    background-color: var(--c-divider);
    border: 0;
    margin: 0;
}

.cfg-panel-body {
    padding: var(--space-4) var(--space-5) var(--space-5);
}

.cfg-panel-body.pad-dense {
    padding: var(--space-3) var(--space-5) var(--space-4);
}

/* Status pill (replaces inline .strategy-badge hex colors) ---------------- */
.cfg-pill {
    display: inline-flex;
    align-items: center;
    gap: var(--space-1);
    font-size: 0.6875rem;
    font-weight: var(--fw-medium);
    letter-spacing: 0.04em;
    padding: 2px var(--space-2);
    border-radius: var(--radius-pill);
    line-height: 1.4;
    white-space: nowrap;
}
.cfg-pill--active {
    background-color: var(--c-accent-soft);
    color: var(--c-accent);
}
.cfg-pill--muted {
    background-color: var(--c-surface-sunken);
    color: var(--c-text-subtle);
}
.cfg-pill--success {
    background-color: var(--c-success-soft);
    color: var(--c-success);
}
.cfg-pill--danger {
    background-color: var(--c-danger-soft);
    color: var(--c-danger);
}

.cfg-pill-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background-color: currentColor;
    opacity: 0.8;
}

/* Logo header ------------------------------------------------------------
   Outer band is full-bleed so the sticky backdrop-blur spans the viewport;
   inner wrapper centers the brand chrome on the same axis as the shell. */
.cfg-header {
    position: sticky;
    top: 0;
    z-index: 10;
    background-color: color-mix(in oklab, var(--c-surface) 92%, transparent);
    backdrop-filter: saturate(1.2) blur(10px);
    -webkit-backdrop-filter: saturate(1.2) blur(10px);
}

.cfg-header-inner {
    max-width: var(--cfg-shell-max);
    margin-inline: auto;
    padding: var(--space-4) clamp(var(--space-4), 4vw, var(--space-7));
    display: flex;
    align-items: center;
    gap: var(--space-3);
}

.cfg-header-title {
    font-size: var(--text-lg);
    font-weight: var(--fw-semibold);
    color: var(--c-text);
    letter-spacing: -0.01em;
}

.cfg-header-sub {
    font-size: var(--text-xs);
    font-weight: var(--fw-regular);
    color: var(--c-text-subtle);
    letter-spacing: 0.02em;
}

.cfg-logo-chip {
    width: 34px;
    height: 34px;
    min-width: 34px;
    border-radius: var(--radius-sm);
    display: grid;
    place-items: center;
    border: 1px solid var(--c-border);
}
.cfg-logo-chip img { width: 20px; height: 20px; display: block; }
.cfg-logo-chip--paradigm { background-color: var(--c-paradigm-soft); }
.cfg-logo-chip--hubspot  { background-color: var(--c-hubspot-soft); }

.cfg-logo-link {
    font-size: 0.8125rem;
    color: var(--c-text-muted);
    font-weight: var(--fw-medium);
    line-height: 1;
    display: inline-block;
    translate: 0 -1px;
}

/* Save footer ------------------------------------------------------------
   Outer band is full-bleed so the backdrop-blur spans the viewport edge to
   edge; inner wrapper keeps the hint + button aligned with the shell. */
.cfg-footer {
    position: fixed;
    inset: auto 0 0 0;
    z-index: 1000;
    background-color: color-mix(in oklab, var(--c-surface) 94%, transparent);
    backdrop-filter: saturate(1.2) blur(10px);
    -webkit-backdrop-filter: saturate(1.2) blur(10px);
    border-top: 1px solid var(--c-border);
    animation: cfg-footer-in var(--dur-med) var(--ease-out-2);
}

.cfg-footer-inner {
    max-width: var(--cfg-shell-max);
    margin-inline: auto;
    padding: var(--space-3) clamp(var(--space-4), 4vw, var(--space-7));
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-4);
}
@keyframes cfg-footer-in {
    from { transform: translateY(8px); opacity: 0; }
    to   { transform: translateY(0);   opacity: 1; }
}
.cfg-footer-hint {
    font-size: var(--text-sm);
    color: var(--c-text-muted);
}

/* Inline alert — softer, friendlier than the default MudAlert --------------
   Matches the "reduce anxiety" principle: states explain themselves. */
.cfg-note {
    display: flex;
    gap: var(--space-3);
    align-items: flex-start;
    padding: var(--space-3) var(--space-4);
    border-radius: var(--radius-md);
    font-size: var(--text-sm);
    line-height: var(--lh-base);
    border: 1px solid transparent;
}
.cfg-note .cfg-note-icon { margin-top: 1px; flex-shrink: 0; }
.cfg-note-info    { background-color: var(--c-info-soft);    color: var(--c-info);    border-color: color-mix(in oklab, var(--c-info)    20%, transparent); }
.cfg-note-warn    { background-color: var(--c-warning-soft); color: oklch(32% 0.08 70); border-color: color-mix(in oklab, var(--c-warning) 28%, transparent); }
.cfg-note-danger  { background-color: var(--c-danger-soft);  color: var(--c-danger);  border-color: color-mix(in oklab, var(--c-danger)  22%, transparent); }
.cfg-note-success { background-color: var(--c-success-soft); color: var(--c-success); border-color: color-mix(in oklab, var(--c-success) 22%, transparent); }
.cfg-note strong  { font-weight: var(--fw-semibold); }
.cfg-note .cfg-note-body { color: var(--c-text); flex: 1; }
.cfg-note .cfg-note-body p { margin: 0; }
.cfg-note .cfg-note-body p + p { margin-top: var(--space-1); color: var(--c-text-muted); }

/* Strategy option card (replaces inline .option-card hex) ---------------- */
.cfg-option {
    border: 1px solid var(--c-border);
    border-radius: var(--radius-md);
    padding: var(--space-3) var(--space-4);
    background-color: var(--c-surface);
    cursor: pointer;
    transition: border-color var(--dur-fast) var(--ease-out),
                background-color var(--dur-fast) var(--ease-out),
                box-shadow var(--dur-fast) var(--ease-out),
                transform var(--dur-fast) var(--ease-out);
    display: flex;
    flex-direction: column;
    gap: var(--space-1);
    height: 100%;
    min-height: 116px;
}
.cfg-option:hover {
    border-color: var(--c-border-strong);
    background-color: var(--c-surface-muted);
}
.cfg-option:active { transform: translateY(0.5px); }
.cfg-option.is-selected {
    border-color: var(--c-accent);
    background-color: var(--c-accent-soft);
    box-shadow:
        0 0 0 2px var(--c-accent) inset,
        0 6px 18px -6px color-mix(in oklab, var(--c-accent) 28%, transparent),
        var(--shadow-xs);
}
.cfg-option.is-selected .cfg-option-title {
    color: var(--c-accent-pressed);
}
.cfg-option.is-disabled {
    background-color: var(--c-surface-sunken);
    border-color: var(--c-border);
    cursor: not-allowed;
    opacity: 0.65;
}

/* Card forwards focus ring when the inner radio input is focused by keyboard.
   Keeps the MudRadio as the ARIA contract while giving visual focus on the
   full card surface. */
.cfg-option:has(input:focus-visible) {
    box-shadow: var(--ring);
    border-radius: var(--radius-md);
}

/* Disabled panel — token-based replacement for inline opacity:0.5.
   Preserves legibility (4.5:1) while clearly signalling inactive. */
.cfg-panel.is-disabled {
    background-color: var(--c-surface-sunken);
}
.cfg-panel.is-disabled .cfg-panel-title,
.cfg-panel.is-disabled .cfg-panel-desc,
.cfg-panel.is-disabled .cfg-label {
    color: var(--c-text-muted);
}
.cfg-panel.is-disabled .cfg-panel-body {
    pointer-events: none;
}

/* Data grid treatment shared across all cfg-scoped MudDataGrids ---------- */
.cfg-grid .mud-table-head th {
    font-size: var(--text-xs);
    font-weight: var(--fw-semibold);
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--c-text-subtle);
    background-color: var(--c-surface-muted);
    border-bottom: 1px solid var(--c-divider);
}
.cfg-grid .mud-table-row:hover {
    background-color: var(--c-surface-muted);
}

/* Per-row icon-button actions stay compact on desktop, bump to 44px on
   touch viewports per WCAG 2.5.5. */
@media (max-width: 768px) {
    .cfg-grid .cfg-grid-row-action.mud-icon-button {
        min-width: 44px;
        min-height: 44px;
    }
}

/* Visually hide a grid column's header while keeping it in the accessibility
   tree — lets AT users hear the column purpose without visual noise. */
.cfg-grid-visually-hidden {
    clip-path: inset(50%);
    height: 1px;
    width: 1px;
    overflow: hidden;
    white-space: nowrap;
}

/* Empty state for data grids + other "nothing here" surfaces ------------- */
.cfg-empty {
    padding: var(--space-7) var(--space-4);
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-2);
}
.cfg-empty-title {
    margin: 0;
    font-size: var(--text-xl);
    font-weight: var(--fw-semibold);
    letter-spacing: -0.005em;
    color: var(--c-text);
}
.cfg-empty-desc {
    margin: 0;
    font-size: var(--text-base);
    color: var(--c-text-muted);
    line-height: var(--lh-prose);
    max-width: 52ch;
}

/* Tabular figures wherever digits need to align — data grids, pagers,
   error-code pills, activity timestamps. Inherits to descendants. */
.cfg-grid,
.mud-table-pagination,
.cfg-pill--muted,
.cfg-pill--success,
.cfg-pill--danger,
.cfg-pill--active {
    font-variant-numeric: tabular-nums;
}
.cfg-option-title {
    font-size: var(--text-lg);
    font-weight: var(--fw-semibold);
    letter-spacing: var(--tracking-heading);
    color: var(--c-text);
    line-height: var(--lh-snug);
}
.cfg-option-desc {
    font-size: var(--text-sm);
    color: var(--c-text-muted);
    line-height: var(--lh-base);
    max-width: 52ch;
}

/* Horizontal row of strategy options — always 4 across on desktop,
   reflows to 2 on tablet and 1 on narrow viewports. */
.cfg-options-row {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: var(--space-3);
}
@media (max-width: 1080px) {
    .cfg-options-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 560px) {
    .cfg-options-row { grid-template-columns: 1fr; }
}

/* Buttons — primary uses brand color (overrides MudBlazor filled primary) */
.cfg-btn-primary.mud-button-filled.mud-button-filled-primary,
.cfg-btn-primary.mud-button-filled-primary {
    background-color: var(--c-accent);
    color: var(--c-text-on-accent);
    box-shadow: var(--shadow-xs);
    transition: background-color var(--dur-fast) var(--ease-out),
                box-shadow var(--dur-fast) var(--ease-out),
                transform var(--dur-fast) var(--ease-out);
}
.cfg-btn-primary.mud-button-filled.mud-button-filled-primary:hover,
.cfg-btn-primary.mud-button-filled-primary:hover {
    background-color: var(--c-accent-hover);
    box-shadow: var(--shadow-sm);
}
.cfg-btn-primary.mud-button-filled.mud-button-filled-primary:active,
.cfg-btn-primary.mud-button-filled-primary:active {
    background-color: var(--c-accent-pressed);
    transform: translateY(0.5px);
}

/* Subtle in-app focus ring on keyboard navigation */
.cfg-shell :is(button, [tabindex], a):focus-visible,
.cfg-nav .mud-nav-link:focus-visible,
.cfg-option:focus-visible {
    outline: 0;
    box-shadow: var(--ring);
    border-radius: var(--radius-sm);
}

/* Mud overrides used within cfg context */
.cfg-shell .mud-typography {
    color: inherit;
}
.cfg-shell .mud-alert {
    border-radius: var(--radius-md);
}

/* Small helpers */
.cfg-stack { display: flex; flex-direction: column; }
.cfg-row   { display: flex; flex-direction: row; align-items: center; }
.cfg-gap-1 { gap: var(--space-1); }
.cfg-gap-2 { gap: var(--space-2); }
.cfg-gap-3 { gap: var(--space-3); }
.cfg-gap-4 { gap: var(--space-4); }

.cfg-label {
    font-size: var(--text-xs);
    font-weight: var(--fw-semibold);
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--c-text-subtle);
}

.cfg-divider {
    height: 1px;
    background-color: var(--c-divider);
    border: 0;
}
