/* HZAPI Studio — polished native console presentation
 * Adapted from design/polish-v4/native-console.css.
 * Keeps the accepted native DOM, routes, permissions and business states.
 * The light palette applies only to the default light theme; native dark and
 * custom-preset tokens remain authoritative. No visibility or input-state rules
 * are replaced. Corresponding React sources retain their original notices.
 */

:root:not(.dark),
html:not(.dark) body[data-theme-preset='default'] {
  --background: #F6F5F0;
  --foreground: #13141A;
  --card: #FFFFFF;
  --card-foreground: #13141A;
  --popover: #FFFFFF;
  --popover-foreground: #13141A;
  --primary: #5B3EFF;
  --primary-foreground: #FFFFFF;
  --secondary: #EFECE6;
  --secondary-foreground: #343642;
  --muted: #EFECE6;
  --muted-foreground: #555866;
  --accent: #EFEAFE;
  --accent-foreground: #482CE2;
  --border: #E4E2DC;
  --input: #D2CFC6;
  --ring: #5B3EFF;
  --sidebar: #F6F5F0;
  --sidebar-foreground: #4E515E;
  --sidebar-primary: #5B3EFF;
  --sidebar-primary-foreground: #FFFFFF;
  --sidebar-accent: #EFEAFE;
  --sidebar-accent-foreground: #482CE2;
  --sidebar-border: #E4E2DC;
  --hz-shadow: 0 12px 28px -18px rgb(19 20 26 / 8%);
  --hz-glow: rgb(91 62 255 / 10%);
  --radius: 0.72rem;
}

/* Resolve local presentation tokens on body so an existing native preset can
 * supply its own palette, including when it is different from the html theme. */
body {
  --hz-studio-bg: var(--background);
  --hz-studio-soft: var(--muted);
  --hz-studio-surface: var(--card);
  --hz-studio-border: var(--border);
  --hz-studio-border-strong: var(--input);
  --hz-studio-violet: var(--primary);
  --hz-studio-violet-deep: var(--accent-foreground);
  --hz-studio-violet-soft: var(--accent);
  --hz-studio-ink: var(--foreground);
  --hz-studio-muted: var(--muted-foreground);
  background-color: var(--background);
  color: var(--foreground);
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
    'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body[data-theme-radius='xl'],
body[data-theme-radius='lg'] {
  --radius: 0.72rem;
}

.hz-workspace a.underline,
.hz-section-content a.underline,
[data-slot='card'] a.underline {
  text-decoration-color: color-mix(in srgb, var(--primary) 40%, transparent);
  text-underline-offset: 3px;
}

.hz-workspace a.underline:not(.text-destructive),
.hz-section-content a.underline:not(.text-destructive),
[data-slot='card'] a.underline:not(.text-destructive) {
  color: var(--primary);
}

/* AuthLayout's existing structure; native form controls and validation stay. */
.relative.grid.h-svh.max-w-none {
  position: relative;
  background:
    radial-gradient(46% 42% at 18% 14%, rgb(208 190 250 / 25%), transparent 70%),
    radial-gradient(44% 40% at 84% 18%, rgb(196 218 252 / 22%), transparent 70%),
    var(--background);
}

.relative.grid.h-svh.max-w-none::before {
  content: '';
  position: fixed;
  width: min(560px, 90vw);
  height: 360px;
  left: 50%;
  top: 46%;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: radial-gradient(circle, rgb(124 92 246 / 12%), transparent 72%);
  filter: blur(44px);
  pointer-events: none;
  z-index: 0;
}

.relative.grid.h-svh.max-w-none > a.absolute {
  padding: 0.42rem 0.9rem 0.42rem 0.55rem;
  border-radius: 999px;
  background: color-mix(in srgb, var(--card) 90%, transparent);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border);
  box-shadow: 0 6px 18px -8px rgb(48 32 118 / 8%);
}

.relative.grid.h-svh.max-w-none > a.absolute h1 {
  font-size: 0.92rem;
  font-weight: 720;
  letter-spacing: -0.02em;
  color: var(--foreground);
}

