/**
 * math-visual-studio.css
 * Styling for Math Visual Engine & Media Exporter Studio.
 * Professional EdTech B2B interface with Mobile-First Responsive Layout,
 * SGK Blueprint Mode, 3D Viewport Controls & Autograding Inspection Panel.
 */

.math-visual-studio-container {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  width: 100%;
}

.math-visual-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.25rem;
  background: var(--surface-color, #ffffff);
  border: 1px solid var(--border-color, #e2e8f0);
  border-radius: var(--radius-lg, 12px);
  box-shadow: var(--shadow-sm, 0 1px 3px rgba(0,0,0,0.05));
}

.math-visual-header-title {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.math-visual-header-title h2 {
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--text-color, #0f172a);
  margin: 0;
  letter-spacing: -0.02em;
}

.math-visual-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 380px;
  gap: 1.25rem;
  align-items: start;
}

/* 3D Viewport Area */
.math-visual-viewport-wrapper {
  display: flex;
  flex-direction: column;
  background: var(--surface-color, #ffffff);
  border: 1px solid var(--border-color, #e2e8f0);
  border-radius: var(--radius-lg, 12px);
  overflow: hidden;
  box-shadow: var(--shadow-md, 0 4px 6px -1px rgba(0,0,0,0.06));
}

.math-visual-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.65rem 1rem;
  background: var(--surface-subtle, #f8fafc);
  border-bottom: 1px solid var(--border-color, #e2e8f0);
}

.math-visual-canvas-box {
  position: relative;
  width: 100%;
  height: 520px;
  min-height: 380px;
  background: #ffffff;
  cursor: grab;
  touch-action: none;
}

.math-visual-canvas-box:active {
  cursor: grabbing;
}

/* Timeline Control Bar */
.math-visual-timeline-bar {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: 0.85rem 1.25rem;
  background: var(--surface-color, #ffffff);
  border-top: 1px solid var(--border-color, #e2e8f0);
}

.math-visual-timeline-info {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.85rem;
}

.math-visual-step-badge {
  background: #eff6ff;
  color: #1d4ed8;
  font-weight: 700;
  padding: 0.2rem 0.6rem;
  border-radius: 9999px;
  border: 1px solid #bfdbfe;
}

.math-visual-step-desc {
  color: var(--text-color, #0f172a);
  font-weight: 600;
}

.math-visual-timeline-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
}

/* Right Panel: Geometry Controls & AutoGrading Inspection */
.math-visual-sidebar {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  max-height: calc(100vh - 150px);
  min-height: 520px;
  overflow-y: auto;
  overflow-x: hidden;
  padding-right: 0.35rem;
  scrollbar-width: thin;
  scrollbar-color: #cbd5e1 transparent;
}

.math-visual-sidebar::-webkit-scrollbar {
  width: 6px;
}

.math-visual-sidebar::-webkit-scrollbar-track {
  background: transparent;
}

.math-visual-sidebar::-webkit-scrollbar-thumb {
  background-color: #cbd5e1;
  border-radius: 9999px;
}

.math-visual-tabs-bar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--surface-color, #ffffff);
  padding: 0.5rem 0.25rem;
  border-bottom: 1px solid var(--border-color, #e2e8f0);
  border-radius: var(--radius-md, 8px);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

.math-visual-card {
  background: var(--surface-color, #ffffff);
  border: 1px solid var(--border-color, #e2e8f0);
  border-radius: var(--radius-lg, 12px);
  padding: 1.25rem;
  box-shadow: var(--shadow-sm, 0 1px 3px rgba(0,0,0,0.05));
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

/* Collapsible Auxiliary Drawers (Input & Telemetry) */
.math-visual-collapsible-card {
  background: var(--surface-color, #ffffff);
  border: 1px solid var(--border-color, #e2e8f0);
  border-radius: var(--radius-lg, 12px);
  box-shadow: var(--shadow-sm, 0 1px 3px rgba(0,0,0,0.05));
  overflow: hidden;
  transition: all 0.2s ease;
}

.math-visual-collapsible-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.65rem 0.95rem;
  background: #f8fafc;
  cursor: pointer;
  user-select: none;
  border-bottom: 1px solid #e2e8f0;
}

.math-visual-collapsible-header:hover {
  background: #f1f5f9;
}

.math-visual-collapsible-header h3 {
  font-size: 0.86rem;
  font-weight: 700;
  color: var(--text-color, #0f172a);
  margin: 0;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.math-visual-collapsible-header .math-collapsible-toggle-icon {
  font-size: 0.72rem;
  color: #64748b;
  transition: transform 0.2s ease;
}

.math-visual-collapsible-card.collapsed .math-collapsible-toggle-icon {
  transform: rotate(-90deg);
}

.math-visual-collapsible-card.collapsed .math-visual-collapsible-body {
  display: none;
}

.math-visual-collapsible-card.collapsed .math-visual-collapsible-header {
  border-bottom: none;
}

.math-visual-collapsible-body {
  padding: 0.9rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.math-visual-card h3 {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-color, #0f172a);
  margin: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.math-visual-debug-box {
  background: #0f172a;
  color: #38bdf8;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.75rem;
  padding: 0.75rem;
  border-radius: 6px;
  max-height: 220px;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-all;
}

/* Pedagogical Guidance Card */
.math-visual-pedagogical-card {
  border-left: 4px solid #10b981;
  background: linear-gradient(135deg, rgba(240, 253, 244, 0.6) 0%, rgba(255, 255, 255, 0.9) 100%);
}

.math-visual-pedagogical-content {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  margin-top: 0.5rem;
}

.math-visual-pedagogical-item {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.math-visual-pedagogical-label {
  font-size: 0.76rem;
  font-weight: 700;
  color: var(--text-color, #1e293b);
  display: flex;
  align-items: center;
  gap: 0.3rem;
}

.math-visual-pedagogical-value {
  font-size: 0.82rem;
  color: var(--text-muted, #475569);
  line-height: 1.4;
  padding-left: 0.2rem;
}

.math-visual-pedagogical-formula {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.8rem;
  font-weight: 600;
  color: #047857;
  background: #ecfdf5;
  padding: 0.35rem 0.6rem;
  border-radius: 6px;
  border: 1px solid #a7f3d0;
  display: inline-block;
}

/* Stepper Dots Track */
.math-visual-stepper-container {
  display: flex !important;
  flex-direction: row !important;
  flex-wrap: wrap !important;
  align-items: center !important;
  justify-content: flex-start !important;
  gap: 6px !important;
  overflow-x: hidden !important;
  overflow-y: auto !important;
  padding: 5px 10px !important;
  background: #f1f5f9 !important;
  border-radius: 12px !important;
  border: 1px solid #cbd5e1 !important;
  max-width: 100% !important;
  min-width: 0 !important;
  white-space: normal !important;
  box-sizing: border-box !important;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.04);
  scrollbar-width: thin;
}

.math-visual-stepper-container::-webkit-scrollbar {
  height: 4px;
}
.math-visual-stepper-container::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 4px;
}

.math-visual-stepper-dot {
  width: 28px !important;
  height: 28px !important;
  min-width: 28px !important;
  min-height: 28px !important;
  border-radius: 50% !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  font-size: 0.74rem !important;
  font-weight: 700 !important;
  background: #ffffff !important;
  color: #64748b !important;
  cursor: pointer !important;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1) !important;
  border: 1.5px solid #cbd5e1 !important;
  flex-shrink: 0 !important;
  user-select: none !important;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.math-visual-stepper-dot:hover {
  background: #f8fafc !important;
  color: #0f172a !important;
  border-color: #94a3b8 !important;
  transform: translateY(-1px) scale(1.08) !important;
}

.math-visual-stepper-dot.active {
  background: var(--primary-color, #4f46e5) !important;
  color: #ffffff !important;
  border-color: #4338ca !important;
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.25), 0 2px 4px rgba(79, 70, 229, 0.3) !important;
  transform: scale(1.15) !important;
}

.math-visual-stepper-dot.completed {
  background: #10b981 !important;
  color: #ffffff !important;
  border-color: #059669 !important;
}

.math-visual-speed-control {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

/* Interactive Direct Manipulation Toolbar */
.math-visual-interactive-toolbar {
  background: #f1f5f9;
  padding: 0.4rem 0.6rem;
  border-radius: 8px;
  border: 1px solid #e2e8f0;
  margin-bottom: 0.4rem;
}

.math-visual-interactive-toolbar .btn {
  font-size: 0.78rem;
  font-weight: 600;
  transition: all 0.15s ease;
  min-height: 34px;
}

.math-visual-interactive-toolbar .btn.active {
  background: var(--primary-color, #4f46e5);
  color: #ffffff;
  border-color: #4338ca;
  box-shadow: 0 2px 4px rgba(79, 70, 229, 0.25);
}

.math-visual-annotation-canvas {
  touch-action: none;
}

/* ==========================================================================
   Interactive Geometry Problem Solver & Pedagogical Proof Cards
   ========================================================================== */
.math-visual-tabs-bar {
  display: flex;
  gap: 0.45rem;
  flex-wrap: wrap;
  width: 100%;
}

.math-visual-tabs-bar .btn {
  font-size: 0.8rem;
  font-weight: 600;
  padding: 0.35rem 0.75rem;
  border-radius: 8px;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.math-solution-container {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  background: var(--surface-color, #ffffff);
  border: 1px solid var(--border-color, #e2e8f0);
  border-radius: var(--radius-lg, 12px);
  padding: 1.15rem;
  box-shadow: var(--shadow-sm, 0 1px 3px rgba(0,0,0,0.05));
}

.math-solution-header-card {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid #f1f5f9;
}

.math-solution-badge {
  display: inline-block;
  align-self: flex-start;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  color: #4338ca;
  background: #e0e7ff;
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
}

.math-solution-title {
  font-size: 0.98rem;
  font-weight: 700;
  color: #0f172a;
  margin: 0;
  line-height: 1.4;
}

.math-solution-hint {
  font-size: 0.76rem;
  color: #64748b;
  font-style: italic;
}

.math-solution-tools-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 0.25rem;
  margin-bottom: 0.15rem;
  font-size: 0.78rem;
  color: var(--text-muted, #64748b);
}

.math-solution-steps-box {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.math-solution-step-card {
  display: flex;
  flex-direction: column;
  padding: 0.55rem 0.8rem;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.math-solution-step-card:hover {
  background: #f1f5f9;
  border-color: #cbd5e1;
  transform: translateY(-1px);
}

.math-solution-step-card.active {
  background: #eff6ff;
  border-color: #3b82f6;
  box-shadow: 0 0 0 1.5px #3b82f6, 0 4px 6px -1px rgba(59, 130, 246, 0.1);
}

.math-step-card-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
}

.math-step-num-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #3b82f6;
  color: #ffffff;
  font-size: 0.72rem;
  font-weight: 700;
  flex-shrink: 0;
}

.math-solution-step-card.active .math-step-num-pill {
  background: #1d4ed8;
}

.math-step-card-title {
  font-size: 0.84rem;
  font-weight: 700;
  color: #1e293b;
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.math-step-chevron {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  color: #94a3b8;
  transition: transform 0.2s ease;
  margin-left: auto;
  user-select: none;
}

/* Accordion Collapsed vs Active */
.math-solution-step-card.collapsed .math-step-chevron {
  transform: rotate(-90deg);
}

.math-solution-step-card.collapsed .math-step-body {
  display: none;
}

.math-solution-step-card.active .math-step-chevron {
  transform: rotate(0deg);
  color: #2563eb;
}

.math-step-body {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin-top: 0.45rem;
  padding-top: 0.45rem;
  border-top: 1px solid #e2e8f0;
  animation: mathFadeIn 0.2s ease-in-out;
}

@keyframes mathFadeIn {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

.math-step-assertion {
  font-size: 0.82rem;
  color: #334155;
  line-height: 1.45;
}

.math-step-reason {
  font-size: 0.78rem;
  color: #64748b;
  line-height: 1.4;
}

.math-step-fact {
  font-size: 0.8rem;
  color: #0f172a;
  margin-top: 0.25rem;
}

.math-step-fact .math-fact-expr {
  font-weight: 600;
  color: #15803d;
  display: inline-block;
  vertical-align: middle;
}

.math-step-fact code {
  font-size: 0.76rem;
  background: #e2e8f0;
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
  color: #0f172a;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

/* Dynamic Extremum Sandbox (Câu c) */
.math-dynamic-sandbox-card {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  padding: 0.85rem;
  background: #fdf4ff;
  border: 1px solid #f0abfc;
  border-radius: 8px;
  margin-top: 0.25rem;
}

.math-dynamic-sandbox-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.math-dynamic-formula {
  font-size: 0.82rem;
  color: #86198f;
}

.math-dynamic-slider-row {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  font-size: 0.78rem;
  color: #701a75;
  font-weight: 600;
}

.math-dynamic-slider {
  width: 100%;
  height: 6px;
  border-radius: 3px;
  accent-color: #c026d3;
  cursor: pointer;
}

.math-dynamic-result {
  font-size: 0.82rem;
  font-weight: 600;
  padding: 0.4rem 0.6rem;
  background: #ffffff;
  border-radius: 6px;
  border: 1px dashed #d946ef;
  line-height: 1.4;
}

/* Responsive Dual-Mode Breakpoints */
@media (max-width: 992px) {
  .math-visual-layout {
    grid-template-columns: 1fr;
  }
  .math-visual-canvas-box {
    height: 440px;
  }
}

/* Geometry Library Scientific Cards Styling */
.geom-library-card {
  background: var(--surface-color, #ffffff);
  border: 1px solid var(--border-color, #e2e8f0);
  border-radius: var(--radius-md, 10px);
  padding: 0.85rem;
  display: flex;
  flex-direction: column;
  transition: all 0.2s ease;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

.geom-library-card:hover {
  border-color: #3b82f6;
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.1);
  transform: translateY(-1px);
}

.geom-library-card.active-card {
  border-color: #3b82f6;
  background: #f0f7ff;
}

/* Note: Enterprise mobile responsive styles for Math Visual Studio are delegated to mobile-components.css */
@media (max-width: 640px) {
  .geom-library-grid {
    grid-template-columns: 1fr !important;
  }
}

/* Math Visual Solution Modal & Print Layout */
.math-solution-modal-content {
  border: 1px solid #cbd5e1;
  animation: mathModalFadeIn 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes mathModalFadeIn {
  from { opacity: 0; transform: scale(0.97) translateY(8px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

.math-solution-modal-scrollable::-webkit-scrollbar {
  width: 6px;
}
.math-solution-modal-scrollable::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 9999px;
}

@media print {
  body.printing-math-solution * {
    visibility: hidden;
  }
  body.printing-math-solution #modal-math-visual-solution,
  body.printing-math-solution #modal-math-visual-solution .modal-content,
  body.printing-math-solution #modal-math-visual-solution .math-solution-modal-scrollable,
  body.printing-math-solution #modal-math-visual-solution .math-solution-modal-scrollable * {
    visibility: visible !important;
  }
  #modal-math-visual-solution {
    position: static !important;
    background: transparent !important;
    display: block !important;
    padding: 0 !important;
  }
  #modal-math-visual-solution .modal-content {
    box-shadow: none !important;
    border: none !important;
    max-width: 100% !important;
    width: 100% !important;
    padding: 0 !important;
  }
  #btn-close-math-visual-solution,
  #btn-solution-modal-close-footer,
  .math-solution-tools-bar,
  #modal-math-visual-solution .btn-group {
    display: none !important;
  }
  .math-solution-doc-card {
    break-inside: avoid;
    page-break-inside: avoid;
    border: 1px solid #e2e8f0 !important;
    margin-bottom: 12mm;
  }
}

