/**
 * ============================================================================
 * BENTO EXAM VARIANTS & RESPONSIVE ACTION RIBBON STYLES
 * ============================================================================
 * Architectural Layer: Presentation / Styling
 * Principles: SOLID (SRP), SoC, Bento Neo-Minimalism, Mobile First (320px - 1440px)
 * Ceilings: <= 800 lines strictly enforced.
 */

/* --- 1. Primary Action Bar: Add Variant Action Button --- */
.btn-add-variant-action {
  display: inline-flex !important;
  align-items: center !important;
  gap: 0.35rem !important;
  font-size: 0.8rem !important;
  font-weight: 700 !important;
  color: #082850 !important;
  background: #ecfeff !important;
  border: 1px solid #a5f3fc !important;
  border-radius: var(--bento-radius-pill, 9999px) !important;
  padding: 0.35rem 0.8rem !important;
  cursor: pointer !important;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1) !important;
  white-space: nowrap !important;
}

.btn-add-variant-action:hover {
  background: #cffafe !important;
  border-color: #00c5df !important;
  color: #082850 !important;
  transform: translateY(-1px);
  box-shadow: 0 3px 10px rgba(0, 197, 223, 0.25) !important;
}

.btn-add-variant-action:active {
  transform: translateY(0);
}

[data-theme="dark"] .btn-add-variant-action,
body.dark-mode .btn-add-variant-action {
  background: rgba(0, 197, 223, 0.15) !important;
  border-color: rgba(0, 197, 223, 0.4) !important;
  color: #67e8f9 !important;
}

[data-theme="dark"] .btn-add-variant-action:hover,
body.dark-mode .btn-add-variant-action:hover {
  background: rgba(0, 197, 223, 0.28) !important;
  border-color: #00c5df !important;
  color: #ecfeff !important;
}

/* --- 2. Variant Selector Bar: Tab Button (+ Thêm mã đề) --- */
.v-tab.v-tab-add {
  background: #ecfeff !important;
  border: 1.5px dashed #00c5df !important;
  color: #082850 !important;
  font-weight: 700 !important;
  font-size: 0.76rem !important;
  display: inline-flex !important;
  align-items: center !important;
  gap: 0.35rem !important;
  padding: 0.25rem 0.65rem !important;
  border-radius: var(--bento-radius-pill, 9999px) !important;
  cursor: pointer !important;
  transition: all 0.18s ease !important;
  white-space: nowrap !important;
}

.v-tab.v-tab-add:hover {
  background: #cffafe !important;
  border-color: #00b4d8 !important;
  border-style: solid !important;
  color: #082850 !important;
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(0, 197, 223, 0.25) !important;
}

.v-tab.v-tab-add:active {
  transform: translateY(0);
}

[data-theme="dark"] .v-tab.v-tab-add,
body.dark-mode .v-tab.v-tab-add {
  background: rgba(0, 197, 223, 0.12) !important;
  border-color: rgba(0, 197, 223, 0.4) !important;
  color: #67e8f9 !important;
}

