/* ==========================================================
   作业通知系统 - 登录/注册页面全新设计
   响应式：同时适配电脑端和手机端
   ========================================================== */

/* ---------- Google Fonts ---------- */
@import url('https://fonts.googleapis.com/css2?family=Noto+Sans+SC:wght@400;500;600;700;800&family=Plus+Jakarta+Sans:wght@500;600;700;800&display=swap');

/* ---------- CSS Variables ---------- */
:root {
  --auth-primary: #2A5C8F;
  --auth-primary-light: #3A7BC8;
  --auth-primary-dark: #1D3E66;
  --auth-accent: #F59E0B;
  --auth-accent-light: #FCD34D;
  --auth-bg: #F0F4F8;
  --auth-card-bg: #FFFFFF;
  --auth-text: #1E293B;
  --auth-text-secondary: #64748B;
  --auth-border: #E2E8F0;
  --auth-border-focus: #3A7BC8;
  --auth-success: #10B981;
  --auth-error: #EF4444;
  --auth-shadow: 0 4px 24px rgba(42, 92, 143, 0.08);
  --auth-shadow-hover: 0 8px 40px rgba(42, 92, 143, 0.12);
  --auth-radius: 16px;
  --auth-font: 'Noto Sans SC', -apple-system, BlinkMacSystemFont, sans-serif;
  --auth-font-display: 'Plus Jakarta Sans', 'Noto Sans SC', sans-serif;
  --auth-transition: 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ---------- Reset & Base ---------- */
.auth-page *,
.auth-page *::before,
.auth-page *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* ---------- Page Overlay ---------- */
.auth-page {
  font-family: var(--auth-font);
  color: var(--auth-text);
  background: var(--auth-bg);
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  position: relative;
  overflow: hidden;
}

/* Subtle background pattern */
.auth-page::before {
  content: '';
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse at 20% 50%, rgba(42, 92, 143, 0.06) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 20%, rgba(245, 158, 11, 0.04) 0%, transparent 50%),
    radial-gradient(ellipse at 50% 80%, rgba(42, 92, 143, 0.04) 0%, transparent 50%);
  pointer-events: none;
  z-index: 0;
}

/* ---------- Auth Container (Desktop: side-by-side) ---------- */
.auth-container {
  display: flex;
  width: 100%;
  max-width: 1000px;
  min-height: 600px;
  background: var(--auth-card-bg);
  border-radius: 24px;
  box-shadow: var(--auth-shadow);
  position: relative;
  z-index: 1;
  overflow: hidden;
  animation: authFadeIn 0.6s ease-out;
}

@keyframes authFadeIn {
  from { opacity: 0; transform: translateY(16px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

/* ---------- Brand Panel (Left side) ---------- */
.auth-brand {
  flex: 0 0 380px;
  background: linear-gradient(145deg, var(--auth-primary-dark), var(--auth-primary));
  padding: 48px 36px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  position: relative;
  overflow: hidden;
}

/* Decorative circles */
.auth-brand::before {
  content: '';
  position: absolute;
  top: -80px;
  right: -80px;
  width: 240px;
  height: 240px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.04);
}
.auth-brand::after {
  content: '';
  position: absolute;
  bottom: -60px;
  left: -60px;
  width: 180px;
  height: 180px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.03);
}

.auth-brand-icon {
  font-size: 48px;
  margin-bottom: 8px;
  display: block;
}

.auth-brand h1 {
  font-family: var(--auth-font-display);
  font-size: 28px;
  font-weight: 800;
  color: #fff;
  line-height: 1.2;
  margin: 0 0 8px 0;
  position: relative;
  z-index: 1;
}

.auth-brand-sub {
  font-size: 15px;
  color: rgba(255, 255, 255, 0.7);
  font-weight: 400;
  margin-bottom: 32px;
  position: relative;
  z-index: 1;
}

.auth-brand-features {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.auth-brand-feature {
  display: flex;
  align-items: center;
  gap: 12px;
  color: rgba(255, 255, 255, 0.85);
  font-size: 14px;
  line-height: 1.4;
}

.auth-brand-feature .icon {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.12);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
}

.auth-brand-footer {
  position: relative;
  z-index: 1;
  font-size: 12px;
  color: rgba(255, 255, 255, 0.4);
  line-height: 1.6;
}

/* ---------- Form Panel (Right side) ---------- */
.auth-form-panel {
  flex: 1;
  padding: 48px 44px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-width: 0;
}

.auth-form-header {
  margin-bottom: 28px;
}

.auth-form-header h2 {
  font-family: var(--auth-font-display);
  font-size: 24px;
  font-weight: 700;
  color: var(--auth-text);
  margin: 0 0 6px 0;
}

.auth-form-header p {
  color: var(--auth-text-secondary);
  font-size: 15px;
  margin: 0;
}

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

.auth-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.auth-field label {
  font-size: 14px;
  font-weight: 600;
  color: var(--auth-text);
  display: flex;
  align-items: center;
  gap: 4px;
}

.auth-field label .required {
  color: var(--auth-error);
  font-weight: 700;
}

.auth-field input,
.auth-field select {
  width: 100%;
  padding: 12px 16px;
  font-size: 15px;
  font-family: var(--auth-font);
  color: var(--auth-text);
  background: #F8FAFC;
  border: 1.5px solid var(--auth-border);
  border-radius: 10px;
  transition: all var(--auth-transition);
  outline: none;
  -webkit-appearance: none;
  appearance: none;
}

.auth-field input::placeholder {
  color: #94A3B8;
}

.auth-field input:focus,
.auth-field select:focus {
  border-color: var(--auth-border-focus);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(58, 123, 200, 0.12);
}

.auth-field input.error {
  border-color: var(--auth-error);
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.1);
}

