/* ============================================================
   BragBook – Main Stylesheet (Light, Clean, Professional)
   ============================================================ */

@font-face {
  font-family: 'Montserrat';
  src: url('https://fonts.gstatic.com/s/montserrat/v31/JTUSjIg1_i6t8kCHKm459Wlhyw.woff2') format('woff2');
  font-weight: 400 900;
  font-style: normal;
  font-display: swap;
}

/* ── Variables ──────────────────────────────────────────────── */
:root {
  --font: 'Montserrat', -apple-system, BlinkMacSystemFont, sans-serif;

  /* Background — clean white */
  --bg:        #f5f6fa;
  --bg-2:      #eef0f8;

  /* Surface */
  --card-bg:     #ffffff;
  --card-border: #e8eaf0;
  --card-shadow: 0 2px 8px rgba(0,0,0,0.06), 0 12px 40px rgba(79,70,229,0.08);

  /* Accent palette */
  --accent:       #4f46e5;
  --accent-hover: #4338ca;
  --accent-light: #ede9fe;
  --accent-mid:   #6366f1;

  --grad:         linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
  --grad-light:   linear-gradient(135deg, #ede9fe 0%, #e0e7ff 100%);

  /* Text */
  --text:    #111827;
  --text-2:  #6b7280;
  --text-3:  #9ca3af;

  /* Semantic */
  --success:    #059669;
  --success-bg: #ecfdf5;
  --success-border: #a7f3d0;
  --error:      #dc2626;
  --error-bg:   #fef2f2;
  --error-border: #fca5a5;
  --warning:    #d97706;

  /* Inputs */
  --input-bg:     #ffffff;
  --input-border: #d1d5db;
  --input-focus-border: #4f46e5;
  --input-focus-shadow: rgba(79,70,229,0.15);

  /* Radius — tighter, more professional */
  --radius:    12px;
  --radius-md: 8px;
  --radius-sm: 6px;
  --radius-xs: 4px;

  --transition: all 0.18s cubic-bezier(0.4,0,0.2,1);
}

/* ── Reset ──────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; font-size: 16px; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}
a { color: inherit; text-decoration: none; }
button { font-family: var(--font); cursor: pointer; border: none; background: none; }
input, button { outline: none; }
img { display: block; max-width: 100%; }

/* ── Keyframes ──────────────────────────────────────────────── */
@keyframes stepIn {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes stepOut {
  from { opacity: 1; transform: translateY(0); }
  to   { opacity: 0; transform: translateY(-8px); }
}
@keyframes shake {
  0%,100% { transform: translateX(0); }
  25%      { transform: translateX(-6px); }
  75%      { transform: translateX(6px); }
}
@keyframes spin {
  to { transform: rotate(360deg); }
}
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes slideDownIn {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes checkPop {
  0%   { transform: scale(0) rotate(-15deg); opacity: 0; }
  65%  { transform: scale(1.15) rotate(3deg);  opacity: 1; }
  100% { transform: scale(1) rotate(0deg);   opacity: 1; }
}
@keyframes float {
  0%,100% { transform: translateY(0); }
  50%      { transform: translateY(-10px); }
}
@keyframes verifyPulse {
  0%,100% { box-shadow: 0 0 0 0 rgba(79,70,229,0.25); }
  50%      { box-shadow: 0 0 0 8px rgba(79,70,229,0); }
}

/* ── Page Layout ────────────────────────────────────────────── */

/* Two-column split on desktop */
.auth-root {
  min-height: 100vh;
  display: flex;
}

/* LEFT – Illustration panel */
.auth-panel-left {
  flex: 0 0 52%;
  background: var(--grad);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 64px 56px;
  position: relative;
  overflow: hidden;
}
.auth-panel-left::before {
  content: '';
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 60% 50% at 20% 20%, rgba(255,255,255,0.08) 0%, transparent 60%),
    radial-gradient(ellipse 40% 40% at 80% 80%, rgba(0,0,0,0.1) 0%, transparent 55%);
  pointer-events: none;
}
.panel-logo {
  display: flex; align-items: center; gap: 12px;
  margin-bottom: 56px;
  position: relative;
}
.panel-logo-icon {
  width: 44px; height: 44px;
  background: rgba(255,255,255,0.15);
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  backdrop-filter: blur(8px);
}
.panel-logo-icon svg { color: #fff; }
.panel-logo-name {
  font-size: 1.4rem; font-weight: 800;
  color: #fff; letter-spacing: -0.5px;
}
.panel-illustration {
  width: 100%;
  max-width: 380px;
  position: relative;
}
.panel-illustration svg {
  width: 100%; height: auto;
  animation: float 6s ease-in-out infinite;
  filter: drop-shadow(0 24px 48px rgba(0,0,0,0.2));
}
.panel-tagline {
  margin-top: 48px; text-align: center; position: relative;
}
.panel-tagline h2 {
  font-size: 1.5rem; font-weight: 800;
  color: #fff; line-height: 1.3; letter-spacing: -0.3px;
}
.panel-tagline p {
  margin-top: 10px;
  font-size: 0.9rem;
  color: rgba(255,255,255,0.72);
  line-height: 1.6;
}

/* RIGHT – Form panel */
.auth-panel-right {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 48px 40px;
  background: #fff;
  overflow-y: auto;
}

.auth-form-wrap {
  width: 100%;
  max-width: 400px;
  animation: fadeUp 0.3s ease forwards;
}

/* Brand (visible on mobile only) */
.auth-mobile-brand {
  display: none;
  flex-direction: column;
  align-items: center;
  margin-bottom: 32px;
}
.auth-mobile-logo {
  width: 48px; height: 48px;
  background: var(--grad);
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 12px;
}
.auth-mobile-logo svg { color: #fff; }
.auth-mobile-name {
  font-size: 1.4rem; font-weight: 800;
  color: var(--text); letter-spacing: -0.5px;
}

/* Form header */
.auth-header {
  margin-bottom: 28px;
}
.auth-heading {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -0.4px;
  line-height: 1.2;
}
.auth-subtitle {
  margin-top: 6px;
  font-size: 0.875rem;
  color: var(--text-2);
  font-weight: 500;
  transition: var(--transition);
}

/* ── Progress Indicator ─────────────────────────────────────── */
.auth-progress {
  display: none;
  align-items: center;
  gap: 0;
  margin-bottom: 28px;
}
.progress-step {
  width: 28px; height: 28px;
  border-radius: 50%;
  border: 2px solid var(--card-border);
  display: flex; align-items: center; justify-content: center;
  font-size: 0.72rem; font-weight: 700;
  color: var(--text-3);
  transition: var(--transition);
  position: relative; z-index: 1;
  background: #fff;
}
.progress-step.active {
  border-color: var(--accent);
  color: var(--accent);
}
.progress-step.done {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}
.progress-step.done span { display: none; }
.progress-line {
  flex: 1; max-width: 40px; height: 2px;
  background: var(--card-border);
  transition: background 0.3s ease;
}
.progress-line.done { background: var(--accent); }

/* ── Auth Steps ─────────────────────────────────────────────── */
.auth-step { display: none; }
.auth-step.active {
  display: block;
  animation: stepIn 0.22s cubic-bezier(0.4,0,0.2,1) forwards;
}

/* ── Badges ─────────────────────────────────────────────────── */
.email-badge {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: var(--accent-light);
  border: 1px solid rgba(79,70,229,0.2);
  border-radius: 6px;
  padding: 5px 12px;
  font-size: 0.8rem;
  color: var(--accent);
  margin-bottom: 20px;
  font-weight: 600;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.email-badge svg { flex-shrink: 0; opacity: 0.8; }

.new-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--success-bg);
  border: 1px solid var(--success-border);
  border-radius: 6px;
  padding: 4px 10px;
  font-size: 0.72rem;
  color: var(--success);
  margin-bottom: 14px;
  font-weight: 700;
  letter-spacing: 0.02em;
}

/* ── Form Groups ────────────────────────────────────────────── */
.form-group {
  margin-bottom: 16px;
}
.form-label {
  display: block;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 7px;
  letter-spacing: 0.02em;
}
.input-wrapper {
  position: relative;
}
.form-input {
  width: 100%;
  background: var(--input-bg);
  border: 1.5px solid var(--input-border);
  border-radius: var(--radius-md);
  padding: 11px 14px;
  font-size: 0.9rem;
  font-family: var(--font);
  font-weight: 500;
  color: var(--text);
  transition: border-color 0.16s ease, box-shadow 0.16s ease;
  appearance: none;
  -webkit-appearance: none;
}
.form-input::placeholder { color: var(--text-3); font-weight: 400; }
.form-input:focus {
  border-color: var(--input-focus-border);
  box-shadow: 0 0 0 3px var(--input-focus-shadow);
}
.form-input.has-toggle { padding-right: 44px; }
.form-input.error { border-color: var(--error); }

.pw-toggle {
  position: absolute; right: 12px; top: 50%;
  transform: translateY(-50%);
  color: var(--text-3);
  padding: 4px;
  display: flex; align-items: center; justify-content: center;
  transition: color 0.15s;
  background: none; border: none; cursor: pointer;
}
.pw-toggle:hover { color: var(--text-2); }

/* ── Password Strength ──────────────────────────────────────── */
.pw-strength {
  margin-top: 6px;
  display: flex; gap: 3px;
}
.pw-strength-bar {
  height: 3px; flex: 1;
  border-radius: 2px;
  background: var(--card-border);
  transition: background 0.22s;
}
.pw-strength-bar.weak   { background: var(--error); }
.pw-strength-bar.medium { background: var(--warning); }
.pw-strength-bar.strong { background: var(--success); }

/* ── Buttons ────────────────────────────────────────────────── */
.btn-primary {
  width: 100%;
  padding: 12px 20px;
  border-radius: var(--radius-md);
  background: var(--accent);
  color: #fff;
  font-size: 0.9rem;
  font-weight: 700;
  font-family: var(--font);
  letter-spacing: 0.02em;
  position: relative;
  overflow: hidden;
  transition: background 0.15s ease, transform 0.12s ease, box-shadow 0.15s ease;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  margin-top: 4px;
}
.btn-primary:hover:not(:disabled) {
  background: var(--accent-hover);
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(79,70,229,0.3);
}
.btn-primary:active:not(:disabled) {
  transform: translateY(0);
  box-shadow: none;
}
.btn-primary:disabled { opacity: 0.55; cursor: not-allowed; transform: none; box-shadow: none; }
.btn-primary.loading { pointer-events: none; color: transparent; }
.btn-primary.loading::after {
  content: '';
  position: absolute;
  width: 18px; height: 18px;
  border: 2.5px solid rgba(255,255,255,0.35);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.65s linear infinite;
}

.btn-ghost {
  width: 100%; padding: 11px 20px;
  border-radius: var(--radius-md);
  border: 1.5px solid var(--card-border);
  background: transparent;
  color: var(--text-2);
  font-size: 0.875rem; font-weight: 600;
  font-family: var(--font);
  transition: border-color 0.15s, color 0.15s, background 0.15s;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  margin-top: 10px;
}
.btn-ghost:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-light);
}

.link-btn {
  background: none; border: none;
  color: var(--accent);
  font-size: 0.82rem; font-weight: 600;
  cursor: pointer; padding: 0;
  transition: color 0.15s;
  font-family: var(--font);
}
.link-btn:hover { color: var(--accent-hover); text-decoration: underline; }

.btn-row {
  display: flex; justify-content: space-between; align-items: center;
  margin-top: 14px; flex-wrap: wrap; gap: 8px;
}

/* ── OTP / Verification Screen ──────────────────────────────── */
.otp-header {
  text-align: center;
  margin-bottom: 20px;
}
.otp-icon-wrap {
  width: 64px; height: 64px;
  border-radius: 16px;
  background: var(--accent-light);
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 16px;
  font-size: 1.75rem;
}
.otp-message {
  font-size: 0.875rem; color: var(--text-2); line-height: 1.55;
  font-weight: 500;
}
.otp-message strong { color: var(--text); font-weight: 700; }
.otp-hint {
  font-size: 0.82rem; color: var(--text-3);
  margin-top: 10px; line-height: 1.5; text-align: center;
}

/* Auto-verify status indicator */
.verify-status {
  display: flex; align-items: center; gap: 8px;
  background: var(--accent-light);
  border: 1.5px solid rgba(79,70,229,0.2);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  margin: 16px 0;
  font-size: 0.82rem; font-weight: 600; color: var(--accent);
}
.verify-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--accent);
  flex-shrink: 0;
  animation: verifyPulse 1.6s ease-in-out infinite;
}

