/* ===== RESET & BASE ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --monash-blue: #006DAE;
  --monash-dark: #1a1a2e;
  --monash-light-blue: #e8f4fd;
  --monash-border: #C9DAF8;
  --success: #28a745;
  --danger: #dc3545;
  --warning: #ffc107;
  --text: #333;
  --text-muted: #6c757d;
  --bg: #f5f7fa;
  --card-bg: #fff;
  --nav-height: 56px;
  --sidebar-width: 260px;
}
body { font-family: 'Calibri', Arial, sans-serif; background: var(--bg); color: var(--text); font-size: 15px; line-height: 1.5; }
a { color: var(--monash-blue); text-decoration: none; }
a:hover { text-decoration: underline; }
h1,h2,h3,h4,h5 { font-family: Arial, sans-serif; }

/* ===== NAVBAR ===== */
.navbar {
  position: fixed; top: 0; left: 0; right: 0; height: var(--nav-height);
  background: #fff; border-bottom: 1px solid #ddd; display: flex;
  align-items: center; justify-content: space-between; padding: 0 20px;
  z-index: 1000; box-shadow: 0 1px 4px rgba(0,0,0,.1);
}
.navbar-brand { display: flex; align-items: center; gap: 10px; font-weight: bold; color: var(--monash-blue); font-size: 18px; }
.navbar-brand svg { width: 32px; height: 32px; }
.navbar-center { font-size: 14px; color: var(--text-muted); font-weight: 500; }
.navbar-right { display: flex; align-items: center; gap: 16px; }

/* ===== USER AVATAR / PROFILE DROPDOWN ===== */
.user-avatar {
  width: 34px; height: 34px; border-radius: 50%; background: var(--monash-blue);
  color: #fff; font-size: 14px; font-weight: 700; display: flex; align-items: center;
  justify-content: center; cursor: pointer; flex-shrink: 0; border: 2px solid transparent;
  transition: border-color .15s; user-select: none;
}
.user-avatar:hover { border-color: rgba(0,109,174,.4); }
.user-profile-wrap { position: relative; }
.user-dropdown {
  position: absolute; top: calc(100% + 8px); right: 0; min-width: 220px;
  background: #fff; border: 1px solid #ddd; border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0,0,0,.12); z-index: 2000; display: none; overflow: hidden;
}
.user-dropdown.open { display: block; }
.user-dropdown-header {
  padding: 14px 16px; border-bottom: 1px solid #eee; background: var(--monash-light-blue);
}
.user-dropdown-email { font-size: 13px; font-weight: 600; color: var(--monash-blue); word-break: break-all; }
.user-dropdown-sub   { font-size: 11px; color: var(--text-muted); margin-top: 2px; }
.user-dropdown-item  {
  display: flex; align-items: center; gap: 8px; padding: 10px 16px;
  font-size: 13px; cursor: pointer; color: var(--text); transition: background .1s;
  border: none; background: none; width: 100%; text-align: left; text-decoration: none;
}
.user-dropdown-item:hover { background: #f5f5f5; }
.user-dropdown-item.danger { color: var(--danger); }
.timer-display {
  background: var(--monash-blue); color: #fff; padding: 4px 14px;
  border-radius: 4px; font-size: 15px; font-weight: bold; font-family: monospace; min-width: 90px; text-align: center;
}
.timer-display.warning { background: var(--warning); color: #333; }
.timer-display.danger { background: var(--danger); animation: pulse 1s infinite; }
@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:.6} }

/* ===== LAYOUT ===== */
.page-wrapper { padding-top: var(--nav-height); min-height: 100vh; }
.container { max-width: 1100px; margin: 0 auto; padding: 24px 20px; }
.container-fluid { padding: 24px 20px; }

/* ===== EXAM LAYOUT ===== */
.exam-layout { display: flex; min-height: calc(100vh - var(--nav-height)); }
.exam-main { flex: 1; padding: 24px; overflow-y: auto; }
.exam-sidebar {
  width: var(--sidebar-width); background: #fff; border-left: 1px solid #ddd;
  padding: 16px; overflow-y: auto; flex-shrink: 0; position: sticky;
  top: var(--nav-height); height: calc(100vh - var(--nav-height));
}

