/**
 * bento-rubric-components.css
 * Các thành phần giao diện Bento cho Biểu Điểm (Bento Question Cards, Step Matrix, Quick Points,
 * Deduction Rules và Rubric Export Modal).
 * Phân tách theo nguyên lý SOLID / SRP / SoC để đảm bảo độ dài file <= 500 dòng.
 */

/* ==========================================================================
   1. BENTO QUESTION CARD & HEADER
   ========================================================================== */
.rubric-question-card {
  background: var(--surface, #ffffff);
  border: 1px solid var(--border-color, #e2e8f0);
  border-radius: 12px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
  padding: 0.75rem 0.9rem;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
  max-width: 100%;
  width: 100%;
  box-sizing: border-box;
  overflow-x: hidden;
  flex-shrink: 0 !important;
  height: auto !important;
  contain: content;
}

.bento-q-card-inner {
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  min-height: min-content;
  max-width: 100%;
  width: 100%;
  box-sizing: border-box;
  overflow-x: hidden;
}

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

[data-theme="dark"] .rubric-question-card {
  background: #1e293b;
  border-color: rgba(255, 255, 255, 0.08);
}

.bento-q-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 0.5rem;
  flex-wrap: wrap;
}

.bento-q-meta-group {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  flex: 1;
  min-width: 180px;
}

.bento-q-meta-group .q-id-input {
  width: 95px;
  font-weight: 800;
  font-size: 0.8rem;
  color: #1e293b;
  flex-shrink: 0;
}

.bento-q-meta-group .q-title-input {
  flex: 1;
  min-width: 0;
  font-size: 0.8rem;
}

.bento-q-score-group {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  flex-shrink: 0;
}

@media (max-width: 600px) {
  .rubric-question-card {
    padding: 0.55rem 0.65rem;
  }
  .bento-q-header {
    flex-direction: column;
    align-items: stretch;
    gap: 0.4rem;
  }
  .bento-q-meta-group {
    width: 100%;
    min-width: 0;
  }
  .bento-q-meta-group .q-id-input {
    width: 80px;
  }
  .bento-q-meta-group .q-title-input {
    flex: 1 1 auto;
    min-width: 0;
  }
  .bento-q-score-group {
    width: 100%;
    justify-content: flex-end;
  }
}
  align-items: center;
  gap: 0.35rem;
}

.bento-q-score-label {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-muted, #64748b);
  margin: 0;
  white-space: nowrap;
}

.bento-q-score-group .q-score-input {
  width: 65px;
  font-weight: 800;
  text-align: center;
  font-size: 0.82rem;
}

/* ==========================================================================
   2. MULTI-METHOD SELECTOR BAR & TABS
   ========================================================================== */
.bento-methods-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.4rem;
  padding: 0.35rem 0;
  border-bottom: 1px dashed var(--border-color, #e2e8f0);
  margin-bottom: 0.5rem;
  flex-wrap: wrap;
}

.bento-methods-tabs {
  display: flex;
  gap: 0.3rem;
  align-items: center;
  flex-wrap: wrap;
}

.bento-alt-method-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.45rem;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  padding: 0.3rem 0.5rem;
  gap: 0.4rem;
}

[data-theme="dark"] .bento-alt-method-toolbar {
  background: #0f172a;
  border-color: rgba(255, 255, 255, 0.08);
}

.bento-alt-field-wrap {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex: 1;
}

.bento-alt-field-wrap label {
  font-size: 0.72rem;
  font-weight: 700;
  color: #4f46e5;
  margin: 0;
  white-space: nowrap;
}

/* ==========================================================================
   3. SUB-STEP MATRIX GRID & ROWS
   ========================================================================== */
.bento-q-body-grid {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  margin-bottom: 0.45rem;
  width: 100%;
  max-width: 100%;
  min-width: 0;
}

@media (min-width: 1280px) {
  .bento-q-body-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
  }
}

