/**
 * bCom — Sign-in / auth surfaces (client portal, admin).
 * Calibrated toward familiar “big tech” patterns: split brand rail, focused card, crisp fields.
 */

.auth-page {
  --auth-rail: #071426;
  --auth-rail-soft: #0d2847;
  --auth-field-h: 48px;
  /* Enterprise header varies by breakpoint — leave room so the form is never clipped */
  --auth-header-offset: clamp(64px, 12vw, 88px);
}

/* ----- Shell: full-bleed background behind main content ----- */
.portal-login-wrap.auth-signin-shell {
  position: relative;
  isolation: isolate;
  min-height: calc(100vh - var(--auth-header-offset, 72px));
  display: flex;
  flex-direction: column;
  padding: 0;
  margin: 0;
  background:
    radial-gradient(ellipse 90% 55% at 100% -15%, rgba(59, 130, 246, 0.09), transparent 55%),
    radial-gradient(ellipse 55% 40% at 0% 105%, rgba(14, 165, 233, 0.06), transparent 50%),
    linear-gradient(180deg, #f8fafc 0%, #f1f5f9 48%, #eef2f7 100%);
}

.auth-signin-shell::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  opacity: 0.5;
  background-image: url("../media/bcom-grid-dots.svg");
  background-repeat: repeat;
  background-size: 360px 360px;
  mask-image: radial-gradient(ellipse 85% 70% at 50% 45%, black 12%, transparent 78%);
  -webkit-mask-image: radial-gradient(ellipse 85% 70% at 50% 45%, black 12%, transparent 78%);
}

/* ----- Split layout ----- */
.auth-layout {
  position: relative;
  z-index: 1;
  flex: 1;
  display: grid;
  grid-template-columns: 1fr;
  width: 100%;
  max-width: 1120px;
  margin: 0 auto;
  min-height: 0;
  align-items: stretch;
  padding: clamp(1.25rem, 4vw, 2.5rem) clamp(1rem, 4vw, 2rem) clamp(2rem, 5vw, 3rem);
  gap: 0;
}

@media (min-width: 900px) {
  .auth-layout {
    /* Give the form column enough width on laptops; avoid clipping tall forms */
    grid-template-columns: minmax(260px, 1fr) minmax(360px, 1.15fr);
    box-shadow:
      0 1px 0 rgba(255, 255, 255, 0.65) inset,
      0 24px 60px rgba(15, 23, 42, 0.08),
      0 4px 16px rgba(15, 23, 42, 0.04);
    border: 1px solid rgba(15, 23, 42, 0.08);
    background: #ffffff;
    border-radius: 24px;
    overflow: visible;
    align-items: stretch;
    min-height: auto;
  }

  /* Rounded shell without overflow:hidden (prevents cutting off inputs/buttons on short laptops) */
  .auth-brand {
    border-radius: 24px 0 0 24px;
  }

  .auth-main {
    border-radius: 0 24px 24px 0;
  }
}

/* Short laptop screens: tighten brand rail so the form column keeps room */
@media (min-width: 900px) and (max-height: 760px) {
  .auth-brand {
    padding: 1.35rem 1.5rem 1.5rem;
  }

  .auth-brand__bullets {
    margin-top: 1rem;
    gap: 0.45rem;
  }

  .auth-brand__bullets li {
    font-size: 0.8rem;
  }

  .auth-brand__logo {
    margin-bottom: 1rem;
  }
}