/* ===== CARDS ===== */
.card {
  background: var(--card-bg); border: 1px solid #ddd; border-radius: 8px;
  padding: 20px; margin-bottom: 16px; box-shadow: 0 1px 3px rgba(0,0,0,.06);
}
.card-header { border-bottom: 1px solid #eee; padding-bottom: 12px; margin-bottom: 16px; }
.card-title { font-size: 16px; font-weight: 700; color: var(--monash-blue); }
.card-monash { background: #fff; border: 1px solid #ddd; border-radius: 8px; padding: 24px; }

/* ===== BUTTONS ===== */
.btn {
  display: inline-flex; align-items: center; gap: 6px; padding: 8px 16px;
  border: none; border-radius: 5px; cursor: pointer; font-size: 14px;
  font-weight: 600; transition: all .15s; text-decoration: none; line-height: 1.4;
}
.btn:hover { filter: brightness(.92); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--monash-blue); color: #fff; }
.btn-secondary { background: #6c757d; color: #fff; }
.btn-success { background: var(--success); color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-warning { background: var(--warning); color: #333; }
.btn-outline { background: transparent; border: 1.5px solid var(--monash-blue); color: var(--monash-blue); }
.btn-sm { padding: 4px 10px; font-size: 13px; }
.btn-lg { padding: 12px 24px; font-size: 16px; }
.btn-block { width: 100%; justify-content: center; }

/* ===== PROGRESS ===== */
.progress-container { margin-bottom: 16px; font-size: 13px; color: var(--text-muted); }
.progress { height: 8px; background: #e0e0e0; border-radius: 4px; overflow: hidden; margin-top: 4px; }
.progress-bar { height: 100%; background: var(--monash-blue); border-radius: 4px; transition: width .3s; }

/* ===== QUESTION BLOCK ===== */
.question-block {
  background: #fff; border: 1px solid #ddd; border-radius: 8px; padding: 24px;
  margin-bottom: 20px; position: relative;
}
.question-block.current { border-color: var(--monash-blue); box-shadow: 0 0 0 2px rgba(0,109,174,.15); }
.question-meta { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; flex-wrap: wrap; gap: 8px; }
.question-number { font-weight: 700; color: var(--monash-blue); font-size: 15px; }
.question-type-badge {
  font-size: 11px; padding: 2px 8px; border-radius: 12px; font-weight: 600;
  background: var(--monash-light-blue); color: var(--monash-blue); text-transform: uppercase;
}
.question-topic { font-size: 12px; color: var(--text-muted); background: #f0f0f0; padding: 2px 8px; border-radius: 12px; }
.question-text { font-size: 15px; margin-bottom: 18px; line-height: 1.6; }
.question-text p { margin-bottom: 8px; }

/* ===== UNSURE FLAG ===== */
.unsure-flag { display: flex; align-items: center; gap: 6px; cursor: pointer; font-size: 13px; color: var(--text-muted); user-select: none; }
.unsure-flag input { accent-color: var(--warning); }
.unsure-flag.flagged { color: #e67e00; font-weight: 600; }

/* ===== MCQ OPTIONS ===== */
.options-list { list-style: none; display: flex; flex-direction: column; gap: 8px; }
.option-item {
  display: flex; align-items: flex-start; gap: 12px; padding: 10px 14px;
  border: 1.5px solid #ddd; border-radius: 6px; cursor: pointer; transition: all .15s;
}
.option-item:hover { border-color: var(--monash-blue); background: var(--monash-light-blue); }
.option-item.selected { border-color: var(--monash-blue); background: var(--monash-light-blue); }
.option-item.correct { border-color: var(--success); background: #e8f5e9; }
.option-item.incorrect { border-color: var(--danger); background: #fdecea; }
.option-item input[type=radio], .option-item input[type=checkbox] { margin-top: 2px; accent-color: var(--monash-blue); flex-shrink: 0; }
.option-label { line-height: 1.5; }
.option-key { font-weight: 700; color: var(--monash-blue); min-width: 20px; }

/* ===== SHORT ANSWER / ESSAY ===== */
.answer-input {
  width: 100%; padding: 10px 12px; border: 1.5px solid #ccc; border-radius: 5px;
  font-size: 14px; font-family: inherit; resize: vertical; transition: border-color .15s;
  min-height: 80px;
}
.answer-input:focus { outline: none; border-color: var(--monash-blue); box-shadow: 0 0 0 2px rgba(0,109,174,.15); }
.essay-input { min-height: 200px; }

/* ===== REVIEW MODE ===== */
.review-answer { margin-top: 12px; padding: 12px; border-radius: 6px; font-size: 14px; }
.review-answer.correct { background: #e8f5e9; border: 1px solid var(--success); }
.review-answer.incorrect { background: #fdecea; border: 1px solid var(--danger); }
.review-answer .label { font-weight: 700; margin-bottom: 4px; }
.review-answer .model { color: var(--success); margin-top: 6px; }
.explanation { margin-top: 10px; padding: 10px 12px; background: #fffbe6; border: 1px solid #ffe58f; border-radius: 5px; font-size: 13px; }
.explanation strong { color: #b8860b; }

/* ===== NAVIGATION BUTTONS ===== */
.attempt-nav { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 20px; }
.qnbutton {
  width: 36px; height: 36px; border-radius: 5px; border: 1.5px solid #ccc;
  background: #fff; cursor: pointer; font-size: 13px; font-weight: 600;
  display: inline-flex; align-items: center; justify-content: center; transition: all .15s; color: var(--text);
}
.qnbutton:hover { border-color: var(--monash-blue); color: var(--monash-blue); text-decoration: none; }
.qnbutton.answered { background: var(--monash-blue); color: #fff; border-color: var(--monash-blue); }
.qnbutton.flagged { background: #fff3cd; border-color: var(--warning); color: #856404; }
.qnbutton.current { outline: 2px solid var(--monash-blue); outline-offset: 2px; }
.qnbutton.info-btn { background: #6c757d; color: #fff; border-color: #6c757d; font-style: italic; }
.nav-section-label { font-size: 11px; font-weight: 700; text-transform: uppercase; color: var(--text-muted); width: 100%; margin-top: 8px; margin-bottom: 2px; }

/* ===== SIDEBAR NAV KEY ===== */
.question-key { margin-top: 16px; font-size: 12px; }
.question-key h4 { font-size: 12px; font-weight: 700; margin-bottom: 6px; color: var(--text-muted); }
.key-item { display: flex; align-items: center; gap: 6px; margin-bottom: 4px; }
.key-swatch { width: 14px; height: 14px; border-radius: 3px; flex-shrink: 0; }
.key-swatch.answered { background: var(--monash-blue); }
.key-swatch.flagged { background: #fff3cd; border: 1.5px solid var(--warning); }
.key-swatch.unanswered { background: #fff; border: 1.5px solid #ccc; }

/* ===== DASHBOARD GRID ===== */
.dash-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat-card {
  background: #fff; border: 1px solid #ddd; border-radius: 8px; padding: 20px;
  display: flex; align-items: center; gap: 16px;
}
.stat-icon { font-size: 28px; width: 48px; height: 48px; border-radius: 10px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.stat-icon.blue { background: var(--monash-light-blue); }
.stat-icon.green { background: #e8f5e9; }
.stat-icon.orange { background: #fff3e0; }
.stat-icon.red { background: #fdecea; }
.stat-value { font-size: 26px; font-weight: 800; color: var(--text); line-height: 1; }
.stat-label { font-size: 13px; color: var(--text-muted); margin-top: 2px; }

/* ===== TABLES ===== */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { background: var(--monash-blue); color: #fff; padding: 10px 12px; text-align: left; font-weight: 600; }
td { padding: 9px 12px; border-bottom: 1px solid #eee; vertical-align: middle; }
tr:hover td { background: var(--monash-light-blue); }
.badge { display: inline-block; padding: 2px 8px; border-radius: 12px; font-size: 12px; font-weight: 600; }
.badge-success { background: #d4edda; color: #155724; }
.badge-danger { background: #f8d7da; color: #721c24; }
.badge-warning { background: #fff3cd; color: #856404; }
.badge-info { background: var(--monash-light-blue); color: var(--monash-blue); }

/* ===== FORMS ===== */
.form-group { margin-bottom: 16px; }
.form-label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 5px; color: #444; }
.form-control {
  width: 100%; padding: 8px 12px; border: 1.5px solid #ccc; border-radius: 5px;
  font-size: 14px; font-family: inherit; transition: border-color .15s;
}
.form-control:focus { outline: none; border-color: var(--monash-blue); box-shadow: 0 0 0 2px rgba(0,109,174,.15); }
select.form-control { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M0 0l6 8 6-8z' fill='%23666'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; padding-right: 30px; }
textarea.form-control { resize: vertical; min-height: 80px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-hint { font-size: 12px; color: var(--text-muted); margin-top: 3px; }

/* ===== ALERTS ===== */
.alert { padding: 12px 16px; border-radius: 6px; margin-bottom: 16px; font-size: 14px; }
.alert-info { background: var(--monash-light-blue); border: 1px solid var(--monash-border); color: var(--monash-blue); }
.alert-success { background: #d4edda; border: 1px solid #c3e6cb; color: #155724; }
.alert-warning { background: #fff3cd; border: 1px solid #ffeeba; color: #856404; }
.alert-danger { background: #f8d7da; border: 1px solid #f5c6cb; color: #721c24; }

/* ===== MODAL ===== */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 2000;
  display: none; align-items: center; justify-content: center; padding: 20px;
}
.modal-overlay.active { display: flex; }
.modal {
  background: #fff; border-radius: 10px; max-width: 600px; width: 100%;
  max-height: 90vh; overflow-y: auto; box-shadow: 0 8px 32px rgba(0,0,0,.2);
}
.modal-header { padding: 18px 20px; border-bottom: 1px solid #eee; display: flex; justify-content: space-between; align-items: center; }
.modal-title { font-size: 17px; font-weight: 700; color: var(--monash-blue); }
.modal-close { background: none; border: none; font-size: 22px; cursor: pointer; color: #999; line-height: 1; }
.modal-body { padding: 20px; }
.modal-footer { padding: 14px 20px; border-top: 1px solid #eee; display: flex; gap: 8px; justify-content: flex-end; }

/* ===== TABS ===== */
.tabs { display: flex; border-bottom: 2px solid #ddd; margin-bottom: 20px; gap: 0; }
.tab-btn { padding: 10px 20px; background: none; border: none; border-bottom: 3px solid transparent; cursor: pointer; font-size: 14px; font-weight: 600; color: var(--text-muted); margin-bottom: -2px; transition: all .15s; }
.tab-btn:hover { color: var(--monash-blue); }
.tab-btn.active { color: var(--monash-blue); border-bottom-color: var(--monash-blue); }
.tab-content { display: none; }
.tab-content.active { display: block; }

/* ===== ANALYTICS CHARTS ===== */
.chart-container { position: relative; width: 100%; }
.chart-row { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-bottom: 20px; }
.topic-bar { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; font-size: 13px; }
.topic-bar-label { min-width: 160px; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topic-bar-track { flex: 1; height: 14px; background: #eee; border-radius: 7px; overflow: hidden; }
.topic-bar-fill { height: 100%; border-radius: 7px; transition: width .4s; }
.topic-bar-pct { min-width: 40px; text-align: right; font-weight: 600; }

/* ===== SESSION HISTORY ===== */
.session-row { cursor: pointer; }
.session-row:hover td { background: var(--monash-light-blue); }
.score-circle {
  width: 48px; height: 48px; border-radius: 50%; display: inline-flex;
  align-items: center; justify-content: center; font-weight: 800; font-size: 13px;
}

/* ===== IMPORT ZONE ===== */
.drop-zone {
  border: 2px dashed #ccc; border-radius: 8px; padding: 32px 20px;
  text-align: center; color: var(--text-muted); cursor: pointer; transition: all .2s;
}
.drop-zone:hover, .drop-zone.dragover { border-color: var(--monash-blue); background: var(--monash-light-blue); color: var(--monash-blue); }
.drop-zone-icon { font-size: 36px; margin-bottom: 8px; }

/* ===== MISC ===== */
.divider { border: none; border-top: 1px solid #eee; margin: 20px 0; }
.text-center { text-align: center; }
.text-muted { color: var(--text-muted); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-blue { color: var(--monash-blue); }
.fw-bold { font-weight: 700; }
.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.mb-3 { margin-bottom: 24px; }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.d-flex { display: flex; }
.align-center { align-items: center; }
.gap-1 { gap: 8px; }
.gap-2 { gap: 16px; }
.flex-1 { flex: 1; }
.hidden { display: none !important; }
.loading { opacity: .5; pointer-events: none; }
.page-title { font-size: 22px; font-weight: 800; color: var(--monash-blue); margin-bottom: 4px; }
.page-subtitle { color: var(--text-muted); font-size: 14px; margin-bottom: 24px; }
.empty-state { text-align: center; padding: 48px 20px; color: var(--text-muted); }
.empty-state-icon { font-size: 48px; margin-bottom: 12px; }
.empty-state h3 { font-size: 18px; margin-bottom: 8px; color: #555; }

/* ===== SUMMARY PAGE ===== */
.summary-score {
  text-align: center; padding: 32px 20px;
  background: linear-gradient(135deg, var(--monash-blue), #0090e0);
  color: #fff; border-radius: 12px; margin-bottom: 24px;
}
.summary-score .big-score { font-size: 72px; font-weight: 900; line-height: 1; }
.summary-score .score-label { font-size: 16px; opacity: .85; margin-top: 4px; }
.summary-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin: 20px 0; }
.summary-stat { background: rgba(255,255,255,.15); border-radius: 8px; padding: 14px; text-align: center; }
.summary-stat .val { font-size: 24px; font-weight: 800; }
.summary-stat .lbl { font-size: 12px; opacity: .8; margin-top: 2px; }

/* ===== HIGHLIGHTER TOOLBAR ===== */
.hl-toolbar {
  display: flex; align-items: center; gap: 4px; margin-bottom: 14px;
}
.hl-btn {
  width: 28px; height: 28px; border-radius: 4px; border: 2px solid transparent;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  font-size: 13px; background: #f0f0f0; transition: all .15s; flex-shrink: 0;
}
.hl-btn.active { border-color: #333; transform: scale(1.15); box-shadow: 0 1px 4px rgba(0,0,0,.2); }
.hl-btn.hl-pink   { background: #ffb3c1; }
.hl-btn.hl-orange { background: #ffd09b; }
.hl-btn.hl-yellow { background: #fff176; }
.hl-btn.hl-green  { background: #b9f6ca; }
.hl-btn.hl-blue   { background: #b3e5fc; }
.hl-btn.hl-eraser { background: #e0e0e0; color: #555; font-size: 14px; }
.hl-btn.hl-eraser.active { border-color: #555; }

/* Highlight mark colours */
mark.hl-pink   { background: #ffb3c1; color: inherit; }
mark.hl-orange { background: #ffd09b; color: inherit; }
mark.hl-yellow { background: #fff176; color: inherit; }
mark.hl-green  { background: #b9f6ca; color: inherit; }
mark.hl-blue   { background: #b3e5fc; color: inherit; }

/* ===== QUESTION LAYOUT ===== */
.q-divider {
  border: none; border-top: 2px dashed #ccc; margin: 18px 0;
}
.answer-section { margin-bottom: 12px; }
.question-footer {
  display: flex; align-items: center; justify-content: space-between;
  margin-top: 16px; padding-top: 12px; border-top: 1px solid #f0f0f0; flex-wrap: wrap; gap: 8px;
}
.btn-link-sm {
  background: none; border: none; cursor: pointer; font-size: 12px;
  color: var(--text-muted); padding: 4px 6px; border-radius: 4px; transition: all .15s;
}
.btn-link-sm:hover { background: #f0f0f0; color: var(--text); }

/* ===== NOTES ===== */
.question-notes-wrap {
  margin-top: 12px; background: #fefde7; border: 1px solid #f0e68c;
  border-radius: 6px; padding: 14px;
}
.notes-title {
  font-weight: 700; font-size: 14px; color: #8b7700; margin-bottom: 8px; text-align: center;
}
.notes-ta {
  width: 100%; min-height: 120px; border: 1px solid #e8d44d; border-radius: 4px;
  padding: 8px 10px; font-size: 14px; font-family: inherit; resize: vertical;
  background: #fffff0; line-height: 1.5;
}
.notes-ta:focus { outline: none; border-color: #b8a000; box-shadow: 0 0 0 2px rgba(184,160,0,.15); }

/* ===== SECURITY BANNER ===== */
.security-banner {
  position: fixed; top: var(--nav-height); left: 0; right: 0; z-index: 1500;
  background: #dc3545; color: #fff; padding: 10px 20px; font-size: 14px;
  font-weight: 600; display: flex; align-items: center; justify-content: center; gap: 8px;
  box-shadow: 0 2px 8px rgba(220,53,69,.4);
}

/* ===== RESUME BANNER ===== */
.resume-banner {
  background: #fff3cd; border: 1.5px solid #ffc107; border-radius: 8px;
  padding: 14px 18px; margin-bottom: 20px; display: flex; align-items: center;
  justify-content: space-between; gap: 12px; flex-wrap: wrap;
}
.resume-banner-text { font-size: 14px; color: #856404; font-weight: 600; }
.resume-banner-sub  { font-size: 12px; color: #856404; font-weight: 400; margin-top: 2px; }

/* ===== FLEX HELPERS ===== */
.flex-wrap { flex-wrap: wrap; }

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
  .exam-sidebar { display: none; }
  .chart-row { grid-template-columns: 1fr; }
  .form-row { grid-template-columns: 1fr; }
  .summary-grid { grid-template-columns: 1fr 1fr; }
  .dash-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 480px) {
  .dash-grid { grid-template-columns: 1fr; }
  .summary-grid { grid-template-columns: 1fr; }
}

/* ===== PRINT ===== */
@media print {
  .navbar, .exam-sidebar, .attempt-nav, .btn { display: none !important; }
  .exam-main { padding: 0; }
  .question-block { break-inside: avoid; border: 1px solid #ccc; }
}
