body {
  font-family: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
}

.exam-locked {
  user-select: none;
  -webkit-user-select: none;
  position: relative;
}

.exam-watermark {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 10;
  opacity: 0.045;
  display: flex;
  flex-wrap: wrap;
  align-content: space-around;
  justify-content: space-around;
  overflow: hidden;
  font-size: 0.9rem;
  font-weight: 800;
  transform: rotate(-22deg) scale(1.2);
}

.q-nav-btn {
  width: 2.35rem;
  height: 2.35rem;
  border-radius: 0.5rem;
  font-size: 0.75rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  position: relative;
  transition: all 0.15s ease;
  border: 1px solid rgba(148, 163, 184, 0.3);
}

.q-nav-btn.is-active {
  outline: 2px solid #f59e0b;
  outline-offset: 2px;
}

.q-nav-btn.is-answered {
  background-color: #10b981;
  color: #ffffff;
  border-color: #059669;
}

.q-nav-btn.is-flagged::after {
  content: '';
  position: absolute;
  top: -3px;
  right: -3px;
  width: 10px;
  height: 10px;
  border-radius: 9999px;
  background-color: #f59e0b;
  border: 2px solid #0b0f19;
}

.prose-q p { margin-bottom: 0.5rem; }
.prose-q ul { list-style-type: disc; padding-left: 1.5rem; margin: 0.35rem 0; }
.prose-q ol { list-style-type: decimal; padding-left: 1.5rem; margin: 0.35rem 0; }
.prose-q li { margin: 0.15rem 0; }
.prose-q table {
  width: 100%;
  border-collapse: collapse;
  margin: 0.75rem 0;
  font-size: 0.85rem;
}
.prose-q th, .prose-q td {
  border: 1px solid rgba(148, 163, 184, 0.45);
  padding: 0.4rem 0.6rem;
}
.prose-q img {
  max-width: 100%;
  border-radius: 0.5rem;
  margin: 0.5rem 0;
}
html:not(.dark) .prose-q {
  color: #1e293b;
}
html:not(.dark) .prose-q [style*="color: white"],
html:not(.dark) .prose-q [style*="color:white"],
html:not(.dark) .prose-q [style*="color: #fff"],
html:not(.dark) .prose-q [style*="color:#fff"],
html:not(.dark) .prose-q [style*="color: rgb(255, 255, 255)"],
html:not(.dark) .prose-q [style*="color:rgb(255,255,255)"],
html:not(.dark) .prose-q [style*="color: #e2e8f0"],
html:not(.dark) .prose-q [style*="color: #f8fafc"],
html:not(.dark) .prose-q font[color="white"],
html:not(.dark) .prose-q font[color="#ffffff"] {
  color: #1e293b !important;
}
html.dark .prose-q {
  color: #e2e8f0;
}
html.dark .prose-q [style*="background"] {
  background-color: transparent !important;
}
html.dark .prose-q [style*="color: black"],
html.dark .prose-q [style*="color:black"],
html.dark .prose-q [style*="color: #000"],
html.dark .prose-q [style*="color:#000"],
html.dark .prose-q [style*="color: rgb(0, 0, 0)"],
html.dark .prose-q [style*="color:rgb(0,0,0)"],
html.dark .prose-q [style*="color: rgb(15, 23, 42)"],
html.dark .prose-q [style*="color: #0f172a"],
html.dark .prose-q [style*="color:#0f172a"],
html.dark .prose-q [style*="color: windowtext"],
html.dark .prose-q font[color="black"],
html.dark .prose-q font[color="#000"],
html.dark .prose-q font[color="#000000"] {
  color: #e2e8f0 !important;
}

@media print {
  body { background: #ffffff !important; color: #000000 !important; }
  .no-print { display: none !important; }
  .print-sheet {
    border: none !important;
    background: #ffffff !important;
    color: #000000 !important;
    padding: 0 !important;
    box-shadow: none !important;
  }
  .print-sheet table, .print-sheet th, .print-sheet td {
    border: 1px solid #000000 !important;
    color: #000000 !important;
  }
}

.no-scrollbar::-webkit-scrollbar { display: none; }
.no-scrollbar { -ms-overflow-style: none; scrollbar-width: none; }

@page {
  size: A4 portrait;
  margin: 8mm 10mm;
}
#print-area-sheet {
  width: 190mm;
  box-sizing: border-box;
  page-break-inside: avoid;
}
#print-area-sheet table th,
#print-area-sheet table td {
  padding: 2.5px 5px !important;
  font-size: 9.5px !important;
  line-height: 1.22 !important;
}
@media print {
  #print-area-sheet {
    width: 100% !important;
    padding: 0 !important;
    margin: 0 !important;
  }
}