.otp-meta {
  display: flex; align-items: center; justify-content: center;
  margin-top: 10px; gap: 12px;
}
.otp-timer { font-size: 0.78rem; color: var(--text-3); font-weight: 600; }
.otp-resend {
  font-size: 0.78rem; color: var(--accent);
  cursor: pointer; background: none; border: none;
  font-family: var(--font); font-weight: 600;
  transition: color 0.15s;
  display: none;
}
.otp-resend:hover { color: var(--accent-hover); }
.otp-resend.visible { display: inline; }

/* ── Class Selector ─────────────────────────────────────────── */
.class-label {
  font-size: 0.78rem; font-weight: 700;
  color: var(--text); margin-bottom: 8px; letter-spacing: 0.02em;
  display: block;
}
.class-grid {
  display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px;
}
.class-card {
  cursor: pointer; position: relative;
  border: 1.5px solid var(--card-border);
  border-radius: var(--radius-md);
  padding: 12px 6px;
  text-align: center;
  transition: border-color 0.15s, background 0.15s;
  background: #fff;
}
.class-card input[type="radio"] {
  position: absolute; opacity: 0; width: 0; height: 0; pointer-events: none;
}
.class-code {
  display: block;
  font-size: 0.92rem; font-weight: 700;
  color: var(--text-2);
  transition: color 0.15s;
}
.class-tick {
  position: absolute; top: 4px; right: 4px;
  width: 14px; height: 14px;
  background: var(--accent);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 7px; color: #fff;
  opacity: 0; transform: scale(0);
  transition: transform 0.15s, opacity 0.15s;
}
.class-card:hover { border-color: rgba(79,70,229,0.4); background: var(--accent-light); }
.class-card:hover .class-code { color: var(--accent); }
.class-card.selected { border-color: var(--accent); background: var(--accent-light); }
.class-card.selected .class-code { color: var(--accent); }
.class-card.selected .class-tick { opacity: 1; transform: scale(1); animation: checkPop 0.25s ease; }

