/*
 * Copyright (c) 2026 Voxtell
 * All rights reserved.
 *
 * NetSapiens V45+ login (the /auth app) in Voxtell branding.
 *
 * V45 replaced the classic /portal/login page with a standalone React/MUI app
 * at /auth. Our PHP includes and PORTAL_CSS_CUSTOM never reach it; the only
 * hooks are uiconfigs, and this file is linked by TWO of them with the same
 * href (the app de-duplicates it):
 *   PORTAL_AUTH_APP_CSS_CUSTOM = /portal/vt/vt-auth.css  (official hook, but
 *                                the app applies it on the "/" login route only)
 *   PORTAL_CSS_FONT_FILE       = /portal/vt/vt-auth.css  (applied on EVERY /auth
 *                                route - forgot password, reset links, MFA)
 * FONT_FILE is also linked by the classic portal layouts, so every rule is
 * scoped under #root (only the /auth app renders one) and the file imports
 * nothing. No markup or JS can be added, so the brand panel is drawn with
 * pseudo-elements and its call to action is text. See NETSAPIENS-VERSIONS.md.
 *
 * The app sets no ids/classes of its own: selectors use MUI's stable Mui*
 * classes, data-testid hooks and structure. Never target css-xxxx hashes.
 * Login-route rules are gated on the password field existing, so MFA,
 * forgot-password and other /auth screens get the base card styling only.
 */

/* Self-contained on purpose: PORTAL_CSS_FONT_FILE (the only hook that
   reaches EVERY /auth route) also makes classic portal pages link this file,
   so it must stay small and import nothing. Values mirror vt-variables.css. */
@font-face {
  font-family: 'Inter Variable';
  font-style: normal;
  font-display: fallback;
  font-weight: 100 900;
  src: url('fonts/inter-variable.woff2') format('woff2-variations');
}

:root {
  /* design tokens (from vt-variables.css - keep in sync on a rebrand) */
  --vt-auth-fg: oklch(0.05 0.030 261.692);
  --vt-auth-fg-muted: oklch(0.551 0.015 264.364);
  --vt-auth-fg-subtle: oklch(0.446 0.016 256.802);
  --vt-auth-border: oklch(0.928 0.006 264.531);
  --vt-auth-bg: oklch(1 0 0);
  --vt-auth-bg-muted: oklch(0.985 0.002 247.839);
  --vt-auth-accent: oklch(0.511 0.262 279.216);
  --vt-auth-accent-hover: oklch(0.457 0.24 279.216);
  --vt-auth-accent-contrast: #ffffff;
  --vt-auth-glow: oklch(0.673 0.182 279.216);
  --vt-auth-shade: oklch(0.21 0.020 264.665);
  --vt-auth-shadow-sm: 0px 2px 4px color-mix(in srgb, var(--vt-auth-shade) 5%, transparent), 0px 0px 2px color-mix(in srgb, var(--vt-auth-shade) 5%, transparent);
  --vt-auth-shadow-lg: 0px 8px 16px color-mix(in srgb, var(--vt-auth-shade) 5%, transparent), 0px 0px 4px color-mix(in srgb, var(--vt-auth-shade) 5%, transparent);
  --vt-auth-radius: 1.5rem;

  --vt-auth-font: 'Inter Variable', Inter, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;

  /* copy */
  --vt-auth-headline: 'Welcome back';
  --vt-auth-tagline: 'Sign in to your Voxtell manager portal';
  --vt-auth-hero-mark: '\2726  Vee';
  --vt-auth-hero-by: 'BY VOXTELL';
  --vt-auth-hero-title: 'Never Miss Another\A Customer Call Again.';
  --vt-auth-hero-sub: 'Your AI receptionist answers every call\A and text instantly, 24/7. No more\A voicemails, no more missed opportunities.';
  --vt-auth-hero-cta: 'Learn more at voxtell.com';

  /* brand panel (pixel-block vocabulary from DESIGN.md) */
  --vt-auth-panel: #1c0037;
  --vt-auth-cell: 52px;
  --vt-auth-traced: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='52' height='52'%3E%3Crect x='0.5' y='0.5' width='51' height='51' fill='none' stroke='%23351c4d'/%3E%3C/svg%3E");
  --vt-auth-art: url('img/login-hero-placeholder.svg');

  /* geometry shared by the form column and the fixed brand card - the same
     math as the classic login (vt-resets.css): 448px form + 100px gap +
     min(30vw, 680px) card, centered as one group */
  --vt-auth-card-w: min(30vw, 680px);
  --vt-auth-card-h: min(72vh, 900px);
  --vt-auth-card-l: calc(50vw + 274px - var(--vt-auth-card-w) / 2);
  --vt-auth-card-t: calc(50vh - var(--vt-auth-card-h) / 2);
  --vt-auth-pad: clamp(32px, 6vh, 64px);
  --vt-auth-gap: clamp(20px, 4vh, 40px);
  /* two-line title, never wrapping: shrinks with the card instead */
  --vt-auth-title-fs: min(42px, 2.4vw, calc((var(--vt-auth-card-w) - 78px) / 9.8));
  --vt-auth-sub-fs: min(15px, calc((var(--vt-auth-card-w) - 78px) / 21.5));
  /* stacked text rows inside the card (fixed line boxes, so no layout flow
     is needed between pseudo-elements) */
  --vt-auth-row0: calc(var(--vt-auth-card-t) + 7px + var(--vt-auth-pad));
  --vt-auth-row1: calc(var(--vt-auth-row0) + 40px);
  --vt-auth-row2: calc(var(--vt-auth-row1) + 14px + var(--vt-auth-gap));
  --vt-auth-row3: calc(var(--vt-auth-row2) + 2.24 * var(--vt-auth-title-fs) + 16px);
  --vt-auth-row4: calc(var(--vt-auth-row3) + 4.65 * var(--vt-auth-sub-fs) + 24px);
  --vt-auth-row5: calc(var(--vt-auth-row4) + 46px + clamp(16px, 3vh, 32px));
}

