/* Modern SaaS auth UI — scoped to .auth-saas-page (login + register; does not reset global layout) */

.auth-saas-page *,
.auth-saas-page *::before,
.auth-saas-page *::after {
  box-sizing: border-box;
}

.auth-saas-page .hidden {
  display: none !important;
}

.auth-saas-page {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: #fafbfc;
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  line-height: 1.5;
  min-height: 0;
}

.dark .auth-saas-page {
  background: #0c1117;
}

.login-container {
  width: 100%;
  max-width: 400px;
}

.login-container--wide {
  max-width: 460px;
}

.login-card {
  background: #ffffff;
  border-radius: 12px;
  padding: 48px 40px;
  box-shadow:
    0 2px 4px rgba(0, 0, 0, 0.02),
    0 8px 16px rgba(0, 0, 0, 0.06);
  border: 1px solid rgba(0, 0, 0, 0.05);
  position: relative;
}

.dark .login-card {
  background: #161b22;
  border-color: rgba(255, 255, 255, 0.08);
  box-shadow:
    0 2px 4px rgba(0, 0, 0, 0.2),
    0 8px 24px rgba(0, 0, 0, 0.35);
}

.login-header {
  text-align: center;
  margin-bottom: 32px;
}

.logo {
  margin-bottom: 20px;
  display: flex;
  justify-content: center;
}

.logo--custom img {
  max-width: min(220px, 100%);
  height: auto;
  max-height: 44px;
  object-fit: contain;
}

.login-header h1 {
  color: #1a1f36;
  font-size: 1.5rem;
  font-weight: 600;
  margin-bottom: 8px;
  letter-spacing: -0.02em;
}

.dark .login-header h1 {
  color: #f0f3f8;
}

.login-header p {
  color: #8792a2;
  font-size: 14px;
  font-weight: 400;
}

.dark .login-header p {
  color: #9ca8b8;
}

/* Server-side alerts */
.login-alert {
  border-radius: 6px;
  padding: 12px 14px;
  margin-bottom: 24px;
  font-size: 14px;
  font-weight: 500;
  line-height: 1.45;
}

.login-alert--error {
  color: #c53030;
  background: #fef5f5;
  border: 1px solid #fc8181;
}

.dark .login-alert--error {
  color: #feb2b2;
  background: rgba(254, 178, 178, 0.08);
  border-color: rgba(252, 129, 129, 0.4);
}

.login-alert--success {
  color: #276749;
  background: #f0fff4;
  border: 1px solid #9ae6b4;
}

.dark .login-alert--success {
  color: #9ae6b4;
  background: rgba(154, 230, 180, 0.08);
  border-color: rgba(154, 230, 180, 0.35);
}

/* Input Groups with Floating Labels */
.input-group {
  position: relative;
  margin-bottom: 24px;
}

.input-group input {
  width: 100%;
  background: #ffffff;
  border: 1px solid #e3e8ee;
  border-radius: 6px;
  padding: 16px 14px 8px 14px;
  color: #1a1f36;
  font-size: 16px;
  font-weight: 400;
  outline: none;
  transition: all 0.2s ease;
  font-family: inherit;
}

.dark .input-group input {
  background: #0d1117;
  border-color: #30363d;
  color: #f0f3f8;
}

.input-group input:focus {
  border-color: #635bff;
}

.input-group input::placeholder {
  color: transparent;
}

.input-group label {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: #8792a2;
  font-size: 16px;
  font-weight: 400;
  pointer-events: none;
  transition: all 0.2s ease;
  background: #ffffff;
  padding: 0 2px;
}

.dark .input-group label {
  background: #0d1117;
  color: #8b949e;
}

.input-group input:focus + label,
.input-group input:not(:placeholder-shown) + label {
  top: 0;
  font-size: 12px;
  font-weight: 500;
  color: #635bff;
  transform: translateY(-50%);
}

.input-group input:not(:focus):not(:placeholder-shown) + label {
  color: #6b7385;
}

/* Custom Border Animation */
.input-border {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 0;
  height: 2px;
  background: #635bff;
  transition: width 0.3s ease;
}

.input-group input:focus ~ .input-border {
  width: 100%;
}

/* Password Toggle */
.input-group:has(.password-toggle) input {
  padding-right: 42px;
}