.auth-field .field-error {
  font-size: 13px;
  color: var(--auth-error);
  display: none;
}

.auth-field .field-error.visible {
  display: block;
}

/* Password strength */
.password-strength-bar {
  height: 3px;
  border-radius: 2px;
  background: #E2E8F0;
  overflow: hidden;
  margin-top: 4px;
  transition: all var(--auth-transition);
}

.password-strength-fill {
  height: 100%;
  width: 0%;
  border-radius: 2px;
  transition: all 0.3s ease;
}

.password-strength-fill.weak { width: 30%; background: #EF4444; }
.password-strength-fill.medium { width: 60%; background: #F59E0B; }
.password-strength-fill.strong { width: 100%; background: #10B981; }

.password-strength-text {
  font-size: 12px;
  color: var(--auth-text-secondary);
  margin-top: 2px;
  min-height: 18px;
}

/* ---------- Class Grid ---------- */
.class-grid-container {
  max-height: 160px;
  overflow-y: auto;
  border: 1.5px solid var(--auth-border);
  border-radius: 10px;
  padding: 8px;
  background: #F8FAFC;
}

.class-grid-container::-webkit-scrollbar {
  width: 5px;
}
.class-grid-container::-webkit-scrollbar-track {
  background: transparent;
}
.class-grid-container::-webkit-scrollbar-thumb {
  background: #CBD5E1;
  border-radius: 3px;
}

.class-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 6px;
}

.class-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 10px;
  border: 1.5px solid var(--auth-border);
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: 13px;
  color: var(--auth-text);
  user-select: none;
  background: #fff;
  position: relative;
}

.class-item:hover {
  border-color: var(--auth-primary-light);
  background: #F0F7FF;
}

.class-item.selected {
  border-color: var(--auth-primary);
  background: #EBF4FF;
}

.class-item input[type="checkbox"] {
  width: 18px !important;
  height: 18px !important;
  min-width: 18px;
  accent-color: var(--auth-primary);
  cursor: pointer;
  flex-shrink: 0;
  appearance: auto;
  -webkit-appearance: checkbox;
  padding: 0 !important;
  border: none !important;
  border-radius: 0 !important;
  margin: 0;
}


/* ---------- Submit Button ---------- */
.auth-submit {
  width: 100%;
  padding: 14px 24px;
  font-family: var(--auth-font);
  font-size: 16px;
  font-weight: 700;
  color: #fff;
  background: linear-gradient(135deg, var(--auth-primary), var(--auth-primary-light));
  border: none;
  border-radius: 10px;
  cursor: pointer;
  transition: all var(--auth-transition);
  position: relative;
  overflow: hidden;
  margin-top: 4px;
}

.auth-submit:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(42, 92, 143, 0.25);
}

.auth-submit:active {
  transform: translateY(0);
}

.auth-submit:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.auth-submit .spinner {
  display: none;
  width: 20px;
  height: 20px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: authSpin 0.6s linear infinite;
  margin: 0 auto;
}

.auth-submit.loading .btn-text { display: none; }
.auth-submit.loading .spinner { display: block; }

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

