/* css/login.css */

/* ===== 登录页专属根变量与重置 ===== */
#login-modal {
  --bg: #030406; 
  --accent: #3579B6; 
  --accent-hover: #4088CA;
  --accent-disabled: #26567F;
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --fast: cubic-bezier(0.25, 1, 0.5, 1);
  
  position: fixed; inset: 0; z-index: 9999;
  background-color: var(--bg);
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

/* ===== 深邃暗角背景 ===== */
#login-modal .universe {
  position: absolute; inset: 0; z-index: 0; overflow: hidden;
  background: radial-gradient(circle at 50% 100%, #0c1522 0%, #030406 70%);
}
#login-modal .starfield { position: absolute; inset: 0; pointer-events: none; }
#login-modal .star-point { position: absolute; border-radius: 50%; animation: loginTwinkle var(--dur) infinite alternate ease-in-out; }
#login-modal .star-cross { position: absolute; width: 2px; height: 2px; background: #FFF; border-radius: 50%; box-shadow: 0 0 4px rgba(162, 196, 255, 0.6); }
#login-modal .star-cross::before, #login-modal .star-cross::after { content: ''; position: absolute; background: rgba(255,255,255,0.4); }
#login-modal .star-cross::before { top: -6px; left: 0.5px; width: 1px; height: 14px; background: linear-gradient(to bottom, transparent, rgba(255,255,255,0.5), transparent); }
#login-modal .star-cross::after { top: 0.5px; left: -6px; width: 14px; height: 1px; background: linear-gradient(to right, transparent, rgba(255,255,255,0.5), transparent); }
@keyframes loginTwinkle { 0% { opacity: 0.1; } 100% { opacity: 0.9; } }

/* ===== 悬浮卡片 ===== */
#login-modal .login-card {
  position: relative; z-index: 10; width: 100%; max-width: 320px;
  border-radius: 32px; padding: 32px; margin: 20px;
  background: rgba(12, 14, 20, 0.8);
  backdrop-filter: blur(32px) saturate(120%); -webkit-backdrop-filter: blur(32px) saturate(120%);
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: 
    0 50px 100px -20px rgba(0, 0, 0, 1), 
    0 20px 40px -10px rgba(0, 0, 0, 0.8),
    inset 0 1px 0 rgba(255, 255, 255, 0.18),
    inset 0 -2px 0 rgba(0, 0, 0, 0.6);
  overflow: hidden; 
  animation: loginCardEnter 0.9s var(--ease-out) both;
}
#login-modal .login-card::before {
  content: ''; position: absolute; top: -20%; left: -20%; width: 140%; height: 140%;
  background: radial-gradient(circle at 30% 30%, rgba(25, 45, 75, 0.25) 0%, transparent 50%), radial-gradient(circle at 70% 70%, rgba(40, 80, 130, 0.15) 0%, transparent 50%);
  filter: blur(40px); mix-blend-mode: screen; pointer-events: none; z-index: 0;
  animation: loginAurora 15s infinite alternate ease-in-out;
}
@keyframes loginAurora { 0% { transform: translate(0, 0) scale(1); } 50% { transform: translate(8%, 5%) scale(1.05); } 100% { transform: translate(-5%, -8%) scale(1.02); } }
@keyframes loginCardEnter { 0% { opacity: 0; transform: translateY(60px) scale(0.9); filter: blur(10px); } 100% { opacity: 1; transform: translateY(0) scale(1); filter: blur(0); } }

#login-modal .card-content { position: relative; z-index: 1; }

/* ===== 头部头像 ===== */
#login-modal .header { display: flex; flex-direction: column; align-items: center; margin-bottom: 24px; }
#login-modal .avatar-wrap {
  position: relative; width: 72px; height: 72px; margin-bottom: 16px; border-radius: 50%; padding: 2px;
  background: linear-gradient(180deg, rgba(255,255,255,0.2), rgba(255,255,255,0.05));
  box-shadow: 0 4px 16px rgba(0,0,0,0.5);
}
#login-modal .avatar-default {
  display: flex; align-items: center; justify-content: center; width: 100%; height: 100%; border-radius: 50%;
  font-size: 28px; font-weight: 700; color: #FFF; background: linear-gradient(135deg, #25344A 0%, #142033 100%);
  transition: opacity 0.25s var(--ease-out), transform 0.3s var(--spring); will-change: transform, opacity;
  background-size: cover; background-position: center;
}
#login-modal .avatar-default.switching { opacity: 0; transform: scale(0.7); }
#login-modal .header h1 { font-size: 22px; font-weight: 700; letter-spacing: 0.1em; color: #FFFFFF; text-shadow: 0 2px 10px rgba(0,0,0,0.5); }

/* ===== 角色切换 ===== */
#login-modal .role-selector {
  display: flex; background: rgba(0, 0, 0, 0.4); border-radius: 14px; padding: 4px; margin-bottom: 24px;
  position: relative; box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.8); border: 1px solid rgba(0, 0, 0, 0.2);
}
#login-modal .role-btn {
  flex: 1; height: 36px; border: none; background: transparent; color: rgba(255, 255, 255, 0.4);
  font-size: 13px; font-weight: 600; border-radius: 10px; cursor: pointer; font-family: inherit; z-index: 1;
  transition: color 0.3s var(--ease-out); -webkit-tap-highlight-color: transparent;
}
#login-modal .role-btn.active { color: #FFFFFF; }
#login-modal .role-slider {
  position: absolute; top: 4px; left: 4px; width: calc(50% - 4px); height: calc(100% - 8px);
  background: var(--accent); border-radius: 10px; box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4), inset 0 1px 0 rgba(255,255,255,0.2);
  transition: transform 0.45s var(--spring); z-index: 0; will-change: transform;
}
#login-modal .role-selector:active .role-slider[data-index="0"] { transform: translateX(0) scale(0.9); }
#login-modal .role-selector:active .role-slider[data-index="1"] { transform: translateX(100%) scale(0.9); }