.relative.grid.h-svh.max-w-none > a.absolute img {
  object-fit: contain;
  border-radius: 0;
}

.relative.grid.h-svh.max-w-none > .container > .mx-auto {
  position: relative;
  z-index: 1;
  background: color-mix(in srgb, var(--card) 94%, transparent);
  backdrop-filter: blur(22px);
  -webkit-backdrop-filter: blur(22px);
  border: 1px solid var(--border);
  border-radius: 22px;
  padding: 2.25rem 2.2rem;
  box-shadow: 0 22px 54px -22px rgb(48 32 118 / 13%);
}

.relative.grid.h-svh.max-w-none h2.text-2xl {
  font-size: 1.55rem;
  font-weight: 760;
  letter-spacing: -0.03em;
  color: var(--foreground);
}

.relative.grid.h-svh.max-w-none form [data-slot='input'] {
  min-height: 2.55rem;
}

.relative.grid.h-svh.max-w-none form [data-slot='button'].bg-primary {
  min-height: 2.65rem;
  border-radius: 11px;
  font-weight: 650;
}

/* Native header/sidebar, preserving every native hidden/collapsed condition. */
.hz-app-header {
  padding: 8px 14px;
  background: var(--background);
  border: 0;
  border-radius: 0;
}

.hz-app-header > div {
  border-radius: 14px;
  border: 1px solid var(--border);
  background: color-mix(in srgb, var(--card) 92%, transparent);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  box-shadow: 0 6px 20px -12px rgb(48 32 118 / 7%);
}

[data-sidebar='sidebar'] {
  background: var(--sidebar);
  border-right-color: var(--sidebar-border);
}

[data-sidebar='menu-button'] {
  border-radius: 9px;
  font-size: 13px;
  font-weight: 550;
  color: var(--sidebar-foreground);
  transition: background-color 150ms ease, color 150ms ease;
}

[data-sidebar='menu-button']:hover {
  background: var(--sidebar-accent);
  color: var(--sidebar-accent-foreground);
}

[data-sidebar='menu-button'][data-active='true'] {
  background: var(--sidebar-accent) !important;
  color: var(--sidebar-accent-foreground) !important;
  font-weight: 680;
  box-shadow: inset 3px 0 0 var(--sidebar-primary);
}

.hz-workspace [data-slot='sidebar-inset'] {
  background: var(--background);
}

.hz-section-heading,
.hz-overview [data-slot='card'],
.hz-section-content [data-slot='card'],
.hz-workspace [data-slot='card'],
.hz-onboarding,
.hz-request-preview,
.hz-quick-actions [data-slot='card'],
.hz-model-card {
  border-radius: 16px;
  border: 1px solid var(--border);
  background: var(--card);
  box-shadow: 0 8px 24px -16px rgb(48 32 118 / 7%);
}

/* Only the obsolete decorative corner is suppressed. */
.hz-request-preview::after {
  content: none !important;
}

/* Field borders are neutral until focus; invalid and disabled remain native. */
input[data-slot='input'],
select[data-slot='native-select'],
textarea[data-slot='textarea'] {
  border-radius: 9px;
  border-color: var(--input);
  background-color: var(--card);
  color: var(--foreground);
  box-shadow: 0 1px 2px rgb(22 20 36 / 2%);
  transition: border-color 150ms ease, box-shadow 150ms ease;
}

input[data-slot='input'],
select[data-slot='native-select'] {
  min-height: 2.35rem;
}

textarea[data-slot='textarea'] {
  line-height: 1.6;
  padding: 0.65rem 0.8rem;
}

:is(input[data-slot='input'], select[data-slot='native-select'], textarea[data-slot='textarea']):focus-visible:not([aria-invalid='true']) {
  border-color: var(--ring);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--ring) 20%, transparent);
}

:is(input[data-slot='input'], select[data-slot='native-select'], textarea[data-slot='textarea']):disabled {
  background-color: var(--muted);
  border-color: var(--border);
  color: var(--muted-foreground);
  opacity: 0.65;
}

