/* SM-CAT — styling dasar untuk halaman peserta dan pengawas */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --blue:    #1a56db;
  --blue-dk: #1e429f;
  --green:   #057a55;
  --yellow:  #c27803;
  --red:     #c81e1e;
  --gray:    #6b7280;
  --bg:      #f3f4f6;
  --white:   #ffffff;
  --border:  #d1d5db;
  --text:    #111827;
  --radius:  6px;
  --shadow:  0 1px 3px rgba(0,0,0,.12);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 15px;
  color: var(--text);
  background: var(--bg);
  line-height: 1.5;
}
.password-container {
    display: flex;
    align-items: center;
    gap: 8px;
    position: relative;
}

.copy-btn {
    background: #4f46e5;
    color: white;
    border: none;
    padding: 8px 10px;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
}

.copy-btn:hover {
    background: #4338ca;
    transform: scale(1.05);
}

.copy-btn:active {
    transform: scale(0.95);
}

.toast {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: #10b981;
    color: white;
    padding: 12px 20px;
    border-radius: 8px;
    font-size: 14px;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s;
    z-index: 1000;
}

.toast.show {
    opacity: 1;
    visibility: visible;
}
/* ── Layout ── */
.page-center {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 2rem;
  width: 100%;
  max-width: 420px;
}

.card-wide { max-width: 760px; }
.card-full { max-width: 100%; }

.card h1 { font-size: 1.4rem; margin-bottom: 1.2rem; color: var(--blue-dk); }
.card h2 { font-size: 1.1rem; margin-bottom: .8rem; }

