/**
 * single-threaded-workspace.css
 * Single-Threaded Progressive Disclosure & Multi-Persona Standalone Exam Solution Styles
 * Platform: chamnhanh.net (AUTOGRADING)
 * Responsive range: 320px (Compact Mobile) -> 344px (Foldable) -> 390px -> 768px -> 1440px+
 */

/* 1. Single-Threaded Progressive Disclosure Guard */
#panel-studio-quick[data-single-flow-state="CAPTURE"] #quick-workspace-detail-card:not(.has-active-record),
#panel-studio-quick[data-single-flow-state="PROCESSING"] #quick-workspace-detail-card:not(.has-active-record) {
  display: none !important;
}

#panel-studio-quick.focused-exam-solution-mode #btn-quick-stage-audit,
#panel-studio-quick.focused-exam-solution-mode #quick-stage-panel-audit {
  display: none !important;
}

/* 2. 3-Step Single-Threaded Flow Stepper */
.quick-single-flow-stepper {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  flex-wrap: wrap;
  gap: 0.45rem;
  padding: 0.55rem 0.85rem;
  margin-bottom: 0.65rem;
  border-radius: 10px;
  background: var(--surface-card, #ffffff);
  border: 1px solid var(--border-color, #e2e8f0);
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}

.quick-single-flow-stepper:empty {
  display: none;
}

.quick-stepper-item {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.78rem;
  font-weight: 600;
  color: #64748b;
  padding: 0.22rem 0.5rem;
  border-radius: 999px;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.quick-stepper-dot {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  font-size: 0.7rem;
  font-weight: 800;
  background: #e2e8f0;
  color: #475569;
  flex-shrink: 0;
}

.quick-stepper-item.is-active {
  background: #eef2ff;
  color: #3730a3;
  font-weight: 800;
}

.quick-stepper-item.is-active .quick-stepper-dot {
  background: #4f46e5;
  color: #ffffff;
}

.quick-stepper-item.is-completed {
  color: #047857;
}

.quick-stepper-item.is-completed .quick-stepper-dot {
  background: #d1fae5;
  color: #065f46;
}

.quick-stepper-divider {
  font-size: 0.75rem;
  color: #94a3b8;
  user-select: none;
}

/* 3. Teacher Single-Exam Barem Summary & 1-Click Handoff Banner */
.quick-teacher-barem-handoff-banner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.65rem;
  padding: 0.75rem 0.95rem;
  margin-bottom: 0.85rem;
  border-radius: 10px;
  background: linear-gradient(135deg, #eef2ff 0%, #f0f9ff 100%);
  border: 1px solid #c7d2fe;
}

.quick-teacher-audit-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.28rem 0.65rem;
  border-radius: 999px;
  font-size: 0.76rem;
  font-weight: 700;
  border: 1px solid transparent;
  cursor: pointer;
}

.quick-teacher-audit-pill.is-valid {
  background: #dcfce7;
  color: #166534;
  border-color: #86efac;
}

.quick-teacher-audit-pill.has-warning {
  background: #fef3c7;
  color: #92400e;
  border-color: #fcd34d;
}

.quick-handoff-linked-banner {
  padding: 0.6rem 0.8rem;
  margin-bottom: 0.65rem;
  border-radius: 8px;
  background: #ecfdf5;
  border: 1px solid #6ee7b7;
  color: #065f46;
  font-size: 0.8rem;
  font-weight: 700;
  line-height: 1.45;
}

#quick-step3-attach-work-box.is-handoff-highlighted {
  border: 2px solid #4f46e5 !important;
  box-shadow: 0 8px 20px rgba(79, 70, 229, 0.12);
}

/* 4. Learner / Parent 3-Mode Single-Threaded Task Switcher */
.learner-solver-task-switcher {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.55rem;
  margin-bottom: 0.85rem;
  padding: 0.45rem;
  border-radius: 12px;
  background: var(--surface-card, #ffffff);
  border: 1px solid var(--border-color, #e2e8f0);
}

.learner-task-pill {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  gap: 0.15rem;
  min-height: 46px;
  padding: 0.55rem 0.75rem;
  border-radius: 9px;
  border: 1px solid transparent;
  background: #f8fafc;
  color: #334155;
  text-align: left;
  cursor: pointer;
  transition: all 0.15s ease;
}

.learner-task-pill:hover {
  background: #f1f5f9;
  border-color: #cbd5e1;
}

.learner-task-pill.active {
  background: linear-gradient(135deg, #4338ca 0%, #312e81 100%);
  color: #ffffff;
  border-color: #312e81;
  box-shadow: 0 4px 12px rgba(67, 56, 202, 0.22);
}

.learner-task-pill-title {
  font-size: 0.84rem;
  font-weight: 800;
  line-height: 1.25;
}

.learner-task-pill-desc {
  font-size: 0.72rem;
  opacity: 0.86;
  line-height: 1.3;
}

/* 5. Barem-Free Learner & Parent Exam Solution Stage */
.learner-exam-solution-stage {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  max-width: 100%;
  overflow-x: hidden;
}

.learner-exam-banner {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 0.75rem;
  padding: 0.95rem 1.05rem;
  border-radius: 12px;
  background: linear-gradient(135deg, #f0fdf4 0%, #eff6ff 100%);
  border: 1px solid #bfdbfe;
}

.learner-exam-brand-pill {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 800;
  color: #1d4ed8;
  background: #dbeafe;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  margin-bottom: 0.35rem;
}

.learner-exam-heading {
  font-size: 1.02rem;
  font-weight: 800;
  color: #0f172a;
  margin: 0 0 0.2rem 0;
}

.learner-exam-meta {
  font-size: 0.78rem;
  color: #475569;
  margin: 0;
}

.learner-exam-top-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  align-items: center;
}

.learner-exam-top-actions .btn {
  min-height: 40px;
  font-weight: 700;
}

.learner-teacher-action-bar {
  margin-top: 1.5rem;
  padding: 1rem 1.25rem;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.learner-teacher-action-bar .btn {
  min-height: 40px;
}

.learner-exam-question-nav {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scroll-behavior: smooth;
  padding: 0.4rem 0.15rem;
  scrollbar-width: thin;
  position: sticky;
  top: 0;
  z-index: 9;
  background: var(--surface-bg, #ffffff);
}

.learner-q-nav-pill {
  min-height: 40px;
  padding: 0.35rem 0.85rem;
  border-radius: 999px;
  border: 1px solid #cbd5e1;
  background: #ffffff;
  color: #334155;
  font-size: 0.78rem;
  font-weight: 700;
  white-space: nowrap;
  cursor: pointer;
  transition: all 0.15s ease;
}

.learner-q-nav-pill:hover {
  border-color: #0f766e;
  color: #0f766e;
}

.learner-q-nav-pill.active {
  background: #0f766e;
  border-color: #0f766e;
  color: #ffffff;
}

.learner-card-targeted {
  animation: targetCardPulse 1.8s ease-out;
}

@keyframes targetCardPulse {
  0% { box-shadow: 0 0 0 0 rgba(15, 118, 110, 0.45); border-color: #0f766e; }
  40% { box-shadow: 0 0 0 6px rgba(15, 118, 110, 0.2); border-color: #0f766e; }
  100% { box-shadow: 0 2px 6px rgba(15, 23, 42, 0.03); border-color: var(--border-color, #e2e8f0); }
}

.learner-focus-card-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 1rem;
  padding: 0.75rem 1rem;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
}

.learner-focus-counter {
  font-size: 0.82rem;
  color: #475569;
}

.learner-focus-nav-btns {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.learner-exam-questions-list {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.learner-exam-question-card {
  padding: 1rem 1.1rem;
  border-radius: 12px;
  background: var(--surface-card, #ffffff);
  border: 1px solid var(--border-color, #e2e8f0);
  box-shadow: 0 2px 6px rgba(15, 23, 42, 0.03);
}

.learner-q-card-header {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-bottom: 0.6rem;
}

.learner-q-badge {
  padding: 0.22rem 0.6rem;
  border-radius: 6px;
  background: #0f172a;
  color: #ffffff;
  font-size: 0.78rem;
  font-weight: 800;
}

.learner-q-domain-chip {
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  background: #f1f5f9;
  color: #475569;
  font-size: 0.73rem;
  font-weight: 700;
}

.learner-q-statement {
  padding: 0.7rem 0.85rem;
  margin-bottom: 0.7rem;
  border-radius: 8px;
  background: #f8fafc;
  border-left: 3px solid #6366f1;
  font-size: 0.88rem;
  color: #0f172a;
  line-height: 1.55;
  overflow-x: auto;
}

.learner-q-method-box {
  padding: 0.65rem 0.85rem;
  margin-bottom: 0.7rem;
  border-radius: 8px;
  background: #f0fdfa;
  border: 1px solid #99f6e4;
}

.learner-q-section-label {
  font-size: 0.76rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  color: #0f766e;
  margin-bottom: 0.3rem;
}

.learner-q-method-text {
  font-size: 0.84rem;
  color: #134e4a;
  line-height: 1.5;
}

.learner-q-steps-box {
  margin-bottom: 0.7rem;
}

.learner-solution-steps-list {
  list-style: none;
  margin: 0.35rem 0 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.learner-solution-step-item {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  padding: 0.6rem 0.75rem;
  border-radius: 8px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
}

.learner-step-index {
  padding: 0.15rem 0.45rem;
  border-radius: 5px;
  background: #e0e7ff;
  color: #3730a3;
  font-size: 0.72rem;
  font-weight: 800;
  white-space: nowrap;
  flex-shrink: 0;
}

.learner-step-body {
  min-width: 0;
  flex: 1;
  font-size: 0.85rem;
  line-height: 1.55;
  color: #1e293b;
  overflow-x: auto;
}

.learner-step-title {
  font-weight: 700;
  color: #0f172a;
  margin-bottom: 0.15rem;
}

.learner-q-final-answer {
  margin-top: 0.6rem;
  padding: 0.55rem 0.8rem;
  border-radius: 8px;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  color: #1e3a8a;
  font-size: 0.86rem;
  overflow-x: auto;
}

.learner-role-callout {
  padding: 0.7rem 0.85rem;
  border-radius: 8px;
  font-size: 0.82rem;
  line-height: 1.5;
}

.learner-role-callout.is-student {
  background: #fffbeb;
  border: 1px solid #fde68a;
  color: #92400e;
}

.learner-role-callout.is-parent {
  background: #fdf4ff;
  border: 1px solid #f5d0fe;
  color: #701a75;
}

.learner-callout-title {
  font-weight: 800;
  margin-bottom: 0.25rem;
}

.learner-parent-prompt-list {
  margin: 0.25rem 0 0 1.1rem;
  padding: 0;
}

/* 6. Dark Mode Support */
[data-theme="dark"] .quick-single-flow-stepper,
[data-theme="dark"] .learner-solver-task-switcher,
[data-theme="dark"] .learner-exam-question-card {
  background: #0f172a;
  border-color: #1e293b;
}

[data-theme="dark"] .learner-task-pill {
  background: #1e293b;
  color: #e2e8f0;
}

[data-theme="dark"] .learner-exam-banner,
[data-theme="dark"] .quick-teacher-barem-handoff-banner {
  background: #1e293b;
  border-color: #334155;
}

[data-theme="dark"] .learner-exam-heading,
[data-theme="dark"] .learner-q-statement,
[data-theme="dark"] .learner-step-title,
[data-theme="dark"] .learner-step-body {
  color: #f8fafc;
}

[data-theme="dark"] .learner-q-statement,
[data-theme="dark"] .learner-solution-step-item {
  background: #1e293b;
  border-color: #334155;
}

[data-theme="dark"] .learner-q-method-box {
  background: rgba(15, 118, 110, 0.18);
  border-color: rgba(45, 212, 191, 0.35);
}

[data-theme="dark"] .learner-q-method-text {
  color: #99f6e4;
}

[data-theme="dark"] .learner-q-final-answer {
  background: rgba(30, 58, 138, 0.3);
  border-color: rgba(96, 165, 250, 0.4);
  color: #dbeafe;
}

[data-theme="dark"] .learner-role-callout.is-student {
  background: rgba(146, 64, 14, 0.22);
  border-color: rgba(251, 191, 36, 0.35);
  color: #fde68a;
}

[data-theme="dark"] .learner-role-callout.is-parent {
  background: rgba(112, 26, 117, 0.24);
  border-color: rgba(232, 121, 249, 0.35);
  color: #f5d0fe;
}

/* 7. Mobile & Foldable Responsive Breakpoints (320px / 344px / 390px / 768px) */
@media (max-width: 767px) {
  .learner-solver-task-switcher {
    grid-template-columns: 1fr;
  }

  .quick-single-flow-stepper {
    padding: 0.45rem 0.6rem;
    gap: 0.3rem;
  }

  .quick-stepper-divider {
    display: none;
  }

  .learner-exam-banner,
  .learner-exam-question-card {
    padding: 0.8rem;
  }

  .learner-exam-top-actions {
    width: 100%;
  }

  .learner-exam-top-actions .btn {
    width: 100%;
    justify-content: center;
  }

  .learner-teacher-action-bar {
    flex-direction: column;
    align-items: stretch;
  }

  .learner-teacher-action-bar .btn {
    width: 100%;
    justify-content: center;
  }

  .learner-solution-step-item {
    flex-direction: column;
    gap: 0.35rem;
  }
}

@media (max-width: 360px) {
  .quick-stepper-item {
    font-size: 0.72rem;
    padding: 0.18rem 0.4rem;
  }

  .learner-task-pill {
    padding: 0.45rem 0.6rem;
  }

  .learner-exam-banner,
  .learner-exam-question-card {
    padding: 0.65rem;
  }
}

/* Teacher 2-in-1 Exam Purpose Progressive Switch (Solution-Only vs Barem) */
.teacher-exam-purpose-switch {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.5rem;
  margin-bottom: 0.65rem;
  padding: 0.3rem;
  background: var(--surface-subtle, #f1f5f9);
  border: 1px solid var(--bento-border, #e2e8f0);
  border-radius: 12px;
}

.teacher-exam-purpose-btn {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  gap: 0.12rem;
  min-height: 44px;
  padding: 0.5rem 0.75rem;
  border: 1.5px solid transparent;
  border-radius: 9px;
  background: transparent;
  text-align: left;
  cursor: pointer;
  transition: all 0.16s ease;
}

.teacher-exam-purpose-btn .purpose-title {
  font-size: 0.82rem;
  font-weight: 800;
  color: #334155;
}

.teacher-exam-purpose-btn .purpose-sub {
  font-size: 0.71rem;
  color: #64748b;
  line-height: 1.3;
}

.teacher-exam-purpose-btn.active {
  background: #ffffff;
  border-color: #4f46e5;
  box-shadow: 0 2px 8px rgba(79, 70, 229, 0.12);
}

.teacher-exam-purpose-btn.active .purpose-title {
  color: #3730a3;
}

.learner-role-callout.is-teacher {
  background: #eef2ff;
  border: 1px solid #c7d2fe;
  color: #312e81;
}

[data-theme="dark"] .teacher-exam-purpose-switch {
  background: rgba(15, 23, 42, 0.65);
  border-color: rgba(148, 163, 184, 0.2);
}

[data-theme="dark"] .teacher-exam-purpose-btn .purpose-title {
  color: #e2e8f0;
}

[data-theme="dark"] .teacher-exam-purpose-btn .purpose-sub {
  color: #94a3b8;
}

[data-theme="dark"] .teacher-exam-purpose-btn.active {
  background: rgba(30, 41, 59, 0.95);
  border-color: #818cf8;
}

[data-theme="dark"] .teacher-exam-purpose-btn.active .purpose-title {
  color: #a5b4fc;
}

[data-theme="dark"] .learner-role-callout.is-teacher {
  background: rgba(49, 46, 129, 0.28);
  border-color: rgba(129, 140, 248, 0.35);
  color: #e0e7ff;
}

@media (max-width: 640px) {
  .teacher-exam-purpose-switch {
    grid-template-columns: 1fr;
  }
}

/* Export Interaction Lock & Progress Feedback */
.is-stage-exporting {
  cursor: wait !important;
}

.is-stage-exporting button,
.is-stage-exporting .btn {
  pointer-events: none;
  opacity: 0.65;
}

.learner-export-busy-banner {
  background: #f0fdf4;
  border: 1.5px solid #86efac;
  border-radius: 10px;
  padding: 0.85rem 1.15rem;
  margin-bottom: 0.85rem;
  box-shadow: 0 4px 12px rgba(22, 101, 52, 0.08);
  animation: fadeInBanner 0.25s ease-out;
}
.learner-export-busy-header {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  color: #166534;
  font-size: 0.92rem;
  font-weight: 700;
  margin-bottom: 0.35rem;
}
.learner-export-busy-desc {
  font-size: 0.8rem;
  color: #15803d;
  margin: 0 0 0.65rem 0;
  line-height: 1.45;
}

.learner-export-progress-track {
  width: 100%;
  height: 6px;
  background: #dcfce7;
  border-radius: 999px;
  overflow: hidden;
  position: relative;
}

.learner-export-progress-bar {
  width: 45%;
  height: 100%;
  background: linear-gradient(90deg, #16a34a, #22c55e, #16a34a);
  border-radius: 999px;
  animation: pulseProgressBar 1.5s infinite ease-in-out;
}

.learner-export-spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2.2px solid #bbf7d0;
  border-top-color: #166534;
  border-radius: 50%;
  animation: spinExport 0.75s linear infinite;
}

@keyframes spinExport { to { transform: rotate(360deg); } }
@keyframes pulseProgressBar {
  0% { transform: translateX(-100%); }
  50% { transform: translateX(110%); }
  100% { transform: translateX(250%); }
}
@keyframes fadeInBanner {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

[data-theme="dark"] .learner-export-busy-banner {
  background: rgba(20, 83, 45, 0.3);
  border-color: rgba(74, 222, 128, 0.4);
}
[data-theme="dark"] .learner-export-busy-header { color: #86efac; }
[data-theme="dark"] .learner-export-busy-desc { color: #bbf7d0; }