.bento-col-criteria, .bento-col-solution {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  background: var(--surface-hover, #f8fafc);
  border: 1px solid var(--border-color, #e2e8f0);
  border-radius: 8px;
  padding: 0.6rem;
  max-width: 100%;
  min-width: 0;
  box-sizing: border-box;
  overflow-x: hidden;
}

[data-theme="dark"] .bento-col-criteria, [data-theme="dark"] .bento-col-solution {
  background: rgba(15, 23, 42, 0.4);
  border-color: rgba(255, 255, 255, 0.06);
}

.bento-col-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.35rem;
  flex-wrap: wrap;
  min-width: 0;
}

.bento-col-title {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.76rem;
  color: var(--text-main, #1e293b);
  flex-wrap: wrap;
  min-width: 0;
}

.bento-col-actions {
  display: flex;
  align-items: center;
  gap: 3px;
  flex-wrap: wrap;
}

.bento-step-balance-tag {
  font-size: 0.68rem;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 9999px;
  white-space: nowrap;
}

.bento-step-balance-tag.valid {
  background: rgba(16, 185, 129, 0.12);
  color: #065f46;
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.bento-step-balance-tag.warning {
  background: rgba(245, 158, 11, 0.12);
  color: #92400e;
  border: 1px solid rgba(245, 158, 11, 0.3);
}

.bento-steps-matrix-container {
  display: flex;
  flex-direction: column;
  gap: 4px;
  cursor: pointer;
}

.bento-steps-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.bento-step-row {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  background: var(--surface, #ffffff);
  border: 1px solid var(--border-color, #e2e8f0);
  border-radius: 6px;
  padding: 0.3rem 0.5rem;
  transition: background 0.15s ease;
  min-width: 0;
  max-width: 100%;
  box-sizing: border-box;
}

.bento-step-row:hover {
  background: #f1f5f9;
}

[data-theme="dark"] .bento-step-row {
  background: #1e293b;
  border-color: rgba(255, 255, 255, 0.08);
}

.bento-step-num {
  font-size: 0.7rem;
  font-weight: 800;
  color: #2563eb;
  background: #eff6ff;
  padding: 1px 5px;
  border-radius: 4px;
  flex-shrink: 0;
}

.bento-step-text {
  font-size: 0.74rem;
  color: var(--text-main, #334155);
  flex: 1;
  line-height: 1.35;
  min-width: 0;
  overflow-wrap: break-word;
  word-break: break-word;
}

.bento-step-score-pill {
  font-size: 0.72rem;
  font-weight: 800;
  color: #065f46;
  background: rgba(16, 185, 129, 0.12);
  padding: 1px 6px;
  border-radius: 9999px;
  flex-shrink: 0;
}

/* ==========================================================================
   4. QUICK POINTS & DEDUCTION RULES
   ========================================================================== */
.bento-quick-points-bar {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 0.4rem;
  flex-wrap: wrap;
}

.quick-points-label {
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--text-muted, #64748b);
  margin-right: 2px;
}

.btn-quick-point {
  font-size: 0.68rem;
  font-weight: 700;
  color: #2563eb;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  border-radius: 4px;
  padding: 2px 6px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-quick-point:hover {
  background: #2563eb;
  color: #ffffff;
}

.bento-deduction-container {
  margin-top: 0.35rem;
}

/* ==========================================================================
   5. RUBRIC EXPORT MODAL & BENTO CARDS
   ========================================================================== */
#modal-rubric-export .modal-content {
  border-radius: 18px;
  box-shadow: 0 25px 50px -12px rgba(15, 23, 42, 0.25);
  border: 1px solid var(--border-color, #e2e8f0);
}

.rubric-export-card-wrap {
  background: var(--surface, #ffffff);
  border: 1.5px solid var(--border-color, #e2e8f0);
  border-radius: var(--radius-md, 10px);
  padding: 0.85rem;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.rubric-export-card-wrap.primary {
  border-color: #bfdbfe;
  background: #f8fafc;
}

.rubric-export-card-wrap.success {
  border-color: #bbf7d0;
  background: #f8fafc;
}

[data-theme="dark"] .rubric-export-card-wrap {
  background: #1e293b;
  border-color: rgba(255, 255, 255, 0.1);
}

[data-theme="dark"] .rubric-export-card-wrap.primary {
  background: rgba(30, 58, 138, 0.15);
  border-color: rgba(59, 130, 246, 0.4);
}

[data-theme="dark"] .rubric-export-card-wrap.success {
  background: rgba(20, 83, 45, 0.15);
  border-color: rgba(34, 197, 94, 0.4);
}

.rubric-format-choice-box {
  margin-top: 0.65rem;
  padding-top: 0.55rem;
  border-top: 1px dashed var(--border-color, #dcfce7);
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.rubric-format-choice-title {
  font-size: 0.74rem;
  font-weight: 700;
  color: #166534;
  display: flex;
  align-items: center;
  gap: 0.3rem;
}

[data-theme="dark"] .rubric-format-choice-title {
  color: #86efac;
}

.rubric-format-choice-options {
  display: flex;
  gap: 1rem;
  align-items: center;
  flex-wrap: wrap;
}

.rubric-format-option {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  cursor: pointer;
  font-size: 0.76rem;
  font-weight: 600;
  color: var(--text-main, #334155);
  margin: 0;
}

.rubric-format-option input[type="radio"] {
  accent-color: #16a34a;
  cursor: pointer;
}

/* ==========================================================================
   5. UNIFIED STUDIO MULTI-VARIANT RIBBON & AI INTELLIGENCE MENU
   ========================================================================== */
.studio-variant-ribbon-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.45rem 0.65rem;
  background: var(--surface-card, #ffffff);
  border: 1px solid var(--border-color, #e2e8f0);
  border-radius: var(--radius-md, 10px);
  margin-bottom: 0.45rem;
}

[data-theme="dark"] .studio-variant-ribbon-bar {
  background: #1e293b;
  border-color: #334155;
}

.studio-variant-chips-scroll {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  overflow-x: auto;
  scrollbar-width: thin;
  padding: 2px 0;
  flex: 1;
}

.studio-variant-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.35rem 0.65rem;
  background: var(--surface-hover, #f1f5f9);
  border: 1.5px solid var(--border-color, #cbd5e1);
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.18s ease;
  white-space: nowrap;
}

.studio-variant-chip:hover {
  background: #e2e8f0;
  border-color: #94a3b8;
}

.studio-variant-chip.active {
  background: #eff6ff;
  border-color: #3b82f6;
  box-shadow: 0 0 0 1px #3b82f6;
}

[data-theme="dark"] .studio-variant-chip {
  background: #334155;
  border-color: #475569;
}

[data-theme="dark"] .studio-variant-chip.active {
  background: rgba(59, 130, 246, 0.2);
  border-color: #60a5fa;
}

.chip-code-title {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text-main, #1e293b);
}

.studio-variant-chip.active .chip-code-title {
  color: #1d4ed8;
}

[data-theme="dark"] .studio-variant-chip.active .chip-code-title {
  color: #93c5fd;
}

.chip-badge-counts {
  font-size: 0.68rem;
  padding: 0.1rem 0.4rem;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.06);
  color: var(--text-muted, #64748b);
  font-weight: 600;
}

.studio-variant-chip.active .chip-badge-counts {
  background: #dbeafe;
  color: #1e40af;
}

[data-theme="dark"] .studio-variant-chip.active .chip-badge-counts {
  background: #1e3a8a;
  color: #bfdbfe;
}

.studio-variant-ribbon-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
}

.studio-ai-menu-dropdown-wrapper {
  position: relative;
}

.btn-studio-ai-menu-toggle {
  font-weight: 700 !important;
  display: inline-flex !important;
  align-items: center !important;
  gap: 0.35rem !important;
  background: #f0fdf4 !important;
  color: #166534 !important;
  border: 1px solid #86efac !important;
  border-radius: 6px !important;
  padding: 0.25rem 0.6rem !important;
}

[data-theme="dark"] .btn-studio-ai-menu-toggle {
  background: rgba(22, 101, 52, 0.25) !important;
  color: #86efac !important;
  border-color: #166534 !important;
}

.studio-ai-menu-popover {
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  background: var(--surface-card, #ffffff);
  border: 1px solid var(--border-color, #e2e8f0);
  border-radius: 10px;
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.15);
  padding: 0.4rem;
  z-index: 100;
  min-width: 260px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

[data-theme="dark"] .studio-ai-menu-popover {
  background: #1e293b;
  border-color: #334155;
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.5);
}

.studio-ai-menu-item {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  padding: 0.5rem 0.65rem;
  border: none;
  background: transparent;
  border-radius: 6px;
  cursor: pointer;
  text-align: left;
  transition: background 0.15s ease;
  width: 100%;
}

.studio-ai-menu-item:hover {
  background: var(--surface-hover, #f1f5f9);
}

[data-theme="dark"] .studio-ai-menu-item:hover {
  background: #334155;
}

.studio-ai-menu-item .item-text-group {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.studio-ai-menu-item .item-title {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text-main, #1e293b);
}

.studio-ai-menu-item .item-desc {
  font-size: 0.68rem;
  color: var(--text-muted, #64748b);
  line-height: 1.3;
}

/* ==========================================================================
   6. MOBILE COMPACT DOCK & SUMMARY PANE
   ========================================================================== */
.rubric-mobile-sticky-dock {
  display: none;
  align-items: center;
  justify-content: space-between;
  padding: 0.35rem 0.5rem;
  background: var(--surface-card, #ffffff);
  border: 1px solid var(--border-color, #e2e8f0);
  border-radius: 8px;
  margin-bottom: 0.35rem;
  gap: 0.5rem;
}

[data-theme="dark"] .rubric-mobile-sticky-dock {
  background: #1e293b;
  border-color: #334155;
}

.mobile-dock-left {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.mobile-dock-score-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.2rem 0.5rem;
  font-size: 0.74rem;
  font-weight: 800;
  border-radius: 999px;
  border: 1px solid #10b981;
  background: rgba(16, 185, 129, 0.1);
  color: #065f46;
}

.rubric-mobile-summary-pane {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding: 0.5rem 0.25rem;
}

.mobile-summary-card {
  background: var(--surface-card, #ffffff);
  border: 1px solid var(--border-color, #e2e8f0);
  border-radius: 10px;
  padding: 0.75rem;
}

[data-theme="dark"] .mobile-summary-card {
  background: #1e293b;
  border-color: #334155;
}

.mobile-summary-card-title {
  font-size: 0.85rem;
  font-weight: 800;
  margin: 0 0 0.5rem 0;
  color: var(--text-main, #1e293b);
}

.mobile-balance-card {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: 0.6rem;
  background: #f8fafc;
  border-radius: 8px;
}

[data-theme="dark"] .mobile-balance-card {
  background: #0f172a;
}

.mobile-score-progress-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.mobile-ai-control-group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

/* ==========================================================================
   7. RUBRIC STUDIO & COMPACT ASSESSMENT RESPONSIVE OVERRIDES
   ========================================================================== */
.rubric-title-short, .btn-text-short, .header-text-short { display: none !important; }
@media (max-width: 768px) {
  .rubric-title-full, .btn-text-full, .header-text-full { display: none !important; }
  .rubric-title-short, .btn-text-short, .header-text-short { display: inline !important; }
}
.rubric-bento-body, .rubric-studio-body, .rubric-bento-left-pane, .rubric-bento-right-pane,
.rubric-studio-left, .rubric-studio-right { min-width: 0 !important; overflow-x: hidden !important; box-sizing: border-box !important; }
.rubric-q-cards-scroller { overflow-x: hidden !important; overflow-y: auto !important; width: 100% !important; max-width: 100% !important; box-sizing: border-box !important; }
.rubric-question-card { max-width: 100% !important; width: 100% !important; box-sizing: border-box !important; overflow-x: hidden !important; height: auto !important; min-height: min-content !important; flex-shrink: 0 !important; }
.bento-q-card-inner { display: flex !important; flex-direction: column !important; flex-shrink: 0 !important; min-height: min-content !important; max-width: 100% !important; width: 100% !important; box-sizing: border-box !important; overflow-x: hidden !important; }
@media (max-width: 1200px) {
  .bento-q-body-grid, .rubric-q-detail { display: flex !important; flex-direction: column !important; gap: 0.65rem !important; width: 100% !important; max-width: 100% !important; }
}
.bento-col-criteria, .bento-col-solution { max-width: 100% !important; min-width: 0 !important; box-sizing: border-box !important; overflow-x: hidden !important; }
.bento-col-header, .bento-col-title, .bento-col-actions { flex-wrap: wrap !important; min-width: 0 !important; }
.bento-step-row { min-width: 0 !important; max-width: 100% !important; box-sizing: border-box !important; }
.bento-step-text { min-width: 0 !important; overflow-wrap: break-word !important; word-break: break-word !important; }
.rubric-math-box, .rubric-criteria-math-box-wrap, .rubric-solution-math-box-wrap, .rubric-live-math-preview { max-width: 100% !important; overflow-x: auto !important; box-sizing: border-box !important; }
.bento-quick-points-bar { flex-wrap: wrap !important; max-width: 100% !important; }
@media (max-width: 600px) {
  .bento-q-header { display: flex !important; flex-direction: column !important; align-items: stretch !important; gap: 0.4rem !important; }
  .bento-q-meta-group { width: 100% !important; min-width: 0 !important; }
  .bento-q-meta-group .q-id-input { width: 80px !important; flex-shrink: 0 !important; }
  .bento-q-meta-group .q-title-input { flex: 1 1 auto !important; min-width: 0 !important; width: auto !important; }
  .bento-q-score-group { width: 100% !important; justify-content: flex-end !important; }
}
.compact-assessment-bar, #exam-detail-hero-bar, .assessment-main-row { height: auto !important; min-height: 0 !important; }
.assessment-identity-group, .xd-id { height: auto !important; min-width: 0 !important; flex: 1 1 auto !important; max-width: 100% !important; }
@media (max-width: 900px) {
  .assessment-main-row { flex-direction: column !important; align-items: stretch !important; gap: 0.65rem !important; }
  .assessment-identity-group { flex: 0 0 auto !important; width: 100% !important; }
  .assessment-actions-group .actions { display: flex !important; flex-wrap: wrap !important; gap: 6px !important; width: 100% !important; overflow: visible !important; }
}
@media (max-width: 600px) {
  .assessment-actions-group .actions .btn-primary { flex: 1 1 calc(50% - 6px) !important; min-width: 130px !important; justify-content: center !important; }
  .assessment-actions-group .actions .btn-secondary, .assessment-actions-group .actions .btn-outline-indigo { flex: 0 0 auto !important; }
  .assessment-actions-group .actions .assessment-more-dropdown { display: inline-flex !important; }
}