/* Brand rail */
.auth-brand {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: clamp(2rem, 5vw, 3.25rem) clamp(1.75rem, 4vw, 3rem);
  background:
    radial-gradient(ellipse 120% 80% at 90% 10%, rgba(86, 182, 249, 0.22), transparent 52%),
    radial-gradient(ellipse 70% 50% at 10% 95%, rgba(11, 107, 255, 0.18), transparent 48%),
    linear-gradient(155deg, var(--auth-rail) 0%, var(--auth-rail-soft) 48%, #0a1628 100%);
  color: #f1f5f9;
}

@media (max-width: 899px) {
  .auth-brand {
    border-radius: 20px;
    margin-bottom: 1.25rem;
    min-height: auto;
    padding: 1.75rem 1.5rem 2rem;
  }
}

.auth-brand__mesh {
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0.38;
  background: url("../media/bcom-hero-mesh.svg") no-repeat 108% 12% / min(95%, 560px);
  mask-image: radial-gradient(ellipse 88% 75% at 55% 35%, black 22%, transparent 72%);
  -webkit-mask-image: radial-gradient(ellipse 88% 75% at 55% 35%, black 22%, transparent 72%);
}

.auth-brand__grid {
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0.22;
  background-image: linear-gradient(rgba(255, 255, 255, 0.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.05) 1px, transparent 1px);
  background-size: 44px 44px;
}

.auth-brand__inner {
  position: relative;
  z-index: 1;
}

.auth-brand__logo {
  display: inline-flex;
  align-items: center;
  gap: 0.65rem;
  text-decoration: none;
  color: inherit;
  margin-bottom: 1.75rem;
}

.auth-brand__logo img {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
}

.auth-brand__wordmark {
  font-family: var(--shell-display, "DM Sans", system-ui, sans-serif);
  font-weight: 700;
  font-size: 1.35rem;
  letter-spacing: -0.03em;
}

.auth-brand__title {
  font-family: var(--shell-display, "DM Sans", system-ui, sans-serif);
  font-size: clamp(1.65rem, 3.2vw, 2.15rem);
  font-weight: 700;
  letter-spacing: -0.045em;
  line-height: 1.15;
  margin: 0 0 0.85rem;
  color: #ffffff;
}

.auth-brand__lead {
  margin: 0;
  font-size: clamp(0.95rem, 1.6vw, 1.05rem);
  line-height: 1.65;
  color: rgba(226, 232, 240, 0.88);
  max-width: 36ch;
}

.auth-brand__bullets {
  margin: 1.75rem 0 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.auth-brand__bullets li {
  display: flex;
  align-items: flex-start;
  gap: 0.55rem;
  font-size: 0.88rem;
  line-height: 1.45;
  color: rgba(226, 232, 240, 0.82);
}

.auth-brand__bullets li i {
  margin-top: 0.2rem;
  color: var(--primary-light, #56b6f9);
  opacity: 0.95;
}

/* Form column */
.auth-main {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: clamp(1.5rem, 4vw, 2.75rem) clamp(1.25rem, 3vw, 2.75rem);
  background: #ffffff;
  min-height: min(520px, calc(100vh - var(--auth-header-offset, 72px) - 4rem));
}

@media (min-width: 900px) {
  .auth-main {
    justify-content: flex-start;
    padding-top: clamp(2rem, 5vh, 3rem);
    padding-bottom: clamp(2rem, 5vh, 3rem);
    /* Scroll inside column only if truly necessary (tiny laptop heights) */
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
}

@media (max-width: 899px) {
  .auth-main {
    padding: 0 0 0.5rem;
    background: transparent;
    min-height: 0;
    overflow-y: visible;
  }
}

.auth-card {
  width: 100%;
  max-width: 420px;
}

/* Laptop / desktop: separate the form visually from the split panel */
@media (min-width: 900px) {
  .auth-card {
    padding: clamp(1.35rem, 2.5vw, 1.85rem) clamp(1.25rem, 2.5vw, 1.75rem);
    border-radius: 16px;
    border: 1px solid rgba(15, 23, 42, 0.1);
    background: #ffffff;
    box-shadow:
      0 1px 0 rgba(255, 255, 255, 0.9) inset,
      0 12px 40px rgba(15, 23, 42, 0.07);
  }

  .auth-layout .auth-field label {
    font-size: 0.875rem;
    color: #0f172a;
  }

  .auth-layout .auth-field input.auth-input {
    font-size: 1rem;
    border-color: rgba(15, 23, 42, 0.16);
    background: #ffffff;
  }

  .auth-layout .auth-submit {
    font-size: 1rem;
    min-height: 50px;
    height: auto;
  }
}

.auth-card__eyebrow {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--primary-2, #094bb8);
  margin: 0 0 0.5rem;
}

.auth-card__title {
  font-family: var(--shell-display, "DM Sans", system-ui, sans-serif);
  font-size: clamp(1.65rem, 3vw, 2rem);
  font-weight: 700;
  letter-spacing: -0.04em;
  color: var(--text, #0f172a);
  margin: 0 0 0.45rem;
}

.auth-card__subtitle {
  margin: 0 0 1.5rem;
  font-size: 0.95rem;
  line-height: 1.55;
  color: var(--muted, #475569);
}

.auth-field {
  margin-bottom: 1.1rem;
}

.auth-field label {
  display: block;
  font-size: 0.82rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: #334155;
  margin-bottom: 0.4rem;
}

.auth-field__control {
  position: relative;
  display: block;
}

.auth-field input.auth-input {
  width: 100%;
  height: var(--auth-field-h);
  padding: 0 0.95rem;
  font-size: 0.98rem;
  border-radius: 12px;
  border: 1px solid rgba(15, 23, 42, 0.12);
  background: #fafbfc;
  color: var(--text, #0f172a);
  transition:
    border-color 0.18s ease,
    background 0.18s ease,
    box-shadow 0.18s ease;
  box-sizing: border-box;
}

.auth-field input.auth-input:hover {
  border-color: rgba(15, 23, 42, 0.18);
  background: #ffffff;
}

.auth-field input.auth-input:focus {
  outline: none;
  border-color: rgba(11, 107, 255, 0.55);
  background: #ffffff;
  box-shadow: 0 0 0 4px rgba(11, 107, 255, 0.12);
}

.auth-field--password .auth-input {
  padding-right: 3rem;
}

.auth-toggle-pass {
  position: absolute;
  right: 2px;
  top: 50%;
  transform: translateY(-50%);
  width: 42px;
  height: 42px;
  border: none;
  border-radius: 10px;
  background: transparent;
  color: #64748b;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.auth-toggle-pass:hover {
  color: var(--primary, #0b6bff);
  background: rgba(11, 107, 255, 0.06);
}

.auth-submit {
  width: 100%;
  height: var(--auth-field-h);
  margin-top: 0.35rem;
  border: none;
  border-radius: 12px;
  font-size: 0.95rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  background: linear-gradient(180deg, var(--primary, #0b6bff) 0%, var(--primary-2, #094bb8) 100%);
  color: #ffffff;
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.12) inset,
    0 8px 22px rgba(11, 107, 255, 0.28);
  transition:
    transform 0.15s ease,
    box-shadow 0.15s ease,
    filter 0.15s ease;
}

.auth-submit:hover {
  filter: brightness(1.03);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.15) inset,
    0 12px 28px rgba(11, 107, 255, 0.32);
}

.auth-submit:active {
  transform: translateY(1px);
}

.auth-submit:disabled {
  opacity: 0.65;
  cursor: not-allowed;
  transform: none;
}

.auth-card__links {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.75rem 1.25rem;
  margin-top: 1.35rem;
  padding-top: 1.25rem;
  border-top: 1px solid rgba(15, 23, 42, 0.06);
}

.auth-card__links a {
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--primary-2, #094bb8);
  text-decoration: none;
}

.auth-card__links a:hover {
  text-decoration: underline;
}

.auth-card__links span {
  font-size: 0.82rem;
  color: #94a3b8;
}

/* ----- Standalone pages (admin login — no site nav) ----- */
.auth-page--standalone {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  margin: 0;
  background:
    radial-gradient(ellipse 90% 55% at 100% -15%, rgba(59, 130, 246, 0.09), transparent 55%),
    linear-gradient(180deg, #f8fafc 0%, #eef2f7 100%);
}

.auth-page--standalone .auth-layout-standalone {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: clamp(1.25rem, 4vw, 2rem);
  position: relative;
  isolation: isolate;
}

.auth-page--standalone .auth-layout-standalone::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  opacity: 0.45;
  background-image: url("../media/bcom-grid-dots.svg");
  background-repeat: repeat;
  background-size: 360px 360px;
}

.auth-page--standalone .auth-layout {
  position: relative;
  z-index: 1;
  max-width: 960px;
  width: 100%;
  min-height: auto;
}

@media (max-width: 899px) {
  .auth-page--standalone .auth-brand {
    border-radius: 20px 20px 0 0;
    margin-bottom: 0;
  }

  .auth-page--standalone .auth-main {
    background: #ffffff;
    border-radius: 0 0 20px 20px;
    padding: 1.75rem 1.35rem 2rem;
    border: 1px solid rgba(15, 23, 42, 0.06);
    border-top: none;
    box-shadow: 0 16px 40px rgba(15, 23, 42, 0.06);
  }
}

@media (min-width: 900px) {
  /* Do not cap height — avoids clipping the admin form on laptops */
  .auth-page--standalone .auth-layout {
    max-height: none;
    overflow: visible;
  }
}

.auth-standalone-footer {
  padding: 1rem 1.5rem 1.5rem;
  text-align: center;
}

.auth-standalone-footer .login-back {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--primary-2, #094bb8);
  text-decoration: none;
}

.auth-standalone-footer .login-back:hover {
  text-decoration: underline;
}

#loginError.auth-error-visible {
  margin-top: 1rem;
  padding: 0.65rem 0.75rem;
  border-radius: 10px;
  background: rgba(220, 38, 38, 0.08);
  border: 1px solid rgba(220, 38, 38, 0.18);
  color: #991b1b;
  font-size: 0.88rem;
}

@media (prefers-reduced-motion: reduce) {
  .auth-submit:hover {
    transform: none;
  }

  .auth-submit:active {
    transform: none;
  }
}
