/* ============================================================================
   VigilAI — authentication pages (Login / SignUp / Verification)
   Scoped under .vg-auth. Loaded AFTER style.css so it wins on the two auth
   pages without touching the rest of the admin template.
   Palette is taken from style.css, not invented:
     #0090e7 primary · #0d0d0d ground · #2c2e33 surface
     #00d25b success · #ffab00 warning · #fc424a danger
   ========================================================================= */

/* Tokens live on <body> — the modals and the toast are siblings of .vg-auth,
   not descendants, so scoping the custom properties to .vg-auth left them
   resolving to nothing (transparent panels). */
body.vg-auth-body,
.vg-auth {
  --vg-primary:      #0090e7;
  --vg-primary-soft: rgba(0, 144, 231, .14);
  --vg-primary-line: rgba(0, 144, 231, .38);
  --vg-ground:       #0d0d0d;
  --vg-panel:        #0a1119;
  --vg-surface:      #171b21;
  --vg-surface-2:    #2c2e33;
  --vg-line:         #262b33;
  --vg-text:         #eef2f6;
  --vg-muted:        #9aa7b4;
  --vg-faint:        #6b7783;
  --vg-success:      #00d25b;
  --vg-warning:      #ffab00;
  --vg-danger:       #fc424a;
  --vg-radius:       14px;
  --vg-radius-sm:    10px;
  --vg-field-h:      48px;
}

/* ---- shell ------------------------------------------------------------- */

.vg-auth,
.vg-auth body { margin: 0; }

body.vg-auth-body {
  margin: 0;
  min-height: 100vh;
  background: var(--vg-ground);
  color: var(--vg-text);
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
               "Helvetica Neue", Arial, "Noto Sans", sans-serif;
  -webkit-font-smoothing: antialiased;
}

.vg-auth {
  display: flex;
  min-height: 100vh;
  width: 100%;
}

/* ---- brand / artwork panel --------------------------------------------- */

.vg-auth__aside {
  position: relative;
  flex: 0 0 48%;
  max-width: 820px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 30px 38px;
  overflow: hidden;
  background:
    radial-gradient(900px 620px at 18% 12%, rgba(0, 144, 231, .16), transparent 62%),
    radial-gradient(700px 520px at 82% 88%, rgba(143, 95, 232, .12), transparent 60%),
    var(--vg-panel);
  border-right: 1px solid var(--vg-line);
}

/* faint engineering grid behind the artwork */
.vg-auth__aside::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(255, 255, 255, .028) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, .028) 1px, transparent 1px);
  background-size: 46px 46px;
  mask-image: radial-gradient(circle at 50% 45%, #000 20%, transparent 78%);
  -webkit-mask-image: radial-gradient(circle at 50% 45%, #000 20%, transparent 78%);
  pointer-events: none;
}

.vg-auth__brand {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
}

.vg-auth__brand img { height: 46px; width: auto; }

.vg-auth__art {
  position: relative;
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 6px 0;
  min-height: 0;
}

.vg-auth__art img {
  width: 100%;
  max-width: 440px;
  height: auto;
  filter: drop-shadow(0 24px 60px rgba(0, 144, 231, .18));
}

/* ---- artwork slider ------------------------------------------------------ */

/* .vg-auth__art is a flex centring context; its child wrapper would otherwise be
   shrink-to-fit, collapsing the slider's width:100% to nothing. */
.vg-auth__art > div {
  width: 100%;
  max-width: 660px;
}

/* Sized by height rather than aspect-ratio: the panel's vertical space is the
   binding constraint, and aspect-ratio + max-height would distort the box. */
.vg-slider {
  position: relative;
  width: 100%;
  height: clamp(260px, 44vh, 540px);
}

.vg-slide {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transform: scale(.985);
  transition: opacity .6s ease, transform .6s ease, visibility 0s linear .6s;
}

.vg-slide.is-active {
  opacity: 1;
  visibility: visible;
  transform: scale(1);
  transition: opacity .6s ease, transform .6s ease, visibility 0s;
}

/* max-width:none defeats the legacy `.vg-auth__art img { max-width: 440px }`
   rule above, which otherwise silently caps every slide. */
.vg-slide img {
  width: 100%;
  height: 100%;
  max-width: none;
  object-fit: contain;
  filter: none;
}

/* photo slides: framed, dimmed, brand-tinted, with detection boxes on top */
.vg-slide--photo {
  border-radius: var(--vg-radius);
  overflow: hidden;
  border: 1px solid var(--vg-line);
  box-shadow: 0 24px 60px rgba(0, 0, 0, .5);
}

.vg-slide--photo img {
  object-fit: cover;
  filter: saturate(.85) contrast(1.05) brightness(.72);
}

.vg-slide--photo::after {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(180deg, rgba(4, 10, 16, .12) 0%, rgba(4, 10, 16, .62) 100%),
    radial-gradient(120% 90% at 30% 20%, rgba(0, 144, 231, .16), transparent 70%);
  pointer-events: none;
}

/* detection boxes — positioned in % over the photo */
.vg-det {
  position: absolute;
  border: 2px solid var(--vg-primary);
  border-radius: 3px;
  z-index: 2;
  opacity: 0;
  animation: vgDetIn .5s ease forwards;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, .35);
}

