/* ==========================================================================
   AUTOGRADING - BENTO MATH STUDIOS (OCR & VISUAL GEOMETRY)
   Neo-Minimalism Ergonomic Workspace for Digitization & 3D Geometry
   Strictly <= 500 LOC, Separation of Concerns
   ========================================================================== */

/* 3-Column Bento Studio Layout */
.math-studio-3col-layout,
.math-ocr-bento-layout,
.math-visual-bento-layout {
  display: grid;
  grid-template-columns: 340px 1fr 360px;
  gap: 1.15rem;
  align-items: stretch;
  min-height: calc(100vh - 180px);
}

/* Base Studio Tile Primitives */
.math-studio-tile {
  background: var(--bento-surface);
  border: 1px solid var(--bento-border);
  border-radius: var(--bento-radius-card);
  box-shadow: var(--bento-shadow-flat);
  display: flex;
  flex-direction: column;
  padding: 1.25rem;
  gap: 0.85rem;
  position: relative;
  overflow: hidden;
  transition: var(--bento-transition);
}

.math-studio-tile::before {
  content: "";
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 1px;
  background: var(--bento-inner-highlight);
  pointer-events: none;
}

.math-studio-tile-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--bento-border);
  padding-bottom: 0.65rem;
}

.math-studio-tile-title {
  font-size: 0.95rem;
  font-weight: 800;
  color: var(--bento-text-title);
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

/* ==========================================================================
   1. MATH OCR & BAREM DIGITIZATION STUDIO
   ========================================================================== */

/* Circular OCR Progress Gauge */
.ocr-progress-circular-gauge {
  width: 90px;
  height: 90px;
  border-radius: 50%;
  background: conic-gradient(var(--bento-accent-primary) 0% 100%, var(--bento-surface-subtle) 100% 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto;
  position: relative;
  box-shadow: 0 4px 14px rgba(37, 99, 235, 0.2);
}

.ocr-progress-circular-inner {
  width: 72px;
  height: 72px;
  background: var(--bento-surface);
  border-radius: 50%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-family: "Plus Jakarta Sans", sans-serif;
  font-weight: 800;
  font-size: 0.95rem;
  color: var(--bento-text-title);
}

.ocr-progress-sub {
  font-size: 0.62rem;
  text-transform: uppercase;
  color: var(--bento-text-muted);
}

/* KaTeX Formula Preview Card */
.katex-preview-container {
  background: var(--bento-surface-subtle);
  border: 1px solid var(--bento-border);
  border-radius: var(--bento-radius-tile);
  padding: 1rem;
  overflow-x: auto;
  font-size: 1rem;
  color: var(--bento-text-title);
  min-height: 120px;
}

/* Rubric Question Tile in OCR */
.ocr-rubric-question-tile {
  background: var(--bento-surface);
  border: 1px solid var(--bento-border);
  border-radius: var(--bento-radius-tile);
  padding: 0.85rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  transition: var(--bento-transition);
}

.ocr-rubric-question-tile:hover {
  border-color: var(--bento-border-hover);
  box-shadow: var(--bento-shadow-hover);
}

.ocr-rubric-badge-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.ocr-rubric-pts-badge {
  font-family: monospace;
  font-weight: 800;
  font-size: 0.82rem;
  padding: 0.2rem 0.5rem;
  border-radius: var(--bento-radius-pill);
}

.ocr-rubric-pts-badge.pts-blue { background: var(--bento-accent-primary-light); border: 1px solid var(--bento-accent-primary-border); color: var(--bento-accent-primary); }
.ocr-rubric-pts-badge.pts-amber { background: var(--bento-accent-amber-light); border: 1px solid var(--bento-accent-amber-border); color: var(--bento-accent-amber); }
.ocr-rubric-pts-badge.pts-emerald { background: var(--bento-accent-emerald-light); border: 1px solid var(--bento-accent-emerald-border); color: var(--bento-accent-emerald); }

/* Tactile Weight Slider */
.bento-weight-slider {
  width: 100%;
  accent-color: var(--bento-accent-primary);
  height: 6px;
  cursor: pointer;
}

/* ==========================================================================
   2. MATH VISUAL 3D GEOMETRY STUDIO
   ========================================================================== */

/* Three.js 3D Viewport Tile */
.math-visual-canvas-tile {
  background: var(--bento-surface);
  border: 1px solid var(--bento-border);
  border-radius: var(--bento-radius-card);
  box-shadow: var(--bento-shadow-flat);
  position: relative;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.math-visual-canvas-toolbar {
  padding: 0.65rem 1rem;
  background: var(--bento-surface-subtle);
  border-bottom: 1px solid var(--bento-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.math-visual-canvas-viewport {
  flex: 1;
  background: var(--bento-canvas-bg);
  position: relative;
  min-height: 480px;
}

.math-visual-canvas-viewport canvas {
  width: 100% !important;
  height: 100% !important;
  display: block;
}

/* Interactive Bento Sliders in Control Panel */
.bento-slider-row {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.bento-slider-label {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--bento-text-title);
  display: flex;
  justify-content: space-between;
}

.bento-toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.4rem 0;
  border-bottom: 1px solid var(--bento-border);
  font-size: 0.82rem;
  color: var(--bento-text-body);
}

/* Responsive 3-Column Studios */
@media (max-width: 1200px) {
  .math-studio-3col-layout,
  .math-ocr-bento-layout,
  .math-visual-bento-layout {
    grid-template-columns: 1fr;
    gap: 1rem;
  }
}

/* ==========================================================================
   STUDIO SEGMENTED TABS (BENTO / APPLE SEGMENTED CONTROL)
   Ergonomic Mode Selector for Assessment Studio (Audit, Rubric, Digitization)
   ========================================================================== */
.studio-segmented-tabs-wrapper {
  width: 100%;
  margin: 0.85rem 0 1.25rem 0;
  display: flex;
  align-items: center;
  overflow: visible;
}

.studio-segmented-tabs {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px;
  background: rgba(241, 245, 249, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(226, 232, 240, 0.9);
  border-radius: 980px;
  box-shadow: inset 0 1px 2px rgba(15, 23, 42, 0.04), 0 1px 2px rgba(0, 0, 0, 0.02);
  position: relative;
  max-width: 100%;
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.studio-seg-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 18px;
  min-height: 42px;
  border-radius: 980px;
  border: 1px solid transparent;
  background: transparent;
  color: #475569;
  font-family: inherit;
  font-size: 0.86rem;
  font-weight: 550;
  letter-spacing: -0.01em;
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  text-decoration: none;
  position: relative;
  outline: none;
}

.studio-seg-btn .seg-icon-box,
.studio-seg-btn .seg-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.05rem;
  line-height: 1;
  transition: transform 0.2s ease;
}

.studio-seg-btn .seg-label {
  display: inline-block;
  line-height: 1.25;
}

/* Hover state on inactive tabs */
.studio-seg-btn:hover:not(.active) {
  color: #0f172a;
  background: rgba(255, 255, 255, 0.7);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

.studio-seg-btn:hover:not(.active) .seg-icon-box,
.studio-seg-btn:hover:not(.active) .seg-icon {
  transform: scale(1.1);
}

/* Active Floating Pill (Apple & Bento Elegance) */
.studio-seg-btn.active,
.studio-seg-btn[aria-selected="true"] {
  background: #ffffff;
  color: #0284c7;
  font-weight: 650;
  border-color: rgba(2, 132, 199, 0.18);
  box-shadow: 0 4px 12px -2px rgba(2, 132, 199, 0.12), 0 2px 4px rgba(0, 0, 0, 0.04);
  transform: translateY(-0.5px);
}

.studio-seg-btn.active .seg-icon-box,
.studio-seg-btn.active .seg-icon {
  transform: scale(1.08);
}

/* Focus indicator for Accessibility (WCAG 2.1 AA) */
.studio-seg-btn:focus-visible {
  outline: 2px solid #0284c7;
  outline-offset: 2px;
}

/* Tactile Click / Press feedback */
.studio-seg-btn:active {
  transform: scale(0.97) translateY(0);
}

/* Dark Mode Surface Alignment */
[data-theme="dark"] .studio-segmented-tabs {
  background: rgba(15, 37, 71, 0.75);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-color: rgba(43, 74, 122, 0.8);
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.35);
}

[data-theme="dark"] .studio-seg-btn {
  color: #94a3b8;
}

[data-theme="dark"] .studio-seg-btn:hover:not(.active) {
  color: #e2e8f0;
  background: rgba(255, 255, 255, 0.08);
}

[data-theme="dark"] .studio-seg-btn.active,
[data-theme="dark"] .studio-seg-btn[aria-selected="true"] {
  background: #0b1d3b;
  color: #38bdf8;
  border-color: rgba(56, 189, 248, 0.35);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.45), 0 0 10px rgba(56, 189, 248, 0.15);
}

/* Responsive: Mobile & Tablets (320px - 768px) */
@media (max-width: 768px) {
  .studio-segmented-tabs-wrapper {
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding-bottom: 2px;
    margin: 0.65rem 0 1rem 0;
  }

  .studio-segmented-tabs-wrapper::-webkit-scrollbar {
    display: none;
  }

  .studio-segmented-tabs {
    display: flex;
    flex-wrap: nowrap;
    width: max-content;
    min-width: 100%;
    border-radius: 12px;
    padding: 4px;
    gap: 4px;
  }

  .studio-seg-btn {
    flex: 1 0 auto;
    padding: 8px 14px;
    font-size: 0.81rem;
    min-height: 40px;
    border-radius: 9px;
  }

  .studio-seg-btn .seg-icon-box,
  .studio-seg-btn .seg-icon {
    font-size: 0.95rem;
  }
}

@media (max-width: 480px) {
  .studio-seg-btn {
    padding: 7px 12px;
    font-size: 0.78rem;
    gap: 6px;
  }
}

/* --------------------------------------------------------------------------
   Batch Multi-Exam Audit & Studio Interaction Lock Styles
   -------------------------------------------------------------------------- */
.studio-submode-tabs .btn {
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.studio-bundle-card {
  transition: border-color 0.2s ease, box-shadow 0.2s ease, transform 0.15s ease;
}

.studio-bundle-card:hover { box-shadow: 0 4px 12px rgba(0, 0, 0, 0.04); }
[data-theme="dark"] .studio-bundle-card { background: #1e293b !important; border-color: #334155 !important; }
[data-theme="dark"] .studio-bundle-card .bundle-title-input { background: #0f172a !important; color: #f8fafc !important; border-color: #334155 !important; }
.studio-bundle-card.active-viewing { border: 2px solid #6366f1 !important; box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.18) !important; }
[data-theme="dark"] .studio-bundle-card.active-viewing { border-color: #818cf8 !important; box-shadow: 0 0 0 3px rgba(129, 140, 248, 0.25) !important; }

/* Executive Batch Progress Bar & Filters */
.batch-progress-track { width: 100%; height: 6px; background: #e2e8f0; border-radius: 999px; overflow: hidden; margin: 0.4rem 0 0.6rem; }
.batch-progress-fill { height: 100%; background: linear-gradient(90deg, #6366f1, #06b6d4); transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1); }
.batch-filter-chips { display: flex; flex-wrap: wrap; gap: 0.35rem; margin-bottom: 0.65rem; }

.batch-filter-chip { display: inline-flex; align-items: center; gap: 0.25rem; padding: 3px 8px; border-radius: 999px; font-size: 0.72rem; font-weight: 700; cursor: pointer; border: 1px solid #cbd5e1; background: #f8fafc; color: #475569; transition: all 0.15s ease; user-select: none; }

.batch-filter-chip:hover:not(.active) { background: #f1f5f9; border-color: #94a3b8; }
.batch-filter-chip.active { background: #4338ca; color: #ffffff; border-color: #4338ca; }
[data-theme="dark"] .batch-filter-chip { background: #1e293b; border-color: #334155; color: #94a3b8; }
[data-theme="dark"] .batch-filter-chip.active { background: #6366f1; color: #ffffff; border-color: #6366f1; }

/* Interaction Lock visual feedback */
[aria-busy="true"] { cursor: not-allowed !important; user-select: none !important; }
@media (max-width: 640px) {
  .studio-submode-tabs { flex-direction: column; }
  .studio-submode-tabs .btn { width: 100%; min-height: 44px; display: flex; align-items: center; justify-content: center; }
}
/* Batch Action Buttons Grid (Adaptive Desktop & Mobile) */
.studio-batch-actions-grid { display: grid; grid-template-columns: 1fr auto auto; gap: 0.5rem; align-items: stretch; }
@media (max-width: 540px) {
  .studio-batch-actions-grid { grid-template-columns: 1fr 1fr; gap: 0.5rem; }
  .studio-batch-actions-grid #btn-batch-audit-run-all { grid-column: 1 / -1; min-height: 46px; font-size: 0.92rem; }
  .studio-batch-actions-grid #btn-batch-audit-export-summary,
  .studio-batch-actions-grid #btn-batch-audit-clear-bottom { min-height: 42px; justify-content: center; font-size: 0.8rem; }
}

/* 3. Standalone Grading vs Guided Solver Page Separation & Sub-Tab Switchers */
#assessment-studio-view.focused-quick-grade-mode #btn-quick-mode-exam-only,
#panel-studio-quick.focused-quick-grade-mode #btn-quick-mode-exam-only { display: none !important; }
#assessment-studio-view.focused-quick-grade-mode #quick-mode-selector-grid,
#panel-studio-quick.focused-quick-grade-mode #quick-mode-selector-grid { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.quick-solver-question-nav { display: flex; align-items: center; flex-wrap: wrap; gap: 0.45rem 0.65rem; padding: 0.55rem 0.75rem; margin-bottom: 0.85rem; background: linear-gradient(135deg, rgba(2, 132, 199, 0.06) 0%, rgba(79, 70, 229, 0.06) 100%); border: 1px solid rgba(2, 132, 199, 0.22); border-radius: 10px; }
.quick-solver-nav-label { font-size: 0.76rem; font-weight: 700; color: #0369a1; white-space: nowrap; }
.quick-solver-nav-pills { display: flex; align-items: center; flex-wrap: wrap; gap: 0.38rem; }
.quick-solver-nav-pill { appearance: none; display: inline-flex; align-items: center; gap: 0.3rem; padding: 0.26rem 0.65rem; border-radius: 999px; border: 1px solid #cbd5e1; background: #ffffff; color: #334155; font-size: 0.76rem; font-weight: 700; cursor: pointer; transition: all 0.15s ease; }
.quick-solver-nav-pill.active { background: #0284c7; color: #ffffff; border-color: #0284c7; box-shadow: 0 2px 6px rgba(2, 132, 199, 0.25); }
.quick-solver-nav-pts { font-size: 0.68rem; font-weight: 700; padding: 0.05rem 0.38rem; border-radius: 999px; background: rgba(15, 23, 42, 0.08); color: inherit; }
.quick-solver-nav-pill.active .quick-solver-nav-pts { background: rgba(255, 255, 255, 0.22); color: #ffffff; }
.lj-linking-subtabs, .create-exam-mode-switcher { display: flex; align-items: center; gap: 0.45rem; padding: 0.3rem; margin-bottom: 0.85rem; background: #f1f5f9; border: 1px solid #e2e8f0; border-radius: 10px; }
.lj-linking-subtab-btn, .create-exam-mode-tab { flex: 1 1 auto; appearance: none; border: 1px solid transparent; background: transparent; color: #475569; font-size: 0.8rem; font-weight: 700; padding: 0.48rem 0.75rem; border-radius: 8px; cursor: pointer; text-align: center; transition: all 0.15s ease; }
.lj-linking-subtab-btn.active, .create-exam-mode-tab.active { background: #ffffff; color: #0284c7; border-color: rgba(2, 132, 199, 0.25); box-shadow: 0 2px 6px rgba(15, 23, 42, 0.06); }
.studio-header-config-details > summary::-webkit-details-marker { display: none; }
@media (max-width: 640px) {
  .quick-solver-nav-pills { flex-wrap: nowrap; overflow-x: auto; width: 100%; padding-bottom: 2px; }
  .quick-solver-nav-pill { flex: 0 0 auto; }
  .lj-linking-subtabs, .create-exam-mode-switcher { flex-direction: column; align-items: stretch; }
}