/* ---------- Auth Switch Link ---------- */
.auth-switch {
  text-align: center;
  margin-top: 16px;
  font-size: 14px;
  color: var(--auth-text-secondary);
}

.auth-switch a {
  color: var(--auth-primary);
  text-decoration: none;
  font-weight: 600;
  transition: color 0.2s;
  cursor: pointer;
}

.auth-switch a:hover {
  color: var(--auth-primary-light);
  text-decoration: underline;
}

/* ---------- Approval Notice ---------- */
.auth-notice {
  padding: 12px 16px;
  background: #FEF3C7;
  border: 1px solid #FCD34D;
  border-radius: 10px;
  display: none;
}

.auth-notice.visible {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.auth-notice .icon {
  font-size: 18px;
  flex-shrink: 0;
  margin-top: 1px;
}

.auth-notice .text {
  font-size: 13px;
  color: #92400E;
  line-height: 1.5;
}

.auth-notice .text strong {
  display: block;
  margin-bottom: 2px;
}

/* ---------- Status Message ---------- */
.auth-status {
  padding: 12px 16px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 500;
  text-align: center;
  display: none;
  animation: statusSlideIn 0.3s ease;
}

.auth-status.visible { display: block; }
.auth-status.success { background: #D1FAE5; color: #065F46; border: 1px solid #A7F3D0; }
.auth-status.error { background: #FEE2E2; color: #991B1B; border: 1px solid #FECACA; }
.auth-status.info { background: #DBEAFE; color: #1E40AF; border: 1px solid #BFDBFE; }

@keyframes statusSlideIn {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ---------- Role Select Styling ---------- */
.auth-field select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2364748B' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
  cursor: pointer;
}

/* ---------- Responsive: Tablet ---------- */
@media (max-width: 900px) {
  .auth-brand {
    flex: 0 0 280px;
    padding: 36px 28px;
  }
  .auth-form-panel {
    padding: 36px 32px;
  }
  .auth-brand h1 {
    font-size: 22px;
  }
}

/* ---------- Responsive: Mobile ---------- */
@media (max-width: 700px) {
  .auth-page {
    padding: 0;
    align-items: flex-start;
    flex-direction: column;
  }

  .auth-container {
    flex-direction: column;
    min-height: auto;
    border-radius: 0;
    min-height: auto;
    box-shadow: none;
  }

  .auth-brand {
    flex: none;
    padding: 32px 24px 24px;
    border-radius: 0;
  }

  .auth-brand-features {
    display: none;
  }

  .auth-brand-footer {
    display: none;
  }

  .auth-brand h1 {
    font-size: 20px;
    margin-bottom: 4px;
  }

  .auth-brand-sub {
    font-size: 13px;
    margin-bottom: 0;
  }

  .auth-form-panel {
    padding: 24px 20px 32px;
    flex: 1;
  }

  .auth-form-header h2 {
    font-size: 20px;
  }

  .auth-form-header p {
    font-size: 14px;
  }

  .auth-form {
    gap: 14px;
  }

  .auth-field input,
  .auth-field select {
    padding: 11px 14px;
    font-size: 16px; /* Prevent zoom on iOS */
  }

  .auth-submit {
    padding: 13px 20px;
    font-size: 15px;
  }

  .class-grid {
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  }

  .class-grid-container {
    max-height: 130px;
  }
}

/* ---------- Responsive: Very Small ---------- */
@media (max-width: 380px) {
  .auth-brand {
    padding: 24px 16px 20px;
  }
  .auth-form-panel {
    padding: 20px 16px 28px;
  }
  .class-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* ---------- Page Switch (仅对登录/注册页生效) ---------- */
/* 默认隐藏，确保不被原有 style.css 的 .page.active 影响 */
#loginPage,
#registerPage {
  display: none !important;
}

#loginPage.auth-page-visible,
#registerPage.auth-page-visible {
  display: flex !important;
}

#loginPage.auth-page-hidden,
#registerPage.auth-page-hidden {
  display: none !important;
}

/* ---------- Copyright inline on mobile ---------- */
.auth-mobile-copyright {
  display: none;
  text-align: center;
  font-size: 11px;
  color: var(--auth-text-secondary);
  margin-top: 20px;
  padding: 0 20px 16px;
  line-height: 1.5;
}

@media (max-width: 700px) {
  .auth-mobile-copyright {
    display: block;
    padding-bottom: 24px;
    margin-top: auto;
    background: #fff;
    width: 100%;
  }
}