.vg-det::before {
  content: attr(data-label);
  position: absolute;
  top: -21px;
  inset-inline-start: -2px;
  padding: 2px 7px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px;
  font-weight: 700;
  line-height: 1.35;
  white-space: nowrap;
  border-radius: 4px 4px 0 0;
  background: var(--vg-primary);
  color: #02121d;
}

.vg-det--green { border-color: var(--vg-success); }
.vg-det--green::before { background: var(--vg-success); color: #04170c; }
.vg-det--amber { border-color: var(--vg-warning); border-style: dashed; }
.vg-det--amber::before { background: var(--vg-warning); color: #1a1200; border-style: solid; }

@keyframes vgDetIn {
  from { opacity: 0; transform: scale(.94); }
  to   { opacity: 1; transform: scale(1); }
}

.vg-slide.is-active .vg-det { animation: vgDetIn .5s ease forwards; }

/* live badge on photo slides */
.vg-slide__badge {
  position: absolute;
  top: 12px;
  inset-inline-end: 12px;
  z-index: 3;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 5px 11px;
  border-radius: 999px;
  background: rgba(6, 12, 18, .82);
  border: 1px solid var(--vg-line);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px;
  font-weight: 700;
  color: #8fa3b5;
  letter-spacing: .06em;
}

.vg-slide__badge i {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--vg-danger);
  animation: vgRec 2.2s steps(1, end) infinite;
}

@keyframes vgRec { 0%, 50% { opacity: 1; } 51%, 100% { opacity: .25; } }

/* caption + dots */
.vg-slider__caption {
  margin-top: 12px;
  min-height: 18px;
  font-size: .82rem;
  color: var(--vg-faint);
  text-align: center;
  letter-spacing: .02em;
}

.vg-slider__dots {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-top: 10px;
}

.vg-slider__dot {
  appearance: none;
  border: 0;
  padding: 0;
  width: 22px;
  height: 4px;
  border-radius: 999px;
  background: #2b3542;
  cursor: pointer;
  transition: background .2s ease, width .2s ease;
}

.vg-slider__dot.is-active { background: var(--vg-primary); width: 30px; }

/* capability chips — the full detection set */
.vg-caps {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px;
  margin: 14px 0 0;
  padding: 0;
  list-style: none;
}

.vg-caps__chip {
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--vg-line);
  background: rgba(255, 255, 255, .03);
  color: var(--vg-muted);
  font-size: .72rem;
  font-weight: 600;
  letter-spacing: .01em;
  white-space: nowrap;
}

