/*
  Styles for the AI generation modal. Kept in its own file rather than
  appended to assets/styles.css so the core stylesheet stays exactly as
  it was — this feature can be removed by deleting three tags from
  index.html and this folder.

  Everything here builds on the existing .modal-overlay / .modal-box /
  .chip / .btn primitives and the :root purple palette, so the panel
  reads as part of the app rather than a bolt-on.
*/

.ai-modal {
  width: 660px;
  max-width: 94vw;
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  padding: 0;
}
.ai-modal-head {
  padding: 22px 26px 0;
}
.ai-modal-head h3 {
  margin: 0 0 6px;
  font-size: 19px;
}
.ai-modal-body {
  padding: 18px 26px 0;
  overflow-y: auto;
  flex: 1;
}
.ai-modal-foot {
  padding: 16px 26px 22px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  align-items: center;
  margin-top: 16px;
}
.ai-modal-foot .btn { white-space: nowrap; }
.ai-modal-foot .ai-foot-note {
  margin-right: auto;
  font-size: 12.5px;
  color: var(--text-muted);
  max-width: 320px;
  line-height: 1.45;
}

.ai-sub {
  font-size: 13.5px;
  color: var(--text-muted);
  line-height: 1.55;
  margin: 0;
}

.ai-field { margin-bottom: 18px; }
.ai-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 7px;
}
.ai-input,
.ai-textarea,
.ai-select {
  width: 100%;
  box-sizing: border-box;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 14px;
  font-family: inherit;
  color: var(--text-main);
  background: #fff;
}
.ai-textarea { min-height: 84px; resize: vertical; line-height: 1.5; }
.ai-input:focus,
.ai-textarea:focus,
.ai-select:focus {
  outline: none;
  border-color: var(--purple);
  box-shadow: 0 0 0 3px var(--purple-track);
}

.ai-check {
  display: flex;
  gap: 9px;
  align-items: flex-start;
  font-size: 13.5px;
  line-height: 1.5;
  cursor: pointer;
}
.ai-check input { margin-top: 3px; flex: none; }

.ai-backend-line {
  font-size: 12.5px;
  color: var(--text-muted);
  line-height: 1.5;
  margin-top: 8px;
}
.ai-backend-line.warn { color: var(--red-text); }

/* ---- Progress ---- */

.ai-progress {
  background: var(--purple-light);
  border-radius: 12px;
  padding: 14px 16px;
  font-size: 13.5px;
  color: var(--purple-dark);
  margin-bottom: 16px;
}
.ai-progress-bar {
  height: 6px;
  border-radius: 999px;
  background: var(--purple-track);
  margin-top: 10px;
  overflow: hidden;
}
.ai-progress-bar > span {
  display: block;
  height: 100%;
  background: var(--purple);
  border-radius: 999px;
  transition: width .3s ease;
}

/* ---- Preview board ---- */

.ai-board-summary {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}
.ai-pill {
  border-radius: 999px;
  padding: 5px 12px;
  font-size: 12.5px;
  font-weight: 600;
  background: var(--gray-pill);
  color: var(--text-main);
}
.ai-pill.ok { background: var(--green-bg); color: var(--green-text); }
.ai-pill.bad { background: var(--red-bg); color: var(--red-text); }