/* Loaded after native utility layers: restore the semantic invalid border even
 * while focused or disabled, instead of making request errors look successful. */
:is(input[data-slot='input'], select[data-slot='native-select'], textarea[data-slot='textarea'])[aria-invalid='true'] {
  border-color: var(--destructive);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--destructive) 20%, transparent);
}

[data-slot='button'].bg-primary {
  background: var(--primary);
  color: var(--primary-foreground);
  border-radius: 9px;
  font-weight: 620;
  box-shadow: 0 6px 16px -6px color-mix(in srgb, var(--primary) 25%, transparent);
}

[data-slot='button'].bg-primary:disabled,
[data-slot='button'].bg-primary[data-disabled] {
  box-shadow: none;
}

/* The key selector is still the same native card, now aligned with its grid. */
.hz-workspace [data-slot='sidebar-inset'] .max-w-7xl > header + [data-slot='card'].max-w-xl {
  max-width: 100%;
}

.hz-workspace [data-slot='sidebar-inset'] .max-w-7xl > header h1 {
  font-size: 1.4rem;
  font-weight: 750;
  letter-spacing: -0.025em;
  color: var(--foreground);
  border-inline-start: 4px solid var(--primary);
  padding-inline-start: 10px;
}

.hz-workspace [data-slot='toggle-group'] {
  background: var(--muted);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 3px;
  gap: 4px;
}

.hz-workspace [data-slot='toggle-group-item'] {
  border-radius: 7px;
  font-weight: 560;
}

.hz-workspace [data-slot='toggle-group-item'][aria-pressed='true'],
.hz-workspace [data-slot='toggle-group-item'][data-pressed]:not([data-pressed='false']),
.hz-workspace [data-slot='toggle-group-item'][data-state='on'] {
  background: var(--card);
  color: var(--primary);
  font-weight: 660;
  box-shadow: 0 1px 4px rgb(22 20 36 / 6%);
}

#studio-advanced {
  background-color: color-mix(in srgb, var(--muted) 50%, var(--card));
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.78rem;
}

.hz-workspace [data-slot='alert']:not(.text-destructive) {
  border-radius: 10px;
  border-color: var(--border);
  background: var(--card);
}

.hz-workspace [data-slot='alert'].text-destructive {
  border-radius: 10px;
  border-color: color-mix(in srgb, var(--destructive) 35%, var(--border));
  background: color-mix(in srgb, var(--destructive) 5%, var(--card));
  color: var(--destructive);
}

.hz-section-content [data-slot='table-container'],
.hz-section-content .rounded-md.border {
  border-radius: 14px;
  border-color: var(--border);
  background: var(--card);
}

.hz-section-content [data-slot='tabs-list'] {
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--muted);
  padding: 3px;
}

.hz-section-content [data-slot='tabs-trigger'][data-state='active'],
.hz-section-content [data-slot='tabs-trigger'][aria-selected='true'] {
  border-radius: 7px;
  background: var(--card);
  color: var(--primary);
  font-weight: 650;
}

.hz-pricing-hero::after {
  transform: none !important;
  border-color: var(--border) !important;
  border-radius: 22px !important;
}

.hz-pricing-hero h1 {
  background: none;
  color: var(--foreground);
}

.hz-model-card:hover {
  border-color: color-mix(in srgb, var(--primary) 35%, var(--border));
}

html.dark .relative.grid.h-svh.max-w-none {
  background: var(--background);
}

html.dark .relative.grid.h-svh.max-w-none::before {
  opacity: 0.35;
}

@media (max-width: 640px) {
  .relative.grid.h-svh.max-w-none > .container > .mx-auto {
    padding: 1.6rem 1.25rem;
  }

  input[data-slot='input'],
  select[data-slot='native-select'],
  textarea[data-slot='textarea'] {
    font-size: 16px;
  }
}

@media (prefers-reduced-motion: reduce) {
  [data-sidebar='menu-button'],
  input[data-slot='input'],
  select[data-slot='native-select'],
  textarea[data-slot='textarea'] {
    transition: none;
  }
}
