
/* ===== PROFESSIONAL ENTERPRISE TYPOGRAPHY & REFINED SHARP RADIUS ===== */
* {
  font-family: 'Outfit', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

h1, h2, h3, h4, .font-heading {
  font-family: 'Plus Jakarta Sans', 'Outfit', sans-serif;
}

/* Triệt tiêu hoàn toàn góc bo tròn trẻ con, đưa về chuẩn doanh nghiệp sắc nét (Sharp Enterprise) */
[class*="rounded-3xl"],
[class*="rounded-2xl"],
[class*="rounded-xl"],
[class*="rounded-lg"],
.rounded-3xl,
.rounded-2xl,
.rounded-xl,
.rounded-lg {
  border-radius: 4px !important;
}

[class*="rounded-md"],
.rounded-md {
  border-radius: 3px !important;
}

button, input, select, textarea, .card, .modal-box {
  border-radius: 4px !important;
}

img.rounded-full, .avatar-circle, .status-dot {
  border-radius: 9999px !important;
}

.rounded-full:not(img):not(.avatar-circle):not(.status-dot):not([class*="w-"]):not([class*="h-"]) {
  border-radius: 4px !important;
}

/* ===== Google Font Import ===== */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800;900&display=swap');

/* ===================================================================
   SYSTEM BRANDING & DYNAMIC THEME VARIABLES (EMERALD + MINT + CREAM)
   =================================================================== */
:root {
  /* Emerald + Slate Modern Light Palette */
  --bg-color:       #F8FAFC;
  --card-bg:        #FFFFFF;
  --card-subtle:    #F1F5F9;
  --border-color:   #E2E8F0;
  --border-subtle:  #CBD5E1;

  --emerald-deep:   #065F46;
  --emerald-mid:    #059669;
  --emerald-light:  #34d399;
  --mint-light:     #A7F3D0;
  --mint-pale:      #ECFDF5;
  --cream:          #F8FAFC;
  --cream-warm:     #F1F5F9;
  --text-dark:      #0F172A;
  --text-muted:     #64748B;
  --text-on-emerald:#FFFFFF;

  /* Theme mappings for existing classes */
  --primary-color:  #065F46;
  --primary-hover:  #044E3A;
  --primary-light:  #ECFDF5;
  --primary-text:   #ffffff;
  --secondary-color:#059669;
  --accent-color:   #f59e0b;
  --success-color:  #059669;
  --danger-color:   #ef4444;

  /* Spacing & Radius */
  --radius-card:    12px;
  --radius-modal:   20px;
  --radius-btn:     10px;
  --touch-target:   44px;    /* WCAG minimum touch area */
  --bottom-nav-h:   64px;    /* Height of mobile bottom nav */
}

/* ===================================================================
   DARK MODE OVERRIDES (#0F172A, #1E293B, #334155)
   =================================================================== */
html.dark, body.dark {
  --bg-color:       #0F172A;
  --card-bg:        #1E293B;
  --card-subtle:    #334155;
  --border-color:   #334155;
  --border-subtle:  #475569;
  --cream:          #0F172A;
  --cream-warm:     #1E293B;
  --mint-pale:      #064e3b;
  --mint-light:     #047857;
  --text-dark:      #F8FAFC;
  --text-muted:     #94A3B8;
  --primary-light:  #064e3b;
}

@media (prefers-color-scheme: dark) {
  :root:not(.light) {
    --bg-color:       #0F172A;
    --card-bg:        #1E293B;
    --card-subtle:    #334155;
    --border-color:   #334155;
    --border-subtle:  #475569;
    --cream:          #0F172A;
    --cream-warm:     #1E293B;
    --mint-pale:      #064e3b;
    --mint-light:     #047857;
    --text-dark:      #F8FAFC;
    --text-muted:     #94A3B8;
    --primary-light:  #064e3b;
  }
}

/* ===== Base Typography & Color Apply ===== */
body {
  font-family: 'Outfit', sans-serif;
  background-color: var(--bg-color);
  color: var(--text-dark);
  min-height: 100vh;
  transition: background-color 0.2s ease, color 0.2s ease;
}

/* Dark Mode Components Adaptation */
html.dark body, body.dark {
  background-color: #0F172A !important;
  color: #F8FAFC !important;
}

html.dark header {
  background-color: #1E293B !important;
  border-color: #334155 !important;
}

html.dark footer {
  background-color: #1E293B !important;
  border-color: #334155 !important;
  color: #94A3B8 !important;
}

html.dark .bg-white {
  background-color: #1E293B !important;
  color: #F8FAFC !important;
}

html.dark .text-gray-900, html.dark .text-gray-800, html.dark .text-slate-800, html.dark .text-slate-900 {
  color: #F8FAFC !important;
}

html.dark .text-gray-700, html.dark .text-slate-700 {
  color: #E2E8F0 !important;
}

html.dark .text-gray-600, html.dark .text-slate-600, html.dark .text-gray-500, html.dark .text-slate-500 {
  color: #94A3B8 !important;
}

html.dark .border-slate-200, html.dark .border-gray-200, html.dark .border-gray-100 {
  border-color: #334155 !important;
}

html.dark .bg-gray-50, html.dark .bg-slate-50 {
  background-color: #0F172A !important;
}

html.dark .bg-gray-100, html.dark .bg-slate-100 {
  background-color: #334155 !important;
  color: #F8FAFC !important;
}

html.dark .hover\:bg-gray-100:hover, html.dark .hover\:bg-slate-100:hover {
  background-color: #334155 !important;
}

html.dark .soft-card, html.dark .hub-card, html.dark .editor-question-card {
  background-color: #1E293B !important;
  border-color: #334155 !important;
  color: #F8FAFC !important;
}

html.dark .choice-card {
  background-color: #1E293B !important;
  border-color: #334155 !important;
  color: #F8FAFC !important;
}

html.dark input, html.dark textarea, html.dark select {
  background-color: #0F172A !important;
  color: #F8FAFC !important;
  border-color: #334155 !important;
}

h1, h2, h3, h4, h5, h6, .font-heading {
  font-family: 'Plus Jakarta Sans', sans-serif;
}

/* Custom Primary Color classes to support dynamic theme picker */
.bg-theme {
  background-color: var(--primary-color) !important;
  color: var(--primary-text) !important;
}

.bg-theme-light {
  background-color: var(--primary-light) !important;
}

.text-theme {
  color: var(--primary-color) !important;
}

.border-theme {
  border-color: var(--primary-color) !important;
}

.hover-bg-theme:hover {
  background-color: var(--primary-hover) !important;
}

/* ===== Avoid Mobile Bottom Nav Collision ===== */
body.has-bottom-nav main,
body.has-bottom-nav #mainContent,
body.has-bottom-nav #app-root,
body.has-bottom-nav .content-wrap {
  padding-bottom: calc(var(--bottom-nav-h) + 20px) !important;
}

/* ===== Soft Card ===== */
.soft-card {
  background: white;
  border: 2px solid var(--mint-light);
  border-radius: var(--radius-card);
  padding: 16px;
  transition: box-shadow 0.2s, border-color 0.2s, transform 0.2s;
}
.soft-card:hover {
  border-color: var(--emerald-mid);
  box-shadow: 0 4px 16px rgba(6, 95, 70, 0.12);
}

/* ===== Touch Target ===== */
.touch-btn {
  min-height: var(--touch-target);
  min-width: var(--touch-target);
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ===== Horizontal Scrollable Tabs ===== */
.tabs-scroll {
  display: flex;
  overflow-x: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
  gap: 8px;
  padding-bottom: 4px;
}
.tabs-scroll::-webkit-scrollbar { display: none; }
.tab-btn {
  white-space: nowrap;
  padding: 8px 16px;
  border-radius: 20px;
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 0.875rem;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: all 0.2s;
  background: var(--mint-pale);
  color: var(--emerald-deep);
}
.tab-btn:hover {
  background: var(--mint-light);
}
.tab-btn.active {
  background: var(--emerald-deep);
  color: white;
  box-shadow: 0 2px 8px rgba(6, 95, 70, 0.25);
}

/* ===== Bottom Navigation Bar ===== */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: var(--bottom-nav-h);
  background: white;
  border-top: 1.5px solid var(--mint-light);
  display: flex;
  align-items: stretch;
  z-index: 100;
  box-shadow: 0 -2px 16px rgba(6, 95, 70, 0.08);
}
.bottom-nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 0.65rem;
  font-family: 'Outfit', sans-serif;
  font-weight: 500;
  transition: color 0.2s;
  min-height: var(--touch-target);
  border: none;
  background: transparent;
}
.bottom-nav-item i { font-size: 1.25rem; }
.bottom-nav-item.active {
  color: var(--emerald-deep);
  font-weight: 700;
}
.bottom-nav-item.active i {
  background: var(--mint-pale);
  padding: 4px 14px;
  border-radius: 16px;
  color: var(--emerald-deep);
}

