/* ============================================================
 * Grasper Auth — site.css v2.0
 * Unified design system — mirrors web-app theme.scss
 * ============================================================ */

/* --- Geist Font (self-hosted) --- */
@font-face {
  font-family: 'Geist';
  src: url('/fonts/GeistVF.woff2') format('woff2');
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

/* ============================================================
   DESIGN TOKENS
   ============================================================ */

:root {
  /* Neutral palette */
  --n-950: #0D0F12;  --n-900: #181C22;  --n-850: #1E2329;
  --n-800: #222831;  --n-750: #2C333C;  --n-700: #383E46;
  --n-600: #4E535A;  --n-500: #64696F;  --n-400: #7A7E83;
  --n-350: #919498;  --n-300: #A7A9AD;  --n-200: #D3D4D6;
  --n-150: #E9EAEA;  --n-100: #F3F4F4;  --n-50:  #F9F9FA;
  --n-0:   #FFFFFF;

  /* Crimson palette */
  --c-900: #6B1210;  --c-800: #991A17;  --c-700: #C42620;
  --c-600: #D93025;  --c-500: #E24840;  --c-400: #EA6B65;
  --c-300: #F19490;  --c-200: #F8C4C2;  --c-100: #FCE8E7;
  --c-50:  #FEF4F3;

  /* Semantic — Light Mode */
  --bg-page:    var(--n-100);
  --bg-surface: var(--n-0);
  --bg-inset:   var(--n-50);
  --bg-subtle:  var(--n-150);

  --text-primary:   var(--n-800);
  --text-secondary: var(--n-500);
  --text-tertiary:  var(--n-350);
  --text-inverse:   var(--n-0);

  --border:        var(--n-200);
  --border-strong: var(--n-350);
  --border-focus:  var(--c-600);

  --accent:        var(--c-600);
  --accent-hover:  var(--c-500);
  --accent-active: var(--c-700);
  --accent-subtle: var(--c-100);

  --success:     #1E8C42;
  --success-bg:  #F4FBF7;
  --error:       var(--c-600);
  --error-bg:    var(--c-50);
  --error-border: var(--c-200);

  /* Brand panel (left side) — always dark */
  --brand-bg:     var(--n-800);
  --brand-border: rgba(255, 255, 255, 0.06);

  /* Motion */
  --dur-base: 150ms;
  --dur-slow: 300ms;
  --ease:     cubic-bezier(0.16, 1, 0.3, 1);
  --ease-io:  cubic-bezier(0.4, 0, 0.2, 1);

  /* Shadows */
  --sh-sm: 0 1px 2px rgba(0,0,0,.04), 0 1px 3px rgba(0,0,0,.06);
  --sh-md: 0 4px 6px rgba(0,0,0,.05), 0 2px 4px rgba(0,0,0,.06), 0 0 0 1px rgba(0,0,0,.04);
  --sh-lg: 0 10px 15px rgba(0,0,0,.08), 0 4px 6px rgba(0,0,0,.05);
}

/* --- Dark Mode --- */
[data-theme="dark"] {
  --bg-page:    var(--n-950);
  --bg-surface: var(--n-900);
  --bg-inset:   var(--n-950);
  --bg-subtle:  var(--n-750);

  --text-primary:   var(--n-150);
  --text-secondary: var(--n-300);
  --text-tertiary:  var(--n-400);

  --border:        var(--n-700);
  --border-strong: var(--n-500);
  --border-focus:  var(--c-400);

  --accent:        var(--c-500);
  --accent-hover:  var(--c-400);
  --accent-active: var(--c-600);
  --accent-subtle: var(--c-900);

  --success-bg:   rgba(30, 140, 66, 0.15);
  --error:        var(--c-400);
  --error-bg:     var(--c-900);
  --error-border: var(--c-800);

  --brand-bg: var(--n-950);

  --sh-sm: 0 1px 2px rgba(0,0,0,.3), 0 0 0 1px rgba(255,255,255,.04);
  --sh-md: 0 4px 12px rgba(0,0,0,.4), 0 0 0 1px rgba(255,255,255,.06);
  --sh-lg: 0 10px 24px rgba(0,0,0,.5), 0 0 0 1px rgba(255,255,255,.06);
}

/* System preference fallback (when no data-theme cookie set) */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    --bg-page:    var(--n-950);
    --bg-surface: var(--n-900);
    --bg-inset:   var(--n-950);
    --bg-subtle:  var(--n-750);
    --text-primary:   var(--n-150);
    --text-secondary: var(--n-300);
    --text-tertiary:  var(--n-400);
    --border:        var(--n-700);
    --border-strong: var(--n-500);
    --border-focus:  var(--c-400);
    --accent:        var(--c-500);
    --accent-hover:  var(--c-400);
    --accent-active: var(--c-600);
    --accent-subtle: var(--c-900);
    --success-bg:   rgba(30, 140, 66, 0.15);
    --error:        var(--c-400);
    --error-bg:     var(--c-900);
    --error-border: var(--c-800);
    --brand-bg: var(--n-950);
    --sh-sm: 0 1px 2px rgba(0,0,0,.3), 0 0 0 1px rgba(255,255,255,.04);
    --sh-md: 0 4px 12px rgba(0,0,0,.4), 0 0 0 1px rgba(255,255,255,.06);
    --sh-lg: 0 10px 24px rgba(0,0,0,.5), 0 0 0 1px rgba(255,255,255,.06);
  }
}

