/* ============================================
   BASE.CSS — Shared Styles for All Auth Pages
   Aligned with Landing Page Design System
   ============================================ */

/* ============ CSS VARIABLES ============ */
/* Font families, weights, and OpenType features inherited from
   static/css/global/typography.css (see docs/style-guide.md §5.0). */
:root {
  /* Primary — aliases to the global colour system */
  --color-primary: var(--bs-primary, #f7941d);
  --color-primary-hover: var(--bs-primary-active, #e58616);
  --color-primary-light: rgba(var(--bs-primary-rgb, 247, 148, 29), 0.08);
  --color-primary-soft: var(--bs-primary-light, #fef7ed);

  /* Neutrals — matching landing page ink hierarchy */
  --color-ink: var(--foreground);
  --color-ink-light: var(--foreground-soft);
  --color-ink-muted: var(--muted-foreground);
  --color-ink-faint: var(--muted-foreground-faint);
  --color-paper: var(--background);
  --color-paper-cool: var(--slate-50, #f8fafc);

  /* Status */
  --color-success: var(--bs-success);
  --color-success-soft: #d1fae5;
  --color-danger: var(--destructive);
  --color-danger-soft: #fee2e2;
  --color-warning: var(--bs-warning);
  --color-warning-soft: var(--bs-warning-light);

  /* Borders */
  --color-border: var(--slate-200, #e2e8f0);
  --color-border-light: var(--slate-100, #f1f5f9);

  /* Legacy aliases (used by existing templates) */
  --color-accent: var(--bs-primary, #f7941d);
  --color-accent-hover: var(--bs-primary-active, #e58616);
  --color-accent-soft: var(--bs-primary-light, #fef7ed);
  --color-accent-dark: var(--bs-primary-active, #c67610);

  /* Spacing — aliases to canonical scale (global/spacing.css, §5.0).
     These names are used throughout base.css and auth templates. */
  --space-xs: var(--space-2);   /* 0.5rem */
  --space-sm: var(--space-3);   /* 0.75rem */
  --space-md: var(--space-4);   /* 1rem */
  --space-lg: var(--space-5);   /* 1.5rem */
  --space-xl: var(--space-6);   /* 2rem */
  --space-2xl: var(--space-8);  /* 3rem */
  --space-3xl: var(--space-10); /* 4rem */
  --space-4xl: 6rem;            /* auth-only — no canonical equivalent */

  /* Border radius and shadows inherited from global/colours.css (§5.0).
     --shadow-card is auth-only (larger than --shadow-lg). */
  --shadow-card: 0 12px 40px rgba(0, 0, 0, 0.08);

  /* Transitions */
  --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-base: 250ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: 400ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* ============ DARK MODE ============ */
[data-bs-theme=dark] {
  /* Text — matching landing page dark mode (Linear's palette) */
  --color-ink: var(--foreground);
  --color-ink-light: var(--foreground-soft);
  --color-ink-muted: var(--muted-foreground);
  --color-ink-faint: var(--muted-foreground-faint);

  /* Backgrounds — matching landing page */
  --color-paper: var(--background);
  --color-paper-cool: #0b0c0d;
  --color-primary-soft: var(--bs-primary-light);

  /* Borders */
  --color-border: rgba(255, 255, 255, 0.08);
  --color-border-light: rgba(255, 255, 255, 0.05);

  /* Status */
  --color-success: var(--emerald-500);
  --color-success-soft: rgba(52, 211, 153, 0.15);
  --color-danger: var(--red-400);
  --color-danger-soft: rgba(248, 113, 113, 0.15);
  --color-warning: var(--amber-400);
  --color-warning-soft: rgba(251, 191, 36, 0.15);

  --shadow-sm: none;
  --shadow-md: none;
  --shadow-lg: none;
  --shadow-card: none;
}

/* Dark mode — auth page: dark bg matching landing page */
[data-bs-theme=dark] body.auth-bg {
  background: var(--background);
}

/* Dark mode — card stays transparent (no visible container) */

/* Dark mode — autofill */
[data-bs-theme=dark] input:-webkit-autofill,
[data-bs-theme=dark] input:-webkit-autofill:hover,
[data-bs-theme=dark] input:-webkit-autofill:focus {
  -webkit-box-shadow: 0 0 0 1000px var(--color-paper) inset !important;
  -webkit-text-fill-color: var(--color-ink) !important;
}

/* Dark mode — logo swap */
[data-bs-theme=dark] .auth-logo img,
[data-bs-theme=dark] .signup-logo img {
  content: url('/static/images/lawlinQ-logo-dark.png');
}

/* Dark mode — alerts use semantic vars, no overrides needed */

/* ============ RESETS ============ */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ============ AUTH BODY ============ */
body.auth-bg {
  font-family: var(--font-body);
  font-size: 0.9375rem;
  line-height: 1.6;
  letter-spacing: -0.011em;
  font-weight: var(--fw-normal);
  font-optical-sizing: auto;
  font-feature-settings: var(--font-settings);
  color: var(--color-ink-light);
  background: var(--color-paper);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow-x: hidden;
}

/* ============ BACKGROUND GRID ============ */
/* Hidden — Linear-inspired clean background, no pattern */
.auth-bg-waves {
  display: none;
}

/* ============ LOGO ============ */
.auth-logo {
  display: block;
  text-align: center;
  margin-bottom: var(--space-md);
  transition: opacity var(--transition-base);
}

.auth-logo:hover {
  opacity: 0.7;
}

.auth-logo img {
  height: 42px;
  width: auto;
  margin: 0 auto;
}

/* ============ AUTH CONTAINER ============ */
.auth-container {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-xl);
  position: relative;
  min-height: 100vh;
}

/* ============ AUTH BOX ============ */
.auth-box {
  width: 100%;
  max-width: 480px;
  animation: fadeInUp 0.5s ease-out both;
}

/* ============ AUTH CARD ============ */
/* Linear-inspired: no visible card — content floats on page */
.auth-card {
  background: transparent;
  border: none;
  border-radius: 0;
  padding: var(--space-3xl);
  box-shadow: none;
}

/* ============ FORM ELEMENTS ============ */
.form-group {
  margin-bottom: var(--space-lg);
}

.form-label {
  display: block;
  font-size: 0.875rem;
  font-weight: var(--fw-medium);
  color: var(--color-ink);
  margin-bottom: var(--space-xs);
  font-feature-settings: var(--font-settings);
}

.form-control {
  width: 100%;
  padding: 0.75rem 1rem;
  font-family: var(--font-body);
  font-size: 1rem;
  color: var(--color-ink);
  background: var(--color-paper);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
  outline: none;
  height: auto;
  line-height: 1.5;
}

.auth-bg .form-control,
.auth-form .form-control,
.auth-card .form-control {
  border-radius: var(--radius-sm) !important;
}

.form-control::placeholder {
  color: var(--color-ink-muted);
  opacity: 0.6;
}

.form-control:hover {
  border-color: var(--slate-300);
}

.form-control:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px var(--color-primary-light);
}

.form-control.is-invalid {
  border-color: var(--color-danger);
  animation: shake 0.3s ease-in-out;
}

/* Input Group */
.auth-form .input-group,
.auth-card .input-group,
.auth-bg .input-group {
  position: relative;
  display: block !important;
  flex-wrap: nowrap;
}

.auth-bg .input-group > .form-control {
  position: relative;
  flex: none;
  width: 100%;
  min-width: 0;
  z-index: 1;
}

/* Input group icons hidden — Linear-inspired clean inputs */
.auth-form .input-group-icon,
.auth-card .input-group-icon,
.auth-bg .input-group-icon {
  display: none;
}

/* Password Toggle */
.auth-form .password-toggle,
.auth-card .password-toggle,
.auth-bg .password-toggle {
  position: absolute;
  right: 1rem;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: var(--color-ink-muted);
  cursor: pointer;
  padding: 0.5rem;
  transition: color var(--transition-fast);
  z-index: 5;
}

.auth-form .password-toggle:hover,
.auth-card .password-toggle:hover,
.auth-bg .password-toggle:hover {
  color: var(--color-primary);
}

/* ============ BUTTONS ============ */
/* Linear-inspired: pill-shaped, height-based, compact font */
.auth-bg .btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  height: 36px;
  padding: 0 1.75rem;
  font-family: var(--font-body);
  font-size: 0.8125rem;
  font-weight: var(--fw-medium);
  border: 1px solid transparent;
  border-radius: 9999px;
  cursor: pointer;
  transition: border-color 0.15s, background-color 0.15s, color 0.15s, opacity 0.15s;
  text-decoration: none;
  white-space: nowrap;
  line-height: normal;
  user-select: none;
  box-shadow: none;
}

.auth-bg .btn:focus {
  outline: none;
  box-shadow: none;
}

.auth-bg .btn:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

.auth-bg .btn-primary {
  background: var(--color-primary);
  color: var(--bs-primary-inverse);
  border-color: var(--color-primary);
  box-shadow: none;
}

.auth-bg .btn-primary:hover {
  background: var(--color-primary-hover);
  border-color: var(--color-primary-hover);
  color: var(--bs-primary-inverse);
  transform: none;
  box-shadow: none;
}

.auth-bg .btn-primary:active {
  transform: none;
}

.auth-bg .btn-primary:disabled {
  background: var(--slate-300);
  border-color: var(--slate-300);
  cursor: not-allowed;
}

.auth-bg .btn-secondary {
  background: var(--color-paper);
  color: var(--color-ink);
  border-color: var(--color-border);
}

.auth-bg .btn-secondary:hover {
  background: var(--color-paper-cool);
  border-color: var(--color-ink-muted);
}

/* Small button variant */
.auth-bg .btn-sm {
  height: 32px;
  padding: 0 1.25rem;
}

/* Full-width button in auth forms */
.auth-form .btn-primary,
.auth-card .btn-primary {
  width: 100%;
}

/* Button Loading State */
.btn .indicator-progress {
  display: none;
}

.btn[data-kt-indicator="on"] .indicator-label {
  display: none;
}

.btn[data-kt-indicator="on"] .indicator-progress {
  display: inline-flex;
  align-items: center;
}

.spinner-border-sm {
  width: 1rem;
  height: 1rem;
  border-width: 2px;
}

/* ============ LINKS ============ */
.link-primary {
  color: var(--color-primary);
  font-weight: var(--fw-medium);
  transition: color var(--transition-fast);
  text-decoration: none;
}

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

.link-muted {
  color: var(--color-ink-muted);
  font-size: 0.9375rem;
  transition: color var(--transition-fast);
  text-decoration: none;
}

.link-muted:hover {
  color: var(--color-primary);
}

/* ============ ALERTS ============ */
.alert {
  padding: var(--space-md) var(--space-lg);
  border-radius: var(--radius-sm);
  margin-bottom: var(--space-xl);
  display: flex;
  align-items: flex-start;
  gap: var(--space-sm);
  background: var(--color-paper-cool);
  border: 1px solid var(--color-border);
}

.alert-icon {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.125rem;
  margin-top: 1px;
}

.alert-content {
  flex: 1;
}

.alert-title {
  font-weight: var(--fw-semibold);
  margin-bottom: 2px;
  font-size: 0.875rem;
  color: var(--color-ink);
  font-feature-settings: var(--font-settings);
}

.alert-text {
  font-size: 0.875rem;
  line-height: 1.5;
  color: var(--color-ink-muted);
}

.alert-text a {
  font-weight: var(--fw-medium);
  text-underline-offset: 2px;
}

/* Danger — links inherit danger color instead of clashing orange */
.alert-danger .alert-icon {
  color: var(--color-danger);
}

.alert-danger .alert-text a {
  color: var(--color-ink);
  text-decoration: underline;
}

.alert-danger .alert-text a:hover {
  color: var(--color-ink-light);
}

/* Success */
.alert-success .alert-icon {
  color: var(--color-success);
}

/* Warning */
.alert-warning .alert-icon {
  color: var(--color-warning);
}

/* ============ ANIMATIONS ============ */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-5px); }
  75% { transform: translateX(5px); }
}

@keyframes scaleIn {
  from {
    opacity: 0;
    transform: scale(0.5);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

/* Form Row Animation */
.form-row {
  opacity: 0;
  animation: fadeInUp 0.5s ease-out forwards;
}

.form-row:nth-child(1) { animation-delay: 0.05s; }
.form-row:nth-child(2) { animation-delay: 0.1s; }
.form-row:nth-child(3) { animation-delay: 0.15s; }
.form-row:nth-child(4) { animation-delay: 0.2s; }
.form-row:nth-child(5) { animation-delay: 0.25s; }
.form-row:nth-child(6) { animation-delay: 0.3s; }
.form-row:nth-child(7) { animation-delay: 0.35s; }
.form-row:nth-child(8) { animation-delay: 0.4s; }

/* ============ THEME TOGGLE ============ */
.auth-theme-wrapper {
  position: fixed;
  top: 1.25rem;
  right: 1.5rem;
  z-index: 100;
}

.auth-theme-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: none;
  background: transparent;
  color: var(--color-ink-muted);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: color var(--transition-fast), background var(--transition-fast);
  font-size: 1rem;
}

.auth-theme-toggle:hover {
  color: var(--color-primary);
  background: rgba(0, 0, 0, 0.04);
}

[data-bs-theme=dark] .auth-theme-toggle:hover {
  background: rgba(255, 255, 255, 0.06);
}

.auth-theme-toggle .theme-light-show { display: inline; }
.auth-theme-toggle .theme-dark-show { display: none; }
[data-bs-theme=dark] .auth-theme-toggle .theme-light-show { display: none; }
[data-bs-theme=dark] .auth-theme-toggle .theme-dark-show { display: inline; }

/* Theme dropdown menu */
.auth-theme-menu {
  display: none;
  position: absolute;
  top: calc(100% + 0.5rem);
  right: 0;
  min-width: 140px;
  background: var(--color-paper);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg, 0.75rem);
  box-shadow: var(--shadow-md, 0 4px 12px rgba(0,0,0,0.1));
  padding: 0.375rem;
  z-index: 101;
}

.auth-theme-wrapper.open .auth-theme-menu {
  display: block;
}

.auth-theme-option {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius-md, 0.5rem);
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--color-ink-muted);
  text-decoration: none;
  transition: background var(--transition-fast), color var(--transition-fast);
}

.auth-theme-option:hover {
  background: rgba(0, 0, 0, 0.04);
  color: var(--color-ink);
}

[data-bs-theme=dark] .auth-theme-option:hover {
  background: rgba(255, 255, 255, 0.06);
}

.auth-theme-option.active {
  color: var(--color-primary);
  font-weight: 600;
}

.auth-theme-option i {
  width: 1rem;
  text-align: center;
  font-size: 0.875rem;
}

/* ============ UTILITY CLASSES ============ */
.w-100 { width: 100%; }
.text-center { text-align: center; }
.mb-0 { margin-bottom: 0; }
.mt-auto { margin-top: auto; }

/* Hide default browser autofill styling */
input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus {
  -webkit-box-shadow: 0 0 0 1000px var(--color-paper) inset !important;
  -webkit-text-fill-color: var(--color-ink) !important;
  background-color: var(--color-paper) !important;
  transition: background-color 5000s ease-in-out 0s;
}

/* ============ RESPONSIVE — 768px ============ */
@media (max-width: 768px) {
  .auth-container {
    padding: var(--space-md);
    align-items: flex-start;
    padding-top: var(--space-xl);
  }

  .auth-box {
    max-width: 100%;
  }

}

/* ============ RESPONSIVE — 480px ============ */
@media (max-width: 480px) {
  .auth-container {
    padding: var(--space-md);
    padding-top: var(--space-xl);
    align-items: flex-start;
    min-height: 100vh;
  }

  .auth-box {
    max-width: 100%;
  }

  .auth-card {
    padding: var(--space-2xl) var(--space-xl);
  }

}

/* ============ RESPONSIVE — 360px ============ */
@media (max-width: 360px) {
  .auth-container {
    padding-top: var(--space-xl);
  }

  .auth-card {
    padding: var(--space-lg) var(--space-md);
  }
}


/* ── Firm Invite ── */
.firm-invite-alert {
    border-radius: var(--radius-lg);
}


/* ── 2FA Setup Required ── */
.auth-icon-badge {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 3.5rem;
    height: 3.5rem;
    border-radius: var(--radius-md);
    font-size: 1.5rem;
    margin: 0 auto var(--space-md);
}

.auth-icon-badge--warning {
    background: var(--color-warning-soft);
    color: var(--color-warning);
}

.twofa-required-info {
    background: var(--color-paper-cool);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    padding: var(--space-md);
}

.twofa-required-info__text {
    font-size: 0.9rem;
    color: var(--color-ink-muted);
    line-height: 1.6;
    margin: 0;
}

.twofa-required-options {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
}

.twofa-required-option {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    padding: var(--space-md);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    text-decoration: none;
    color: var(--color-ink);
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast), background var(--transition-fast);
}

.twofa-required-option:hover {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px var(--color-primary-light);
    color: var(--color-ink);
    text-decoration: none;
}

.twofa-required-option__icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 2.5rem;
    height: 2.5rem;
    border-radius: var(--radius-sm);
    background: var(--color-primary-soft);
    color: var(--color-primary);
    font-size: 1.1rem;
    flex-shrink: 0;
}

.twofa-required-option__body {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
}

.twofa-required-option__title {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--color-ink);
    line-height: 1.3;
}

.twofa-required-option__desc {
    font-size: 0.82rem;
    color: var(--color-ink-muted);
    line-height: 1.4;
}

.twofa-required-option__arrow {
    color: var(--color-ink-muted);
    font-size: 0.75rem;
    flex-shrink: 0;
    transition: transform var(--transition-fast);
}

.twofa-required-option:hover .twofa-required-option__arrow {
    transform: translateX(2px);
}

.link-muted {
    color: var(--color-ink-muted);
    font-size: 0.9rem;
    text-decoration: none;
}

.link-muted:hover {
    color: var(--color-ink);
    text-decoration: none;
}

[data-bs-theme=dark] .twofa-required-info {
    background: rgba(255, 255, 255, 0.03);
}

[data-bs-theme=dark] .twofa-required-option {
    border-color: rgba(255, 255, 255, 0.08);
    color: var(--slate-200);
}

[data-bs-theme=dark] .twofa-required-option:hover {
    border-color: var(--color-primary);
    background: rgba(var(--bs-primary-rgb, 247, 148, 29), 0.06);
}

[data-bs-theme=dark] .twofa-required-option__title {
    color: var(--slate-100);
}
