/*
 * LWS Agents theme layer for Langflow.
 *
 * Loaded after Langflow's own stylesheet (index.html is patched by apply-branding.sh).
 * It only adjusts design tokens and styles the LWS-specific login markup; nodes, handles,
 * edges and canvas controls keep Langflow's styles. Remove the <link> to lws-theme.css
 * from index.html to disable it without touching anything else.
 */

:root {
  --lws-blue: 200 78% 46%; /* #1a95d2, sampled from the logo nebula */
  --lws-blue-bright: 199 89% 62%;
  --lws-navy: 222 38% 4%; /* #06080d */
  --lws-login-text: #f3f6fb;
  --lws-login-muted: #9aa7bb;
}

/* ---- Design tokens (subtle LWS identity) --------------------------------------------- */

/* Light theme: stock Langflow neutrals, LWS blue for focus and selection. */
html:root {
  --ring: var(--lws-blue);
  --node-selected: var(--lws-blue);
}

/* Dark theme: neutrals shifted slightly towards the LWS navy; primary stays monochrome so
   text-primary copy keeps its contrast. `:root .dark` outranks Langflow's `.dark`. */
:root .dark {
  --background: 222 20% 9%;
  --card: 222 20% 9%;
  --popover: 222 20% 9%;
  --muted: 220 16% 15%;
  --muted-foreground: 218 12% 66%;
  --accent: 220 16% 15%;
  --secondary-hover: 220 16% 15%;
  --border: 218 13% 24%;
  --input: 218 12% 32%;
  --placeholder-foreground: 218 10% 62%;
  --secondary-foreground: 220 14% 90%;
  --primary-hover: 220 14% 88%;
  --canvas: 224 28% 5%;
  --canvas-dot: 220 12% 24%;
  --ring: var(--lws-blue-bright);
  --node-selected: var(--lws-blue-bright);
}

::selection {
  background-color: hsl(var(--lws-blue) / 0.35);
}

/* ---- App mark (replaces the Langflow logo component) ----------------------------------- */

.lws-mark {
  display: inline-block;
  flex: none;
  object-fit: contain;
  border-radius: 9999px;
  user-select: none;
}

/* Header home button: 24px is the smallest size where the emblem still reads as "LWS". */
[data-testid="icon-ChevronLeft"] > .lws-mark {
  width: 1.5rem;
  height: 1.5rem;
}

/* "Welcome" empty state: the stock art carried its own padding and a top-8 offset. */
img[data-testid="empty_page_logo_light"],
img[data-testid="empty_page_logo_dark"] {
  top: 0;
  width: 7rem;
  height: 7rem;
  margin-bottom: 1.25rem;
  border-radius: 9999px;
  box-shadow: 0 0 40px rgb(26 149 210 / 0.22);
}

/* ---- Login page ------------------------------------------------------------------------ */

/* The login surface is always dark (brand surface), whatever the app theme. */
.lws-login.lws-login {
  color-scheme: dark;
  --foreground: 0 0% 100%;
  --background: 222 24% 8%;
  --card: 222 24% 8%;
  --card-foreground: 0 0% 100%;
  --popover: 222 24% 8%;
  --popover-foreground: 0 0% 100%;
  --muted: 220 18% 13%;
  --muted-foreground: 218 12% 68%;
  --border: 218 16% 22%;
  --input: 218 14% 30%;
  --control-boundary: 218 12% 46%;
  --primary: 0 0% 100%;
  --primary-foreground: 0 0% 0%;
  --placeholder-foreground: 218 10% 60%;
  --destructive: 0 84% 60%;
  --ring: var(--lws-blue-bright);
  position: relative;
  isolation: isolate;
  color: var(--lws-login-text);
  background-color: hsl(var(--lws-navy));
  background-image:
    radial-gradient(56rem 34rem at 50% -8%, rgb(26 149 210 / 0.2), transparent 62%),
    radial-gradient(44rem 28rem at 50% 112%, rgb(0 64 128 / 0.22), transparent 64%);
  background-attachment: fixed;
}

