/* Auth Module - Unified Styles */

:root {
  --auth-primary: #4f46e5;
  --auth-primary-hover: #4338ca;
  --auth-text: #1e293b;
  --auth-text-muted: #64748b;
  --auth-bg: #f8fafc;
  --auth-card: #ffffff;
  --auth-border: #e2e8f0;
  --auth-error: #ef4444;
  --auth-error-bg: #fef2f2;
  --auth-success: #22c55e;
  --auth-success-bg: #f0fdf4;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: linear-gradient(-45deg, #f8fafc, #e0e7ff, #f8fafc, #dbeafe);
  background-size: 400% 400%;
  animation: gradient-shift 15s ease infinite;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

@keyframes gradient-shift {
  0%, 100% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
}

/* Card */
.auth-card {
  width: 100%;
  max-width: 400px;
  background: var(--auth-card);
  border-radius: 20px;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.1);
  padding: 40px 32px;
}

/* Header */
.auth-header {
  text-align: center;
  margin-bottom: 32px;
}

.auth-title {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--auth-text);
  margin-bottom: 8px;
}

.auth-subtitle {
  font-size: 0.95rem;
  color: var(--auth-text-muted);
}

/* Flash Messages */
.auth-alert {
  padding: 12px 16px;
  border-radius: 10px;
  margin-bottom: 20px;
  font-size: 0.9rem;
}

.auth-alert.error {
  background: var(--auth-error-bg);
  color: var(--auth-error);
  border: 1px solid rgba(239, 68, 68, 0.2);
}

.auth-alert.success {
  background: var(--auth-success-bg);
  color: var(--auth-success);
  border: 1px solid rgba(34, 197, 94, 0.2);
}

/* Form */
.auth-form {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-label {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--auth-text);
}

.form-input {
  width: 100%;
  padding: 12px 16px;
  border: 1px solid var(--auth-border);
  border-radius: 10px;
  font-size: 1rem;
  color: var(--auth-text);
  background: #fff;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.form-input:focus {
  outline: none;
  border-color: var(--auth-primary);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.form-input::placeholder {
  color: #94a3b8;
}

/* Radio Group */
.radio-group {
  display: flex;
  gap: 24px;
}

.radio-label {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 0.95rem;
  color: var(--auth-text);
}

.radio-label input[type="radio"] {
  width: 18px;
  height: 18px;
  accent-color: var(--auth-primary);
  cursor: pointer;
}

/* Conditional Fields */
.conditional-field {
  display: none;
}

.conditional-field.visible {
  display: block;
}

/* Role Detection Display */
.role-detected {
  padding: 10px 16px;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  border-radius: 10px;
  color: #1d4ed8;
  font-weight: 500;
  font-size: 0.95rem;
}

.role-not-found {
  padding: 10px 16px;
  background: var(--auth-error-bg);
  border: 1px solid rgba(239, 68, 68, 0.2);
  border-radius: 10px;
  color: var(--auth-error);
  font-size: 0.9rem;
}

/* Button */
.btn-primary {
  width: 100%;
  padding: 14px 20px;
  background: var(--auth-primary);
  color: #fff;
  border: none;
  border-radius: 10px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
}

.btn-primary:hover {
  background: var(--auth-primary-hover);
}

.btn-primary:active {
  transform: scale(0.98);
}

/* Footer Links */
.auth-footer {
  text-align: center;
  margin-top: 24px;
  font-size: 0.9rem;
  color: var(--auth-text-muted);
}

.auth-footer a {
  color: var(--auth-primary);
  text-decoration: none;
  font-weight: 500;
}

.auth-footer a:hover {
  text-decoration: underline;
}

/* Success Page */
.auth-success {
  text-align: center;
  padding: 48px 32px;
}

.success-icon {
  width: 64px;
  height: 64px;
  background: var(--auth-success-bg);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 20px;
}

.success-icon svg {
  width: 32px;
  height: 32px;
  color: var(--auth-success);
}

.success-title {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--auth-text);
  margin-bottom: 8px;
}

.success-message {
  color: var(--auth-text-muted);
  margin-bottom: 24px;
}

/* Loading Spinner */
.spinner {
  width: 24px;
  height: 24px;
  border: 3px solid var(--auth-border);
  border-top-color: var(--auth-primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto;
}

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

/* Responsive */
@media (max-width: 480px) {
  body {
    padding: 16px;
  }

  .auth-card {
    padding: 32px 24px;
  }

  .auth-title {
    font-size: 1.5rem;
  }

  .radio-group {
    flex-direction: column;
    gap: 12px;
  }
}

/* Password Strength Indicator */
.password-strength {
  font-size: 0.8rem;
  margin-top: 4px;
  min-height: 1.2em;
}

.password-strength.valid {
  color: var(--auth-success);
}

.password-strength.invalid {
  color: var(--auth-text-muted);
}

/* WeChat Guide Button */
.wechat-guide {
  margin-top: 20px;
  padding-top: 20px;
  border-top: 1px solid var(--auth-border);
}

.btn-wechat {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 20px;
  background: #07c160;
  color: #fff;
  border: none;
  border-radius: 10px;
  font-size: 0.95rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
}

.btn-wechat:hover {
  background: #06ad56;
}

.btn-wechat:active {
  transform: scale(0.98);
}

/* Modal */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s, visibility 0.3s;
  z-index: 1000;
}

.modal-overlay.active {
  opacity: 1;
  visibility: visible;
}

.modal-content {
  background: #fff;
  border-radius: 16px;
  padding: 32px;
  max-width: 320px;
  width: 90%;
  text-align: center;
  position: relative;
  transform: scale(0.9);
  transition: transform 0.3s;
}

.modal-overlay.active .modal-content {
  transform: scale(1);
}

.modal-close {
  position: absolute;
  top: 12px;
  right: 16px;
  background: none;
  border: none;
  font-size: 1.5rem;
  color: var(--auth-text-muted);
  cursor: pointer;
  line-height: 1;
}

.modal-close:hover {
  color: var(--auth-text);
}

.modal-title {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--auth-text);
  margin-bottom: 8px;
}

.modal-subtitle {
  font-size: 0.9rem;
  color: var(--auth-text-muted);
  margin-bottom: 20px;
}

.qrcode-container {
  background: #f8fafc;
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 16px;
}

.qrcode-container img {
  width: 100%;
  max-width: 200px;
  height: auto;
  display: block;
  margin: 0 auto;
}

.modal-hint {
  font-size: 0.85rem;
  color: var(--auth-text-muted);
}