.vg-caps__chip--alert {
  border-color: rgba(255, 171, 0, .38);
  color: #ffd98a;
  background: rgba(255, 171, 0, .08);
}
.vg-slider__dot:focus-visible { outline: 2px solid var(--vg-primary); outline-offset: 3px; }

@media (prefers-reduced-motion: reduce) {
  .vg-slide { transition: opacity .01ms; }
  .vg-det { animation: none; opacity: 1; }
  .vg-slide__badge i { animation: none; }
}

.vg-auth__pitch { position: relative; max-width: 42ch; }

.vg-auth__pitch h2 {
  margin: 0 0 7px;
  font-size: 1.38rem;
  line-height: 1.26;
  font-weight: 650;
  letter-spacing: -.015em;
  color: #fff;
}

.vg-auth__pitch p {
  margin: 0;
  color: var(--vg-muted);
  font-size: .89rem;
  line-height: 1.55;
}

.vg-auth__stats {
  position: relative;
  display: flex;
  gap: 22px;
  margin-top: 14px;
  padding-top: 13px;
  border-top: 1px solid var(--vg-line);
}

.vg-auth__stat b {
  display: block;
  font-size: 1rem;
  font-weight: 650;
  color: #fff;
  letter-spacing: -.01em;
  /* "<1s" and "24/7" contain bidi-neutral characters that flip under dir="rtl"
     (rendering as "1s>"). Isolate them so they always read left-to-right. */
  direction: ltr;
  unicode-bidi: isolate;
}

.vg-auth[dir="rtl"] .vg-auth__stat b { text-align: right; }

.vg-auth__stat span {
  font-size: .72rem;
  color: var(--vg-faint);
  text-transform: uppercase;
  letter-spacing: .06em;
}

/* ---- form side ---------------------------------------------------------- */

.vg-auth__main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow-y: auto;
  max-height: 100vh;
}

.vg-auth__topbar {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 10px;
  padding: 22px 32px 0;
  flex: 0 0 auto;
}

.vg-auth__form-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 28px 32px 44px;
}

.vg-auth__form {
  width: 100%;
  max-width: 430px;
}

.vg-auth--wide .vg-auth__form { max-width: 560px; }

/* mobile-only brand mark, hidden while the aside is visible */
.vg-auth__brand--mobile { display: none; margin-bottom: 26px; }

.vg-auth__title {
  margin: 0 0 6px;
  font-size: 1.7rem;
  font-weight: 650;
  letter-spacing: -.02em;
  color: #fff;
}

.vg-auth__subtitle {
  margin: 0 0 28px;
  color: var(--vg-muted);
  font-size: .94rem;
}

/* ---- language toggle ---------------------------------------------------- */

.vg-lang {
  display: inline-flex;
  padding: 3px;
  gap: 2px;
  background: var(--vg-surface);
  border: 1px solid var(--vg-line);
  border-radius: 999px;
}

/* Rendered as <a> to the server-side /ChangeLanguage handler — the culture cookie
   is HttpOnly so it cannot be switched from script. */
.vg-lang__btn {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--vg-muted);
  font: inherit;
  font-size: .82rem;
  font-weight: 600;
  line-height: 1;
  padding: 7px 14px;
  border-radius: 999px;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  transition: background .18s ease, color .18s ease;
}

.vg-lang__btn:hover { color: var(--vg-text); text-decoration: none; }

.vg-lang__btn.is-active,
.vg-lang__btn[aria-pressed="true"] {
  background: var(--vg-primary);
  color: #fff;
}

.vg-lang__btn:focus-visible {
  outline: 2px solid var(--vg-primary);
  outline-offset: 2px;
}

/* ---- fields ------------------------------------------------------------- */

/* Field styling lives entirely in vg-forms.css (<vg-field> component).
   The generic `.vg-auth input[type=...]` rules that used to live here had
   specificity (0,2,1) and, loading after vg-forms.css, re-applied a border and
   background to the <input> INSIDE .vg-field__box — producing a second border
   starting after the icon. Only the auth-specific leftovers are kept below.   */

