/* =============================================
   ExamPortal — Main Stylesheet
   ============================================= */

:root {
  --sidebar-width: 260px;
  --sidebar-bg: #1a1f2e;
  --sidebar-text: #c8cfd8;
  --sidebar-hover: #2d3452;
  --sidebar-active-bg: #4f6ef7;
  --topbar-height: 60px;
  --primary: #4f6ef7;
  --success: #22c55e;
  --danger:  #ef4444;
  --warning: #f59e0b;
  --body-bg: #f4f6fb;
}

* { box-sizing: border-box; }

body {
  background: var(--body-bg);
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  font-size: 14px;
}

/* ── Sidebar ─────────────────────────────────── */
.sidebar {
  width: var(--sidebar-width);
  min-height: 100vh;
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  overflow-y: auto;
  z-index: 1040;
  transition: transform .25s ease;
}
.sidebar-brand {
  padding: 1.25rem 1.5rem;
  font-size: 1.2rem;
  font-weight: 700;
  color: #fff;
  border-bottom: 1px solid rgba(255,255,255,.08);
  display: flex;
  align-items: center;
  gap: .6rem;
  line-height: 1.15;
}
.sidebar-brand i { color: var(--primary); font-size: 1.4rem; }
.sidebar-brand-logo {width:216px; flex-shrink: 0; border-radius: .25rem; background: #fff; padding: 2px; }

.sidebar-nav { padding: 1rem 0; flex: 1; }
.nav-section { font-size: .65rem; font-weight: 600; letter-spacing: .08em;
               text-transform: uppercase; color: #5c6a82; padding: .75rem 1.5rem .25rem; }
.sidebar-link {
  display: flex; align-items: center; gap: .75rem;
  padding: .6rem 1.5rem; color: var(--sidebar-text);
  text-decoration: none; font-size: .875rem;
  transition: background .15s, color .15s;
  border-left: 3px solid transparent;
}
.sidebar-link:hover { background: var(--sidebar-hover); color: #fff; }
.sidebar-link.active { background: var(--sidebar-hover); color: #fff;
                        border-left-color: var(--primary); }
.sidebar-link i { font-size: 1rem; flex-shrink: 0; width: 1.25rem; }

#page-content-wrapper {
  margin-left: var(--sidebar-width);
  min-height: 100vh;
  transition: margin .25s ease;
}

/* ── Topbar ──────────────────────────────────── */
.topbar {
  height: var(--topbar-height);
  background: #fff;
  border-bottom: 1px solid #e9ecef;
  position: sticky; top: 0; z-index: 1030;
}
.avatar-circle {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--primary); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 600; font-size: .8rem;
}
.avatar-xs {
  width: 26px; height: 26px; border-radius: 50%;
  background: var(--primary); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: .7rem; font-weight: 700; flex-shrink: 0;
}

/* ── Stat Cards ──────────────────────────────── */
.stat-card { border: none; border-radius: .75rem; }
.stat-card-link:hover { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(0,0,0,.1) !important; transition: all .2s; }
.stat-icon {
  width: 52px; height: 52px; border-radius: .65rem;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.4rem; flex-shrink: 0;
}
.stat-value { font-size: 1.6rem; font-weight: 700; line-height: 1.2; }
.stat-label { font-size: .75rem; }

/* ── Cards ───────────────────────────────────── */
.card { border: none; border-radius: .75rem; }
.card-header { background: #fff; border-bottom: 1px solid #f0f0f0; border-radius: .75rem .75rem 0 0 !important; }

/* ── Tables ──────────────────────────────────── */
.table { font-size: .875rem; }
.table th { font-weight: 600; font-size: .78rem; text-transform: uppercase;
            letter-spacing: .04em; color: #6c757d; }

/* ── Buttons ─────────────────────────────────── */
.btn-xs { padding: .15rem .45rem; font-size: .75rem; border-radius: .25rem; }

/* ── Badges & Pills ──────────────────────────── */
.badge { font-size: .72rem; font-weight: 600; }

/* ── Blink animation ─────────────────────────── */
@keyframes blink { 0%,100%{opacity:1} 50%{opacity:.3} }
.blink { animation: blink 1.5s ease infinite; }

/* ── Question palette ────────────────────────── */
.q-palette-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: .3rem;
}
.q-nav-btn {
  width: 100%; aspect-ratio: 1;
  border: 1.5px solid #dee2e6; border-radius: .35rem;
  background: #fff; font-size: .8rem; font-weight: 600; cursor: pointer;
  transition: all .15s;
}
.q-nav-btn.answered { background: #22c55e; border-color: #22c55e; color: #fff; }
.q-nav-btn.flagged  { background: #f59e0b; border-color: #f59e0b; color: #fff; }
.q-nav-btn.current  { box-shadow: 0 0 0 2px var(--primary); }
.legend-dot { display:inline-block; width:12px; height:12px; border-radius:3px; }
.legend-dot.answered { background:#22c55e; }
.legend-dot.flagged  { background:#f59e0b; }
.legend-dot.current  { background:var(--primary); }

/* ── Exam layout ─────────────────────────────── */
.exam-layout { background: var(--body-bg); }
.exam-header {
  position: sticky; top: 0; z-index: 100;
  background: var(--sidebar-bg); color: #fff;
  padding: .75rem 0; box-shadow: 0 2px 8px rgba(0,0,0,.2);
}
.exam-title { font-size: .95rem; }
.exam-timer { font-size: 1.4rem; font-weight: 700; font-variant-numeric: tabular-nums;
              letter-spacing: .05em; }
.exam-timer.timer-warning { color: #f59e0b; }
.exam-timer.timer-danger  { color: #ef4444; animation: blink 1s infinite; }
.exam-body { padding: 1.5rem 1rem; max-width: 1200px; margin: 0 auto; }

/* ── Proctoring overlay (PIP) — fixed small size on all devices ── */
.proctor-overlay {
  position: fixed;
  bottom: 70px; right: 8px;
  z-index: 9999;
  width: 72px;
  border-radius: .5rem;
  overflow: hidden;
  box-shadow: 0 2px 10px rgba(0,0,0,.5);
  background: transparent;
  border: 2px solid #22c55e;
  cursor: grab;
  user-select: none;
  touch-action: none;
}
.proctor-overlay:active { cursor: grabbing; }
.proctor-overlay .pip-drag-hint {
  font-size: .45rem; color: rgba(255,255,255,.7);
  text-align: center; padding: 1px 0; background: rgba(0,0,0,.55);
}
.proctor-video {
  width: 100% !important;
  height: 54px !important;
  max-height: 54px !important;
  display: block;
  object-fit: cover;
  background: #111;
}
.proctor-status {
  background: rgba(0,0,0,.8); color: #fff;
  font-size: .5rem; padding: .1rem .3rem;
  display: flex; align-items: center; gap: .2rem;
  white-space: nowrap;
}
.status-dot { width: 5px; height: 5px; border-radius: 50%; flex-shrink:0; }
.status-dot.active { background: #22c55e; animation: blink 2s infinite; }
.status-dot.error  { background: #ef4444; }

/* tablet (600–991px) */
@media (min-width: 600px) {
  .proctor-overlay { width: 88px; bottom: 80px; right: 12px; }
  .proctor-video   { height: 66px !important; max-height: 66px !important; }
}
/* desktop (992px+) */
@media (min-width: 992px) {
  .proctor-overlay { width: 120px; top: 68px; bottom: auto; right: 16px; }
  .proctor-video   { height: 90px !important; max-height: 90px !important; }
}

/* ── Proctor toast warnings (small banner, not full screen) ── */
.proctor-toast {
  position: fixed;
  top: 65px; left: 50%; transform: translateX(-50%);
  background: #dc2626; color: #fff;
  padding: .5rem 1.25rem;
  border-radius: .5rem;
  font-weight: 600;
  font-size: .82rem;
  z-index: 10000;
  box-shadow: 0 4px 20px rgba(0,0,0,.35);
  animation: slideDown .3s ease;
  max-width: 88vw;
  text-align: center;
  line-height: 1.3;
  pointer-events: none;
}
@keyframes slideDown { from{opacity:0;transform:translate(-50%,-12px)} to{opacity:1;transform:translate(-50%,0)} }

/* ── Auth layouts ────────────────────────────── */
.auth-wrapper {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #1a1f2e 0%, #2d3452 100%);
}
.auth-card { width: 100%; max-width: 440px; border-radius: 1rem; }
.auth-logo { height: 44px; width: auto; }

/* ── Forms ───────────────────────────────────── */
.form-control, .form-select {
  border-radius: .5rem;
  font-size: .875rem;
}
.form-label { font-weight: 500; font-size: .85rem; }
.invalid-feedback { font-size: .8rem; }

/* ── Mobile ──────────────────────────────────── */
@media (max-width: 992px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.show { transform: translateX(0); }
  #page-content-wrapper { margin-left: 0; }
  /* proctor handled above with responsive rules */
}
@media (max-width: 480px) {
  .auth-card { max-width: 100%; }
  .auth-logo { height: 36px; }
  .sidebar-brand-logo { height: 18px; }
}

/* ── Utilities ───────────────────────────────── */
.cursor-pointer { cursor: pointer; }
.rounded-lg { border-radius: .75rem !important; }
.shadow-card { box-shadow: 0 2px 12px rgba(0,0,0,.08); }
