/* 认证相关样式 */

/* ============================================
   认证模态框
   ============================================ */

.auth-modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 10000;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  padding: 20px;
  box-sizing: border-box;
}

.auth-modal[style*="flex"] {
  display: flex !important;
}

.auth-modal-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
}

.auth-modal-content {
  position: relative;
  background: white;
  border-radius: 12px;
  padding: 1.5rem;
  max-width: 360px;
  width: 360px;
  min-width: 300px;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  z-index: 1;
  animation: modalFadeIn 0.3s ease;
  margin: 0;
  box-sizing: border-box;
  flex-shrink: 0;
}

@keyframes modalFadeIn {
  from {
    opacity: 0;
    transform: scale(0.9) translateY(-20px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

.auth-modal-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  background: none;
  border: none;
  font-size: 1.5rem;
  color: #718096;
  cursor: pointer;
  padding: 0.5rem;
  line-height: 1;
  transition: color 0.2s;
}

.auth-modal-close:hover {
  color: #2d3748;
}

.auth-form h2 {
  margin: 0 0 1.25rem 0;
  font-size: 1.5rem;
  font-weight: 700;
  color: #2d3748;
}

/* ============================================
   OAuth按钮
   ============================================ */

.auth-oauth-buttons {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}

.auth-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  padding: 0.75rem 1.25rem;
  border: 2px solid #e2e8f0;
  border-radius: 10px;
  background: white;
  color: #2d3748;
  font-size: 0.95rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  width: 100%;
}

.auth-btn:hover {
  border-color: #cbd5e0;
  background: #f7fafc;
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.auth-btn-github {
  background: #24292e;
  color: white;
  border-color: #24292e;
}

.auth-btn-github:hover {
  background: #1a1e22;
  border-color: #1a1e22;
}

.auth-btn-google {
  border-color: #e2e8f0;
}

.auth-btn-google:hover {
  border-color: #cbd5e0;
  background: #f9fafb;
}

.auth-btn-primary {
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.8) 0%, rgba(16, 185, 129, 0.8) 100%);
  color: white;
  border-color: transparent;
  font-weight: 600;
}

.auth-btn-primary:hover {
  background: linear-gradient(135deg, rgba(37, 99, 235, 0.9) 0%, rgba(5, 150, 105, 0.9) 100%);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.4);
}

.auth-btn-header {
  padding: 0.5rem 1rem;
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.8) 0%, rgba(16, 185, 129, 0.8) 100%);
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
  line-height: 1.5;
  height: fit-content;
  display: inline-flex;
  align-items: center;
}

.auth-btn-header:hover {
  background: linear-gradient(135deg, rgba(37, 99, 235, 0.9) 0%, rgba(5, 150, 105, 0.9) 100%);
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(59, 130, 246, 0.3);
}

/* ============================================
   分割线
   ============================================ */

.auth-divider {
  position: relative;
  text-align: center;
  margin: 1.5rem 0;
}

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

.auth-divider span {
  position: relative;
  background: white;
  padding: 0 1rem;
  color: #a0aec0;
  font-size: 0.85rem;
}

/* ============================================
   表单
   ============================================ */

.auth-form-group {
  margin-bottom: 1.25rem;
}

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

.auth-form-group input {
  width: 100%;
  padding: 0.75rem;
  border: 2px solid #e2e8f0;
  border-radius: 8px;
  font-size: 0.95rem;
  transition: all 0.2s;
  box-sizing: border-box;
}

.auth-form-group input:focus {
  outline: none;
  border-color: rgba(59, 130, 246, 0.8);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.auth-form-help {
  display: block;
  margin-top: 0.25rem;
  font-size: 0.8rem;
  color: #718096;
}

.auth-form-footer {
  margin-top: 1.5rem;
  text-align: center;
  font-size: 0.9rem;
  color: #718096;
}

.auth-form-footer a {
  color: rgba(59, 130, 246, 0.9);
  text-decoration: none;
  font-weight: 500;
}

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

/* ============================================
   加载和错误提示
   ============================================ */

.auth-loading {
  text-align: center;
  padding: 2rem;
}

.auth-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid #e2e8f0;
  border-top-color: rgba(59, 130, 246, 0.8);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 1rem;
}

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

