/**
 * bento-speedgrader-pro.css - AutoGrading SpeedGrader Split Studio Ergonomics
 */
/* 1. STUDENT ROSTER SEARCH & PROGRESS BAR */
.sg-roster-header {
  padding: 0.65rem 0.65rem 0.5rem 0.65rem;
  background: var(--bento-surface, #ffffff);
  border-bottom: 1px solid var(--bento-border, #e2e8f0);
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  position: sticky;
  top: 0;
  z-index: 10;
}

[data-theme="dark"] .sg-roster-header, body.dark-mode .sg-roster-header {
  background: var(--bento-surface, #1e293b);
  border-bottom-color: rgba(255, 255, 255, 0.08);
}

.sg-roster-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.roster-header-text {
  font-size: 0.76rem;
  font-weight: 800;
  color: var(--bento-text-muted, #64748b);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* Roster Grading Progress Card */
.sg-roster-progress-card {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 0.35rem 0.5rem;
}

[data-theme="dark"] .sg-roster-progress-card, body.dark-mode .sg-roster-progress-card {
  background: rgba(15, 23, 42, 0.6);
  border-color: rgba(255, 255, 255, 0.08);
}

.sg-roster-progress-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.72rem;
  font-weight: 700;
  color: #475569;
  margin-bottom: 0.25rem;
}

[data-theme="dark"] .sg-roster-progress-meta, body.dark-mode .sg-roster-progress-meta { color: #94a3b8; }

.sg-roster-progress-track {
  height: 5px;
  background: #e2e8f0;
  border-radius: 9999px;
  overflow: hidden;
}

[data-theme="dark"] .sg-roster-progress-track, body.dark-mode .sg-roster-progress-track { background: #334155; }

.sg-roster-progress-bar {
  height: 100%;
  background: linear-gradient(90deg, #3b82f6 0%, #10b981 100%);
  border-radius: 9999px;
  transition: width 0.3s ease;
}

/* Instant Search Filter */
.sg-roster-search-box {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
}

.sg-search-svg {
  position: absolute;
  left: 0.55rem;
  color: #94a3b8;
  pointer-events: none;
}

.sg-roster-search-input {
  width: 100%;
  height: 32px;
  padding: 0 1.6rem 0 1.8rem;
  font-size: 0.78rem;
  color: var(--bento-text-main, #1e293b);
  background: #ffffff;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  outline: none;
  transition: all 0.2s ease;
}

[data-theme="dark"] .sg-roster-search-input,
body.dark-mode .sg-roster-search-input {
  background: #0f172a;
  border-color: #334155;
  color: #f8fafc;
}

.sg-roster-search-input:focus {
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

.sg-clear-search-btn {
  position: absolute;
  right: 0.4rem;
  background: transparent;
  border: none;
  color: #94a3b8;
  font-size: 0.75rem;
  padding: 0.2rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
}

.sg-clear-search-btn:hover {
  color: #475569;
}

/* Roster List Scroll Container */
.sg-roster-list {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 0.4rem 0.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

/* 2. STICKY RUBRIC AI CTA DOCK */
.sg-sticky-cta-dock {
  position: sticky;
  bottom: 0;
  z-index: 25;
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-top: 1px solid var(--bento-border, #e2e8f0);
  padding: 0.75rem 0.5rem 0.5rem 0.5rem;
  margin-top: auto;
  box-shadow: 0 -4px 18px rgba(0, 0, 0, 0.05);
}

[data-theme="dark"] .sg-sticky-cta-dock,
body.dark-mode .sg-sticky-cta-dock {
  background: rgba(30, 41, 59, 0.96);
  border-top-color: rgba(255, 255, 255, 0.1);
  box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.3);
}

.btn-sg-hero-cta {
  width: 100%;
  height: 42px;
  background: linear-gradient(135deg, #4f46e5 0%, #6366f1 100%);
  color: #ffffff !important;
  font-weight: 700;
  font-size: 0.92rem;
  border-radius: 8px;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  box-shadow: 0 4px 12px rgba(79, 70, 229, 0.25);
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  cursor: pointer;
}

.btn-sg-hero-cta:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(79, 70, 229, 0.35);
  background: linear-gradient(135deg, #4338ca 0%, #4f46e5 100%);
}

.btn-sg-hero-cta:active {
  transform: translateY(0);
}

.sg-cta-sparkle {
  font-size: 1.05rem;
}

.btn-sg-regrade {
  width: 100%;
  margin-bottom: 0.6rem;
  font-weight: 700;
  color: #4f46e5;
  border-color: #c7d2fe;
  background: #eef2ff;
  border-radius: 7px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
}

[data-theme="dark"] .btn-sg-regrade, body.dark-mode .btn-sg-regrade {
  background: rgba(99, 102, 241, 0.15);
  border-color: rgba(99, 102, 241, 0.3);
  color: #a5b4fc;
}

.sg-override-inline-group {
  margin-bottom: 0.5rem;
}

.sg-override-label {
  font-size: 0.74rem;
  font-weight: 700;
  color: #64748b;
  display: block;
  margin-bottom: 0.25rem;
}

[data-theme="dark"] .sg-override-label, body.dark-mode .sg-override-label { color: #94a3b8; }

.sg-override-input-row {
  display: flex;
  gap: 0.45rem;
}

.sg-student-pager-row {
  display: flex;
  justify-content: space-between;
  margin-top: 0.5rem;
  gap: 0.5rem;
}

.sg-student-pager-row .btn {
  flex: 1;
  text-align: center;
}

/* 3. CANVAS ERROR RECOVERY CARD */

.sg-canvas-empty-state,
.sg-canvas-recovery-card {
  padding: 2.5rem 1.5rem;
  max-width: 480px;
  margin: 2rem auto;
  text-align: center;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 14px;
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.05);
}

[data-theme="dark"] .sg-canvas-empty-state,
[data-theme="dark"] .sg-canvas-recovery-card,
body.dark-mode .sg-canvas-empty-state,
body.dark-mode .sg-canvas-recovery-card {
  background: #1e293b;
  border-color: rgba(255, 255, 255, 0.1);
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.4);
}

.sg-canvas-empty-icon {
  font-size: 2.8rem;
  margin-bottom: 0.6rem;
}

.sg-canvas-empty-title {
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--bento-text-main, #1e293b);
  margin-bottom: 0.4rem;
}

[data-theme="dark"] .sg-canvas-empty-title, body.dark-mode .sg-canvas-empty-title { color: #f8fafc; }

.sg-canvas-empty-desc {
  font-size: 0.82rem;
  color: var(--bento-text-muted, #64748b);
  line-height: 1.5;
  margin-bottom: 1.25rem;
}

.sg-canvas-recovery-actions {
  display: flex;
  gap: 0.55rem;
  justify-content: center;
  flex-wrap: wrap;
}

.btn-sg-camera-capture {
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-weight: 600;
}

/* 4. MOBILE RESPONSIVE OPTIMIZATIONS (<= 768px) */
@media (max-width: 768px) {
  .sg-roster-search-input {
    height: 40px;
    font-size: 0.85rem;
  }

  .sg-roster-header {
    padding: 0.75rem 0.5rem;
  }

  .sg-sticky-cta-dock {
    /* Push CTA up to avoid overlap with fixed bottom navigation dock */
    padding-bottom: calc(var(--mobile-dock-height, 60px) + 20px) !important;
    position: relative;
    box-shadow: none;
    background: transparent;
    border-top: none;
  }

  .btn-sg-hero-cta {
    height: 46px;
    font-size: 0.95rem;
  }

  .sg-canvas-empty-state,
  .sg-canvas-recovery-card {
    margin: 1rem 0.5rem;
    padding: 1.75rem 1rem;
  }

  .sg-canvas-recovery-actions .btn {
    flex: 1 1 100%;
    min-height: 42px;
    display: flex;
    align-items: center;
    justify-content: center;
  }
}

/* 5. DESKTOP ERGONOMICS & ANTI-CLIPPING RECOVERY */
/* 5.1 Center Column: Generous Spacing between Toolbar and Page Tabs */
.speedgrader-center-pane {
  display: flex !important;
  flex-direction: column !important;
  height: 100% !important;
  align-self: stretch !important;
  overflow: hidden !important;
  background: var(--bento-surface, #ffffff) !important;
}

.speedgrader-canvas-toolbar {
  margin: 0.75rem 0.85rem 0.45rem 0.85rem !important;
  border-radius: 12px !important;
  background: rgba(255, 255, 255, 0.95) !important;
  backdrop-filter: blur(18px) saturate(180%) !important;
  -webkit-backdrop-filter: blur(18px) saturate(180%) !important;
  border: 1px solid var(--bento-border, #e2e8f0) !important;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.04) !important;
  box-sizing: border-box !important;
  padding: 0.45rem 0.75rem !important;
}

[data-theme="dark"] .speedgrader-canvas-toolbar,
body.dark-mode .speedgrader-canvas-toolbar {
  background: rgba(30, 41, 59, 0.95) !important;
  border-color: rgba(255, 255, 255, 0.1) !important;
}

.sg-page-tabs-bar {
  margin: 0 0.85rem 0.75rem 0.85rem !important;
  padding: 4px 6px !important;
  border-radius: 10px !important;
  background: #f1f5f9 !important;
  border: 1px solid #e2e8f0 !important;
  box-sizing: border-box !important;
  width: auto !important;
  max-width: calc(100% - 1.7rem) !important;
}

.sg-page-tabs-bar:not(.visible),
.sg-page-tabs-bar[style*="display: none"] {
  display: none !important;
  margin: 0 !important;
  padding: 0 !important;
  border: none !important;
  height: 0 !important;
  min-height: 0 !important;
}

[data-theme="dark"] .sg-page-tabs-bar,
body.dark-mode .sg-page-tabs-bar {
  background: rgba(15, 23, 42, 0.6) !important;
  border-color: rgba(255, 255, 255, 0.08) !important;
}

.sg-page-tab-btn {
  border-radius: 7px !important;
  padding: 0.22rem 0.65rem !important;
  font-size: 0.76rem !important;
}

/* 5.2 Responsive Viewport Capping & Anti-Horizontal Scroll Studio Layout */
.speedgrader-studio-layout {
  display: grid !important;
  grid-template-columns: minmax(230px, 260px) 1fr minmax(320px, 360px) !important;
  grid-template-rows: 100% !important;
  align-items: stretch !important;
  height: calc(100vh - 145px) !important;
  max-height: calc(100vh - 145px) !important;
  min-height: 520px !important;
  gap: 0.75rem !important;
  overflow: hidden !important;
  box-sizing: border-box !important;
}

body.speedgrader-active .speedgrader-studio-layout {
  height: calc(100vh - 96px) !important;
  max-height: calc(100vh - 96px) !important;
}

@media (max-width: 1280px) {
  .speedgrader-studio-layout {
    grid-template-columns: minmax(180px, 210px) 1fr minmax(280px, 310px) !important;
    gap: 0.55rem !important;
    height: calc(100vh - 96px) !important;
    max-height: calc(100vh - 96px) !important;
  }
  .speedgrader-studio-layout.roster-collapsed {
    grid-template-columns: 52px 1fr minmax(280px, 310px) !important;
  }
}

@media (max-width: 768px) {
  .speedgrader-studio-layout {
    display: block !important;
    height: auto !important;
    max-height: none !important;
    min-height: auto !important;
    overflow: visible !important;
  }
}

.speedgrader-center-pane {
  min-width: 0 !important;
  max-width: 100% !important;
  height: 100% !important;
  max-height: 100% !important;
  min-height: 0 !important;
  align-self: stretch !important;
  display: flex !important;
  flex-direction: column !important;
  overflow: hidden !important;
  box-sizing: border-box !important;
}

.speedgrader-canvas-viewport {
  flex: 1 1 auto !important;
  min-height: 0 !important;
  display: flex !important;
  flex-direction: column !important;
  align-items: stretch !important;
  justify-content: flex-start !important;
  overflow: hidden !important;
  position: relative !important;
  padding: 0 !important;
  box-sizing: border-box !important;
}

.speedgrader-canvas-viewport .viewer-canvas-area {
  flex: 1 1 auto !important;
  min-height: 0 !important;
  width: 100% !important;
  height: 100% !important;
  display: flex !important;
  align-items: flex-start !important;
  justify-content: center !important;
  overflow: auto !important;
  padding: 1.25rem 1rem !important;
  box-sizing: border-box !important;
}

.speedgrader-canvas-viewport .document-page-wrapper {
  margin: 0 auto !important;
  flex-shrink: 0 !important;
}

.speedgrader-right-pane {
  min-width: 0 !important;
  max-width: 100% !important;
  height: 100% !important;
  max-height: 100% !important;
  align-self: stretch !important;
  display: flex !important;
  flex-direction: column !important;
  overflow-x: clip !important;
  overflow-y: auto !important;
  box-sizing: border-box !important;
  padding: 0.85rem 0.65rem !important;
}

.sg-right-pane-header, .speedgrader-right-pane .sg-sticky-cta-dock, .sg-rubric-view-tabs { flex-shrink: 0 !important; }

#sg-pane-ai-criteria, #sg-pane-visual-rubric {
  flex: 1 1 auto !important; min-height: 0 !important; display: flex;
  flex-direction: column !important; gap: 0.6rem !important;
}
#sg-pane-ai-criteria[style*="display: none"], #sg-pane-visual-rubric[style*="display: none"] { display: none !important; }

#sg-rubric-breakdown {
  overflow-y: auto !important;
  max-height: calc(100vh - 290px) !important;
  padding-right: 0.2rem;
  scrollbar-width: thin;
  display: flex !important;
  flex-direction: column !important;
  gap: 0.6rem !important;
  width: 100% !important;
  min-height: min-content !important;
  flex-shrink: 0 !important;
}
#sg-rubric-breakdown::-webkit-scrollbar { width: 4px; }
#sg-rubric-breakdown::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 4px; }

.sg-rubric-card { flex-shrink: 0 !important; min-height: 44px !important; width: 100% !important; box-sizing: border-box !important; }
.sg-copilot-commentary-box { flex-shrink: 0 !important; width: 100% !important; box-sizing: border-box !important; }

.speedgrader-right-pane * {
  max-width: 100%;
  box-sizing: border-box;
}

.sg-micro-btn {
  min-height: 24px !important;
  max-height: 24px !important;
  padding: 0.15rem 0.45rem !important;
  font-size: 0.7rem !important;
  line-height: 1 !important;
}

.sg-rubric-view-tabs {
  display: flex !important;
  width: 100% !important;
  box-sizing: border-box !important;
  border-radius: 10px !important;
  padding: 3px !important;
  gap: 3px !important;
  margin-top: 0.35rem !important;
  margin-bottom: 0.65rem !important;
  background: rgba(0, 0, 0, 0.04) !important;
}

[data-theme="dark"] .sg-rubric-view-tabs,
body.dark-mode .sg-rubric-view-tabs {
  background: rgba(255, 255, 255, 0.06) !important;
}

.sg-rubric-view-tabs .sg-tab-btn {
  flex: 1 1 0 !important;
  min-width: 0 !important;
  font-size: 0.76rem !important;
  white-space: nowrap !important;
  text-overflow: ellipsis !important;
  overflow: hidden !important;
  justify-content: center !important;
  padding: 0.35rem 0.25rem !important;
}

.sg-vr-toolbar {
  display: flex !important;
  justify-content: space-between !important;
  align-items: center !important;
  background: #f8fafc !important;
  border: 1px solid #e2e8f0 !important;
  border-radius: 8px !important;
  padding: 0.25rem 0.35rem !important;
  gap: 0.25rem !important;
  width: 100% !important;
  box-sizing: border-box !important;
  overflow: hidden !important;
  flex-wrap: wrap !important;
}

.sg-vr-toolbar button.btn, .sg-vr-toolbar .btn-xs, .sg-vr-toolbar .sg-vr-btn,
.sg-vr-toolbar #btn-sg-vr-prev-page, .sg-vr-toolbar #btn-sg-vr-next-page,
.sg-vr-toolbar #btn-sg-vr-zoom-out, .sg-vr-toolbar #btn-sg-vr-zoom-in,
.sg-vr-toolbar #btn-sg-vr-rotate, .sg-vr-toolbar #btn-sg-vr-lightbox {
  width: 24px !important; height: 24px !important; min-width: 24px !important; min-height: 24px !important;
  max-width: 24px !important; max-height: 24px !important; padding: 0 !important; margin: 0 !important;
  line-height: 22px !important; font-size: 0.7rem !important; display: inline-flex !important;
  align-items: center !important; justify-content: center !important; border-radius: 6px !important;
  flex-shrink: 0 !important; box-sizing: border-box !important;
}

[data-theme="dark"] .sg-vr-toolbar,
body.dark-mode .sg-vr-toolbar {
  background: rgba(15, 23, 42, 0.7) !important;
  border-color: rgba(255, 255, 255, 0.1) !important;
}

#sg-vr-page-indicator {
  white-space: nowrap !important;
  display: inline-block !important;
  font-size: 0.72rem !important;
  padding: 0 0.15rem !important;
}

#sg-vr-zoom-level {
  font-size: 0.7rem !important;
  min-width: 30px !important;
  text-align: center !important;
}

/* SPEEDGRADER DESKTOP FOCUS MODE & TOP STICKY DOCK ERGONOMICS */
/* 1. Desktop Vertical Screen Real Estate Maximization */
body.speedgrader-active #exam-background-processing-banner {
  display: none !important;
}

body.speedgrader-active .assessment-management-hero {
  padding: 0.4rem 0.85rem !important;
  margin-bottom: 0.45rem !important;
}

body.speedgrader-active .assessment-sub-row {
  margin-top: 0.25rem !important;
  gap: 0.4rem !important;
}

body.speedgrader-active .assessment-main-row {
  margin-bottom: 0.2rem !important;
}

/* 2. Top-Anchored Scoring Dock in Right Pane */
.speedgrader-right-pane .sg-sticky-cta-dock {
  background: var(--bento-surface, #ffffff);
  border: 1px solid var(--bento-border, #e2e8f0);
  border-radius: 8px;
  padding: 0.55rem 0.65rem;
  margin-top: 0.35rem;
  margin-bottom: 0.45rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

[data-theme="dark"] .speedgrader-right-pane .sg-sticky-cta-dock, body.dark-mode .speedgrader-right-pane .sg-sticky-cta-dock {
  background: #1e293b;
  border-color: rgba(255, 255, 255, 0.08);
}

.speedgrader-right-pane .sg-override-inline-group {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  margin-bottom: 0.35rem;
}

.speedgrader-right-pane .sg-override-label {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--bento-text-muted, #64748b);
}

.speedgrader-right-pane .sg-override-input-row {
  display: flex;
  gap: 0.35rem;
  align-items: center;
}

.speedgrader-right-pane .sg-override-input-row input.form-control {
  height: 32px;
  font-size: 0.95rem;
  font-weight: 700;
  text-align: center;
  border-radius: 6px;
  color: #082850;
  border: 1.5px solid #cbd5e1;
}

.speedgrader-right-pane .sg-student-pager-row {
  display: flex;
  gap: 0.35rem;
  margin-top: 0.25rem;
}

.speedgrader-right-pane .sg-student-pager-row button {
  flex: 1;
  min-height: 28px;
  font-weight: 600;
  font-size: 0.72rem;
  padding: 0.2rem 0.4rem;
}


/* 4. Full-Screen Zen Mode (Phím Z / Button) */
.speedgrader-studio-layout.speedgrader-zen-mode {
  position: fixed !important;
  top: 0 !important;
  left: 0 !important;
  width: 100vw !important;
  height: 100vh !important;
  max-height: 100vh !important;
  z-index: 99999 !important;
  background: var(--bento-bg, #f8fafc) !important;
  margin: 0 !important;
  border-radius: 0 !important;
  padding: 0.5rem !important;
  box-sizing: border-box !important;
}

body.sg-zen-active {
  overflow: hidden !important;
}

body.sg-zen-active .top-nav,
body.sg-zen-active .sidebar,
body.sg-zen-active .assessment-management-hero {
  display: none !important;
}

#btn-sg-zen-mode.active {
  background: var(--primary, #00c5df) !important;
  color: #ffffff !important;
  border-color: var(--primary, #00c5df) !important;
}

/* 5. Mobile 3-Segmented Tabs & Touch Ergonomics */
.mobile-sg-tab-bar {
  display: none;
  background: #e2e8f0;
  border-radius: 10px;
  padding: 3px;
  gap: 3px;
  margin-bottom: 0.4rem;
}

@media (max-width: 768px) {
  .mobile-sg-tab-bar {
    display: flex !important;
    width: 100% !important;
    box-sizing: border-box !important;
  }
}

.mobile-sg-tab-btn {
  flex: 1;
  min-height: 38px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: #64748b;
  font-weight: 700;
  font-size: 0.76rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.3rem;
  transition: all 0.2s ease;
}

.mobile-sg-tab-btn.active {
  background: #ffffff;
  color: var(--primary, #00c5df);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
}

[data-theme="dark"] .mobile-sg-tab-bar,
body.dark-mode .mobile-sg-tab-bar {
  background: #1e293b;
}

[data-theme="dark"] .mobile-sg-tab-btn.active,
body.dark-mode .mobile-sg-tab-btn.active {
  background: #334155;
  color: #38bdf8;
}

