/* 登录页样式 — 由 templates/auth/login.html 拆出，勿在模板内再写 <style> */

/* 登录页面 - LeetCode 风格，浅色背景图 */
body.auth-page .main-container, body.auth-page .page-content {
  background: transparent !important;
}
body.auth-page {
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  color: #262626;
  min-height: 100vh;
  overflow-x: hidden;
  overflow-y: auto;
  background-image: 
    radial-gradient(circle at 1px 1px, rgba(0,0,0,0.04) 1px, transparent 0) !important;
  background-size: 24px 24px !important;
  background-color: #f8f9fa !important;
}
body.auth-page::before, body.auth-page::after { content: none !important; }

.modern-footer { display: none !important; }
body.auth-page .main-container {
  padding-top: 0 !important;
  padding-bottom: 3rem !important;
  max-width: none !important;
}

/* 登录容器 - 居中，卡片放大；预留双行顶栏高度，避免 fixed navbar 挡住表单 */
.login-container {
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
  padding: 2rem;
  position: relative;
  z-index: 2;
  margin-top: max(120px, calc(var(--navbar-height, 56px) + 3rem));
  padding-top: env(safe-area-inset-top, 0px);
}

.login-card {
  background: #ffffff !important;
  border: 1px solid #e9ecef;
  border-radius: 16px;
  padding: 2.5rem 3rem;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.08);
  position: relative;
  overflow: visible;
  width: 100%;
}

.login-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, #667eea 0%, #764ba2 100%);
  border-radius: 12px 12px 0 0;
}

/* Logo区域 */
.logo-section {
  text-align: center;
  margin-bottom: 1.5rem;
}

.logo {
  font-size: 2rem;
  font-weight: 700;
  color: #262626;
  margin-bottom: 0.5rem;
}

.logo-subtitle {
  color: #6c757d;
  font-size: 0.95rem;
  font-weight: 400;
}

/* 表单样式 */
.form-group {
  margin-bottom: 1.5rem;
  position: relative;
}

.form-label {
  display: block;
  color: #262626;
  font-weight: 500;
  margin-bottom: 0.5rem;
  font-size: 0.9rem;
}

.form-input {
  width: 100%;
  padding: 0.9rem 1rem 0.9rem 2.75rem;
  background: #ffffff;
  border: 1px solid #e9ecef;
  border-radius: 8px;
  color: #262626;
  font-size: 16px;
  transition: all 0.2s ease;
  box-sizing: border-box;
  pointer-events: auto;
  position: relative;
  z-index: 1;
}

.form-input:focus {
  outline: none;
  border-color: #667eea;
  box-shadow: 0 0 0 2px rgba(102, 126, 234, 0.25);
}

.form-input::placeholder {
  color: #6c757d;
}

/* 输入框与图标对齐：图标相对于 input-wrap 垂直居中 */
.input-wrap {
  position: relative;
  display: block;
}
.input-icon {
  position: absolute;
  left: 1rem;
  top: 50%;
  transform: translateY(-50%);
  color: #6c757d;
  font-size: 1rem;
  transition: color 0.2s ease;
  pointer-events: none;
}

.form-input:focus ~ .input-icon,
.input-wrap:focus-within .input-icon {
  color: #667eea;
}

/* 复选框样式 */
.checkbox-group {
  display: flex;
  align-items: center;
  margin-bottom: 1.2rem;
}

.checkbox {
  appearance: none;
  width: 20px;
  height: 20px;
  border: 2px solid #e9ecef;
  border-radius: 6px;
  margin-right: 0.75rem;
  position: relative;
  cursor: pointer;
  transition: all 0.2s ease;
}

.checkbox:checked {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  border-color: #667eea;
}

.checkbox:checked::after {
  content: '✓';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: #ffffff;
  font-size: 12px;
  font-weight: bold;
}

.checkbox-label {
  color: #6c757d;
  font-size: 0.9rem;
  cursor: pointer;
}

