/* =================================================================
   TMS BUG REPORTER — floating button + wizard modal
   Self-contained (no page CSS-var or icon-font dependency), styled to
   the TMS blue. Ported from WSOL's bug reporter, adapted to the vault's
   online editor pages (corpus / audit / team). Class prefix: tmsbug-
   ================================================================= */

/* ---- Floating button ---- */
.tmsbug-fab {
  position: fixed;
  right: 18px;
  bottom: 18px;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  border: none;
  background: #1769d6;
  color: #fff;
  cursor: pointer;
  box-shadow: 0 2px 10px rgba(20, 25, 35, .28);
  z-index: 2147483000;
  display: none;               /* revealed by JS once signed in */
  align-items: center;
  justify-content: center;
  transition: transform .15s ease, background .15s ease, box-shadow .15s ease;
}
.tmsbug-fab.tmsbug-show { display: flex; }
.tmsbug-fab:hover { background: #1257b3; transform: scale(1.08); box-shadow: 0 6px 16px rgba(23, 105, 214, .4); }
.tmsbug-fab:active { transform: scale(.95); }
.tmsbug-fab svg { width: 22px; height: 22px; display: block; fill: currentColor; }

/* ---- Overlay ---- */
.tmsbug-modal {
  position: fixed;
  inset: 0;
  background: rgba(16, 22, 34, .5);
  z-index: 2147483001;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.tmsbug-modal.tmsbug-hidden { display: none; }

/* ---- Card ---- */
.tmsbug-card {
  background: #fff;
  color: #14181f;
  border-radius: 14px;
  width: 100%;
  max-width: 480px;
  box-shadow: 0 20px 60px rgba(20, 25, 35, .3);
  overflow: hidden;
  animation: tmsbug-in .2s ease-out;
}
@keyframes tmsbug-in {
  from { opacity: 0; transform: translateY(16px) scale(.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* ---- Header ---- */
.tmsbug-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 14px 18px;
  background: #1769d6;
  color: #fff;
}
.tmsbug-head h3 { margin: 0; font-size: 16px; font-weight: 700; display: flex; align-items: center; gap: 8px; }
.tmsbug-head h3 svg { width: 18px; height: 18px; fill: currentColor; }
.tmsbug-x { background: none; border: none; color: #fff; font-size: 22px; line-height: 1; cursor: pointer; opacity: .85; padding: 0 2px; }
.tmsbug-x:hover { opacity: 1; }

/* ---- Body ---- */
.tmsbug-body { padding: 18px; }
.tmsbug-step.tmsbug-hidden { display: none; }
.tmsbug-q { font-size: 16px; font-weight: 600; margin: 0 0 14px; text-align: center; }

.tmsbug-choices { display: flex; flex-direction: column; gap: 10px; }
.tmsbug-choice {
  display: flex; align-items: center; gap: 10px;
  padding: 13px 15px;
  border: 2px solid #e6e8ec; border-radius: 9px;
  background: #fff; color: #14181f; font-size: 14px; font-family: inherit;
  cursor: pointer; text-align: left;
  transition: border-color .15s, background .15s;
}
.tmsbug-choice:hover { border-color: #1769d6; background: #f3f8ff; }
.tmsbug-choice svg { width: 18px; height: 18px; flex: none; fill: #5b6472; }

.tmsbug-tip {
  display: flex; align-items: flex-start; gap: 9px;
  background: #ecfdf5; border-left: 4px solid #10b981; border-radius: 6px;
  padding: 11px 13px; margin-bottom: 14px; font-size: 13px; line-height: 1.5; color: #065f46;
}
.tmsbug-tip svg { width: 16px; height: 16px; flex: none; margin-top: 2px; fill: #10b981; }

.tmsbug-label { display: block; font-size: 12px; font-weight: 700; letter-spacing: .4px; text-transform: uppercase; color: #5b6472; margin: 0 0 6px; }
.tmsbug-textarea {
  width: 100%; box-sizing: border-box; padding: 10px 12px;
  border: 2px solid #e6e8ec; border-radius: 8px; font-size: 14px; font-family: inherit;
  background: #fff; color: #14181f; resize: vertical; margin-bottom: 14px;
  transition: border-color .15s;
}
.tmsbug-textarea:focus { outline: none; border-color: #1769d6; }

.tmsbug-prio { display: flex; gap: 6px; margin-bottom: 16px; }
.tmsbug-prio button {
  flex: 1; padding: 8px 4px; border: 2px solid #e6e8ec; border-radius: 6px;
  background: #fff; color: #14181f; font-size: 12px; font-weight: 600; font-family: inherit; cursor: pointer;
  transition: all .15s;
}
.tmsbug-prio button:hover { border-color: #9aa3b2; }
.tmsbug-prio button.tmsbug-active[data-prio="low"]      { background: #22c55e; border-color: #22c55e; color: #fff; }
.tmsbug-prio button.tmsbug-active[data-prio="normal"]   { background: #eab308; border-color: #eab308; color: #fff; }
.tmsbug-prio button.tmsbug-active[data-prio="high"]     { background: #f97316; border-color: #f97316; color: #fff; }
.tmsbug-prio button.tmsbug-active[data-prio="critical"] { background: #dc2626; border-color: #dc2626; color: #fff; }

.tmsbug-disclose { font-size: 11.5px; color: #5b6472; line-height: 1.5; margin: 0 0 14px; }

.tmsbug-actions { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.tmsbug-back {
  padding: 9px 14px; border: none; border-radius: 6px; background: #f0f2f6; color: #5b6472;
  font-size: 13px; font-family: inherit; cursor: pointer; display: inline-flex; align-items: center; gap: 6px;
}
.tmsbug-back:hover { background: #e6e8ec; }
.tmsbug-submit {
  padding: 10px 20px; border: none; border-radius: 7px; background: #1769d6; color: #fff;
  font-size: 14px; font-weight: 700; font-family: inherit; cursor: pointer;
  display: inline-flex; align-items: center; gap: 8px;
}
.tmsbug-submit:hover { background: #1257b3; }
.tmsbug-submit:disabled { opacity: .6; cursor: default; }

.tmsbug-center { text-align: center; padding: 26px 0; color: #5b6472; }
.tmsbug-center .tmsbug-spin { width: 34px; height: 34px; margin: 0 auto 12px; border: 3px solid #dfe3ea; border-top-color: #1769d6; border-radius: 50%; animation: tmsbug-rot .8s linear infinite; }
@keyframes tmsbug-rot { to { transform: rotate(360deg); } }
.tmsbug-center .tmsbug-ok { width: 44px; height: 44px; margin: 0 auto 10px; display: block; fill: #22c55e; }
.tmsbug-center h4 { margin: 0 0 6px; font-size: 16px; color: #14181f; }
.tmsbug-center p { margin: 4px 0; font-size: 13px; }

.tmsbug-err { color: #c0392b; font-size: 13px; margin: 0 0 10px; min-height: 1em; }

/* ---- Dark mode ---- */
@media (prefers-color-scheme: dark) {
  .tmsbug-card { background: #1a1f28; color: #e7eaf0; }
  .tmsbug-choice { background: #232a34; color: #e7eaf0; border-color: #333c48; }
  .tmsbug-choice:hover { background: #2a3644; border-color: #4a90e2; }
  .tmsbug-choice svg { fill: #9aa3b2; }
  .tmsbug-textarea, .tmsbug-prio button { background: #232a34; color: #e7eaf0; border-color: #333c48; }
  .tmsbug-back { background: #2a313c; color: #b7c0ce; }
  .tmsbug-back:hover { background: #333c48; }
  .tmsbug-tip { background: rgba(16,185,129,.12); color: #6ee7b7; }
  .tmsbug-tip svg { fill: #6ee7b7; }
  .tmsbug-center h4 { color: #e7eaf0; }
}

/* ---- Mobile ---- */
@media (max-width: 480px) {
  .tmsbug-fab { right: 12px; bottom: 12px; width: 42px; height: 42px; }
  .tmsbug-prio { flex-wrap: wrap; }
  .tmsbug-prio button { flex: 1 1 45%; }
}