/* ---------- base: every /auth screen ---------- */

#root,
#root :is(.MuiTypography-root, .MuiInputBase-root, .MuiButtonBase-root,
  .MuiFormLabel-root, .MuiLink-root, .MuiSelect-select, .MuiAlert-message, .MuiMenuItem-root) {
  font-family: var(--vt-auth-font) !important;
}

/* our ground from the first frame (the app applies PORTAL_CSS_BACKGROUND
   only after fetching its settings; with the Apache pre-load this file is
   already here) */
#root > div {
  background-color: var(--vt-auth-bg);
}

#root .MuiCard-root {
  box-sizing: border-box;
  width: 448px;
  max-width: calc(100vw - 48px);
  padding: 28px;
  background-color: var(--vt-auth-bg);
  border: 1px solid var(--vt-auth-border);
  border-radius: 32px;
  box-shadow: var(--vt-auth-shadow-sm);
  color: var(--vt-auth-fg);
}

#root .MuiCardContent-root,
#root .MuiCardContent-root:last-child {
  padding: 0;
}

/* our wordmark, served locally, in place of the NS image-store logo (same
   choice as the classic login) */
#root img[data-testid='img-login'] {
  width: 132px;
  max-width: none !important;
  height: auto;
  content: url('img/voxtell-wordmark.svg');
  filter: invert(1);
}

#root .MuiCard-root h1.MuiTypography-root {
  font-size: 20px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--vt-auth-fg);
}

/* the footer boxes are fixed 360px wide - match the card */
#root .MuiCard-root ~ div,
#root .MuiCard-root ~ div > div {
  width: 448px;
  max-width: calc(100vw - 48px);
}

/* fields: static label above a boxed input (MUI "standard" floats the label
   inside the input and draws an underline - both replaced) */
#root .MuiTextField-root {
  margin: 0;
}

#root .MuiTextField-root .MuiInputLabel-root {
  position: static;
  transform: none !important;
  max-width: none;
  margin-bottom: 6px;
  font-size: 13px;
  font-weight: 500;
  line-height: 1.4;
  color: var(--vt-auth-fg);
}

#root .MuiTextField-root .MuiInputLabel-root.Mui-error {
  color: #dc2626;
}

#root .MuiInput-root {
  box-sizing: border-box;
  height: 40px;
  margin-top: 0 !important;
  padding: 0 14px;
  font-size: 14px;
  color: var(--vt-auth-fg);
  background-color: var(--vt-auth-bg-muted);
  border: 1px solid var(--vt-auth-border);
  border-radius: 10px;
  transition: box-shadow 0.15s ease, border-color 0.15s ease;
}

#root .MuiInput-root::before,
#root .MuiInput-root::after {
  display: none;
}

#root .MuiInput-root.Mui-focused {
  border-color: var(--vt-auth-accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--vt-auth-accent) 35%, transparent);
}