/* 按钮样式 - 蓝紫科技风，与主页一致 */
.btn-login {
  width: 100%;
  padding: 0.9rem;
  background: linear-gradient(90deg, #4f46e5 0%, #4338ca 50%, #6366f1 100%);
  border: none;
  border-radius: 8px;
  color: #ffffff;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  box-shadow: 0 4px 14px rgba(102, 126, 234, 0.4);
}

.btn-login:hover {
  background: linear-gradient(90deg, #5b21b6 0%, #4f46e5 50%, #6366f1 100%);
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(102, 126, 234, 0.45);
}

.btn-login:active {
  transform: translateY(0);
}

/* 分割线 */
.divider {
  margin: 1.2rem 0;
  text-align: center;
  position: relative;
}

.divider::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 0;
  right: 0;
  height: 1px;
  background: #e9ecef;
}

.divider-text {
  background: #ffffff;
  padding: 0 1rem;
  color: #6c757d;
  font-size: 0.9rem;
}

/* 注册链接 */
.register-link {
  text-align: center;
  color: #6c757d;
  font-size: 0.9rem;
}

.register-link a {
  color: #667eea;
  text-decoration: none;
  font-weight: 500;
  transition: color 0.2s ease;
}

.register-link a:hover {
  color: #764ba2;
}

.login-help-link {
  text-align: center;
  margin-top: 1rem;
}
.login-help-link .login-help-a {
  color: #94a3b8;
  font-size: 0.85rem;
  text-decoration: none;
}
.login-help-link .login-help-a:hover {
  color: #64748b;
  text-decoration: underline;
}

/* 错误消息 */
.alert {
  padding: 0.8rem 1rem;
  border-radius: 8px;
  margin-bottom: 1rem;
  border: 1px solid #e9ecef;
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #ffffff;
}

.alert-danger {
  background: #fff5f5;
  border-color: #feb2b2;
  color: #c53030;
}

.alert-success {
  background: #f0fff4;
  border-color: #9ae6b4;
  color: #276749;
}

.alert-content {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.alert-close {
  background: none;
  border: none;
  color: #6c757d;
  cursor: pointer;
  font-size: 1rem;
  padding: 0.25rem;
}

.alert-close:hover {
  color: #262626;
}

/* 动画效果 */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(30px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.fade-in-up {
  animation: fadeInUp 0.8s ease-out forwards;
}

.fade-in-up-delay-1 {
  animation: fadeInUp 0.8s ease-out 0.2s forwards;
}

.fade-in-up-delay-2 {
  animation: fadeInUp 0.8s ease-out 0.4s forwards;
}

@media (prefers-reduced-motion: reduce) {
  .fade-in-up,
  .fade-in-up-delay-1,
  .fade-in-up-delay-2 {
    animation: none !important;
    opacity: 1 !important;
    transform: none !important;
  }
}

/* 移动端响应式设计 - 强制单列布局 */
@media (max-width: 768px) {
  body.auth-page {
    padding: 0;
    margin: 0;
    background-color: #f8f9fa !important;
    background-image: radial-gradient(circle at 1px 1px, rgba(0,0,0,0.04) 1px, transparent 0) !important;
    background-size: 24px 24px !important;
    overflow-x: hidden;
  }
  
  /* 移动端字体大小调整 */
  .logo {
    font-size: 2rem !important;
    margin-bottom: 0.8rem;
  }
  
  .logo-subtitle {
    font-size: 0.9rem !important;
    line-height: 1.5;
  }
  
  .form-label {
    font-size: 0.95rem !important;
    margin-bottom: 0.6rem;
  }
  
  .form-input {
    font-size: 14px !important;
    padding: 1.2rem 1rem 1.2rem 3rem;
  }
  
  .input-icon {
    font-size: 1rem !important;
    left: 1rem;
  }
  
  .checkbox-label {
    font-size: 0.9rem !important;
  }
  
  .btn-login {
    font-size: 16px !important;
    padding: 1.2rem;
  }
  
  .divider-text {
    font-size: 0.8rem !important;
  }
  
  .register-link {
    font-size: 0.9rem !important;
  }
  
  .register-link a {
    font-size: 0.9rem !important;
  }
  
  .alert {
    font-size: 0.85rem !important;
    padding: 1rem;
  }
  
  .login-container {
    width: 100% !important;
    max-width: 100% !important;
    padding: 0 16px 3rem !important;
    margin: clamp(40px, 10vh, 128px) auto 0 !important;
    min-height: auto !important;
    display: block !important;
    position: relative;
    text-align: center;
    left: auto !important;
    right: auto !important;
    transform: none !important;
    padding-top: 2rem !important;
    box-sizing: border-box !important;
  }
  
  .login-card {
    width: 100% !important;
    max-width: 480px !important;
    margin: 0 auto !important;
    border-radius: 16px !important;
    padding: 2.5rem 2rem !important;
    min-height: auto !important;
    display: block !important;
    background: #ffffff;
    border: 1px solid #e9ecef !important;
    box-shadow: 0 4px 12px rgba(0,0,0,.08) !important;
  }
  
  .logo-section {
    margin-bottom: 2.5rem;
    padding: 0 2rem;
    text-align: center;
    order: 1;
  }
  
  .logo {
    font-size: 1.6rem;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
  }
  
  .logo-subtitle {
    font-size: 0.95rem;
    line-height: 1.6;
    color: #6c757d;
  }
  
  .form-group {
    margin-bottom: 1.8rem;
    padding: 0; /* 取消左右内边距，避免与按钮不对齐 */
    order: 2;
    width: 100%;
    max-width: 300px;
    margin-left: auto;
    margin-right: auto; /* 与按钮保持同样的居中方式 */
    box-sizing: border-box;
  }
  
  .form-label {
    font-size: 1.1rem;
    margin-bottom: 0.8rem;
    color: #262626;
    font-weight: 600;
  }
  
  .form-input {
    width: 100% !important;
    padding: 1.2rem 0.9rem 1.2rem 3rem;
    font-size: 15px;
    border-radius: 8px;
    border: 1px solid #e9ecef;
    background: #ffffff;
    color: #262626;
    box-sizing: border-box;
  }
  
  .form-input:focus {
    border-color: #667eea;
    box-shadow: 0 0 0 2px rgba(102, 126, 234, 0.25);
    outline: none;
  }
  
  .form-input::placeholder {
    color: #6c757d;
  }
  
  .input-icon {
    left: 1.2rem;
    font-size: 1.2rem;
    color: #6c757d;
  }
  
  .checkbox-group {
    padding: 0 2rem;
    margin-bottom: 2rem;
    order: 3;
    width: 100%;
    max-width: 320px;
  }
  
  .checkbox {
    width: 18px;
    height: 18px;
    margin-right: 1rem;
    accent-color: #667eea;
  }
  
  .checkbox-label {
    font-size: 0.95rem;
    color: #ffffff;
  }
  
  .btn-login {
    width: 100% !important;
    max-width: 300px !important;
    margin: 0 auto; /* 与输入框完全对齐 */
    padding: 1rem;
    font-size: 16px;
    font-weight: 700;
    border-radius: 8px;
    background: linear-gradient(90deg, #4f46e5 0%, #4338ca 50%, #6366f1 100%);
    border: none;
    color: #ffffff;
    cursor: pointer;
    transition: all 0.3s ease;
    order: 4;
    display: flex !important;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    box-sizing: border-box;
    box-shadow: 0 4px 14px rgba(102, 126, 234, 0.4);
  }
  
  .btn-login:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.45);
  }
  
  .divider {
    margin: 2rem 2rem;
    order: 5;
  }
  
  .register-link {
    padding: 0 2rem 1rem;
    font-size: 1.1rem;
    text-align: center;
    order: 6;
  }
  
  .register-link a {
    font-size: 1.1rem;
    font-weight: 600;
    color: #667eea;
  }
  
  .alert {
    margin: 0 2rem 1.5rem;
    padding: 1.2rem;
    border-radius: 15px;
    font-size: 1rem;
    order: 0;
  }
  
    /* 强制隐藏任何可能的侧边栏或分栏 */
.login-card > * {
  width: 100% !important;
  max-width: 100% !important;
  float: none !important;
  display: block !important;
}

/* 确保所有元素都是垂直排列 */
.login-card {
  flex-direction: column !important;
}

.login-card > * {
  flex: 0 0 auto !important;
  width: 100% !important;
}

/* 隐藏任何可能的水平滚动 */
html, body {
  overflow-x: hidden !important;
  width: 100% !important;
  margin: 0 !important;
  padding: 0 !important;
}

/* 确保输入框在移动端有足够的宽度 */
input[type="text"], 
input[type="password"] {
  width: 100% !important;
  max-width: 100% !important;
  box-sizing: border-box !important;
}

/* 移除会影响居中的全局边距重置（避免偏移） */
/* 删除全局 margin-left/right 重置，改为局部控制 */

/* 强制居中所有内容 */
.login-container * {
  text-align: center !important;
}

/* 取消此前的向右偏移，保持水平居中 */
.login-container { padding-left: 0 !important; padding-right: 0 !important; }
.login-card { padding-left: 0 !important; padding-right: 0 !important; }

/* 确保表单元素居中 */
.form-group {
  display: flex !important;
  flex-direction: column !important;
  align-items: center !important;
  width: 100% !important;
}

/* 确保输入框居中 */
.form-input {
  text-align: center !important;
  margin: 0 auto !important;
}

/* 确保按钮居中 */
.btn-login {
  margin: 0 auto !important;
  text-align: center !important;
}

/* 确保容器完全居中 */
.login-container {
  position: relative !important;
  width: auto !important;
  max-width: 100% !important;
  height: auto !important;
  margin-left: auto !important;
  margin-right: auto !important;
  overflow-y: visible !important;
}

.login-card {
  position: relative !important;
  width: 100% !important;
  max-width: 420px !important;
  min-height: auto !important;
  margin-left: auto !important;
  margin-right: auto !important;
  overflow-y: visible !important;
  padding-bottom: 1.5rem !important;
}
}

/* 超小屏幕优化 */
@media (max-width: 480px) {
  .logo-section {
    padding: 0 1.5rem;
    margin-bottom: 2rem;
  }
  
  .logo {
    font-size: 1.6rem !important;
  }
  
  .logo-subtitle {
    font-size: 0.85rem !important;
  }
  
  .form-label {
    font-size: 0.9rem !important;
  }
  
  .form-input {
    font-size: 12px !important;
    padding: 0.9rem 0.8rem 0.9rem 2.6rem;
  }
  
  .input-icon {
    font-size: 0.9rem !important;
    left: 0.8rem;
  }
  
  .checkbox-label {
    font-size: 0.85rem !important;
  }
  
  .btn-login {
    font-size: 14px !important;
    padding: 0.9rem;
  }
  
  .form-group {
    padding: 0 1.5rem;
  }
  
  .checkbox-group {
    padding: 0 1.5rem;
  }
  
  .btn-login {
    margin: 0 1.5rem;
    width: calc(100% - 3rem) !important;
  }
  
  .divider {
    margin: 1.5rem 1.5rem;
  }
  
  .register-link {
    padding: 0 1.5rem 1rem;
  }
  
  .alert {
    margin: 0 1.5rem 1rem;
  }
}

/* 超小屏幕进一步优化 */
@media (max-width: 360px) {
  .logo-section {
    padding: 0 1rem;
    margin-bottom: 2rem;
  }
  
  .logo {
    font-size: 1.5rem !important;
  }
  
  .logo-subtitle {
    font-size: 0.8rem !important;
  }
  
  .form-group {
    padding: 0 1rem;
  }
  
  .form-label {
    font-size: 0.85rem !important;
  }
  
  .form-input {
    font-size: 11px !important;
    padding: 0.8rem 0.7rem 0.8rem 2.4rem;
  }
  
  .input-icon {
    font-size: 0.85rem !important;
    left: 0.7rem;
  }
  
  .checkbox-group {
    padding: 0 1rem;
  }
  
  .checkbox-label {
    font-size: 0.8rem !important;
  }
  
  .btn-login {
    margin: 0 1rem;
    padding: 0.9rem;
    font-size: 13px !important;
    width: calc(100% - 2rem) !important;
  }
  
  .divider {
    margin: 1.5rem 1rem;
  }
  
  .register-link {
    padding: 0 1rem 1rem;
  }
  
  .alert {
    margin: 0 1rem 1rem;
  }
}

/* 强制移动端单列布局的额外保障 */
@media (max-width: 768px) {
  /* 确保没有任何浮动或分栏 */
  * {
    float: none !important;
  }
  
  /* 强制所有内容都是块级元素 */
  .login-card > * {
    display: block !important;
    width: 100% !important;
    max-width: 100% !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
  }
  
  /* 确保容器不会超出屏幕（并保持水平居中与两侧留白） */
  .login-container,
  .login-card {
    width: auto !important;
    max-width: 100% !important;
    left: auto !important;
    right: auto !important;
    margin-left: auto !important;
    margin-right: auto !important;
  }
}

/* 输入框错误状态 */
.form-input.error {
  border-color: #c53030;
  box-shadow: 0 0 0 2px rgba(197, 48, 48, 0.2);
}

.form-input.error:focus {
  border-color: #c53030;
  box-shadow: 0 0 0 2px rgba(197, 48, 48, 0.3);
}

/* 按钮禁用状态 */
.btn-login:disabled {
  opacity: 0.7;
  cursor: not-allowed;
  transform: none !important;
}

.btn-login:disabled:hover {
  transform: none !important;
  box-shadow: none !important;
}

/* Flash消息动画 */
.alert {
  transition: opacity 0.3s ease;
}

/* 客户端错误消息样式 */
#client-error {
  animation: shake 0.5s ease-in-out;
}

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

.login-captcha-row {
  display: flex;
  gap: 8px;
  align-items: center;
}
.login-captcha-input {
  flex: 1;
  padding-right: 0.75rem;
}
.login-captcha-box {
  background: #f0f0f0;
  padding: 6px 14px;
  border-radius: 8px;
  font-family: monospace;
  font-size: 16px;
  font-weight: bold;
  color: #333;
  letter-spacing: 2px;
  user-select: none;
  cursor: pointer;
  flex-shrink: 0;
}
.login-checkbox-group {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.35rem;
}
.login-forgot-link {
  margin-left: auto;
  font-size: 0.85rem;
  color: #5b67e1;
  text-decoration: none;
}