/* ── Messages ───────────────────────────────────────────────── */
.auth-error, .auth-success {
  border-radius: var(--radius-md);
  padding: 10px 12px;
  font-size: 0.82rem;
  font-weight: 600;
  display: none;
  align-items: flex-start; gap: 8px;
  margin-top: 12px;
  animation: slideDownIn 0.2s ease;
  line-height: 1.45;
}
.auth-error {
  background: var(--error-bg);
  border: 1px solid var(--error-border);
  color: var(--error);
}
.auth-success {
  background: var(--success-bg);
  border: 1px solid var(--success-border);
  color: var(--success);
}
.auth-error.shake { animation: shake 0.35s ease; }
.msg-icon { flex-shrink: 0; margin-top: 1px; }

/* ── Divider ────────────────────────────────────────────────── */
.separator {
  display: flex; align-items: center; gap: 10px;
  margin: 18px 0;
  color: var(--text-3); font-size: 0.72rem; font-weight: 600;
}
.separator::before, .separator::after {
  content: ''; flex: 1; height: 1px;
  background: var(--card-border);
}

/* ── Forgot screens ─────────────────────────────────────────── */
.forgot-intro {
  font-size: 0.875rem; color: var(--text-2); line-height: 1.6; margin-bottom: 20px;
}
.forgot-intro strong { color: var(--text); font-weight: 700; }

