/* ===== PORTAL TOKENS (inherits from AIC design system) ===== */
:root {
  --white: #ffffff;
  --bg: #fafbff;
  --bg-gray: #f3f4f8;
  --text: #1a1a2e;
  --text-2: #4a4a6a;
  --text-3: #8888a8;
  --blue: #4f6ef7;
  --purple: #8b5cf6;
  --pink: #ec4899;
  --orange: #f59e0b;
  --green: #10b981;
  --teal: #06b6d4;
  --red: #ef4444;
  --radius: 16px;
  --radius-lg: 24px;
  --font: 'Inter', 'Noto Sans SC', system-ui, -apple-system, sans-serif;
}

/* ===== RESET ===== */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; min-height: 100%; }
body {
  font-family: var(--font);
  color: var(--text);
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  background: linear-gradient(160deg, #e8f0fe 0%, #f3e8ff 35%, #fce7f3 65%, #fef3c7 100%);
  position: relative;
  overflow-x: hidden;
}

/* ===== Floating shapes background ===== */
.portal-shapes {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}
.portal-shapes .shape {
  position: absolute;
  font-size: 2rem;
  opacity: 0.12;
  animation: floatShape 14s ease-in-out infinite;
}
@keyframes floatShape {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  50% { transform: translateY(-22px) rotate(10deg); }
}
.portal-shapes .s1 { top: 8%; left: 6%; animation-delay: 0s; font-size: 2.8rem; }
.portal-shapes .s2 { top: 15%; right: 10%; animation-delay: 2s; font-size: 2.2rem; }
.portal-shapes .s3 { top: 50%; left: 3%; animation-delay: 4s; font-size: 3rem; }
.portal-shapes .s4 { top: 35%; right: 5%; animation-delay: 6s; }
.portal-shapes .s5 { bottom: 20%; left: 12%; animation-delay: 1s; font-size: 2.4rem; }
.portal-shapes .s6 { bottom: 10%; right: 15%; animation-delay: 3s; }
.portal-shapes .s7 { top: 70%; left: 50%; animation-delay: 5s; font-size: 2.6rem; }
.portal-shapes .s8 { bottom: 35%; right: 40%; animation-delay: 7s; }

/* ===== Portal container ===== */
.portal-wrapper {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 460px;
  margin: 2rem 1.5rem;
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

/* ===== Brand header ===== */
.portal-brand {
  text-align: center;
  margin-bottom: 1.8rem;
}
.portal-brand-link {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  text-decoration: none;
  color: var(--text);
  font-size: 0.85rem;
  font-weight: 500;
  opacity: 0.7;
  transition: opacity 0.2s;
  margin-bottom: 1rem;
}
.portal-brand-link:hover { opacity: 1; }
.portal-brand-link span { font-size: 1.1rem; }
.portal-logo {
  font-size: 2rem;
  margin-bottom: 0.5rem;
}
.portal-title {
  font-size: 1.5rem;
  font-weight: 800;
  background: linear-gradient(135deg, var(--blue) 0%, var(--purple) 50%, var(--pink) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: 0.04em;
}
.portal-subtitle {
  font-size: 0.82rem;
  color: var(--text-3);
  margin-top: 0.3rem;
}

/* ===== Glass card ===== */
.portal-card {
  background: rgba(255, 255, 255, 0.72);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-radius: var(--radius-lg);
  border: 1px solid rgba(255, 255, 255, 0.5);
  box-shadow:
    0 8px 32px rgba(79, 110, 247, 0.08),
    0 2px 8px rgba(0, 0, 0, 0.04);
  overflow: hidden;
  animation: cardSlideUp 0.5s ease;
}
@keyframes cardSlideUp {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ===== Tabs ===== */
.portal-tabs {
  display: flex;
  border-bottom: 1px solid rgba(0, 0, 0, 0.06);
}
.portal-tab {
  flex: 1;
  padding: 0.9rem 0.5rem;
  font-size: 0.85rem;
  font-weight: 600;
  text-align: center;
  color: var(--text-3);
  background: none;
  border: none;
  cursor: pointer;
  position: relative;
  transition: color 0.3s;
}
.portal-tab:hover {
  color: var(--text-2);
}
.portal-tab.active {
  color: var(--blue);
}
.portal-tab::after {
  content: '';
  position: absolute;
  bottom: -1px;
  left: 50%;
  transform: translateX(-50%) scaleX(0);
  width: 60%;
  height: 2.5px;
  background: linear-gradient(135deg, var(--blue), var(--purple));
  border-radius: 99px;
  transition: transform 0.3s ease;
}
.portal-tab.active::after {
  transform: translateX(-50%) scaleX(1);
}

/* ===== Form area ===== */
.portal-body {
  padding: 2rem 2rem 1.5rem;
}
.portal-form {
  display: none;
}
.portal-form.active {
  display: block;
  animation: formFadeIn 0.35s ease;
}
@keyframes formFadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Login mode toggle (phone vs school name) */
.login-mode-toggle {
  display: flex;
  gap: 0;
  margin-bottom: 1.2rem;
  background: rgba(0, 0, 0, 0.04);
  border-radius: 10px;
  padding: 3px;
}
.login-mode-toggle .mode-btn {
  flex: 1;
  padding: 0.5rem 0.8rem;
  font-size: 0.78rem;
  font-weight: 600;
  font-family: var(--font);
  color: var(--text-3);
  background: none;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.25s ease;
}
.login-mode-toggle .mode-btn:hover {
  color: var(--text-2);
}
.login-mode-toggle .mode-btn.active {
  color: var(--blue);
  background: var(--white);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
}

/* ===== Form groups ===== */
.form-group {
  margin-bottom: 1.1rem;
}
.form-label {
  display: block;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-2);
  margin-bottom: 0.4rem;
}
.form-input-wrapper {
  position: relative;
}
.form-input {
  width: 100%;
  padding: 0.72rem 1rem;
  font-size: 0.88rem;
  font-family: var(--font);
  color: var(--text);
  background: rgba(255, 255, 255, 0.7);
  border: 1.5px solid rgba(0, 0, 0, 0.08);
  border-radius: 12px;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
}
.form-input::placeholder {
  color: var(--text-3);
  font-size: 0.82rem;
}
.form-input:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(79, 110, 247, 0.1);
  background: var(--white);
}
.form-input.error {
  border-color: var(--red);
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.1);
}
.form-input.error:focus {
  border-color: var(--red);
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.15);
}