/* Web Lockdown Mode (Safari / Chrome) */
body.exam-lockdown {
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}
body.exam-lockdown input,
body.exam-lockdown textarea {
  -webkit-user-select: text;
  user-select: text;
}


/* datetime-local-amber: high-contrast orange picker icon */
html.dark input[type="datetime-local"] {
  color-scheme: dark;
}
input[type="datetime-local"]::-webkit-calendar-picker-indicator {
  filter: invert(72%) sepia(92%) saturate(1352%) hue-rotate(359deg) brightness(101%) contrast(97%);
  cursor: pointer;
  opacity: 0.95;
}
.prose-q {
  max-width: 100%;
  overflow-wrap: anywhere;
  word-break: break-word;
}


/* Light Mode Comfort Overrides */
html:not(.dark) body {
  background-color: #f4f1ea;
  color: #1e293b;
}
html:not(.dark) .bg-obsidian-900,
html:not(.dark) .bg-obsidian-900\/90,
html:not(.dark) .bg-obsidian-900\/80,
html:not(.dark) .bg-obsidian-900\/60,
html:not(.dark) .bg-obsidian-900\/50,
html:not(.dark) .bg-obsidian-900\/40,
html:not(.dark) .bg-obsidian-900\/30,
html:not(.dark) .bg-\[\#0f172a\] {
  background-color: #f8f6f1 !important;
  color: #1e293b !important;
}
html:not(.dark) .bg-obsidian-800 {
  background-color: #ffffff !important;
  color: #1e293b !important;
}
html:not(.dark) .border-slate-800,
html:not(.dark) .border-slate-700,
html:not(.dark) .divide-slate-800 > :not([hidden]) ~ :not([hidden]) {
  border-color: #e2ddd3 !important;
}
html:not(.dark) .text-slate-300,
html:not(.dark) .text-slate-200 {
  color: #334155 !important;
}
html:not(.dark) .text-slate-400 {
  color: #64748b !important;
}
html:not(.dark) input,
html:not(.dark) select,
html:not(.dark) textarea {
  color: #0f172a !important;
}
html:not(.dark) input[type="datetime-local"] {
  color-scheme: light;
}

html:not(.dark) .bg-slate-700:not(.text-white),
html:not(.dark) .bg-slate-800:not(.text-white),
html:not(.dark) .bg-slate-900:not(.text-white),
html:not(.dark) .bg-slate-900\/80:not(.text-white) {
  background-color: #ebe6dc !important;
  color: #1e293b !important;
}


/* Mobile-First Responsive Polish & Floating Menu (v2.96) */
html, body {
  max-width: 100%;
  overflow-x: hidden;
}

#staff-content .overflow-x-auto {
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border: 1px solid rgba(148, 163, 184, 0.22);
  border-radius: 0.75rem;
}

