/* ============================================================
   MedLearno Rich Content Toolkit — styles
   ============================================================ */

/* ── Toolbar ── */
.mlrc-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  align-items: center;
  background: #f1f4f9;
  border: 1.5px solid #cdd5e0;
  border-bottom: none;
  border-radius: 7px 7px 0 0;
  padding: 6px 8px;
  font-family: inherit;
}
.mlrc-toolbar .mlrc-grp { display: flex; gap: 3px; align-items: center; flex-wrap: wrap; }
.mlrc-toolbar .mlrc-sep { width: 1px; height: 18px; background: #cdd5e0; margin: 0 4px; }
.mlrc-toolbar button {
  background: #fff;
  border: 1px solid #d1d9e0;
  border-radius: 5px;
  padding: 4px 9px;
  font: 600 12px/1 inherit;
  color: #1f2937;
  cursor: pointer;
  transition: background .12s, color .12s, border-color .12s, transform .12s;
  min-width: 28px;
}
.mlrc-toolbar button:hover {
  background: #4f46e5;
  color: #fff;
  border-color: #4f46e5;
  transform: translateY(-1px);
}
.mlrc-toolbar button:active { transform: translateY(0); }
.mlrc-toolbar select {
  font: 600 12px/1 inherit;
  background: #fff;
  border: 1px solid #d1d9e0;
  border-radius: 5px;
  padding: 4px 8px;
  cursor: pointer;
}
.mlrc-syms-pop { display: inline-flex; flex-wrap: wrap; gap: 2px; max-width: 360px; }
.mlrc-syms-pop .mlrc-sym { min-width: 24px; padding: 3px 6px; font-size: 13px; font-weight: 500; }

/* ── Editor surface ── */
.mlrc-editor {
  min-height: 70px;
  padding: 10px 13px;
  border: 1.5px solid #cdd5e0;
  border-radius: 0 0 7px 7px;
  background: #fff;
  font: 14px/1.7 'Times New Roman', serif;
  color: #111827;
  outline: none;
  white-space: pre-wrap;
  word-break: break-word;
}
.mlrc-editor:focus { border-color: #4f46e5; box-shadow: 0 0 0 3px rgba(79,70,229,.12); }
.mlrc-editor[placeholder]:empty::before {
  content: attr(placeholder);
  color: #adb5bd;
  font-family: inherit;
  font-size: 13px;
}
.mlrc-editor img {
  max-width: 100%;
  max-height: 320px;
  height: auto;
  display: inline-block;
  vertical-align: middle;
  margin: 2px 4px;
  border-radius: 4px;
  background: #f8fafc;
}
.mlrc-img-broken {
  display: inline-block;
  padding: 10px 14px;
  margin: 4px 2px;
  background: #fff3cd;
  border: 1px dashed #c49a1a;
  border-radius: 6px;
  color: #92400e;
  font-size: 12px;
  font-weight: 600;
}
.mlrc-img-loading {
  display: inline-block;
  padding: 6px 10px;
  margin: 0 2px;
  background: #eef2ff;
  border: 1px dashed #6366f1;
  border-radius: 6px;
  color: #3730a3;
  font-size: 12px;
}
.mlrc-editor.mlrc-dropping {
  background: #eef2ff;
  border-color: #4f46e5;
  box-shadow: 0 0 0 3px rgba(79,70,229,.18);
}
.mlrc-editor .mlrc-chem { font-family: 'Times New Roman', serif; color: #7c3aed; font-weight: 600; }
.mlrc-editor .ml-math { background: #fef9c3; border-radius: 3px; padding: 1px 4px; }

/* ── Render-side: question content blocks ── */
.ml-rich-content {
  font: 15px/1.75 'Source Sans 3', system-ui, sans-serif;
  color: inherit;
  word-break: break-word;
}
.ml-rich-content img {
  max-width: 100%;
  height: auto;
  vertical-align: middle;
  margin: 4px 4px;
  border-radius: 4px;
  cursor: zoom-in;
}
.ml-rich-content sup, .ml-rich-content sub { font-size: .78em; line-height: 0; }

/* ── Preserve multi-line question structure ───────────────────────────────
   Quill / imported content stores each statement on its own <p>. Without
   explicit margins those lines collapse into a single paragraph visually.
   We keep the last-child margin-free so no trailing gap appears after
   the last option/statement. ── */
.ml-rich-content p {
    margin: 0 0 0.38em;
    line-height: inherit;
}
.ml-rich-content p:last-child { margin-bottom: 0; }
/* <br> separators (plain-text imports stored with \n → br) */
.ml-rich-content br { display: block; content: ''; margin-bottom: 0.25em; }

/* Match-the-following / assertion-reason: table cells also need breathing room */
.ml-rich-content td p, .ml-rich-content th p { margin: 0 0 0.25em; }
.ml-rich-content td p:last-child, .ml-rich-content th p:last-child { margin-bottom: 0; }
.ml-rich-content table {
  border-collapse: collapse;
  margin: 8px 0;
}
.ml-rich-content table td, .ml-rich-content table th {
  border: 1px solid #d1d5db;
  padding: 4px 8px;
}
.ml-rich-content .ml-math, .ml-rich-content mjx-container { font-size: 1.05em; }

/* ── Lightbox ── */
.mlrc-lightbox {
  position: fixed; inset: 0; z-index: 999999;
  background: rgba(0,0,0,.85);
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
  cursor: zoom-out;
}
.mlrc-lightbox img {
  max-width: 96vw; max-height: 92vh;
  object-fit: contain;
  border-radius: 8px;
  box-shadow: 0 20px 60px rgba(0,0,0,.6);
}
.mlrc-lightbox .mlrc-lb-x {
  position: absolute; top: 18px; right: 22px;
  width: 40px; height: 40px;
  background: #fff; color: #111;
  border: 0; border-radius: 50%;
  font-size: 22px; font-weight: 800; cursor: pointer;
  box-shadow: 0 4px 14px rgba(0,0,0,.4);
}

/* ── Reveal / collapse helpers ── */
.ml-q-reveal {
  display: inline-block;
  background: #1d4ed8; color: #fff;
  border: 0; border-radius: 6px;
  padding: 5px 12px; font: 600 12px/1 inherit;
  cursor: pointer;
  transition: background .15s;
}
.ml-q-reveal:hover { background: #2563eb; }
.ml-q-answer.ml-hidden { display: none !important; }
.ml-q-answer {
  background: #f0fdf4;
  border: 1.5px solid #86efac;
  border-radius: 7px;
  padding: 8px 14px;
  margin-top: 8px;
  font-size: 13px;
  font-weight: 600;
  color: #166534;
}

/* ── Print/Word adjustments — keep math + images visible ── */
@media print {
  .mlrc-toolbar, .ml-q-reveal { display: none !important; }
  .ml-rich-content img, .mlrc-editor img { max-width: 100%; }
  .mlrc-lightbox { display: none !important; }
}