#root .MuiInput-root.Mui-error {
  border-color: #dc2626;
}

/* text fields only: the language picker is a Select built from the same
   MuiInputBase-input class and needs its own padding for the arrow */
#root .MuiTextField-root .MuiInputBase-input {
  height: 38px;
  padding: 0;
  font-size: 14px;
}

#root .MuiTextField-root .MuiInputBase-input:-webkit-autofill {
  -webkit-box-shadow: 0 0 0 1000px var(--vt-auth-bg-muted) inset;
  -webkit-text-fill-color: #101010;
  caret-color: #101010;
}

#root .MuiInputAdornment-root .MuiIconButton-root {
  color: var(--vt-auth-fg-muted);
}

/* every button in sentence case (MUI uppercases by default; NS labels are
   lowercase: 'log in' -> 'Log In', 'send' -> 'Send', 'back' -> 'Back') */
#root .MuiButton-root {
  font-weight: 600;
  letter-spacing: normal;
  text-transform: capitalize;
  border-radius: 10px;
}

#root .MuiButton-root.MuiButton-text {
  color: var(--vt-auth-fg-muted);
}

#root .MuiButton-root.MuiButton-text:hover {
  color: var(--vt-auth-fg);
  background-color: var(--vt-auth-bg-muted);
}

/* primary CTA */
#root .MuiButton-root.MuiButton-contained {
  height: 40px;
  padding: 0 16px;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: normal;
  /* NS ships the label lowercase ('log in'); the classic button read 'Log In' */
  text-transform: capitalize;
  color: var(--vt-auth-accent-contrast);
  background: var(--vt-auth-accent);
  border-radius: 10px;
  box-shadow: none;
  transition: background-color 0.15s ease, opacity 0.15s ease;
}

#root .MuiButton-root.MuiButton-contained:hover {
  background: var(--vt-auth-accent-hover);
  box-shadow: none;
}

#root .MuiButton-root.MuiButton-contained.Mui-disabled {
  color: var(--vt-auth-accent-contrast);
  background: var(--vt-auth-accent);
  opacity: 0.45;
}

#root .MuiButton-root.MuiButton-contained:focus-visible {
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--vt-auth-accent) 40%, transparent);
}

#root .MuiLink-root {
  font-size: 13px;
  color: var(--vt-auth-fg-muted);
  text-decoration: none;
}

#root .MuiLink-root:hover {
  color: var(--vt-auth-fg);
  text-decoration: underline;
}

/* forgot links read 'Forgot Login Name' like the classic page (NS strings
   are sentence case) */
#root form .MuiLink-root {
  text-transform: capitalize;
}

/* language picker: NS's pill Select in our tokens */
#root .MuiSelect-select {
  font-size: 13px;
  color: var(--vt-auth-fg-muted);
}

#root .MuiOutlinedInput-root:has(.MuiSelect-select) .MuiOutlinedInput-notchedOutline {
  border-color: var(--vt-auth-border) !important;
}

#root .MuiAlert-root {
  border-radius: 10px;
  font-size: 13px;
}

/* ---------- login screen: split layout ---------- */

/* the scroll container (MUI Box: 100vh flex, centered) - shift the form
   column left to pair with the fixed brand card; soft brand glow behind the
   card, same as the classic login */
#root:has([data-testid='TextField-password']) > div {
  background-color: var(--vt-auth-bg);
  background-image:
    radial-gradient(min(34vw, 760px) min(80vh, 1000px) at calc(50% + 274px) 50%,
      color-mix(in srgb, var(--vt-auth-glow) 30%, transparent),
      transparent 72%);
  background-attachment: fixed;
  box-sizing: border-box;
  padding-right: calc(100px + min(30vw, 680px));
}

/* the column: headline + tagline above the card, Claude-style */
#root:has([data-testid='TextField-password']) > div > div {
  gap: 0;
}

#root:has([data-testid='TextField-password']) > div > div::before,
#root:has([data-testid='TextField-password']) > div > div::after {
  display: block;
  text-align: center;
  font-family: var(--vt-auth-font);
}

#root:has([data-testid='TextField-password']) > div > div::before {
  content: var(--vt-auth-headline);
  order: -2;
  margin-bottom: 10px;
  font-size: clamp(32px, 2.2vw, 56px);
  line-height: 1.2;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--vt-auth-fg);
}