/* Phone input with prefix */
.phone-input-group {
  display: flex;
  gap: 0.5rem;
}
.phone-prefix {
  width: 56px;
  flex-shrink: 0;
  padding: 0.72rem 0;
  font-size: 0.85rem;
  font-weight: 600;
  text-align: center;
  color: var(--text-2);
  background: rgba(0, 0, 0, 0.03);
  border: 1.5px solid rgba(0, 0, 0, 0.08);
  border-radius: 12px;
  font-family: var(--font);
}
.phone-input-group .form-input {
  flex: 1;
}

/* SMS code row */
.sms-row {
  display: flex;
  gap: 0.5rem;
}
.sms-row .form-input {
  flex: 1;
}
.sms-btn {
  flex-shrink: 0;
  padding: 0.72rem 1rem;
  font-size: 0.78rem;
  font-weight: 600;
  font-family: var(--font);
  color: var(--blue);
  background: rgba(79, 110, 247, 0.08);
  border: 1.5px solid rgba(79, 110, 247, 0.15);
  border-radius: 12px;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.2s, transform 0.2s;
}
.sms-btn:hover:not(:disabled) {
  background: rgba(79, 110, 247, 0.14);
  transform: translateY(-1px);
}
.sms-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  color: var(--text-3);
  border-color: rgba(0, 0, 0, 0.06);
  background: rgba(0, 0, 0, 0.03);
}

/* Error messages */
.form-error {
  display: none;
  font-size: 0.72rem;
  color: var(--red);
  margin-top: 0.3rem;
  padding-left: 0.2rem;
  animation: errorShake 0.3s ease;
}
.form-error.visible {
  display: block;
}
@keyframes errorShake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-4px); }
  75% { transform: translateX(4px); }
}