@keyframes sidebarFloatIn {
  from { opacity: 0; transform: translateY(-6px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@media (max-width: 767px) {
  html, body, #app-main, #staff-content, #staff-content > div {
    max-width: 100% !important;
    min-width: 0 !important;
  }

  #staff-sidebar:not(.hidden) {
    animation: sidebarFloatIn 0.16s ease-out;
  }

  #staff-content select,
  #staff-content input:not([type="checkbox"]):not([type="radio"]) {
    max-width: 100% !important;
    min-width: 0 !important;
  }

  #staff-content .overflow-x-auto table {
    width: max-content !important;
    min-width: 100% !important;
    border-collapse: collapse;
  }

  #staff-content .overflow-x-auto th,
  #staff-content .overflow-x-auto td {
    white-space: nowrap !important;
    padding: 0.55rem 0.65rem !important;
    font-size: 0.75rem !important;
    vertical-align: middle !important;
  }

  #staff-content td.prose-q {
    white-space: normal !important;
    min-width: 210px !important;
    max-width: 280px !important;
  }

  #staff-content .overflow-x-auto th:first-child,
  #staff-content .overflow-x-auto td:first-child {
    padding-left: 0.75rem !important;
  }

  #staff-content .mobile-sticky-col th:first-child,
  #staff-content .mobile-sticky-col td:first-child {
    position: sticky;
    left: 0;
    z-index: 2;
    background-color: #ffffff;
    box-shadow: 2px 0 6px -2px rgba(15, 23, 42, 0.08);
  }

  html.dark #staff-content .mobile-sticky-col th:first-child,
  html.dark #staff-content .mobile-sticky-col td:first-child {
    background-color: #111827;
    box-shadow: 2px 0 6px -2px rgba(0, 0, 0, 0.4);
  }

  html:not(.dark) #staff-content .mobile-sticky-col thead th:first-child {
    background-color: #f5f5f4;
  }

  html.dark #staff-content .mobile-sticky-col thead th:first-child {
    background-color: #0b0f19;
  }

  .mobile-btn-grid {
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 0.5rem !important;
    width: 100% !important;
  }

  .mobile-btn-grid > button,
  .mobile-btn-grid > a,
  .mobile-btn-grid > label {
    width: 100% !important;
    min-height: 40px !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 0.35rem !important;
    text-align: center !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    padding-left: 0.6rem !important;
    padding-right: 0.6rem !important;
    font-size: 0.72rem !important;
  }

  .mobile-btn-grid > :last-child:nth-child(odd) {
    grid-column: 1 / -1 !important;
  }
}


/* Sleek Emerald-Obsidian Collapsible & Floating Sidebar (v2.97) */
@keyframes sidebarSlideLeft {
  from { opacity: 0; transform: translateX(-16px); }
  to { opacity: 1; transform: translateX(0); }
}

@media (max-width: 767px) {
  #staff-sidebar:not(.hidden) {
    animation: sidebarSlideLeft 0.18s ease-out;
  }
}

@media (min-width: 768px) {
  #staff-sidebar {
    transition: width 0.2s ease;
  }
  #staff-sidebar.is-collapsed {
    width: 68px !important;
    padding-left: 0.65rem !important;
    padding-right: 0.65rem !important;
  }
  #staff-sidebar.is-collapsed .sb-text,
  #staff-sidebar.is-collapsed .sb-user-card {
    display: none !important;
  }
  #staff-sidebar.is-collapsed .sb-brand {
    justify-content: center !important;
    padding-left: 0 !important;
    padding-right: 0 !important;
  }
  #staff-sidebar.is-collapsed .sb-item {
    justify-content: center !important;
    padding-left: 0 !important;
    padding-right: 0 !important;
    width: 40px !important;
    height: 40px !important;
    margin-left: auto !important;
    margin-right: auto !important;
  }
}

@media print {
  body.exam-lockdown { display: none !important; }
}
body.exam-lockdown img {
  pointer-events: none !important;
  -webkit-user-drag: none !important;
  -webkit-touch-callout: none !important;
}

/* Sharp, high-contrast sidebar icons & labels in Light Mode (v2.157) */
html:not(.dark) #staff-sidebar .sb-item {
  color: #1e293b !important;
}
html:not(.dark) #staff-sidebar .sb-item:hover {
  color: #0f172a !important;
}
html:not(.dark) #staff-sidebar .sb-item.bg-amber-500,
html:not(.dark) #staff-sidebar .sb-item.bg-\[\#e5b93c\] {
  color: #0f172a !important;
}
html:not(.dark) #staff-sidebar .sb-brand button {
  color: #475569 !important;
}

/* Dukungan Bahasa Arab Berharakat (RTL) */
.rtl-arab, .prose-q [dir="rtl"], #q-editor [dir="rtl"], .gf-opt-editor [dir="rtl"] {
  direction: rtl !important;
  text-align: right !important;
  font-family: 'Noto Naskh Arabic', 'Amiri', 'Traditional Arabic', serif !important;
  font-size: 1.2em;
  line-height: 2.2;
}