/* ============================================================
   BASE
   ============================================================ */

*, *::before, *::after { box-sizing: border-box; }

html { height: 100%; }

body {
  font-family: 'Geist', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 15px;
  line-height: 1.6;
  color: var(--text-primary);
  background: var(--bg-page);
  margin: 0;
  padding: 0;
  min-height: 100%;
  transition: background-color var(--dur-slow) var(--ease-io),
              color var(--dur-slow) var(--ease-io);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

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

/* ============================================================
   SPLIT LAYOUT — Brand panel (left) + Form panel (right)
   ============================================================ */

.auth-page {
  display: flex;
  min-height: 100vh;
}

/* Brand panel — always dark, sticky on the left */
.auth-brand {
  display: none;
  position: sticky;
  top: 0;
  height: 100vh;
  width: 420px;
  flex-shrink: 0;
  background: var(--brand-bg);
  color: var(--n-150);
  padding: 48px 40px;
  flex-direction: column;
  justify-content: space-between;
  border-right: 1px solid var(--brand-border);
  transition: background-color var(--dur-slow) var(--ease-io);
  overflow: hidden;
}

/* Subtle dot grid overlay */
.auth-brand::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image: radial-gradient(circle, rgba(255,255,255,0.05) 1px, transparent 1px);
  background-size: 24px 24px;
  pointer-events: none;
}

/* Crimson glow accent */
.auth-brand::after {
  content: '';
  position: absolute;
  bottom: -120px;
  left: -80px;
  width: 420px;
  height: 420px;
  background: radial-gradient(circle, rgba(217, 48, 37, 0.12) 0%, transparent 65%);
  pointer-events: none;
}

.auth-brand-top {
  position: relative;
  z-index: 1;
}

.auth-brand-logo {
  display: flex;
  align-items: center;
  gap: 12px;
}

.auth-brand-logo img {
  height: 34px;
  width: auto;
}

.auth-brand-logo .brand-name {
  font-size: 21px;
  font-weight: 700;
  color: var(--n-150);
  letter-spacing: -0.025em;
}

.auth-brand-body {
  position: relative;
  z-index: 1;
}

.auth-brand-headline {
  font-size: 26px;
  font-weight: 700;
  color: var(--n-150);
  line-height: 1.25;
  letter-spacing: -0.03em;
  margin: 0 0 14px;
}

.auth-brand-desc {
  font-size: 14px;
  color: var(--n-400);
  line-height: 1.65;
  margin: 0 0 32px;
}

.auth-brand-features {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.auth-brand-features li {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-size: 14px;
  color: var(--n-350);
  line-height: 1.5;
}

.auth-brand-features li .feat-icon {
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  margin-top: 1px;
  stroke: var(--c-400);
  fill: none;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.auth-brand-footer {
  position: relative;
  z-index: 1;
  font-size: 12px;
  color: var(--n-600);
}

/* Form panel — right side, theme-aware */
.auth-form-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 48px 24px;
  background: var(--bg-page);
  position: relative;
  transition: background-color var(--dur-slow) var(--ease-io);
}

/* Scrollable for longer forms (register) */
.auth-form-panel.scrollable {
  justify-content: flex-start;
  padding-top: 64px;
  padding-bottom: 64px;
}

/* ============================================================
   THEME TOGGLE BUTTON
   ============================================================ */

.theme-toggle {
  position: absolute;
  top: 20px;
  right: 20px;
  width: 40px;
  height: 40px;
  border-radius: 8px;
  border: 1.5px solid var(--border);
  background: var(--bg-surface);
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
  transition: background-color var(--dur-base) var(--ease),
              color var(--dur-base) var(--ease),
              border-color var(--dur-base) var(--ease);
}

.theme-toggle:hover {
  background: var(--bg-subtle);
  color: var(--text-primary);
  border-color: var(--border-strong);
}

.theme-toggle svg {
  width: 18px;
  height: 18px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* Light mode → show moon; Dark mode → show sun */
.theme-toggle .icon-moon { display: block; }
.theme-toggle .icon-sun  { display: none; }

[data-theme="dark"] .theme-toggle .icon-moon { display: none; }
[data-theme="dark"] .theme-toggle .icon-sun  { display: block; }

@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) .theme-toggle .icon-moon { display: none; }
  :root:not([data-theme]) .theme-toggle .icon-sun  { display: block; }
}