/* Desktop: An bottom nav */
@media (min-width: 768px) {
  .bottom-nav { display: none !important; }
  body.has-bottom-nav main,
  body.has-bottom-nav #mainContent,
  body.has-bottom-nav #app-root {
    padding-bottom: 0 !important;
  }
}

/* ===== Adaptive Modal ===== */
@media (max-width: 767px) {
  .modal-large .modal-content,
  .modal-large > div:not(.modal-backdrop) {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    margin: 0;
    border-radius: var(--radius-modal) var(--radius-modal) 0 0;
    max-height: 90vh;
    overflow-y: auto;
    animation: slideUp 0.3s ease-out;
  }
  @keyframes slideUp {
    from { transform: translateY(100%); }
    to   { transform: translateY(0); }
  }
}
.modal-small .modal-content {
  border-radius: var(--radius-modal);
}

/* ===== Responsive Table → Card on Mobile ===== */
@media (max-width: 767px) {
  .responsive-table thead { display: none !important; }
  .responsive-table tr {
    display: block;
    background: white;
    border: 2px solid var(--mint-light);
    border-radius: var(--radius-card);
    margin-bottom: 12px;
    padding: 12px;
    box-shadow: 0 2px 8px rgba(6, 95, 70, 0.04);
  }
  .responsive-table td {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 0;
    border: none;
    font-size: 0.875rem;
    text-align: right;
  }
  .responsive-table td::before {
    content: attr(data-label);
    font-weight: 600;
    color: var(--text-muted);
    font-size: 0.75rem;
    min-width: 80px;
    text-align: left;
    margin-right: 8px;
  }
  .responsive-table td:empty {
    display: none;
  }
}