/* --- 3. Mobile Assessment Bar & Actions Ribbon (<= 768px) --- */
@media (max-width: 768px) {
  .compact-assessment-bar {
    padding: 0.75rem 0.95rem !important;
    gap: 0.65rem !important;
    height: auto !important;
    min-height: 0 !important;
  }

  .assessment-main-row {
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 0.65rem !important;
    height: auto !important;
    min-height: 0 !important;
  }

  .assessment-identity-group {
    width: 100% !important;
    justify-content: flex-start !important;
    flex-wrap: wrap !important;
    gap: 0.45rem !important;
    flex: 0 0 auto !important;
    height: auto !important;
    min-height: 0 !important;
  }

  .compact-assessment-title {
    font-size: 1rem !important;
  }

  /* Clean wrap action buttons on mobile: zero horizontal scrolling or clipping */
  .assessment-actions-group {
    width: 100% !important;
    display: flex !important;
    flex-wrap: wrap !important;
    overflow-x: visible !important;
    gap: 0.45rem !important;
    margin-left: 0 !important;
    padding: 2px 0 4px 0 !important;
  }

  .assessment-actions-group::-webkit-scrollbar {
    display: none !important;
  }

  .assessment-actions-group .btn,
  .assessment-actions-group button {
    flex: 0 0 auto !important;
    min-height: 34px !important;
    padding: 0.3rem 0.65rem !important;
    font-size: 0.76rem !important;
    border-radius: var(--bento-radius-pill, 9999px) !important;
    justify-content: center !important;
    white-space: nowrap !important;
  }

  .assessment-actions-group #btn-submit-exam-work {
    order: 0 !important;
    flex-basis: auto !important;
  }

  .assessment-more-dropdown {
    flex: 0 0 auto !important;
  }

  /* Safe positioning for popover on mobile: prevents off-screen clipping */
  .assessment-more-popover {
    left: auto !important;
    right: 0 !important;
    width: 240px !important;
    max-width: min(280px, calc(100vw - 1.5rem)) !important;
  }

  /* Sub Row & Filter Tabs on Mobile */
  .assessment-sub-row {
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 0.45rem !important;
    padding-top: 0.35rem !important;
  }

  .assessment-meta-pill {
    width: 100% !important;
    flex-wrap: wrap !important;
    border-radius: 10px !important;
    padding: 0.3rem 0.55rem !important;
    font-size: 0.72rem !important;
    line-height: 1.4 !important;
  }

  .studio-sub-controls {
    width: 100% !important;
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 0.45rem !important;
  }

  .studio-mode-pills {
    width: 100% !important;
    display: grid !important;
    grid-template-columns: 1fr 1fr !important;
    gap: 4px !important;
    padding: 3px !important;
    background: var(--bento-surface-subtle, #f1f5f9) !important;
    border-radius: 12px !important;
  }

  .variant-filter-wrap {
    width: 100% !important;
    display: flex !important;
    flex-wrap: wrap !important;
    align-items: center !important;
    overflow-x: visible !important;
    gap: 0.4rem !important;
    padding: 1px 0 !important;
  }

  .variant-filter-wrap::-webkit-scrollbar {
    display: none !important;
  }

  .variant-tab-group {
    display: flex !important;
    flex-wrap: wrap !important;
    gap: 0.35rem !important;
    overflow-x: visible !important;
  }

  .variant-tab-group .v-tab {
    flex-shrink: 0 !important;
    min-height: 32px !important;
    padding: 0.25rem 0.6rem !important;
    font-size: 0.74rem !important;
  }
}