/* Password toggle */
.password-toggle {
  position: absolute;
  right: 0.8rem;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1rem;
  color: var(--text-3);
  padding: 0.2rem;
  transition: color 0.2s;
}
.password-toggle:hover {
  color: var(--text-2);
}
.form-input-wrapper .form-input {
  padding-right: 2.8rem;
}

/* Checkbox */
.form-checkbox-group {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  margin-bottom: 1.2rem;
}
.form-checkbox {
  width: 16px;
  height: 16px;
  margin-top: 3px;
  accent-color: var(--blue);
  cursor: pointer;
  flex-shrink: 0;
}
.form-checkbox-label {
  font-size: 0.75rem;
  color: var(--text-2);
  line-height: 1.5;
  cursor: pointer;
}
.form-checkbox-label a {
  color: var(--blue);
  text-decoration: none;
  font-weight: 600;
}
.form-checkbox-label a:hover {
  text-decoration: underline;
}

/* ===== Submit button ===== */
.portal-submit {
  width: 100%;
  padding: 0.82rem;
  font-size: 0.92rem;
  font-weight: 700;
  font-family: var(--font);
  color: #fff;
  background: linear-gradient(135deg, var(--blue), var(--purple));
  border: none;
  border-radius: 12px;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s, opacity 0.2s;
  box-shadow: 0 4px 16px rgba(79, 110, 247, 0.25);
  position: relative;
  overflow: hidden;
}
.portal-submit:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 6px 24px rgba(79, 110, 247, 0.35);
}
.portal-submit:active:not(:disabled) {
  transform: translateY(0);
}
.portal-submit:disabled {
  opacity: 0.65;
  cursor: not-allowed;
  transform: none;
}
.portal-submit .btn-text {
  transition: opacity 0.2s;
}
.portal-submit.loading .btn-text {
  opacity: 0;
}
.portal-submit .spinner {
  display: none;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 20px;
  height: 20px;
  border: 2.5px solid rgba(255, 255, 255, 0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}
.portal-submit.loading .spinner {
  display: block;
}
@keyframes spin {
  to { transform: translate(-50%, -50%) rotate(360deg); }
}

/* ===== Tab switch links ===== */
.portal-footer {
  text-align: center;
  padding: 1.2rem 2rem;
  border-top: 1px solid rgba(0, 0, 0, 0.04);
  background: rgba(0, 0, 0, 0.015);
}
.portal-footer-text {
  font-size: 0.78rem;
  color: var(--text-3);
}
.portal-footer-link {
  color: var(--blue);
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  background: none;
  border: none;
  font-family: var(--font);
  font-size: 0.78rem;
  transition: color 0.2s;
}
.portal-footer-link:hover {
  color: var(--purple);
  text-decoration: underline;
}

/* ===== Toast notifications ===== */
.toast-container {
  position: fixed;
  top: 1.5rem;
  right: 1.5rem;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.toast {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.8rem 1.2rem;
  border-radius: 12px;
  font-size: 0.82rem;
  font-weight: 500;
  font-family: var(--font);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
  animation: toastSlideIn 0.35s ease;
  backdrop-filter: blur(12px);
  max-width: 360px;
}
.toast.leaving {
  animation: toastSlideOut 0.3s ease forwards;
}
.toast-icon {
  font-size: 1.1rem;
  flex-shrink: 0;
}
.toast-success {
  background: rgba(16, 185, 129, 0.12);
  color: #047857;
  border: 1px solid rgba(16, 185, 129, 0.2);
}
.toast-error {
  background: rgba(239, 68, 68, 0.12);
  color: #b91c1c;
  border: 1px solid rgba(239, 68, 68, 0.2);
}
.toast-info {
  background: rgba(79, 110, 247, 0.12);
  color: #1d4ed8;
  border: 1px solid rgba(79, 110, 247, 0.2);
}
@keyframes toastSlideIn {
  from { opacity: 0; transform: translateX(40px); }
  to { opacity: 1; transform: translateX(0); }
}
@keyframes toastSlideOut {
  from { opacity: 1; transform: translateX(0); }
  to { opacity: 0; transform: translateX(40px); }
}

/* ===== Divider ===== */
.form-divider {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  margin: 1.2rem 0;
}
.form-divider::before,
.form-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: rgba(0, 0, 0, 0.06);
}
.form-divider span {
  font-size: 0.72rem;
  color: var(--text-3);
  font-weight: 500;
}

/* ===== Password strength indicator ===== */
.password-strength {
  display: flex;
  gap: 4px;
  margin-top: 0.4rem;
}
.strength-bar {
  flex: 1;
  height: 3px;
  border-radius: 99px;
  background: rgba(0, 0, 0, 0.06);
  transition: background 0.3s;
}
.strength-bar.active.weak { background: var(--red); }
.strength-bar.active.medium { background: var(--orange); }
.strength-bar.active.strong { background: var(--green); }
.strength-text {
  font-size: 0.68rem;
  color: var(--text-3);
  margin-top: 0.2rem;
  transition: color 0.3s;
}
.strength-text.weak { color: var(--red); }
.strength-text.medium { color: var(--orange); }
.strength-text.strong { color: var(--green); }

/* ===== Page Footer ===== */
.page-footer {
  text-align: center; padding: 2rem 1.5rem;
  background: rgba(255,255,255,0.6);
  border-top: 1px solid rgba(0,0,0,0.04);
  margin-top: auto;
  width: 100%;
}
.page-footer p { font-size: 0.8rem; color: var(--text-2); }
.footer-copy { font-size: 0.72rem !important; color: var(--text-3) !important; margin-top: 0.3rem; }
.footer-copy a { color: var(--blue); text-decoration: none; font-weight: 600; }
.footer-copy a:hover { text-decoration: underline; }
.footer-downloads {
  display: flex; flex-wrap: wrap; justify-content: center; align-items: center;
  gap: 0.3rem 0.5rem; margin-bottom: 0.8rem;
}
.footer-dl-label { font-size: 0.72rem; font-weight: 600; color: var(--text-2); }
.footer-downloads a {
  font-size: 0.68rem; font-weight: 500; color: var(--blue);
  text-decoration: none; padding: 0.2rem 0.5rem;
  border-radius: 6px; background: rgba(79,110,247,0.06);
  transition: background 0.2s;
}
.footer-downloads a:hover { background: rgba(79,110,247,0.14); }

/* ===== Public Welfare Notice ===== */
.pw-notice {
  display: flex; gap: 0.8rem; align-items: flex-start;
  margin-top: 1.2rem; padding: 1rem 1.2rem;
  border-radius: var(--radius);
  background: rgba(16,185,129,0.06);
  border: 1px solid rgba(16,185,129,0.2);
}
.pw-notice .pw-icon { font-size: 1.4rem; flex-shrink: 0; margin-top: 0.1rem; }
.pw-notice .pw-content h3 {
  font-size: 0.82rem; font-weight: 700; color: #047857; margin-bottom: 0.25rem;
}
.pw-notice .pw-content p {
  font-size: 0.75rem; color: var(--text-2); line-height: 1.6; margin: 0;
}
.pw-notice .pw-content a {
  color: #047857; font-weight: 600;
  text-decoration: underline; text-underline-offset: 2px;
}
.pw-notice .pw-content a:hover { color: #065f46; }

/* ===== RESPONSIVE ===== */
@media (max-width: 520px) {
  body {
    align-items: flex-start;
  }
  .portal-wrapper {
    margin: 1rem 0.8rem;
    max-width: 100%;
  }
  .portal-body {
    padding: 1.5rem 1.2rem 1.2rem;
  }
  .portal-title {
    font-size: 1.3rem;
  }
  .portal-tab {
    font-size: 0.78rem;
    padding: 0.75rem 0.3rem;
  }
  .portal-footer {
    padding: 1rem 1.2rem;
  }
  .pw-notice { flex-direction: column; gap: 0.6rem; }
}
