/* ═══════════════════════════════════════════
   LP TEACHER — Main Layout & Components
   ═══════════════════════════════════════════ */

/* ── Main 3-column grid ── */
.main-grid {
  margin-top: var(--header-h);
  display: grid;
  grid-template-columns: 300px 1fr 320px;
  grid-template-rows: 1fr;          /* flex-fill, not fixed px */
  gap: 10px;
  padding: 10px 10px 14px;          /* extra bottom breathing room */
  height: calc(100vh - var(--header-h));
  overflow: hidden;
}

/* ── Columns ── */
.left-col, .right-col {
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow: hidden;
  min-height: 0;
}

.center-col {
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow: hidden;
  min-height: 0;
}

/* ═══════════════════════════════════════════
   LP PANEL
   ═══════════════════════════════════════════ */

.lp-display-panel { flex: 1; min-height: 0; }
.lp-display-panel .panel-body { padding: 10px 12px; }

/* LP header action buttons */
.lp-header-btns {
  display: flex;
  align-items: center;
  gap: 5px;
}

.btn-generate {
  background: var(--accent);
  color: #fff;
  font-size: 0.78rem;
  padding: 4px 10px;
  border-radius: var(--r-sm);
  border: none;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  cursor: pointer;
  font-weight: 600;
  transition: all var(--t-fast);
}
.btn-generate:hover { background: var(--accent-hov); transform: translateY(-1px); }

/* ── Collapsible options panel ── */
.options-panel {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.28s ease, opacity 0.28s ease;
  opacity: 0;
  border-bottom: 0px solid var(--border);
}
.options-panel.open {
  max-height: 260px;
  opacity: 1;
  border-bottom-width: 1px;
}
.options-inner {
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: var(--bg-surface);
}

/* Empty state */
.lp-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  text-align: center;
  color: var(--text-muted);
  gap: 6px;
  font-size: 0.82rem;
}

/* LP content when generated */
.lp-obj-section, .lp-constraints-section, .lp-nn-section {
  margin-bottom: 12px;
}

.lp-section-label {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 5px;
}

.lp-obj-line {
  font-family: var(--font-mono);
  font-size: 0.88rem;
  color: var(--text-h);
  padding: 6px 10px;
  background: transparent;
  border-radius: var(--r-sm);
  border-left: 3px solid var(--accent);
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  transition: all var(--t-fast);
}
.lp-obj-line:hover, .lp-obj-line.highlighted {
  background: var(--accent-light);
  box-shadow: var(--shadow-xs);
}
.lp-obj-line:hover .c-actions { opacity: 1; }
.lp-obj-line .c-actions { margin-left: auto; }

.obj-type { font-weight: 700; color: var(--accent); font-size: 0.78rem; }
.obj-var  { color: var(--accent); font-style: italic; }
.coeff    { color: var(--text-h); font-weight: 600; }
.op       { color: var(--text-muted); }

/* Constraint list */
.constraint-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.constraint-row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 8px;
  border-radius: var(--r-sm);
  border: 1.5px solid transparent;
  cursor: pointer;
  transition: all var(--t-fast);
  position: relative;
}
.constraint-row:hover {
  background: var(--bg-hover);
  border-color: var(--border);
}
.constraint-row.highlighted {
  border-color: var(--c-color, var(--accent));
  background: var(--c-bg, var(--accent-light));
}

.c-badge {
  width: 19px; height: 19px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.65rem;
  font-weight: 800;
  color: #fff;
  background: var(--c-color, var(--accent));
  flex-shrink: 0;
}

.c-expr {
  flex: 1;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--text-body);
}

.c-actions {
  display: flex;
  gap: 2px;
  opacity: 0;
  transition: opacity var(--t-fast);
}
.constraint-row:hover .c-actions { opacity: 1; }

/* Inline editor */
.constraint-editor {
  padding: 8px 10px;
  background: var(--bg-surface);
  border: 1.5px solid var(--border-foc);
  border-radius: var(--r-md);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin: 4px 0;
}

.coeff-in, .rhs-in {
  width: 54px;
  padding: 4px 6px;
  border: 1.5px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--bg-input);
  color: var(--text-h);
  font-family: var(--font-mono);
  font-size: 0.82rem;
  text-align: center;
  outline: none;
}
.coeff-in:focus, .rhs-in:focus { border-color: var(--border-foc); }

.var-lbl {
  font-family: var(--font-mono);
  font-size: 0.88rem;
  font-style: italic;
  color: var(--accent);
}

.sense-sel {
  padding: 4px 6px;
  border: 1.5px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--bg-input);
  color: var(--text-body);
  font-size: 0.82rem;
  outline: none;
  cursor: pointer;
}
.sense-sel:focus { border-color: var(--border-foc); }

.editor-btns { display: flex; gap: 4px; margin-left: auto; }
.btn-save   { background: var(--green); color: #fff; padding: 4px 10px; border: none; border-radius: var(--r-sm); font-size: 0.78rem; font-weight: 700; cursor: pointer; }
.btn-cancel { background: var(--bg-hover); color: var(--text-sub); padding: 4px 10px; border: 1px solid var(--border); border-radius: var(--r-sm); font-size: 0.78rem; cursor: pointer; }

/* Add constraint btn */
.add-constraint-btn {
  width: 100%;
  margin-top: 6px;
  padding: 6px;
  border: 1.5px dashed var(--border);
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--text-muted);
  font-size: 0.78rem;
  cursor: pointer;
  transition: all var(--t-fast);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
}
.add-constraint-btn:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-light); }

/* Non-negativity */
.lp-nn {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--text-muted);
  padding-left: 10px;
}