/* ── Form ── */
.form-group { margin-bottom: 1rem; }
.form-group label { display: block; font-weight: 600; margin-bottom: .3rem; }
.form-group input,
.form-group textarea,
.form-group select {
  width: 100%;
  padding: .55rem .75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 1rem;
  outline: none;
  transition: border-color .15s;
}
.form-group input:focus,
.form-group textarea:focus { border-color: var(--blue); }

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  padding: .5rem 1.1rem;
  border: none;
  border-radius: var(--radius);
  font-size: .95rem;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s, transform .05s;
  text-decoration: none;
}
.btn:active { transform: scale(.97); }
.btn-primary  { background: var(--blue);  color: #fff; }
.btn-primary:hover  { background: var(--blue-dk); }
.btn-success  { background: var(--green); color: #fff; }
.btn-danger   { background: var(--red);   color: #fff; }
.btn-outline  { background: transparent; border: 1.5px solid var(--border); color: var(--text); }
.btn-outline:hover { background: var(--bg); }
.btn-sm       { padding: .3rem .7rem; font-size: .85rem; }
.btn-block    { width: 100%; justify-content: center; margin-top: .5rem; }

/* ── Alert ── */
.alert {
  padding: .7rem 1rem;
  border-radius: var(--radius);
  margin-bottom: 1rem;
  font-size: .93rem;
}
.alert-danger  { background: #fef2f2; border-left: 4px solid var(--red);   color: #7f1d1d; }
.alert-success { background: #f0fdf4; border-left: 4px solid var(--green); color: #14532d; }
.alert-info    { background: #eff6ff; border-left: 4px solid var(--blue);  color: #1e3a8a; }

/* ── Navbar ── */
.navbar {
  background: var(--blue-dk);
  color: #fff;
  padding: .6rem 1.2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.navbar-brand { font-weight: 700; font-size: 1.1rem; letter-spacing: .02em; }
.navbar-right { display: flex; align-items: center; gap: .8rem; }
.navbar a, .navbar button { color: #fff; text-decoration: none; background: none; border: none; cursor: pointer; font-size: .9rem; }
.navbar a:hover { text-decoration: underline; }

/* ── Timer ── */
.timer-box {
  background: var(--blue-dk);
  color: #fff;
  border-radius: var(--radius);
  padding: .35rem .9rem;
  font-size: 1.2rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: .05em;
}
.timer-box.warning { background: var(--yellow); color: #fff; }
.timer-box.danger  { background: var(--red);    color: #fff; animation: pulse 1s infinite; }

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: .7; }
}

/* ── Exam layout ── */
.exam-layout {
  display: grid;
  grid-template-rows: auto 1fr;
  grid-template-columns: 1fr 220px;
  grid-template-areas:
    "header header"
    "main   sidebar";
  height: 100vh;          /* kunci ke tinggi layar agar area dalam bisa scroll */
}

.exam-header {
  grid-area: header;
  background: var(--blue-dk);
  color: #fff;
  padding: .6rem 1.2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.exam-main {
  grid-area: main;
  padding: 1.2rem;
  overflow-y: auto;
  min-height: 0;          /* izinkan scroll di dalam track grid 1fr */
}

.exam-sidebar {
  grid-area: sidebar;
  background: var(--white);
  border-left: 1px solid var(--border);
  padding: .8rem;
  display: flex;
  flex-direction: column;
  min-height: 0;          /* grid nomor di dalamnya yang scroll, bukan halaman */
  overflow: hidden;
}

/* ── Soal card ── */
.soal-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.2rem;
  margin-bottom: 1rem;
}

.soal-nomor { font-weight: 700; color: var(--gray); margin-bottom: .5rem; }
.soal-teks  { margin-bottom: 1rem; line-height: 1.7; }
.soal-teks img { max-width: 100%; height: auto; border-radius: 4px; }

/* ── Pilihan jawaban ── */
.choices-list { list-style: none; display: flex; flex-direction: column; gap: .5rem; }
.choice-item {
  display: flex;
  align-items: flex-start;
  gap: .6rem;
  padding: .6rem .8rem;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: border-color .12s, background .12s;
  background: var(--white);
}
.choice-item:hover { border-color: var(--blue); background: #eff6ff; }
.choice-item.selected { border-color: var(--blue); background: #dbeafe; }
.choice-letter {
  font-weight: 700;
  min-width: 1.4rem;
  text-align: center;
  background: var(--border);
  border-radius: 3px;
  padding: .1rem .35rem;
}
.choice-item.selected .choice-letter { background: var(--blue); color: #fff; }

/* ── Navigasi soal (sidebar grid) ── */
.nav-soal-title { font-weight: 600; font-size: .85rem; color: var(--gray); margin-bottom: .6rem; }
.nav-soal-grid  {
  display: flex;
  flex-wrap: wrap;
  gap: .35rem;
  flex: 1 1 auto;         /* ambil sisa tinggi sidebar */
  min-height: 0;
  overflow-y: auto;       /* scroll nomor soal saat jumlahnya banyak */
  align-content: flex-start;
  padding-right: .25rem;  /* ruang untuk scrollbar */
}
.nav-btn {
  width: 36px; height: 36px;
  border-radius: 4px;
  border: 1.5px solid var(--border);
  background: var(--white);
  font-size: .82rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text);
  transition: background .1s, border-color .1s;
}
.nav-btn:hover        { border-color: var(--blue); color: var(--blue); }
.nav-btn.answered     { background: var(--green);  border-color: var(--green);  color: #fff; }
.nav-btn.marked       { background: var(--yellow); border-color: var(--yellow); color: #fff; }
.nav-btn.current      { border-color: var(--blue); box-shadow: 0 0 0 2px #93c5fd; }
.nav-btn.answered.current { box-shadow: 0 0 0 2px #6ee7b7; }

.nav-legend { margin-top: .6rem; font-size: .78rem; color: var(--gray); display: flex; flex-direction: column; gap: .2rem; }
.nav-legend span { display: inline-flex; align-items: center; gap: .3rem; }
.dot { width: 10px; height: 10px; border-radius: 2px; display: inline-block; }
.dot-answered { background: var(--green); }
.dot-marked   { background: var(--yellow); }
.dot-empty    { background: var(--border); }

/* ── Nav prev/next ── */
.soal-nav-actions {
  display: flex;
  gap: .5rem;
  margin-top: 1rem;
  align-items: center;
  flex-wrap: wrap;
}

/* ── Mark button ── */
#mark-label { font-size: .9rem; color: var(--yellow); font-weight: 600; }

/* ── Save status ── */
.save-ok  { color: var(--green); font-size: .85rem; }
.save-err { color: var(--red);   font-size: .85rem; }

/* ── Badge ── */
.badge {
  display: inline-block;
  padding: .2rem .55rem;
  border-radius: 99px;
  font-size: .78rem;
  font-weight: 600;
}
.badge-hadir      { background: #d1fae5; color: var(--green); }
.badge-tidak-hadir { background: #fee2e2; color: var(--red); }

/* ── Table ── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th, td { padding: .5rem .7rem; text-align: left; border-bottom: 1px solid var(--border); }
th { background: #f9fafb; font-weight: 600; color: var(--gray); }
tr:hover td { background: #f9fafb; }

/* ── Token display ── */
.token-display {
  font-size: 3rem;
  font-weight: 900;
  letter-spacing: .4em;
  color: var(--blue-dk);
  text-align: center;
  padding: 1.5rem;
  background: #eff6ff;
  border-radius: var(--radius);
  border: 2px dashed var(--blue);
  margin: 1rem 0;
}

/* ── Recap ── */
.recap-score {
  font-size: 3.5rem;
  font-weight: 900;
  color: var(--blue-dk);
  text-align: center;
  margin: 1rem 0 .3rem;
}
.recap-label { text-align: center; color: var(--gray); margin-bottom: 1.2rem; }
.recap-sections { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: .7rem; margin-top: 1rem; }
.recap-section-card {
  background: #f9fafb;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .8rem 1rem;
}
.recap-section-name { font-weight: 600; font-size: .9rem; color: var(--gray); }
.recap-section-val  { font-size: 1.4rem; font-weight: 700; color: var(--blue-dk); }

/* ── Info rows ── */
.info-row { display: flex; justify-content: space-between; padding: .35rem 0; border-bottom: 1px solid var(--border); font-size: .92rem; }
.info-row:last-child { border-bottom: none; }
.info-label { color: var(--gray); }
.info-value { font-weight: 600; }

/* ── Profile verification card ── */
.profile-header {
  display: flex;
  flex-direction: column; /* foto di atas */
  align-items: center;   /* center horizontal */
  text-align: center;
  gap: 12px;
}

.profile-photo {
  width: 410px;
  height: 410px;
  background: #e5e7eb;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;

  border: 3px solid #fff;
  box-shadow: 0 0 0 1px var(--border);
}

.profile-photo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.profile-name {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--blue-dk);
  margin: 0 0 .15rem;
}
.profile-no-ujian {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: .85rem;
  color: var(--gray);
  background: #f1f5f9;
  padding: .15rem .5rem;
  border-radius: 4px;
  display: inline-block;
}
.profile-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: .65rem 1.25rem;
  margin: 1rem 0;
}
.profile-grid__item {
  display: flex;
  flex-direction: column;
  font-size: .9rem;
}
.profile-grid__label {
  font-size: .72rem;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--gray);
  margin-bottom: .1rem;
}
.profile-grid__value {
  font-weight: 600;
  color: var(--text);
}
.profile-confirm {
  display: flex;
  gap: .5rem;
  align-items: center;
  padding: .65rem .9rem;
  background: #fffbeb;
  border-left: 3px solid var(--orange, #f59e0b);
  border-radius: 6px;
  font-size: .88rem;
  margin-bottom: 1.2rem;
}
.profile-confirm strong { color: #92400e; }

/* ── HTMX loading indicator ── */
.htmx-indicator { display: none; }
.htmx-request .htmx-indicator { display: inline; }

@media (max-width: 640px) {
  /* Di layar kecil: tumpuk vertikal & biarkan halaman scroll normal,
     bukan terkunci 100vh seperti di desktop. */
  html, body { overflow: auto !important; }
  .exam-layout {
    grid-template-columns: 1fr;
    grid-template-areas: "header" "main" "sidebar";
    height: auto;
    min-height: 100vh;
  }
  .exam-main { overflow: visible; min-height: 0; }
  .exam-sidebar {
    border-left: none;
    border-top: 1px solid var(--border);
    overflow: visible;
  }
  .nav-soal-grid { overflow: visible; flex: 0 0 auto; }
}

/* ── Pengawas dashboard: sidebar navigasi ── */
.pengawas-shell {
  display: grid;
  grid-template-columns: 240px 1fr;
  align-items: start;
  min-height: 100vh;
}

.pengawas-sidebar {
  background: var(--blue-dk);
  color: #fff;
  padding: 1.1rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  min-height: 100vh;
  position: sticky;
  top: 0;
}
.pengawas-sidebar .sidebar-brand {
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: .02em;
  padding-bottom: .8rem;
  border-bottom: 1px solid rgba(255, 255, 255, .2);
}
.pengawas-sidebar .sidebar-profile {
  display: flex;
  flex-direction: column;
  gap: .25rem;
  font-size: .85rem;
  line-height: 1.4;
}
.pengawas-sidebar .sidebar-profile .profile-label {
  font-size: .72rem;
  text-transform: uppercase;
  letter-spacing: .04em;
  opacity: .65;
}
.pengawas-sidebar .sidebar-profile .profile-value {
  font-weight: 600;
  word-break: break-word;
}
.pengawas-sidebar .sidebar-menu {
  display: flex;
  flex-direction: column;
  gap: .35rem;
  margin-top: .5rem;
}
.pengawas-sidebar .sidebar-menu a,
.pengawas-sidebar .sidebar-menu button {
  display: block;
  width: 100%;
  text-align: left;
  color: #fff;
  text-decoration: none;
  background: none;
  border: none;
  cursor: pointer;
  font: inherit;
  font-size: .92rem;
  padding: .55rem .7rem;
  border-radius: var(--radius);
}
.pengawas-sidebar .sidebar-menu a:hover,
.pengawas-sidebar .sidebar-menu button:hover {
  background: rgba(255, 255, 255, .12);
}
.pengawas-sidebar .sidebar-menu a.active {
  background: rgba(255, 255, 255, .18);
  font-weight: 600;
}

.pengawas-main {
  padding: 1.5rem 1rem;
  min-width: 0;
}

@media (max-width: 768px) {
  .pengawas-shell {
    grid-template-columns: 1fr;
  }
  .pengawas-sidebar {
    min-height: auto;
    position: static;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    gap: .6rem 1.2rem;
  }
  .pengawas-sidebar .sidebar-brand { width: 100%; padding-bottom: .5rem; }
  .pengawas-sidebar .sidebar-menu { flex-direction: row; margin-top: 0; }
}

/* ── Daftar hadir: nama peserta dapat diklik untuk lihat foto ── */
.peserta-foto-link {
  color: var(--text);
  text-decoration: none;
  font-weight: 600;
  cursor: pointer;
}
.peserta-foto-link:hover { color: var(--blue); text-decoration: underline; }

.foto-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.foto-modal[hidden] { display: none; }
.foto-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, .55);
}
.foto-modal-box {
  position: relative;
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: 0 10px 30px rgba(0, 0, 0, .3);
  padding: 1.1rem;
  max-width: 360px;
  width: 100%;
  text-align: center;
}
.foto-modal-close {
  position: absolute;
  top: .4rem;
  right: .6rem;
  background: none;
  border: none;
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  color: var(--gray);
}
.foto-modal-close:hover { color: var(--text); }
.foto-modal-nama {
  font-weight: 700;
  margin-bottom: .75rem;
  color: var(--blue-dk);
}
.foto-modal-body img {
  max-width: 100%;
  max-height: 60vh;
  border-radius: var(--radius);
  border: 1px solid var(--border);
}
.foto-modal-empty { color: var(--gray); margin: 1.5rem 0; }