/* ================================================================
   STUDENT DASHBOARD
================================================================ */
.student-page {
  background: var(--bg);
  min-height: 100vh;
  display: flex; flex-direction: column;
}

.student-nav {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 32px;
  border-bottom: 1px solid var(--card-border);
  background: #fff;
  position: sticky; top: 0; z-index: 10;
}
.nav-brand { display: flex; align-items: center; gap: 10px; }
.nav-logo { width: 30px; height: 30px; }
.nav-name {
  font-size: 1rem; font-weight: 800;
  color: var(--text);
}

.btn-signout {
  display: flex; align-items: center; gap: 7px;
  padding: 7px 14px;
  border: 1.5px solid var(--card-border);
  border-radius: 6px;
  color: var(--text-2); font-size: 0.8rem; font-weight: 600;
  transition: var(--transition);
  font-family: var(--font); cursor: pointer; background: none;
}
.btn-signout:hover {
  border-color: var(--error);
  color: var(--error);
  background: var(--error-bg);
}

.student-main {
  flex: 1; display: flex; align-items: center; justify-content: center;
  padding: 48px 16px;
}

.profile-card {
  width: 100%; max-width: 500px;
  background: #fff;
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  padding: 48px 40px 40px;
  box-shadow: var(--card-shadow);
  text-align: center;
  opacity: 0; transform: translateY(16px);
  transition: opacity 0.4s ease, transform 0.4s ease;
}
.profile-card.visible { opacity: 1; transform: translateY(0); }