/* ===================================================================
   KATEX & MATH FORMULA STYLING (Mobile Overflow Guard)
   =================================================================== */
.katex {
  font-size: clamp(0.85rem, 2.5vw, 1.15rem) !important;
  line-height: 1.2;
}

.katex-display {
  margin: 0.75em 0 !important;
  overflow-x: auto;
  overflow-y: hidden;
  max-width: 100%;
  padding: 4px 0;
  -webkit-overflow-scrolling: touch;
}

/* ===================================================================
   EXAM TAKING & QUESTION NAVIGATION
   =================================================================== */
.question-pill {
  width: 38px;
  height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.875rem;
  font-weight: 600;
  border-radius: 0.5rem;
  transition: all 0.2s ease;
  cursor: pointer;
  border: 1px solid var(--border-color);
  background-color: #ffffff;
}

.question-pill:hover {
  border-color: var(--primary-color);
  transform: translateY(-1px);
}

.question-pill.active {
  background-color: var(--primary-color);
  color: #ffffff;
  border-color: var(--primary-color);
  box-shadow: 0 4px 6px -1px rgba(6, 95, 70, 0.25);
}

.question-pill.answered {
  background-color: #dcfce7;
  color: #166534;
  border-color: #86efac;
}

.question-pill.answered.active {
  background-color: var(--primary-color);
  color: #ffffff;
}

.question-pill.flagged {
  border-color: #f59e0b;
  position: relative;
}