/* ===== 输入框 ===== */
#login-modal .input-wrap { position: relative; margin-bottom: 32px; }
#login-modal .input-field {
  width: 100%; height: 52px; background: rgba(0, 0, 0, 0.3);
  border: 1px solid rgba(255, 255, 255, 0.08); border-radius: 16px;
  text-align: center; letter-spacing: 4px;
  padding: 0 20px; color: #FFFFFF; font-size: 18px; font-family: inherit;
  outline: none; transition: background 0.3s var(--ease-out), border-color 0.3s var(--ease-out), box-shadow 0.4s var(--ease-out);
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.3);
}
#login-modal .input-field::placeholder { 
  color: rgba(255, 255, 255, 0.6); font-weight: 500; transition: opacity 0.2s; letter-spacing: 1px; font-size: 15px;
}
#login-modal .input-field:focus::placeholder { opacity: 0.8; }
#login-modal .input-field:focus {
  background: rgba(0, 0, 0, 0.5); border-color: var(--accent);
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.3), 0 0 0 4px rgba(53, 121, 182, 0.2);
}
#login-modal .login-error {
  position: absolute; bottom: -24px; left: 0; width: 100%; text-align: center;
  color: #FFFFFF; font-size: 12px; font-weight: 600; opacity: 0; transform: translateY(-4px); 
  transition: all 0.3s var(--ease-out); pointer-events: none; text-shadow: 0 0 10px rgba(255, 69, 58, 0.9);
}
#login-modal .login-error.show { opacity: 1; transform: translateY(0); }

/* ===== 按钮 ===== */
#login-modal .submit-btn {
  position: relative; /* 强制锁定在正常文档流，防止被吸顶 */
  z-index: 10;
  flex-shrink: 0;
  
  width: 100%; height: 52px; 
  margin-top: 8px; /* 与上方的输入框拉开一点点物理距离 */
  
  background: var(--accent); color: #FFFFFF; 
  border: 1px solid rgba(0, 0, 0, 0.2); border-radius: 16px; 
  font-size: 16px; font-weight: 700; letter-spacing: 0.08em;
  cursor: pointer; font-family: inherit;
  display: flex; align-items: center; justify-content: center; gap: 12px;
  
  box-shadow: 
    inset 0 1px 0 rgba(255, 255, 255, 0.3), 
    inset 0 -2px 0 rgba(0, 0, 0, 0.3), 
    0 8px 20px -6px rgba(0, 0, 0, 0.8); 
  transition: transform 0.1s var(--fast), background 0.3s var(--ease-out), box-shadow 0.2s var(--ease-out);
  -webkit-tap-highlight-color: transparent;
}
#login-modal .submit-btn:hover {
  background: var(--accent-hover); transform: translateY(-1px);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.4), inset 0 -2px 0 rgba(0, 0, 0, 0.3), 0 12px 24px -6px rgba(0, 0, 0, 0.9);
}
#login-modal .submit-btn:active { 
  transform: translateY(2px) scale(0.97); background: #2D68A0;
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.4), 0 2px 6px -2px rgba(0, 0, 0, 0.6);
}
#login-modal .submit-btn.is-loading {
  background: var(--accent-disabled); transform: translateY(1px) scale(0.98);
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.5); cursor: not-allowed; pointer-events: none;
}
#login-modal .spinner {
  display: none; width: 18px; height: 18px;
  border: 2px solid rgba(255, 255, 255, 0.3); border-top-color: #FFFFFF;
  border-radius: 50%; animation: loginSpin 0.8s linear infinite;
}
#login-modal .submit-btn.is-loading .spinner { display: block; flex: 0 0 auto; }
#login-modal .submit-btn.is-loading #login-btn-text { letter-spacing: 0.04em; }
@keyframes loginSpin { to { transform: rotate(360deg); } }

#login-modal .shake { animation: loginShake 0.4s var(--ease-out); }
@keyframes loginShake {
  0%, 100% { transform: translateX(0); }
  20%, 60% { transform: translateX(-4px); }
  40%, 80% { transform: translateX(4px); }
}
/* ===== 输入框错误抖动 ===== */
#login-modal .input-field.shake {
  border-color: var(--danger);
  animation: loginInputShake 0.4s var(--ease-out);
}
@keyframes loginInputShake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-6px); }
  50% { transform: translateX(6px); }
  75% { transform: translateX(-4px); }
}
/* The button uses is-loading, never the full-page .loading class. */
#login-modal #login-enter-btn, #login-modal #login-enter-btn.is-loading {
  display: flex; flex-direction: row; align-items: center; justify-content: center;
  gap: 12px; min-height: 52px; white-space: nowrap;
}
#login-modal #login-enter-btn.is-loading { color: #112533; opacity: 1; }
#login-modal #login-enter-btn.is-loading .spinner {
  display: block; width: 18px; height: 18px; flex: 0 0 18px;
  border: 2px solid rgba(17,37,51,.28); border-top-color: #112533;
  animation: loginSpin .8s linear infinite;
}
#login-modal #login-enter-btn #login-btn-text { display: inline-block; line-height: 1; }
