/* ==========================================================================
   PNLE-REVIEW — Mistake Bank
   Filters, stat cards, mistake table, study tip and the review dialog.
   Chips, answer options and the dialog shell come from components.css.
   ========================================================================== */

/* Fit-to-screen rows: top bar · filters · stats · list */
.main--mistakes { --fit-rows: auto auto auto 1fr; }

/* ============================== Filters ============================== */
.mk-filters {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 4px;
}
.mk-filters .chips { margin-bottom: 0; }
.mk-filters .chip:not(.is-active) { background: var(--card-solid); border-color: var(--card-border); }

/* ============================== Stats ============================== */
.mk-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}
.mk-stat {
  position: relative;
  display: flex;
  align-items: center;
  gap: 16px;
  min-height: 108px;
  padding: 18px 20px;
  text-align: left;
  border: 1px solid transparent;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.mk-stat:hover { transform: translateY(-2px); }
.mk-stat.is-active { box-shadow: 0 0 0 2px var(--primary), var(--shadow); }
.mk-stat--purple { background: var(--tint-rose); border-color: var(--tint-rose-border); }
.mk-stat--pink { background: var(--tint-pink); border-color: var(--tint-pink-border); }
.mk-stat--green { background: var(--tint-green); border-color: var(--tint-green-border); }
.mk-stat__icon {
  display: grid;
  place-items: center;
  flex: none;
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.75);
}
:root[data-theme="dark"] .mk-stat__icon { background: rgba(255, 255, 255, 0.08); }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .mk-stat__icon { background: rgba(255, 255, 255, 0.08); }
}
.mk-stat__icon .icon { width: 22px; height: 22px; }
.mk-stat--purple .mk-stat__icon { color: #8a63d2; }
.mk-stat--pink .mk-stat__icon { color: var(--pink); }
.mk-stat--green .mk-stat__icon { color: #2f9d7e; }
.mk-stat__text span { display: block; font-size: 12.5px; color: var(--text-2); }
.mk-stat__text strong { display: block; margin-top: 4px; font-size: 26px; font-weight: 600; color: var(--text); }

.mk-rate {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 14px 20px;
}
.ring--rate { width: 84px; height: 84px; flex: none; }
.ring--rate .ring__label { font-size: 17px; }
.mk-rate__label { display: block; font-size: 12.5px; color: var(--text-2); }
.mk-rate__value { display: block; margin-top: 2px; font-size: 22px; font-weight: 600; color: var(--text); }
.mk-rate__hint { display: block; font-size: 10px; color: var(--muted); }
.mk-rate__flower { position: absolute; right: -10px; bottom: -8px; width: 70px; transform: rotate(-35deg); pointer-events: none; }

/* ============================== List ============================== */
.mk-bottom {
  display: grid;
  grid-template-columns: minmax(0, 3.6fr) minmax(220px, 1fr);
  gap: 14px;
  min-height: 0;
}
.mk-list { display: flex; flex-direction: column; padding: 14px 16px 10px; }
.mk-list .card__head { margin-bottom: 10px; }
.mk-list .card__title { font-size: 14px; }
.mk-list__status { font-size: 12px; font-weight: 400; color: var(--muted); }
.mk-list .btn--md .icon { width: 14px; height: 14px; }

.mk-table { width: 100%; border-collapse: collapse; font-size: 11.5px; }
.mk-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  padding: 8px 12px;
  font-size: 11px;
  font-weight: 500;
  text-align: left;
  color: var(--muted);
  background: var(--subtle);
}
.mk-table th:first-child { border-radius: 8px 0 0 8px; }
.mk-table th:last-child { border-radius: 0 8px 8px 0; }
.mk-table td {
  padding: 10px 12px;
  color: var(--text);
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
.mk-table tbody tr:last-child td { border-bottom: 0; }
.mk-table tbody tr:hover td { background: var(--primary-softer); }
.mk-table__q { width: 40%; max-width: 0; overflow: hidden; text-overflow: ellipsis; }
.mk-table__date { color: var(--text-2) !important; }
.mk-table__action { width: 1%; text-align: center !important; }
.mk-table tr.is-mastered td { color: var(--muted); }
.mk-done { display: inline-flex; vertical-align: -2px; margin-right: 6px; color: #36a271; }
.mk-done .icon { width: 14px; height: 14px; stroke-width: 2.5; }
.mk-table__empty { padding: 34px 0 !important; text-align: center; color: var(--muted) !important; white-space: normal !important; }
.mk-table__empty .icon { display: block; width: 24px; height: 24px; margin: 0 auto 8px; color: var(--orange); }

.topic-tag {
  display: inline-block;
  padding: 3px 10px;
  font-size: 10px;
  font-weight: 500;
  border-radius: 6px;
}
.topic-tag--pharma { color: #cf4767; background: var(--tone-pink); }
.topic-tag--patho { color: #8a63d2; background: var(--tone-purple); }
.topic-tag--medsurg { color: #2f8f6a; background: var(--tone-green); }
.topic-tag--community { color: #c4741a; background: var(--tint-peach); }
.topic-tag--maternal { color: var(--primary-600); background: var(--tone-blue); }
.topic-tag--medsurg2 { color: #3a8fc4; background: var(--tint-sky); }
.topic-tag--psych { color: #cf4767; background: var(--tone-pink); }

.ans { display: inline-flex; align-items: center; gap: 5px; font-weight: 600; }
.ans .icon { width: 12px; height: 12px; stroke-width: 2.6; }
.ans--wrong { color: var(--pink); }
.ans--right { color: #2f8f6a; }
.ans--skip { color: var(--muted); }

/* ============================== Study tip ============================== */
.study-tip {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 18px 18px 16px;
  background:
    url("../../assests/images/flowers-corner.svg") right -8px top 6px / 96px auto no-repeat,
    linear-gradient(180deg, #eef0fb 0%, #e3e9f7 100%);
}
.study-tip::before {
  content: "";
  position: absolute;
  inset: auto 0 0 0;
  aspect-ratio: 280 / 320;
  background: url("../../assests/images/exam-quote.svg") center bottom / 100% auto no-repeat;
  -webkit-mask-image: linear-gradient(180deg, transparent 0%, #000 40%);
          mask-image: linear-gradient(180deg, transparent 0%, #000 40%);
  pointer-events: none;
}
.study-tip > * { position: relative; z-index: 1; }
/* The card keeps its light wash in dark mode, so its text stays dark */
.study-tip .card__title { font-size: 14px; color: #1c3163; }
.study-tip .card__title .icon { color: #3c6fd4; }
.study-tip__text { font-size: 18px; line-height: 1.5; color: #2a3f73; }
.study-tip__text .note-heart { display: inline-block; vertical-align: middle; }
.study-tip__next { align-self: flex-start; color: #56678f; }

/* ============================== Review dialog ============================== */
.modal--review { width: min(640px, calc(100vw - 32px)); }
.modal--review h2 { display: flex; align-items: center; gap: 10px; }
.mastered-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 9px;
  font-size: 10.5px;
  font-weight: 600;
  color: #24835b;
  background: var(--tone-green);
  border-radius: 999px;
}
.mastered-pill .icon { width: 12px; height: 12px; }
.review-q { margin-top: 16px; font-size: 15.5px; font-weight: 500; line-height: 1.6; color: var(--text); }
.review-prev { display: flex; align-items: center; gap: 6px; margin-top: 8px; font-size: 12px; color: var(--pink); }
.review-prev .icon { width: 14px; height: 14px; flex: none; }
.review-hint { margin-top: 6px; font-size: 11.5px; color: var(--muted); }
.modal--review .options { margin-top: 14px; }
.review-actions { align-items: center; }
.review-actions__spacer { flex: 1; }
.review-actions .btn .icon { width: 14px; height: 14px; }

/* ============================== Breakpoints ============================== */
@media (max-width: 1320px) {
  .mk-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 1024px) {
  .mk-bottom { grid-template-columns: minmax(0, 1fr); }
  .study-tip { min-height: 220px; }
}
@media (max-width: 720px) {
  .mk-filters { flex-wrap: wrap; }
  .mk-stats { grid-template-columns: minmax(0, 1fr); }
  .mk-table th:nth-child(5), .mk-table td:nth-child(5),
  .mk-table th:nth-child(2), .mk-table td:nth-child(2) { display: none; }
}

/* Dark mode: keep the watercolor art, but on a deep wash so the card doesn't glare */
:root[data-theme="dark"] .study-tip { background: url("../../assests/images/flowers-corner.svg") right -8px top 6px / 96px auto no-repeat, linear-gradient(180deg, #27325e 0%, #1c2647 100%); }
:root[data-theme="dark"] .study-tip::before { opacity: 0.5; }
:root[data-theme="dark"] .study-tip__text, .study-tip .card__title, .study-tip__next { color: var(--script) !important; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .study-tip { background: url("../../assests/images/flowers-corner.svg") right -8px top 6px / 96px auto no-repeat, linear-gradient(180deg, #27325e 0%, #1c2647 100%); }
  :root:not([data-theme="light"]) .study-tip::before { opacity: 0.5; }
  :root:not([data-theme="light"]) .study-tip__text, .study-tip .card__title, .study-tip__next { color: var(--script) !important; }
}
:root[data-theme="dark"] .study-tip .card__title .icon { color: var(--primary); }

/* ============================== Exam rows ============================== */
.mk-exam { cursor: pointer; }
.mk-exam:focus-visible { outline: 0; }
.mk-exam:focus-visible td { background: var(--primary-softer); }
.mk-exam__icon {
  display: inline-grid;
  place-items: center;
  width: 26px;
  height: 26px;
  margin-right: 10px;
  vertical-align: middle;
  color: var(--pink);
  background: var(--tone-pink);
  border-radius: 7px;
}
.mk-exam__icon .icon { width: 14px; height: 14px; }
.mk-exam.is-mastered .mk-exam__icon { color: #2f8f6a; background: var(--tone-green); }
.mk-exam .mk-table__q { font-weight: 500; }
.np-pill { display: inline-block; padding: 3px 10px; font-size: 10px; font-weight: 600; color: var(--primary-600); background: var(--tone-blue); border-radius: 6px; }

/* ============================== Exam dialog: all wrong answers ============================== */
.modal--mistakes {
  width: min(1180px, calc(100vw - 48px));
  max-width: none;
  max-height: calc(100vh - 48px);
}
.modal--mistakes[open] { display: flex; flex-direction: column; }
.modal--mistakes .modal__body { display: flex; flex-direction: column; min-height: 0; padding: 0; }
.mk-sheet__head { padding: 20px 24px 16px; border-bottom: 1px solid var(--line); }
.mk-sheet__head h2 { font-size: 19px; }
.mk-sheet__tools { display: flex; align-items: center; gap: 10px; flex: none; }
.mk-sheet__tools .btn { gap: 7px; }
.mk-sheet__tools .btn .icon { width: 14px; height: 14px; }
.mk-sheet__list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin: 0;
  padding: 18px 24px 24px;
  overflow-y: auto;
  list-style: none;
}
.mk-card {
  padding: 16px 18px;
  background: var(--card-solid);
  border: 1px solid var(--card-border);
  border-left: 4px solid var(--pink);
  border-radius: 12px;
}
.mk-card.is-mastered { border-left-color: #36a271; }
.mk-card__top { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.mk-card__num {
  display: grid;
  place-items: center;
  min-width: 26px;
  height: 26px;
  padding: 0 6px;
  font-size: 12px;
  font-weight: 700;
  color: var(--primary-600);
  background: var(--primary-soft);
  border-radius: 999px;
}
.mk-card__spacer { flex: 1; }
.mk-card__top .btn { gap: 6px; padding: 6px 12px; font-size: 11.5px; }
.mk-card__top .btn .icon { width: 13px; height: 13px; }
.mk-card__q { margin-top: 10px; font-size: 14.5px; font-weight: 500; line-height: 1.6; color: var(--text); }
.mk-card__answers { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-top: 12px; }
.mk-ans {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 10px 12px;
  font-size: 12.5px;
  line-height: 1.5;
  border-radius: 10px;
}
.mk-ans .icon { flex: none; width: 15px; height: 15px; margin-top: 2px; stroke-width: 2.6; }
.mk-ans b { font-weight: 600; }
.mk-ans--wrong, .mk-ans--skip { color: #b3264f; background: var(--tone-pink); }
.mk-ans--right { color: #1f7a52; background: var(--tone-green); }
.mk-card__why { margin-top: 10px; padding: 10px 12px; font-size: 12.5px; line-height: 1.6; color: var(--text-2); background: var(--subtle); border-radius: 10px; }
.mk-card__why b { color: var(--text); font-weight: 600; }
@media (max-width: 760px) {
  .mk-card__answers { grid-template-columns: minmax(0, 1fr); }
  .mk-sheet__head { flex-wrap: wrap; }
}

/* Select & delete */
.mk-list__tools { display: flex; align-items: center; gap: 10px; }
.mk-table .bulk-check { margin-right: 10px; vertical-align: middle; }

/* Confidence, guesses, retry progress and "why?" tags */
.mk-pill { display: inline-flex; align-items: center; padding: 2px 9px; font-size: 10.5px; font-weight: 600; color: var(--text-2); background: var(--subtle); border-radius: 999px; }
.mk-pill--warn { color: #b3264f; background: var(--tone-pink); }
.mk-pill--guess { color: #c4741a; background: var(--tint-peach); }
.mk-pill--progress { color: var(--primary-600); background: var(--primary-soft); }
.mk-ans--guess { color: #8a5a12; background: var(--tint-peach); }
.mk-ans--guess em { font-style: normal; font-weight: 600; }
.mk-reason { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 10px; font-size: 11.5px; color: var(--muted); }
.mk-reason > span { margin-right: 2px; font-weight: 600; }
.mk-reason__btn {
  padding: 4px 10px;
  font: inherit;
  font-size: 11px;
  color: var(--text-2);
  background: var(--card-solid);
  border: 1px solid var(--card-border);
  border-radius: 999px;
  cursor: pointer;
}
.mk-reason__btn:hover { border-color: var(--primary); }
.mk-reason__btn.is-on { color: var(--primary-600); background: var(--primary-softer); border-color: var(--primary); font-weight: 600; }