/* ============================================================
   AUTH CARD
   ============================================================ */

.auth-card {
  width: 100%;
  max-width: 400px;
}

.auth-card.wide {
  max-width: 480px;
}

/* Logo — mobile only (hidden on desktop when brand panel shows) */
.auth-mobile-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 28px;
}

.auth-mobile-logo img {
  height: 28px;
  width: auto;
}

.auth-mobile-logo .brand-name {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.025em;
}

.auth-title {
  font-size: 24px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.03em;
  margin: 0 0 6px;
  line-height: 1.2;
}

.auth-subtitle {
  font-size: 14px;
  color: var(--text-secondary);
  margin: 0 0 28px;
  line-height: 1.55;
}

/* ============================================================
   FORM ELEMENTS
   ============================================================ */

.g-form-group {
  margin-bottom: 20px;
}

.g-form-group:last-child {
  margin-bottom: 0;
}

.g-label {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  margin-bottom: 6px;
}

.g-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}

.g-label-row .g-label {
  margin-bottom: 0;
}

.g-input-wrap {
  position: relative;
}

.g-input {
  display: block;
  width: 100%;
  height: 44px;
  padding: 0 16px;
  font-family: 'Geist', -apple-system, sans-serif;
  font-size: 15px;
  color: var(--text-primary);
  background: var(--bg-inset);
  border: 1.5px solid var(--border);
  border-radius: 8px;
  outline: none;
  -webkit-appearance: none;
  appearance: none;
  transition: border-color var(--dur-base) var(--ease),
              box-shadow var(--dur-base) var(--ease),
              background-color var(--dur-slow) var(--ease-io);
}

.g-input::placeholder {
  color: var(--text-tertiary);
}

.g-input:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(217, 48, 37, 0.15);
  background: var(--bg-surface);
}

.g-input.is-invalid,
.g-input.has-error {
  border-color: var(--error) !important;
  background: var(--error-bg);
}

.g-input.is-valid {
  border-color: var(--success);
}

/* Password field with reveal toggle */
.g-input-wrap.has-reveal .g-input {
  padding-right: 48px;
}

/* iOS Safari renders password bullets using the system font at a much larger
   size than the declared font-size. Force the field to use a monospace font
   that renders bullets at the correct 15px size across all mobile browsers. */
input[type="password"].g-input {
  font-family: Verdana, sans-serif;
  font-size: 15px;
  letter-spacing: 0.1em;
}

.g-reveal-btn {
  position: absolute;
  right: 1px;
  top: 1px;
  bottom: 1px;
  width: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  color: var(--text-tertiary);
  cursor: pointer;
  padding: 0;
  border-radius: 0 7px 7px 0;
  transition: color var(--dur-base) var(--ease);
}

.g-reveal-btn:hover {
  color: var(--text-primary);
}

.g-reveal-btn svg {
  width: 16px;
  height: 16px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* Validation error text — works with jQuery validate's is-invalid */
span.is-invalid,
div.is-invalid {
  display: block;
  font-size: 12px;
  color: var(--error);
  margin-top: 5px;
  padding: 0;
  background: transparent;
  border: none;
}

/* ============================================================
   BUTTON
   ============================================================ */

.g-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  height: 52px;
  padding: 0 28px;
  font-family: 'Geist', -apple-system, sans-serif;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.01em;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  text-decoration: none;
  -webkit-appearance: none;
  appearance: none;
  transition: background-color var(--dur-base) var(--ease),
              transform 100ms var(--ease),
              box-shadow var(--dur-base) var(--ease);
}

.g-btn-primary {
  background: var(--accent);
  color: #FFFFFF;
}

.g-btn-primary:hover {
  background: var(--accent-hover);
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(217, 48, 37, 0.3);
  color: #FFFFFF;
  text-decoration: none;
}