#root:has([data-testid='TextField-password']) > div > div::after {
  content: var(--vt-auth-tagline);
  order: -1;
  margin-bottom: 28px;
  font-size: 15px;
  line-height: 1.4;
  color: var(--vt-auth-fg-muted);
}

/* the card's own title ("Log in to ...") is replaced by the headline */
#root:has([data-testid='TextField-password']) .MuiCard-root h1.MuiTypography-root {
  display: none;
}

/* wordmark top-left, aligned with the content column (classic position) */
#root:has([data-testid='TextField-password']) img[data-testid='img-login'] {
  position: fixed;
  top: 28px;
  left: max(28px, calc(50vw - (448px + 100px + min(30vw, 680px)) / 2));
  z-index: 3;
}

/* forgot links below the button, centered with a divider (classic order) */
#root:has([data-testid='TextField-password']) form > div:has(> a.MuiLink-root) {
  order: 99;
  justify-content: center;
  gap: 21px;
  margin: 0;
}

#root:has([data-testid='TextField-password']) form > div:has(> a.MuiLink-root) > a + a {
  position: relative;
}

#root:has([data-testid='TextField-password']) form > div:has(> a.MuiLink-root) > a + a::before {
  content: '';
  position: absolute;
  left: -11px;
  top: 3px;
  height: 13px;
  border-left: 1px solid var(--vt-auth-border);
}

/* copyright + version: bottom of the form column (classic footer) */
#root:has([data-testid='TextField-password']) .MuiCard-root ~ div > div:last-child {
  position: fixed;
  bottom: 0;
  left: 0;
  z-index: 3;
  display: flex;
  justify-content: center;
  gap: 8px;
  width: calc(100vw - 100px - min(30vw, 680px));
  max-width: none;
  margin: 0;
  padding: 12px 20px;
  box-sizing: border-box;
}

#root:has([data-testid='TextField-password']) .MuiCard-root ~ div > div:last-child > * {
  margin: 0;
  font-size: 12px !important;
  font-weight: 400 !important;
  color: var(--vt-auth-fg-subtle) !important;
}

/* ---------- login screen: brand card (pseudo-elements only) ---------- */