/* --- 4. SPEEDGRADER CANVAS CONTROLS STREAMLINING (<= 768px) --- */
@media (max-width: 768px) {
  .speedgrader-canvas-toolbar {
    padding: 0.4rem 0.65rem !important;
    gap: 0.35rem !important;
    flex-direction: column !important;
    align-items: stretch !important;
    background: var(--bento-surface, #ffffff) !important;
    border-bottom: 1px solid var(--bento-border, #e2e8f0) !important;
  }

  /* Row 1: Student Title & Layer Select */
  .sg-toolbar-identity {
    width: 100% !important;
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    gap: 0.4rem !important;
  }

  .sg-student-title-text {
    max-width: 190px !important;
    font-size: 0.8rem !important;
    font-weight: 700 !important;
  }

  .sg-page-indicator-pill {
    font-size: 0.7rem !important;
    padding: 0.15rem 0.45rem !important;
  }

  /* Row 2: Unified Single-Line Sleek Controls Ribbon */
  .speedgrader-canvas-toolbar > div.sg-toolbar-controls-cluster,
  .speedgrader-canvas-toolbar .sg-toolbar-controls-cluster,
  div.sg-toolbar-controls-cluster {
    width: 100% !important;
    display: flex !important;
    flex-wrap: nowrap !important;
    align-items: center !important;
    justify-content: space-between !important;
    overflow-x: auto !important;
    scrollbar-width: none !important;
    -webkit-overflow-scrolling: touch !important;
    gap: 0.35rem !important;
    padding: 2px 0 !important;
  }

  .speedgrader-canvas-toolbar .sg-toolbar-controls-cluster::-webkit-scrollbar,
  .sg-toolbar-controls-cluster::-webkit-scrollbar {
    display: none !important;
  }

  .speedgrader-canvas-toolbar select.sg-select-layer,
  .sg-select-layer {
    min-height: 28px !important;
    height: 28px !important;
    border-radius: var(--bento-radius-pill, 9999px) !important;
    max-width: none !important;
    width: auto !important;
    flex-shrink: 0 !important;
  }

  /* Segmented Control Pills */
  .speedgrader-canvas-toolbar .sg-ctrl-group,
  .sg-ctrl-group {
    display: inline-flex !important;
    flex-wrap: nowrap !important;
    align-items: center !important;
    background: var(--bento-surface-subtle, #f1f5f9) !important;
    border: 1px solid var(--bento-border, #e2e8f0) !important;
    border-radius: var(--bento-radius-pill, 9999px) !important;
    padding: 1px !important;
    gap: 1px !important;
    flex-shrink: 0 !important;
  }

  .speedgrader-canvas-toolbar .sg-ctrl-group button,
  .speedgrader-canvas-toolbar .sg-ctrl-group .btn,
  .speedgrader-canvas-toolbar .sg-ctrl-group .sg-btn-icon,
  .sg-ctrl-group button,
  .sg-ctrl-group .btn,
  .sg-ctrl-group .sg-btn-icon {
    min-width: 28px !important;
    height: 26px !important;
    padding: 0 0.35rem !important;
    border: none !important;
    background: transparent !important;
    border-radius: 9999px !important;
    font-size: 0.72rem !important;
    color: var(--bento-text-body, #334155) !important;
    box-shadow: none !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
  }

  .speedgrader-canvas-toolbar .sg-ctrl-group button:active,
  .speedgrader-canvas-toolbar .sg-ctrl-group button:hover,
  .speedgrader-canvas-toolbar .sg-ctrl-group .btn:active,
  .speedgrader-canvas-toolbar .sg-ctrl-group .btn:hover {
    background: var(--bento-surface, #ffffff) !important;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1) !important;
    color: var(--bento-accent-primary, #00c5df) !important;
  }

  /* Long labels hidden inside action icons on mobile */
  .sg-btn-label {
    display: none !important;
  }

  /* Interactive Page Switcher Tabs Ribbon */
  .sg-page-tabs-bar {
    display: flex !important;
    flex-wrap: nowrap !important;
    overflow-x: auto !important;
    scrollbar-width: none !important;
    -webkit-overflow-scrolling: touch !important;
    gap: 0.35rem !important;
    padding: 0.35rem 0.5rem !important;
  }

  .sg-page-tabs-bar::-webkit-scrollbar {
    display: none !important;
  }

  .sg-page-tab-btn {
    flex-shrink: 0 !important;
    white-space: nowrap !important;
    font-size: 0.74rem !important;
    padding: 0.25rem 0.6rem !important;
  }
}

/* --- 5. Stacking Context & Responsive Adaptations for Add Variant Modal --- */
#modal-add-variant {
  z-index: 10090 !important;
}

@media (max-width: 640px) {
  #modal-add-variant .modal-content {
    margin: 0.5rem !important;
    padding: 1rem !important;
    max-height: 94vh !important;
  }

  #modal-add-variant form > div[style*="grid-template-columns: 1fr 2fr"],
  #modal-add-variant .form-code-title-grid {
    grid-template-columns: 1fr !important;
    gap: 0.65rem !important;
  }

  #modal-add-variant .dual-upload-grid {
    grid-template-columns: 1fr !important;
    gap: 0.75rem !important;
  }

  #modal-add-variant .upload-field-card {
    padding: 0.85rem !important;
  }
}

/* ====================================================================
   6. BACKGROUND PROCESSING BANNER & STATUS BADGES (APPLE-GRADE HUD)
   ==================================================================== */
.exam-background-processing-banner {
  margin-bottom: 1rem;
  padding: 0.85rem 1.15rem;
  border-radius: var(--radius-md, 12px);
  border: 1.5px solid rgba(129, 140, 248, 0.4);
  background: linear-gradient(135deg, rgba(238, 242, 255, 0.95) 0%, rgba(245, 243, 255, 0.95) 100%);
  box-shadow: 0 4px 16px rgba(99, 102, 241, 0.08);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  transition: all 0.3s ease;
}

.exam-background-processing-banner.status-ready {
  border-color: rgba(52, 211, 153, 0.45);
  background: linear-gradient(135deg, rgba(236, 253, 245, 0.95) 0%, rgba(240, 253, 250, 0.95) 100%);
  box-shadow: 0 4px 16px rgba(16, 185, 129, 0.08);
}

.exam-bg-banner-content {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  flex: 1;
}

.exam-bg-banner-icon-wrapper {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.exam-bg-banner-icon {
  font-size: 1.35rem;
  line-height: 1;
  display: inline-block;
  animation: pulseBgIcon 2s infinite ease-in-out;
}

@keyframes pulseBgIcon {
  0%, 100% { transform: scale(1); opacity: 0.9; }
  50% { transform: scale(1.15); opacity: 1; }
}

.exam-bg-banner-text-group {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.exam-bg-banner-title-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.exam-bg-banner-title {
  font-size: 0.9rem;
  font-weight: 700;
  color: #3730a3;
  line-height: 1.3;
}

.exam-background-processing-banner.status-ready .exam-bg-banner-title {
  color: #065f46;
}

.exam-bg-banner-tag {
  font-size: 0.7rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  line-height: 1.2;
}

.exam-bg-banner-tag.badge-processing {
  background: #e0e7ff;
  color: #4338ca;
  border: 1px solid #c7d2fe;
}

.exam-bg-banner-tag.badge-ready {
  background: #d1fae5;
  color: #047857;
  border: 1px solid #a7f3d0;
}

.exam-bg-banner-desc {
  font-size: 0.8rem;
  color: #4b5563;
  line-height: 1.4;
}

.exam-bg-banner-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
}

.btn-bg-banner-dismiss {
  background: transparent;
  border: none;
  font-size: 1rem;
  color: #9ca3af;
  cursor: pointer;
  padding: 0.25rem 0.45rem;
  border-radius: var(--radius-sm, 6px);
  transition: all 0.15s ease;
  line-height: 1;
}

.btn-bg-banner-dismiss:hover {
  color: #374151;
  background: rgba(0, 0, 0, 0.05);
}

/* Header status capsule badge */
.badge-status-capsule {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
  margin-left: 0.4rem;
  vertical-align: middle;
  transition: all 0.2s ease;
}

.badge-status-capsule.badge-processing {
  background: #e0e7ff;
  color: #4338ca;
  border: 1px solid #c7d2fe;
  animation: subtlePulse 2s infinite ease-in-out;
}

.badge-status-capsule.badge-ready {
  background: #ecfdf5;
  color: #047857;
  border: 1px solid #a7f3d0;
}

@keyframes subtlePulse {
  0%, 100% { opacity: 0.95; }
  50% { opacity: 0.65; }
}

/* Rubric Button Micro Status Dot */
.micro-status-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  margin-left: 4px;
  vertical-align: middle;
}

.micro-status-dot.dot-processing {
  background-color: #f59e0b;
  box-shadow: 0 0 0 2px rgba(245, 158, 11, 0.25);
  animation: pulseDot 1.5s infinite;
}

.micro-status-dot.dot-ready {
  background-color: #10b981;
}

@keyframes pulseDot {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.3); opacity: 0.7; }
}