/* Solution result */
.solution-box {
  margin-top: 8px;
  padding: 10px 12px;
  border-radius: var(--r-md);
  border-left: 3px solid var(--green);
  background: var(--green-bg);
  font-family: var(--font-mono);
  font-size: 0.8rem;
  line-height: 1.7;
  color: var(--text-body);
}
.solution-box.infeasible  { border-color: var(--red);   background: var(--red-bg);   }
.solution-box.unbounded   { border-color: var(--amber); background: var(--amber-bg); }
.solution-title { font-weight: 700; color: var(--green); margin-bottom: 2px; }
.solution-box.infeasible .solution-title  { color: var(--red);   }
.solution-box.unbounded  .solution-title  { color: var(--amber); }
.solution-val  { color: var(--text-h); }

/* ═══════════════════════════════════════════
   GENERATOR CONTROLS
   ═══════════════════════════════════════════ */

.gen-controls { display: flex; flex-direction: column; gap: 12px; }

.ctrl-group { display: flex; flex-direction: column; gap: 6px; }

.ctrl-label {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-sub);
  display: flex;
  align-items: center;
  gap: 6px;
}

.ctrl-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 18px;
  padding: 0 5px;
  background: var(--accent);
  color: #fff;
  border-radius: 10px;
  font-size: 0.7rem;
  font-weight: 800;
}

.ctrl-row { display: flex; gap: 5px; }

.opt-btn {
  flex: 1;
  padding: 6px 4px;
  border: 1.5px solid var(--border);
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--text-sub);
  font-size: 0.76rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--t-fast);
  text-align: center;
  white-space: nowrap;
}
.opt-btn:hover { border-color: var(--accent); color: var(--accent); }
.opt-btn.selected { background: var(--accent); border-color: var(--accent); color: #fff; }

.gen-btn { width: 100%; justify-content: center; padding: 9px; font-size: 0.88rem; }

/* ═══════════════════════════════════════════
   VISUALIZER
   ═══════════════════════════════════════════ */

.viz-panel { flex: 1; min-height: 0; }  /* fills full center column now */

.viz-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.viz-hint {
  font-size: 0.72rem;
  color: var(--text-muted);
  font-style: italic;
}
.mouse-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-sans);
  font-size: 0.62rem;
  font-weight: 700;
  font-style: normal;
  padding: 1px 4px;
  background: var(--bg-elevated, var(--bg-panel));
  border: 1px solid var(--border);
  border-radius: 3px;
  color: var(--text-h);
  vertical-align: middle;
  line-height: 1.4;
  margin: 0 1px;
}

.viz-body {
  padding: 0 !important;
  position: relative;
  overflow: hidden;
}

.viz-body canvas {
  display: block;
  width: 100%;
  height: 100%;
}

/* Grab/grabbing cursor for both 2D canvas and 3D renderer canvas */
.viz-grab    { cursor: grab !important; }
.viz-grabbing { cursor: grabbing !important; }

/* ═══════════════════════════════════════════
   AI TEACHER
   ═══════════════════════════════════════════ */

.ai-panel { flex: 1; min-height: 0; }

.ai-messages {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px 14px;
  min-height: 0;
}

.ai-msg {
  display: flex;
  gap: 8px;
  max-width: 100%;
}
.ai-msg.user { flex-direction: row-reverse; }

.ai-avatar {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: var(--accent-grad);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  color: #fff;
  font-weight: 800;
  flex-shrink: 0;
  margin-top: 2px;
}

.ai-bubble {
  padding: 9px 12px;
  border-radius: var(--r-md);
  font-size: 0.82rem;
  line-height: 1.55;
  max-width: calc(100% - 40px);
  word-break: break-word;
}

.ai-msg.assistant .ai-bubble {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
  color: var(--text-body);
}

.ai-msg.user .ai-bubble {
  background: var(--accent);
  color: #fff;
  border-bottom-right-radius: 4px;
}

/* ── Explain Next Step row ── */
.ai-explain-row {
  padding: 0 12px 10px;
  flex-shrink: 0;
}

.btn-explain {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 9px 12px;
  background: var(--accent-grad);
  color: #fff;
  border: none;
  border-radius: var(--r-md);
  font-size: 0.83rem;
  font-weight: 700;
  cursor: pointer;
  transition: all var(--t-fast);
  letter-spacing: 0.01em;
}
.btn-explain:hover:not(:disabled) {
  filter: brightness(1.1);
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}
.btn-explain:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
  filter: none;
}

/* Explain step marker in chat */
.ai-explain-marker {
  text-align: center;
  font-size: 0.71rem;
  font-weight: 600;
  color: var(--violet);
  padding: 4px 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  opacity: 0.85;
}

/* AI input */
.ai-input-area {
  padding: 10px 12px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 7px;
  align-items: flex-end;
  flex-shrink: 0;
}

.ai-textarea {
  flex: 1;
  padding: 8px 11px;
  border-radius: var(--r-md);
  border: 1.5px solid var(--border);
  background: var(--bg-input);
  color: var(--text-h);
  font-family: var(--font);
  font-size: 0.82rem;
  resize: none;
  outline: none;
  min-height: 36px;
  max-height: 100px;
  line-height: 1.4;
  transition: border-color var(--t-fast);
}
.ai-textarea:focus { border-color: var(--border-foc); }

.ai-send-btn {
  width: 34px; height: 34px;
  border-radius: var(--r-md);
  border: none;
  background: var(--accent);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  font-size: 0.85rem;
  transition: all var(--t-fast);
}
.ai-send-btn:hover { background: var(--accent-hov); transform: scale(1.05); }
.ai-send-btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }

/* ── AI typing bubble ── */
.ai-typing-bubble {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
  border-radius: var(--r-md);
  padding: 9px 14px;
}