.vg-auth .form-group { margin-bottom: 18px; }

/* the one remaining plain control on these pages is the hidden storage field */
.vg-auth .form-group > label { 
  display: block;
  margin-bottom: 7px;
  font-size: .84rem;
  font-weight: 600;
  color: var(--vg-muted);
}


/* ---- buttons ------------------------------------------------------------ */

.vg-auth .btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: var(--vg-field-h);
  padding: 0 20px;
  border-radius: var(--vg-radius-sm);
  border: 1px solid transparent;
  font-size: .95rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform .12s ease, background .16s ease,
              border-color .16s ease, box-shadow .16s ease;
}

.vg-auth .btn:active { transform: translateY(1px); }
.vg-auth .btn:focus-visible { outline: 2px solid var(--vg-primary); outline-offset: 2px; }

.vg-auth .btn-vg-primary,
.vg-auth .btn-success {
  width: 100%;
  background: var(--vg-primary);
  border-color: var(--vg-primary);
  color: #fff;
  box-shadow: 0 8px 22px rgba(0, 144, 231, .22);
}

.vg-auth .btn-vg-primary:hover,
.vg-auth .btn-success:hover { background: #0a9ff5; border-color: #0a9ff5; color: #fff; }

.vg-auth .btn-vg-primary[disabled],
.vg-auth .btn-success[disabled] { opacity: .6; cursor: not-allowed; box-shadow: none; }

.vg-auth .btn-outline-primary,
.vg-auth .btn-vg-ghost {
  background: transparent;
  border-color: var(--vg-line);
  color: var(--vg-text);
}

.vg-auth .btn-outline-primary:hover,
.vg-auth .btn-vg-ghost:hover {
  background: var(--vg-surface);
  border-color: var(--vg-primary-line);
  color: #fff;
}

.vg-auth__actions { margin-top: 24px; }

.vg-auth__meta {
  margin-top: 18px;
  text-align: center;
  font-size: .88rem;
  color: var(--vg-muted);
}

.vg-auth__meta a,
.vg-auth .login-link a {
  color: var(--vg-primary);
  text-decoration: none;
  font-weight: 600;
}

.vg-auth__meta a:hover,
.vg-auth .login-link a:hover { text-decoration: underline; }

.vg-auth__link {
  background: none;
  border: 0;
  padding: 0;
  font: inherit;
  color: var(--vg-primary);
  font-weight: 600;
  cursor: pointer;
}

.vg-auth__link:hover { text-decoration: underline; }

/* ---- alerts -------------------------------------------------------------- */

.vg-auth .alert {
  border-radius: var(--vg-radius-sm);
  border: 1px solid;
  padding: 12px 14px;
  font-size: .88rem;
  margin-bottom: 20px;
}

.vg-auth .alert p { margin: 0; }
.vg-auth .alert p + p { margin-top: 4px; }

.vg-auth .alert-danger {
  background: rgba(252, 66, 74, .1);
  border-color: rgba(252, 66, 74, .35);
  color: #ffb3b7;
}

.vg-auth .alert-success {
  background: rgba(0, 210, 91, .1);
  border-color: rgba(0, 210, 91, .35);
  color: #93f0bd;
}

.vg-auth .alert-warning {
  background: rgba(255, 171, 0, .1);
  border-color: rgba(255, 171, 0, .35);
  color: #ffd98a;
}

/* ---- SignUp-specific bits ------------------------------------------------ */

.vg-auth .required-note {
  font-size: .82rem;
  color: var(--vg-faint);
  margin-bottom: 18px;
}

.vg-auth .form-footer {
  display: flex;
  flex-direction: column-reverse;
  gap: 10px;
  margin-top: 26px;
}

.vg-auth .form-footer > div { width: 100%; }
.vg-auth .form-footer .btn { width: 100%; }

.vg-auth .login-link {
  margin-top: 18px;
  text-align: center;
  font-size: .88rem;
  color: var(--vg-muted);
}

/* password strength meter */
.vg-auth .password-strength-container { margin-top: 10px; }

.vg-auth .password-strength-label {
  display: flex;
  justify-content: space-between;
  font-size: .78rem;
  color: var(--vg-faint);
  margin-bottom: 6px;
}

.vg-auth .password-strength-text { font-weight: 600; color: var(--vg-muted); }

.vg-auth .password-strength-bar-container {
  height: 5px;
  border-radius: 999px;
  background: var(--vg-surface-2);
  overflow: hidden;
}

.vg-auth .password-strength-bar {
  height: 100%;
  width: 0;
  border-radius: 999px;
  background: var(--vg-danger);
  transition: width .25s ease, background .25s ease;
}

.vg-auth .password-strength-desc {
  margin-top: 7px;
  font-size: .76rem;
  line-height: 1.5;
  color: var(--vg-faint);
}

/* intl-tel-input sits inside .input-group and injects its own wrapper */
.vg-auth .iti { width: 100%; display: block; }
.vg-auth .iti__flag-container { z-index: 4; }
.vg-auth .iti--separate-dial-code .iti__selected-flag {
  background: transparent;
  border-radius: var(--vg-radius-sm) 0 0 var(--vg-radius-sm);
}
.vg-auth .iti__country-list {
  background: var(--vg-surface);
  border: 1px solid var(--vg-line);
  border-radius: var(--vg-radius-sm);
  color: var(--vg-text);
}
.vg-auth .iti__country.iti__highlight { background: rgba(0, 144, 231, .18); }
.vg-auth .iti__divider { border-color: var(--vg-line); }

/* leaflet map is intentionally 1px tall in the markup; keep it invisible */
.vg-auth #map { border-radius: var(--vg-radius-sm); overflow: hidden; }

/* ---- modals -------------------------------------------------------------- */

/* Only Bootstrap 5's JS is loaded on these pages — the CSS comes from the
   BS4-era admin template — so the dialog geometry is restated here rather
   than assumed. */
.vg-auth-modal .modal-dialog {
  max-width: 460px;
  margin: 1.75rem auto;
}

.vg-auth-modal.modal.show { display: block; }

.vg-auth-modal .modal-dialog-centered {
  display: flex;
  align-items: center;
  min-height: calc(100% - 3.5rem);
}

.vg-auth-modal .modal-content {
  width: 100%;
  background: var(--vg-surface, #171b21);
  border: 1px solid var(--vg-line, #262b33);
  border-radius: var(--vg-radius, 14px);
  color: var(--vg-text, #eef2f6);
  box-shadow: 0 26px 70px rgba(0, 0, 0, .55);
}

.vg-auth-modal .modal-header,
.vg-auth-modal .modal-body,
.vg-auth-modal .modal-footer { padding: 16px 20px; }

.vg-auth-modal .modal-header,
.vg-auth-modal .modal-footer {
  display: flex;
  align-items: center;
}

.vg-auth-modal .modal-header { justify-content: space-between; }
.vg-auth-modal .modal-footer { justify-content: flex-end; gap: 10px; }
.vg-auth-modal .modal-body p { color: var(--vg-muted, #9aa7b4); font-size: .9rem; margin: 0 0 16px; }

.vg-auth-modal .modal-header,
.vg-auth-modal .modal-footer { border-color: var(--vg-line); }

.vg-auth-modal .modal-title { font-size: 1.05rem; font-weight: 650; }

/* Bootstrap 5's .btn-close CSS is not loaded here (only its JS), so draw it. */
.vg-auth-modal .btn-close,
.vg-auth-toast .btn-close {
  appearance: none;
  width: 30px;
  height: 30px;
  padding: 0;
  border: 0;
  border-radius: 8px;
  opacity: .75;
  cursor: pointer;
  background: transparent
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%23eef2f6' stroke-width='1.8' stroke-linecap='round'%3E%3Cpath d='M4 4l8 8M12 4l-8 8'/%3E%3C/svg%3E")
    center / 14px 14px no-repeat;
  filter: none;
  transition: opacity .16s ease, background-color .16s ease;
}

.vg-auth-modal .btn-close:hover,
.vg-auth-toast .btn-close:hover { opacity: 1; background-color: rgba(255, 255, 255, .08); }

.vg-auth-modal .btn-close:focus-visible,
.vg-auth-toast .btn-close:focus-visible { outline: 2px solid var(--vg-primary, #0090e7); outline-offset: 2px; }

.vg-auth-modal .form-control {
  width: 100%;
  height: var(--vg-field-h);
  padding: 0 14px;
  background: #10161d;
  border: 1px solid var(--vg-line);
  border-radius: var(--vg-radius-sm);
  color: var(--vg-text);
}

.vg-auth-modal .form-control:focus {
  outline: none;
  border-color: var(--vg-primary);
  box-shadow: 0 0 0 4px var(--vg-primary-soft);
}

.vg-auth-modal label { font-size: .84rem; font-weight: 600; color: var(--vg-muted); margin-bottom: 7px; display: block; }
.vg-auth-modal .btn { border-radius: var(--vg-radius-sm); height: 42px; padding: 0 18px; font-weight: 600; }
.vg-auth-modal .btn-primary { background: var(--vg-primary); border-color: var(--vg-primary); }
.vg-auth-modal .btn-secondary { background: transparent; border-color: var(--vg-line); color: var(--vg-text); }

/* floating alert */
.vg-auth-toast {
  position: fixed;
  top: 22px;
  inset-inline-end: 22px;
  z-index: 1090;
  display: none;
  min-width: 280px;
  max-width: 400px;
  border-radius: var(--vg-radius-sm);
  border: 1px solid var(--vg-line);
  background: var(--vg-surface);
  color: var(--vg-text);
  padding: 13px 40px 13px 15px;
  box-shadow: 0 18px 40px rgba(0, 0, 0, .45);
  font-size: .9rem;
}

.vg-auth-toast .btn-close {
  position: absolute;
  top: 9px;
  inset-inline-end: 9px;
  filter: invert(1) grayscale(1) brightness(1.6);
}

/* ---- RTL ----------------------------------------------------------------- */

.vg-auth[dir="rtl"] { direction: rtl; }
.vg-auth[dir="rtl"] .vg-auth__aside { border-right: 0; border-left: 1px solid var(--vg-line); }
.vg-auth[dir="rtl"] .vg-auth__topbar { justify-content: flex-start; }
.vg-auth[dir="rtl"] .password-strength-label { direction: rtl; }

/* ---- responsive ---------------------------------------------------------- */

@media (max-width: 1200px) {
  .vg-auth__aside { flex-basis: 40%; padding: 36px 34px; }
}

@media (max-width: 991.98px) {
  .vg-auth { flex-direction: column; }
  .vg-auth__aside { display: none; }
  .vg-auth__brand--mobile { display: flex; align-items: center; gap: 12px; }
  .vg-auth__brand--mobile img { height: 42px; width: auto; }
  .vg-auth__main { max-height: none; overflow: visible; }
  .vg-auth__form-wrap { align-items: flex-start; padding: 8px 22px 40px; }
  .vg-auth__topbar { padding: 18px 22px 0; }
}

@media (max-width: 480px) {
  .vg-auth__form-wrap { padding: 4px 16px 32px; }
  .vg-auth__title { font-size: 1.45rem; }
  .vg-auth { --vg-field-h: 46px; }
}

@media (prefers-reduced-motion: reduce) {
  .vg-auth *,
  .vg-auth *::before,
  .vg-auth *::after { transition-duration: .01ms !important; animation-duration: .01ms !important; }
}