/* Responsive Mobile Adaptations */
@media (max-width: 640px) {
  .exam-background-processing-banner {
    flex-direction: column;
    align-items: flex-start;
    padding: 0.75rem 0.9rem;
    gap: 0.75rem;
  }

  .exam-bg-banner-actions {
    width: 100%;
    justify-content: flex-end;
  }
}

/* --- Rubric Studio Audit Alert Banner (Neo-Bento & Ergonomics) --- */
.rubric-studio-audit-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.85rem;
  padding: 0.85rem 1.15rem;
  margin-bottom: 0.75rem;
  border-radius: 10px;
  border: 1.5px solid #fca5a5;
  background: #fff5f5;
  box-shadow: 0 1px 3px rgba(220, 38, 38, 0.06);
  flex-wrap: wrap;
  transition: all 0.2s ease;
}

.rubric-audit-banner-left {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  flex: 1 1 480px;
}

.rubric-audit-banner-icon {
  font-size: 1.35rem;
  line-height: 1;
  flex-shrink: 0;
  margin-top: 2px;
}

.rubric-audit-banner-content {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.rubric-audit-banner-title {
  font-size: 0.88rem;
  font-weight: 800;
  color: #991b1b;
  line-height: 1.35;
}

.rubric-audit-banner-desc {
  font-size: 0.8rem;
  color: #b91c1c;
  line-height: 1.45;
}

.rubric-audit-banner-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  flex-shrink: 0;
}

.btn-rubric-audit-report {
  color: #991b1b !important;
  border-color: #fca5a5 !important;
  background: #ffffff !important;
  font-weight: 700 !important;
  font-size: 0.78rem !important;
  padding: 0.35rem 0.75rem !important;
  border-radius: 6px !important;
  transition: all 0.15s ease !important;
}

.btn-rubric-audit-report:hover {
  background: #fee2e2 !important;
  border-color: #f87171 !important;
  color: #7f1d1d !important;
}