.ai-card {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 16px;
  margin-bottom: 12px;
}
.ai-card.flagged { border-color: #f0c9c3; background: #fffaf9; }
.ai-card.dropped { opacity: .5; }

.ai-card-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}
.ai-card-num {
  font-size: 12px;
  font-weight: 700;
  color: var(--purple-dark);
  background: var(--purple-track);
  border-radius: 999px;
  padding: 3px 9px;
  flex: none;
}
.ai-card-topic {
  font-size: 12.5px;
  color: var(--text-muted);
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ai-card-actions { display: flex; gap: 6px; flex: none; }

.ai-mini-btn {
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 999px;
  padding: 4px 11px;
  font-size: 12px;
  cursor: pointer;
  color: var(--text-main);
}
.ai-mini-btn:hover { background: var(--gray-pill); }
.ai-mini-btn.danger { color: var(--red-text); }

.ai-stem {
  font-size: 14px;
  line-height: 1.5;
  margin: 0 0 10px;
}
.ai-choices { list-style: none; margin: 0; padding: 0; }
.ai-choices li {
  font-size: 13.5px;
  padding: 4px 0 4px 24px;
  position: relative;
  line-height: 1.45;
}
.ai-choices li::before {
  content: attr(data-letter);
  position: absolute;
  left: 0;
  font-weight: 600;
  color: var(--text-muted);
}
.ai-choices li.correct { color: var(--green-text); font-weight: 600; }
.ai-choices li.correct::before { color: var(--green-text); }

.ai-flags {
  margin-top: 10px;
  border-top: 1px dashed var(--border);
  padding-top: 9px;
  font-size: 12.5px;
  line-height: 1.55;
}
.ai-flag { display: block; }
.ai-flag.bad { color: var(--red-text); }
.ai-flag.note { color: var(--text-muted); }
.ai-flag code {
  background: var(--gray-pill);
  border-radius: 5px;
  padding: 1px 5px;
  font-size: 12px;
}

.ai-card-diagram { margin: 10px 0; }
.ai-card-diagram svg { max-width: 100%; height: auto; }

/* ---- Inline editor ---- */

.ai-edit { margin-top: 10px; }
.ai-edit .ai-label { margin-top: 10px; }
.ai-edit-choice {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}
.ai-edit-choice input[type="radio"] { flex: none; }
.ai-edit-choice .ai-input { flex: 1; }

.ai-rejects {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 14px;
  font-size: 12.5px;
  color: var(--text-muted);
  line-height: 1.55;
  margin-bottom: 12px;
}
.ai-rejects strong { color: var(--text-main); }

.ai-error {
  background: var(--red-bg);
  color: var(--red-text);
  border-radius: 12px;
  padding: 14px 16px;
  font-size: 13.5px;
  line-height: 1.55;
  white-space: pre-wrap;
  margin-bottom: 16px;
}

.ai-warn {
  background: #fff8e8;
  color: #8a6100;
  border-radius: 12px;
  padding: 12px 14px;
  font-size: 12.5px;
  line-height: 1.55;
  margin-bottom: 14px;
}

/* ---- Settings panel additions ---- */

.ssp-ai-block {
  border-top: 1px solid var(--border);
  margin-top: 12px;
  padding-top: 12px;
}
.ssp-ai-block .ai-label { margin-bottom: 6px; }
.ssp-ai-block .ai-select,
.ssp-ai-block .ai-input { font-size: 13px; padding: 8px 10px; }
.ssp-ai-block .ai-backend-line { margin-top: 6px; }
.ssp-ai-key { margin-top: 10px; }
.ssp-ai-open {
  margin-top: 12px;
  width: 100%;
  padding: 9px 14px;
  font-size: 13.5px;
}

/* ---- Archived attempt review ---------------------------------------
   A banner rather than a subtle badge: replaying a past attempt looks
   almost identical to taking the quiz, and someone who doesn't notice
   will wonder why their clicks do nothing. */

.attempt-review-banner {
  display: flex;
  align-items: center;
  gap: 14px;
  justify-content: space-between;
  flex-wrap: wrap;
  background: var(--purple-light);
  color: var(--purple-dark);
  border-bottom: 1px solid var(--purple-track);
  padding: 10px 22px;
  font-size: 13px;
  line-height: 1.5;
}
.attempt-review-banner .link-btn {
  color: var(--purple-dark);
  font-weight: 600;
  white-space: nowrap;
}

/* The whiteboard toolbar while a past attempt is on screen: the drawing
   tools are inert (blocked at the pointer handler), so they shouldn't
   look available. */
#annotate-toolbar.at-readonly .at-btn[data-tool]:not([data-tool="select"]) {
  opacity: 0.4;
  pointer-events: none;
}

/* ---- Profile badge --------------------------------------------------
   Sits at the end of the header row. Fixed size so the header height
   never shifts between the monogram and photo states. */

.profile-badge {
  width: 32px;
  height: 32px;
  flex: none;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--gray-pill);
  color: var(--text-muted);
  font-size: 12.5px;
  font-weight: 700;
  letter-spacing: .02em;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  padding: 0;
  margin-left: 2px;
}
.profile-badge:hover { background: var(--gray-pill-hover); color: var(--purple-dark); }
.profile-badge.has-photo { border-color: var(--purple-track); background: #fff; }
.profile-badge img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