.profile-avatar {
  width: 80px; height: 80px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.8rem; font-weight: 800; color: #fff;
  margin: 0 auto 18px;
  background: var(--grad);
}

.profile-name {
  font-size: 1.6rem; font-weight: 800;
  letter-spacing: -0.4px; color: var(--text);
  margin-bottom: 6px;
}
.profile-class-badge {
  display: inline-block;
  padding: 3px 14px;
  border-radius: 6px;
  background: var(--accent-light);
  border: 1px solid rgba(79,70,229,0.2);
  color: var(--accent);
  font-size: 0.75rem; font-weight: 700;
  letter-spacing: 0.06em;
  margin-bottom: 24px;
}

.profile-divider {
  height: 1px; background: var(--card-border); margin: 0 -40px 24px;
}

.profile-info { text-align: left; }
.info-row {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 0;
  border-bottom: 1px solid var(--bg);
}
.info-row:last-child { border-bottom: none; }
.info-icon {
  width: 32px; height: 32px; flex-shrink: 0;
  border-radius: var(--radius-md);
  background: var(--accent-light);
  display: flex; align-items: center; justify-content: center;
  color: var(--accent);
}
.info-content { flex: 1; min-width: 0; }
.info-label { font-size: 0.68rem; font-weight: 700; color: var(--text-3); letter-spacing: 0.06em; text-transform: uppercase; }
.info-value { font-size: 0.88rem; font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Loading skeleton */
#student-loading {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  min-height: 50vh; gap: 14px;
}
.loading-ring {
  width: 40px; height: 40px;
  border: 3px solid var(--card-border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
}
.loading-text { color: var(--text-3); font-size: 0.85rem; font-weight: 600; }

/* ================================================================
   404 PAGE
================================================================ */
.error-page {
  background: #fff;
  min-height: 100vh;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: 24px 16px; text-align: center;
}
.error-number {
  font-size: clamp(5rem, 18vw, 9rem);
  font-weight: 900; line-height: 1;
  background: var(--grad);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text;
  animation: float 5s ease-in-out infinite;
  letter-spacing: -4px; user-select: none;
}
.error-title {
  font-size: 1.5rem; font-weight: 800;
  margin: 14px 0 8px; color: var(--text);
}
.error-subtitle {
  font-size: 0.92rem; color: var(--text-2);
  max-width: 360px; line-height: 1.6; margin-bottom: 32px;
}
.btn-home {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 12px 26px;
  border-radius: var(--radius-md);
  background: var(--accent);
  color: #fff; font-size: 0.9rem; font-weight: 700;
  font-family: var(--font);
  transition: background 0.15s, transform 0.12s;
  border: none; cursor: pointer;
}
.btn-home:hover { background: var(--accent-hover); transform: translateY(-1px); }

/* ── Responsive ─────────────────────────────────────────────── */
@media (max-width: 860px) {
  .auth-panel-left { display: none; }
  .auth-panel-right {
    background: var(--bg);
    padding: 32px 20px;
  }
  .auth-mobile-brand { display: flex; }
  .auth-form-wrap {
    background: #fff;
    border-radius: var(--radius);
    padding: 32px 28px;
    box-shadow: var(--card-shadow);
    border: 1px solid var(--card-border);
  }
}

@media (max-width: 480px) {
  .auth-form-wrap { padding: 28px 20px; }
  .profile-card { padding: 36px 24px 28px; }
  .profile-divider { margin: 0 -24px 20px; }
  .student-nav { padding: 12px 16px; }
  .class-grid { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 360px) {
  .class-grid { grid-template-columns: repeat(2, 1fr); }
}