.btn-rubric-audit-edit {
  font-weight: 700 !important;
  font-size: 0.78rem !important;
  padding: 0.35rem 0.75rem !important;
  border-radius: 6px !important;
  background: #dc2626 !important;
  border-color: #dc2626 !important;
  color: #ffffff !important;
  transition: all 0.15s ease !important;
}

.btn-rubric-audit-edit:hover {
  background: #b91c1c !important;
  border-color: #b91c1c !important;
}

/* Studio Chip Audit Badge */
.studio-chip-audit-badge {
  display: inline-flex;
  align-items: center;
  background: #fee2e2;
  color: #b91c1c;
  border: 1px solid #fca5a5;
  font-size: 0.68rem;
  padding: 1px 5px;
  border-radius: 4px;
  font-weight: 700;
  margin-left: 4px;
  line-height: 1.2;
}

/* Dark Mode Support */
[data-theme="dark"] .rubric-studio-audit-banner,
body.dark-mode .rubric-studio-audit-banner {
  background: rgba(220, 38, 38, 0.12);
  border-color: rgba(239, 68, 68, 0.35);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.25);
}

[data-theme="dark"] .rubric-audit-banner-title,
body.dark-mode .rubric-audit-banner-title {
  color: #fca5a5;
}

[data-theme="dark"] .rubric-audit-banner-desc,
body.dark-mode .rubric-audit-banner-desc {
  color: #f87171;
}

[data-theme="dark"] .btn-rubric-audit-report,
body.dark-mode .btn-rubric-audit-report {
  background: rgba(30, 41, 59, 0.85) !important;
  border-color: rgba(239, 68, 68, 0.45) !important;
  color: #fca5a5 !important;
}

[data-theme="dark"] .btn-rubric-audit-report:hover,
body.dark-mode .btn-rubric-audit-report:hover {
  background: rgba(239, 68, 68, 0.25) !important;
  color: #ffffff !important;
}

[data-theme="dark"] .studio-chip-audit-badge,
body.dark-mode .studio-chip-audit-badge {
  background: rgba(239, 68, 68, 0.2) !important;
  color: #fca5a5 !important;
  border-color: rgba(239, 68, 68, 0.4) !important;
}

/* Responsive Adaptations for Tablet & Mobile (<= 1024px and <= 768px) */
@media (max-width: 1024px) {
  .rubric-studio-audit-banner {
    padding: 0.75rem 1rem;
    gap: 0.75rem;
  }
}

@media (max-width: 768px) {
  .rubric-studio-audit-banner {
    flex-direction: column !important; align-items: stretch !important;
    padding: 0.45rem 0.65rem !important; gap: 0.4rem !important;
    margin-bottom: 0.35rem !important; flex-shrink: 0 !important;
  }
  .rubric-audit-banner-left { flex: 0 0 auto !important; gap: 0.45rem !important; }
  .rubric-audit-banner-icon { font-size: 1.1rem !important; margin-top: 1px !important; }
  .rubric-audit-banner-title { font-size: 0.82rem !important; line-height: 1.3 !important; }
  .rubric-audit-banner-desc {
    font-size: 0.75rem !important; line-height: 1.35 !important;
    display: -webkit-box !important; -webkit-line-clamp: 2 !important;
    -webkit-box-orient: vertical !important; overflow: hidden !important; text-overflow: ellipsis !important;
  }
  .rubric-audit-banner-actions { width: 100% !important; display: flex !important; gap: 0.4rem !important; flex-direction: row !important; }
  .btn-rubric-audit-report, .btn-rubric-audit-edit {
    flex: 1 1 0 !important; text-align: center !important; justify-content: center !important;
    min-height: 30px !important; padding: 0.25rem 0.4rem !important; font-size: 0.72rem !important; white-space: nowrap !important;
  }
}

@media (max-width: 480px) {
  .rubric-audit-banner-actions { flex-direction: row !important; gap: 0.35rem !important; }
  .btn-rubric-audit-report, .btn-rubric-audit-edit { width: auto !important; flex: 1 1 0 !important; min-height: 28px !important; font-size: 0.7rem !important; }
}

/* Highlight pulse for Question Editor scroll target */
@keyframes highlightEditorPulse {
  0% { box-shadow: 0 0 0 0 rgba(0, 197, 223, 0.6); }
  50% { box-shadow: 0 0 0 8px rgba(0, 197, 223, 0.2); }
  100% { box-shadow: 0 0 0 0 rgba(0, 197, 223, 0); }
}

.highlight-pulse {
  animation: highlightEditorPulse 1.2s ease-in-out 2;
  border-radius: 8px;
}