.g-btn-primary:active {
  background: var(--accent-active);
  transform: translateY(0);
  box-shadow: none;
}

.g-btn-primary:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(217, 48, 37, 0.3);
}

@keyframes btn-spin {
  to { transform: rotate(360deg); }
}

.g-btn-loading {
  pointer-events: none;
  opacity: 0.85;
}

.g-btn-loading::before {
  content: '';
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, 0.4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: btn-spin 0.65s linear infinite;
  flex-shrink: 0;
}

/* ============================================================
   ALERTS
   ============================================================ */

.g-alert {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 16px;
  border-radius: 8px;
  font-size: 14px;
  line-height: 1.5;
  margin-bottom: 24px;
}

.g-alert svg {
  flex-shrink: 0;
  width: 16px;
  height: 16px;
  margin-top: 2px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.g-alert-error {
  background: var(--error-bg);
  color: var(--error);
  border: 1px solid var(--error-border);
}

.g-alert-success {
  background: var(--success-bg);
  color: var(--success);
  border: 1px solid rgba(30, 140, 66, 0.25);
}

/* ============================================================
   LINKS & MISC
   ============================================================ */

.g-link {
  color: var(--accent);
  text-decoration: none;
  font-weight: 500;
  transition: color var(--dur-base) var(--ease);
}

.g-link:hover {
  color: var(--accent-hover);
  text-decoration: underline;
}

.g-text-sm {
  font-size: 14px;
  color: var(--text-secondary);
  text-align: center;
  margin: 0;
  line-height: 1.55;
}

.g-actions {
  margin-top: 24px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* ============================================================
   OTP / PASSCODE BOXES
   ============================================================ */

.otp-group {
  display: flex;
  gap: 10px;
  justify-content: center;
  margin-bottom: 24px;
}

.otp-input {
  width: 52px;
  height: 56px;
  text-align: center;
  font-size: 22px;
  font-weight: 600;
  font-family: 'Geist', monospace;
  color: var(--text-primary);
  background: var(--bg-inset);
  border: 1.5px solid var(--border);
  border-radius: 8px;
  outline: none;
  -webkit-appearance: none;
  appearance: none;
  -moz-appearance: textfield;
  transition: border-color var(--dur-base) var(--ease),
              box-shadow var(--dur-base) var(--ease);
}

.otp-input::-webkit-outer-spin-button,
.otp-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
}

.otp-input:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(217, 48, 37, 0.15);
  background: var(--bg-surface);
}

/* ============================================================
   PASSWORD STRENGTH CHECKLIST
   ============================================================ */

/* .fa-ul is kept for jQuery compatibility — styled here */
.fa-ul {
  list-style: none;
  padding: 14px 16px;
  margin: 10px 0 20px;
  background: var(--bg-inset);
  border: 1px solid var(--border);
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.fa-ul li {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-secondary);
}

.fa-li {
  display: flex;
  align-items: center;
  flex-shrink: 0;
}

/* Inline SVG icons for check/x (replacing FontAwesome) */
.fa-ul li svg {
  width: 14px;
  height: 14px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.fa-circle-xmark { color: var(--error); }
.fa-circle-check { color: var(--success); }

/* ============================================================
   RESPONSIVE — Show brand panel on desktop
   ============================================================ */

@media (min-width: 1024px) {
  .auth-brand {
    display: flex;
  }
  .auth-mobile-logo {
    display: none;
  }
}

@media (min-width: 1280px) {
  .auth-brand {
    width: 460px;
    padding: 56px 48px;
  }
}

/* ============================================================
   AUTOFILL FIX
   ============================================================ */

input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus {
  -webkit-text-fill-color: var(--n-800) !important;
  -webkit-box-shadow: 0 0 0 1000px var(--n-50) inset !important;
  transition: background-color 5000s ease-in-out 0s;
}

[data-theme="dark"] input:-webkit-autofill,
[data-theme="dark"] input:-webkit-autofill:hover,
[data-theme="dark"] input:-webkit-autofill:focus {
  -webkit-text-fill-color: var(--n-150) !important;
  -webkit-box-shadow: 0 0 0 1000px var(--n-950) inset !important;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) input:-webkit-autofill,
  :root:not([data-theme]) input:-webkit-autofill:hover,
  :root:not([data-theme]) input:-webkit-autofill:focus {
    -webkit-text-fill-color: var(--n-150) !important;
    -webkit-box-shadow: 0 0 0 1000px var(--n-950) inset !important;
  }
}