/* Hairline grid, faded towards the edges. */
.lws-login.lws-login::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgb(148 163 184 / 0.05) 1px, transparent 1px),
    linear-gradient(90deg, rgb(148 163 184 / 0.05) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: radial-gradient(ellipse at 50% 40%, #000 20%, transparent 72%);
  -webkit-mask-image: radial-gradient(ellipse at 50% 40%, #000 20%, transparent 72%);
}

.lws-login-brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  text-align: center;
}

.lws-login-emblem {
  width: 6rem;
  height: 6rem;
  margin-bottom: 0.5rem;
  border-radius: 9999px;
  box-shadow:
    0 0 0 1px rgb(26 149 210 / 0.25),
    0 0 48px rgb(26 149 210 / 0.28);
  user-select: none;
}

.lws-login-title {
  margin: 0;
  color: var(--lws-login-text);
  font-size: 2.25rem;
  line-height: 2.5rem;
  font-weight: 600;
  letter-spacing: -0.025em;
}

.lws-login-subtitle {
  margin: 0;
  color: var(--lws-login-muted);
  font-size: 0.9375rem;
  line-height: 1.375rem;
  font-weight: 500;
  letter-spacing: 0.01em;
}

.lws-login section[aria-labelledby="login-form-title"] {
  border-color: rgb(148 163 184 / 0.16);
  border-radius: 1rem;
  background-color: rgb(13 17 25 / 0.82);
  box-shadow:
    0 1px 0 rgb(255 255 255 / 0.04) inset,
    0 24px 64px -16px rgb(0 0 0 / 0.6);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.lws-login section[aria-labelledby="login-form-title"] input {
  background-color: hsl(220 18% 11%);
}

.lws-login button[type="submit"] {
  color: #fff;
  background-color: hsl(var(--lws-blue));
  border: 1px solid hsl(199 80% 52%);
  font-weight: 600;
  transition: background-color 150ms ease, box-shadow 150ms ease;
}

.lws-login button[type="submit"]:hover {
  background-color: hsl(200 78% 40%);
}

.lws-login button[type="submit"]:focus-visible {
  outline: 2px solid hsl(var(--lws-blue-bright));
  outline-offset: 2px;
}

.lws-login-footer {
  margin: 0;
  color: var(--lws-login-muted);
  font-size: 0.8125rem;
  line-height: 1.25rem;
  text-align: center;
}

.lws-login-footer strong {
  color: #cfd8e6;
  font-weight: 600;
}

@media (max-width: 480px) {
  .lws-login-emblem {
    width: 5rem;
    height: 5rem;
  }
  .lws-login-title {
    font-size: 1.875rem;
    line-height: 2.25rem;
  }
}

@media (prefers-reduced-transparency: reduce) {
  .lws-login section[aria-labelledby="login-form-title"] {
    background-color: hsl(222 24% 8%);
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
  }
}

/* ---- Langflow community promotion (not relevant to a private LWS deployment) --------- */

/* Account menu: GitHub / Discord / X rows, and the group wrapping them. */
div:has(> a[role="menuitem"] > [data-testid="menu_github_button"]),
a[role="menuitem"]:has(> [data-testid="menu_github_button"]),
a[role="menuitem"]:has(> [data-testid="menu_discord_button"]),
a[role="menuitem"]:has(> [data-testid="menu_twitter_button"]),
/* Help menu: "Get Langflow Desktop". */
[data-testid="canvas_controls_dropdown_get_langflow_desktop"],
/* Empty "Welcome" page: GitHub / Discord cards. */
[data-testid="empty_page_github_button"],
[data-testid="empty_page_discord_button"],
/* Sidebar "Get started" checklist (star on GitHub, join Discord, ...). */
div:has(> div > [data-testid="get_started_progress_title"]) {
  display: none !important;
}