.question-pill.flagged::after {
  content: '';
  position: absolute;
  top: 2px;
  right: 2px;
  width: 7px;
  height: 7px;
  background-color: #f59e0b;
  border-radius: 50%;
}

/* Option Cards */
.choice-card {
  border: 1.5px solid #e2e8f0;
  border-radius: 0.625rem;
  padding: 0.875rem 1rem;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  background-color: #ffffff;
}

.choice-card:hover {
  border-color: var(--mint-light);
  background-color: #f8fafc;
}

.choice-card.selected {
  border-color: var(--primary-color);
  background-color: var(--primary-light);
  box-shadow: 0 0 0 1px var(--primary-color);
}

/* True / False 4-Item Grid Styling */
.tf-row {
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  align-items: center;
  gap: 1rem;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid #f1f5f9;
  border-radius: 0.375rem;
}

.tf-row:hover {
  background-color: #f8fafc;
}

/* ===================================================================
   ANTI-CHEAT SYSTEM STYLES
   =================================================================== */
.anti-cheat-overlay {
  position: fixed;
  inset: 0;
  background-color: rgba(15, 23, 42, 0.92);
  z-index: 99999;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(8px);
  animation: fadeIn 0.2s ease-out;
}

.anti-cheat-card {
  background: white;
  border-radius: 1rem;
  max-width: 540px;
  width: 90%;
  padding: 2rem;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
  border-top: 6px solid #ef4444;
  animation: scaleUp 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.warning-pulse {
  animation: pulseWarning 1.5s infinite;
}

@keyframes pulseWarning {
  0% { transform: scale(1); box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.5); }
  70% { transform: scale(1.03); box-shadow: 0 0 0 14px rgba(239, 68, 68, 0); }
  100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); }
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes scaleUp {
  from { opacity: 0; transform: scale(0.95); }
  to { opacity: 1; transform: scale(1); }
}

/* ===================================================================
   TOAST NOTIFICATIONS
   =================================================================== */
#toast-container {
  position: fixed;
  bottom: 5.5rem; /* Avoid collision with Netlify bottom-right badge */
  right: 1.5rem;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  pointer-events: none;
}

.toast {
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.875rem 1.25rem;
  border-radius: 0.5rem;
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1);
  font-size: 0.9rem;
  font-weight: 500;
  animation: slideInRight 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  background-color: white;
}

@keyframes slideInRight {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* ===================================================================
   LIVE EXAM EDITOR STYLES
   =================================================================== */
.editor-question-card {
  border: 1px solid #e2e8f0;
  border-radius: 0.75rem;
  background-color: #ffffff;
  transition: box-shadow 0.2s ease, border-color 0.2s ease;
}

.editor-question-card:hover {
  border-color: #cbd5e1;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
}

.editor-question-card.active-editing {
  border-color: var(--primary-color);
  box-shadow: 0 0 0 2px var(--primary-light);
}

/* Image preview modal */
.img-zoom-modal {
  position: fixed;
  inset: 0;
  background-color: rgba(0, 0, 0, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 99999;
  cursor: zoom-out;
}

.img-zoom-modal img {
  max-width: 90vw;
  max-height: 90vh;
  object-fit: contain;
  border-radius: 0.5rem;
}

/* ===================================================================
   SYSTEM SECURITY & ANTI-COPY / ANTI-DEVTOOLS
   =================================================================== */
/* Prevent text highlighting across exam areas */
.no-select, body.security-locked, .question-card, .exam-content {
  -webkit-user-select: none !important;
  -moz-user-select: none !important;
  -ms-user-select: none !important;
  user-select: none !important;
}

/* Allow text selection inside genuine input areas */
input, textarea, [contenteditable="true"] {
  -webkit-user-select: text !important;
  -moz-user-select: text !important;
  -ms-user-select: text !important;
  user-select: text !important;
}

/* ===================================================================
   MODERN DASHBOARD HUB CARDS (LIGHTWEIGHT & HIGH PERFORMANCE)
   =================================================================== */
.hub-card {
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
  border: 1px solid #e2e8f0;
  position: relative;
  background-color: #ffffff;
}

.hub-card:hover {
  border-color: var(--emerald-mid);
  box-shadow: 0 4px 12px -2px rgba(6, 95, 70, 0.1);
}

.hub-card:active {
  background-color: #f8fafc;
}

.hub-icon-wrapper {
  transition: opacity 0.15s ease;
}

.hub-card:hover .hub-icon-wrapper {
  opacity: 0.9;
}

/* ===================================================================
   QR CODE PROTECTION: IMMUNITY TO DARK MODE & DARK READER
   =================================================================== */
#qr-upload-modal {
  color-scheme: light !important;
}

#qr-code-box,
#qr-code-target,
#qr-code-target * {
  color-scheme: light !important;
  forced-color-adjust: none !important;
  -webkit-filter: none !important;
  filter: none !important;
  background-color: #ffffff !important;
}