.password-toggle {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  cursor: pointer;
  color: #8792a2;
  padding: 6px;
  border-radius: 4px;
  transition: color 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.password-toggle:hover {
  color: #635bff;
}

/* Form Options */
.form-options {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 28px;
  flex-wrap: wrap;
  gap: 16px;
}

.checkbox-container {
  display: flex;
  align-items: center;
  cursor: pointer;
  font-size: 14px;
  color: #6b7385;
  font-weight: 500;
}

.dark .checkbox-container {
  color: #9ca8b8;
}

.checkbox-container input[type="checkbox"] {
  display: none;
}

.checkmark {
  width: 18px;
  height: 18px;
  border: 1.5px solid #d1d9e0;
  border-radius: 4px;
  margin-right: 10px;
  position: relative;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  color: transparent;
}

.dark .checkmark {
  border-color: #30363d;
}

.checkbox-container input[type="checkbox"]:checked + .checkmark {
  background: #635bff;
  border-color: #635bff;
  color: white;
}

.forgot-link {
  color: #635bff;
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  transition: color 0.2s ease;
}

.forgot-link:hover {
  color: #4c44d4;
}

/* Submit Button */
.submit-btn {
  width: 100%;
  background: #635bff;
  color: #ffffff;
  border: none;
  border-radius: 6px;
  padding: 14px 20px;
  cursor: pointer;
  font-family: inherit;
  font-size: 16px;
  font-weight: 500;
  position: relative;
  margin-bottom: 24px;
  transition: all 0.2s ease;
  overflow: hidden;
  min-height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.submit-btn:hover {
  background: #4c44d4;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(99, 91, 255, 0.4);
}

.submit-btn:active {
  transform: translateY(0);
}

.submit-btn:disabled {
  background: #a2a7b5;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.btn-text {
  transition: opacity 0.2s ease;
}

.btn-loader {
  position: absolute;
  opacity: 0;
  transition: opacity 0.2s ease;
  color: #ffffff;
}

.submit-btn.loading .btn-text {
  opacity: 0;
}

.submit-btn.loading .btn-loader {
  opacity: 1;
}

/* Signup Link */
.signup-link {
  text-align: center;
  font-size: 14px;
  color: #8792a2;
}

.dark .signup-link {
  color: #8b949e;
}

.signup-link a {
  color: #635bff;
  text-decoration: none;
  font-weight: 500;
  transition: color 0.2s ease;
}

.signup-link a:hover {
  color: #4c44d4;
  text-decoration: underline;
}

/* Error States */
.error-message {
  color: #f56565;
  font-size: 12px;
  font-weight: 500;
  margin-top: 6px;
  opacity: 0;
  transform: translateY(-4px);
  transition: all 0.2s ease;
}

.error-message.show {
  opacity: 1;
  transform: translateY(0);
}

.input-group.error input {
  border-color: #f56565;
  background: #fef5f5;
}

.dark .input-group.error input {
  background: rgba(245, 101, 101, 0.08);
}

.input-group.error input:focus {
  border-color: #f56565;
}

.input-group.error label {
  color: #f56565;
}

.input-group.error .input-border {
  background: #f56565;
}

/* Success Message */
.success-message {
  display: none;
  text-align: center;
  padding: 32px 20px;
  opacity: 0;
  transform: translateY(16px);
  transition: all 0.3s ease;
}

.success-message.show {
  display: block;
  opacity: 1;
  transform: translateY(0);
}

.success-icon {
  margin: 0 auto 16px;
  animation: successPop 0.5s ease-out;
}

@keyframes successPop {
  0% {
    transform: scale(0);
  }
  50% {
    transform: scale(1.1);
  }
  100% {
    transform: scale(1);
  }
}

.success-message h3 {
  color: #1a1f36;
  font-size: 1.25rem;
  font-weight: 600;
  margin-bottom: 4px;
}

.dark .success-message h3 {
  color: #f0f3f8;
}

.success-message p {
  color: #8792a2;
  font-size: 14px;
}

/* Register: role segment, plan select, two-column names */
.reg-role-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: #6b7385;
  margin-bottom: 10px;
}

.dark .reg-role-label {
  color: #9ca8b8;
}

.role-segment {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding: 4px;
  border-radius: 8px;
  border: 1px solid #e3e8ee;
  background: #f1f3f5;
}

.dark .role-segment {
  border-color: #30363d;
  background: #0d1117;
}

.role-segment button {
  padding: 12px 14px;
  border-radius: 6px;
  border: none;
  cursor: pointer;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  color: #6b7385;
  background: transparent;
  transition: all 0.2s ease;
}

.dark .role-segment button {
  color: #9ca8b8;
}

.role-segment button.is-active {
  background: #ffffff;
  color: #1a1f36;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.dark .role-segment button.is-active {
  background: #21262d;
  color: #f0f3f8;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
}

.reg-role-wrap {
  margin-bottom: 24px;
}

.reg-field-static {
  margin-bottom: 24px;
}

.reg-field-static > .reg-field-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: #6b7385;
  margin-bottom: 8px;
}

.dark .reg-field-static > .reg-field-label {
  color: #9ca8b8;
}

.reg-select-wrap {
  position: relative;
}

.reg-select-wrap select {
  width: 100%;
  height: 48px;
  padding: 0 40px 0 14px;
  border: 1px solid #e3e8ee;
  border-radius: 6px;
  font-size: 16px;
  font-family: inherit;
  color: #1a1f36;
  background: #ffffff;
  appearance: none;
  cursor: pointer;
  outline: none;
  transition: border-color 0.2s ease;
}

.reg-select-wrap select:focus {
  border-color: #635bff;
}

.dark .reg-select-wrap select {
  background: #0d1117;
  border-color: #30363d;
  color: #f0f3f8;
}

.reg-select-wrap .reg-select-chevron {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  pointer-events: none;
  color: #8792a2;
}

.reg-field-hint {
  font-size: 12px;
  color: #8792a2;
  margin-top: 8px;
  line-height: 1.45;
}

.dark .reg-field-hint {
  color: #8b949e;
}

.reg-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 0;
}

.reg-grid-2 .input-group {
  margin-bottom: 24px;
}

@media (max-width: 480px) {
  .reg-grid-2 {
    grid-template-columns: 1fr;
  }
}

/* Mobile Responsive */
@media (max-width: 480px) {
  .auth-saas-page {
    padding: 16px;
  }

  .login-card {
    padding: 36px 28px;
    border-radius: 8px;
  }

  .login-header h1 {
    font-size: 1.375rem;
  }

  .form-options {
    flex-direction: column;
    align-items: flex-start;
    gap: 16px;
  }
}

/* Accessibility: keyboard focus within auth panel */
.auth-saas-page :focus-visible {
  outline: 2px solid currentColor;
  outline-offset: 2px;
  border-radius: 4px;
}

@media (prefers-reduced-motion: reduce) {
  .auth-saas-page *,
  .auth-saas-page *::before,
  .auth-saas-page *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