/* frosted frame */
body:has(#root [data-testid='TextField-password'])::before,
/* deep-violet panel + pixel blocks + product art */
body:has(#root [data-testid='TextField-password'])::after {
  content: '';
  position: fixed;
  z-index: 1;
  pointer-events: none;
  box-sizing: border-box;
  border-radius: var(--vt-auth-radius);
}

body:has(#root [data-testid='TextField-password'])::before {
  left: var(--vt-auth-card-l);
  top: var(--vt-auth-card-t);
  width: var(--vt-auth-card-w);
  height: var(--vt-auth-card-h);
  background: oklch(1 0 0 / 0.16);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
  box-shadow: var(--vt-auth-shadow-lg), 0 0 0 1px var(--vt-auth-border);
}

body:has(#root [data-testid='TextField-password'])::after {
  left: calc(var(--vt-auth-card-l) + 7px);
  top: calc(var(--vt-auth-card-t) + 7px);
  width: calc(var(--vt-auth-card-w) - 14px);
  height: calc(var(--vt-auth-card-h) - 14px);
  /* cells step by cell-1px so shared hairlines collapse; the extra -1px
     pushes edge hairlines into the panel's rounded clip */
  background:
    var(--vt-auth-traced) left -1px top -1px / var(--vt-auth-cell) var(--vt-auth-cell) no-repeat,
    var(--vt-auth-traced) left 50px top -1px / var(--vt-auth-cell) var(--vt-auth-cell) no-repeat,
    var(--vt-auth-traced) left -1px top 50px / var(--vt-auth-cell) var(--vt-auth-cell) no-repeat,
    linear-gradient(#8a05ff, #8a05ff) right -1px top -1px / var(--vt-auth-cell) var(--vt-auth-cell) no-repeat,
    linear-gradient(#c29eff, #c29eff) right 50px top -1px / var(--vt-auth-cell) var(--vt-auth-cell) no-repeat,
    var(--vt-auth-traced) right -1px top 50px / var(--vt-auth-cell) var(--vt-auth-cell) no-repeat,
    linear-gradient(#d67f2e, #d67f2e) left -1px bottom -1px / var(--vt-auth-cell) var(--vt-auth-cell) no-repeat,
    var(--vt-auth-traced) left 50px bottom -1px / var(--vt-auth-cell) var(--vt-auth-cell) no-repeat,
    var(--vt-auth-traced) left -1px bottom 50px / var(--vt-auth-cell) var(--vt-auth-cell) no-repeat,
    var(--vt-auth-traced) right -1px bottom 50px / var(--vt-auth-cell) var(--vt-auth-cell) no-repeat,
    linear-gradient(#e7dbff, #e7dbff) right -1px bottom -1px / var(--vt-auth-cell) var(--vt-auth-cell) no-repeat,
    var(--vt-auth-panel);
}

/* product art: bottom-anchored in the space left under the CTA */
#root:has([data-testid='TextField-password']) > div > div > div:first-child::after {
  content: '';
  position: fixed;
  z-index: 2;
  pointer-events: none;
  left: calc(var(--vt-auth-card-l) + 39px);
  width: calc(var(--vt-auth-card-w) - 78px);
  top: var(--vt-auth-row5);
  bottom: calc(100vh - var(--vt-auth-card-t) - var(--vt-auth-card-h) + 5px);
  background: var(--vt-auth-art) center bottom / contain no-repeat;
}

/* copy rows: each a fixed, full-card-width, centered line box */
#root:has([data-testid='TextField-password'])::before,
#root:has([data-testid='TextField-password'])::after,
#root:has([data-testid='TextField-password']) > div::before,
#root:has([data-testid='TextField-password']) > div::after,
#root:has([data-testid='TextField-password']) > div > div > div:first-child::before {
  position: fixed;
  z-index: 2;
  pointer-events: none;
  left: var(--vt-auth-card-l);
  width: var(--vt-auth-card-w);
  text-align: center;
  white-space: pre;
  font-family: var(--vt-auth-font);
  color: #ffffff;
}

#root:has([data-testid='TextField-password'])::before {
  content: var(--vt-auth-hero-mark);
  top: var(--vt-auth-row0);
  font-size: 30px;
  line-height: 36px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

#root:has([data-testid='TextField-password'])::after {
  content: var(--vt-auth-hero-by);
  top: var(--vt-auth-row1);
  font-size: 11px;
  line-height: 14px;
  font-weight: 600;
  letter-spacing: 0.28em;
  color: oklch(1 0 0 / 0.64);
}

#root:has([data-testid='TextField-password']) > div::before {
  content: var(--vt-auth-hero-title);
  top: var(--vt-auth-row2);
  font-size: var(--vt-auth-title-fs);
  line-height: 1.12;
  font-weight: 700;
  letter-spacing: -0.02em;
}

#root:has([data-testid='TextField-password']) > div::after {
  content: var(--vt-auth-hero-sub);
  top: var(--vt-auth-row3);
  font-size: var(--vt-auth-sub-fs);
  line-height: 1.55;
  color: oklch(1 0 0 / 0.80);
}

/* the call to action is text: /auth accepts no links, and a button-shaped
   label that does nothing would mislead - an outlined chip, no hover */
#root:has([data-testid='TextField-password']) > div > div > div:first-child::before {
  content: var(--vt-auth-hero-cta);
  top: var(--vt-auth-row4);
  left: calc(var(--vt-auth-card-l) + var(--vt-auth-card-w) / 2);
  width: auto;
  transform: translateX(-50%);
  padding: 12px 26px;
  font-size: 14px;
  line-height: 20px;
  font-weight: 600;
  border: 1px solid oklch(1 0 0 / 0.48);
  border-radius: 9999px;
  background-color: oklch(1 0 0 / 0.06);
}

/* narrow screens: no brand card, form centered (classic breakpoint) */
@media (max-width: 1023px) {
  #root:has([data-testid='TextField-password']) > div {
    padding-right: 0;
    background-image: none;
  }

  body:has(#root [data-testid='TextField-password'])::before,
  body:has(#root [data-testid='TextField-password'])::after,
  #root:has([data-testid='TextField-password'])::before,
  #root:has([data-testid='TextField-password'])::after,
  #root:has([data-testid='TextField-password']) > div::before,
  #root:has([data-testid='TextField-password']) > div::after,
  #root:has([data-testid='TextField-password']) > div > div > div:first-child::before,
  #root:has([data-testid='TextField-password']) > div > div > div:first-child::after {
    content: none;
  }

  #root:has([data-testid='TextField-password']) img[data-testid='img-login'] {
    left: 28px;
  }

  #root:has([data-testid='TextField-password']) .MuiCard-root ~ div > div:last-child {
    width: 100vw;
  }
}