#qr-code-target canvas,
#qr-code-target img,
#qr-code-target svg {
  color-scheme: light !important;
  forced-color-adjust: none !important;
  -webkit-filter: none !important;
  filter: none !important;
  background-color: #ffffff !important;
  image-rendering: -webkit-optimize-contrast !important;
  image-rendering: pixelated !important;
  image-rendering: crisp-edges !important;
}

/* ===================================================================
   STUDENT PAPER GPU VIEW & CANVAS ANNOTATION LAYER
   =================================================================== */
.student-paper-viewport {
  position: relative;
  overflow: hidden;
  background-color: #0f172a;
  border-radius: 14px;
  user-select: none;
  min-height: 520px;
  display: flex;
  align-items: center;
  justify-content: center;
  touch-action: none;
}

.student-paper-layer-wrapper {
  position: relative;
  display: inline-block;
  transform-origin: center center;
  transition: transform 0.05s ease-out;
  cursor: grab;
}

.student-paper-layer-wrapper.panning {
  cursor: grabbing !important;
}

.student-paper-layer-wrapper.annotating {
  cursor: crosshair !important;
}

.student-paper-view {
  display: block;
  max-width: 100%;
  max-height: 80vh;
  object-fit: contain;
  transform: translateZ(0);
  will-change: filter, transform;
  pointer-events: none;
  border-radius: 6px;
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.4);
}

/* 3 GPU Filter Modes */
.student-paper-view.filter-default {
  filter: none;
}
.student-paper-view.filter-clarity {
  filter: contrast(135%) brightness(105%) grayscale(30%);
}
.student-paper-view.filter-invert {
  filter: invert(90%) hue-rotate(180%) contrast(120%);
}

/* Canvas Annotation Layer */
.annotation-canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: auto;
  touch-action: none;
}

/* Split-View Layout for Essay Grading */
.split-view-container {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  width: 100%;
  height: 85vh;
  max-height: 85vh;
}

@media (min-width: 1024px) {
  .split-view-container {
    flex-direction: row;
    align-items: stretch;
  }
  .split-view-left {
    flex: 0 0 65%;
    max-width: 65%;
    min-width: 0;
    height: 100%;
    display: flex;
    flex-direction: column;
  }
  .split-view-right {
    flex: 0 0 35%;
    max-width: 35%;
    min-width: 0;
    height: 100%;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
  }
}

/* Floating Annotation Toolbar */
.floating-annotation-bar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 14px;
  background: rgba(15, 23, 42, 0.9);
  backdrop-filter: blur(10px);
  color: white;
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.4);
  z-index: 30;
}

.annotation-tool-btn {
  height: 34px;
  padding: 0 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  background: rgba(255, 255, 255, 0.08);
  color: #f8fafc;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}

.annotation-tool-btn:hover {
  background: rgba(255, 255, 255, 0.2);
  transform: translateY(-1px);
}

.annotation-tool-btn.active {
  background: #059669;
  border-color: #34d399;
  color: white;
  box-shadow: 0 0 10px rgba(52, 211, 153, 0.5);
}

.color-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  display: inline-block;
  border: 2px solid white;
}



/* ===== BOTTOM NAVIGATION SAFE AREA FIX (Lỗi 11) ===== */
#bottomNav {
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