.auth-error {
  background: #fed7d7;
  color: #c53030;
  padding: 0.75rem 1rem;
  border-radius: 8px;
  margin-top: 1rem;
  font-size: 0.9rem;
}

/* ============================================
   用户菜单
   ============================================ */

.user-menu {
  margin-left: 0; /* 在 main-nav 中已经通过 flex 布局推到右侧 */
  position: relative;
  display: flex;
  align-items: center;
  flex-shrink: 0;
}

.user-menu-guest {
  display: flex;
  align-items: center;
}

.user-menu-authenticated {
  position: relative;
}

.user-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.8) 0%, rgba(16, 185, 129, 0.8) 100%);
  color: white;
  font-weight: 600;
  font-size: 0.9rem;
  transition: transform 0.2s;
  border: 2px solid white;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.user-avatar:hover {
  transform: scale(1.05);
}

.user-avatar img {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
}

.user-dropdown {
  position: absolute;
  top: calc(100% + 0.5rem);
  right: 0;
  background: white;
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
  min-width: 240px;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-10px);
  transition: all 0.2s;
  z-index: 1000;
  overflow: hidden;
}

.user-dropdown.open {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.user-info {
  padding: 1rem;
  background: linear-gradient(135deg, #f7fafc 0%, #edf2f7 100%);
  border-bottom: 1px solid #e2e8f0;
}

.user-name {
  font-weight: 600;
  color: #2d3748;
  font-size: 0.95rem;
  margin-bottom: 0.25rem;
}

.user-email {
  font-size: 0.8rem;
  color: #718096;
}

.user-dropdown-menu {
  padding: 0.5rem 0;
}

.user-menu-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  color: #2d3748;
  text-decoration: none;
  font-size: 0.9rem;
  transition: background 0.2s;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  cursor: pointer;
}

.user-menu-item:hover {
  background: #f7fafc;
}

.user-menu-icon {
  font-size: 1.1rem;
  width: 20px;
  text-align: center;
}

.user-menu-divider {
  margin: 0.5rem 0;
  border: none;
  border-top: 1px solid #e2e8f0;
}

.user-menu-logout {
  color: #e53e3e;
}

.user-menu-logout:hover {
  background: #fed7d7;
  color: #c53030;
}

/* 响应式 */
@media (max-width: 768px) {
  .auth-modal {
    padding: 1rem;
  }
  
  .auth-modal-content {
    padding: 1.25rem;
    max-width: calc(100vw - 2rem) !important;
    width: calc(100vw - 2rem) !important;
    min-width: 280px;
  }
  
  .auth-form h2 {
    font-size: 1.25rem;
  }
  
  /* 移动端用户菜单优化 */
  .user-menu {
    width: 100%;
    margin-left: 0;
    margin-top: 0.5rem;
    justify-content: flex-start;
    order: 999; /* 确保在导航菜单之后显示 */
  }
  
  .user-menu-authenticated {
    width: 100%;
  }
  
  .user-avatar {
    width: 48px;
    height: 48px;
    font-size: 1.1rem;
  }
  
  .user-dropdown {
    position: static; /* 移动端改为静态定位，显示在菜单内 */
    right: auto;
    left: auto;
    min-width: 100%;
    width: 100%;
    box-shadow: none;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    margin-top: 0.5rem;
    opacity: 1;
    visibility: visible;
    transform: none;
    transition: none;
  }
  
  .user-dropdown.open {
    /* 移动端下拉菜单始终可见 */
    opacity: 1;
    visibility: visible;
    transform: none;
  }
  
  .user-info {
    padding: 1rem;
  }
  
  .user-name {
    font-size: 1rem;
  }
  
  .user-email {
    font-size: 0.85rem;
  }
  
  .user-menu-item {
    padding: 0.875rem 1rem;
    font-size: 0.95rem;
  }
  
  .auth-btn-header {
    width: 100%;
    justify-content: center;
    padding: 0.75rem 1rem;
    font-size: 1rem;
  }
}

@media (max-width: 480px) {
  .user-avatar {
    width: 44px;
    height: 44px;
    font-size: 1rem;
  }
  
  .user-dropdown {
    border-radius: 6px;
  }
  
  .user-menu-item {
    padding: 0.75rem 0.875rem;
    font-size: 0.9rem;
  }
}

