/*
 * LexiCore — the agent review panel.
 *
 * A sheet over the screen the user is already on, so the records being changed
 * stay in their context rather than the app jumping somewhere else to ask.
 * Deliberately plain: this is the moment a person decides whether something
 * happens to a client's matter, and decoration here competes with the diff.
 *
 * Colour is never the only signal. A locked row carries the word LOCKED and its
 * reason; before/after are distinguished by position and label as well as tint.
 */

#agent-review-panel {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: flex;
  align-items: stretch;
  justify-content: flex-end;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

#agent-review-panel .ar-scrim {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
}

#agent-review-panel .ar-sheet {
  position: relative;
  width: min(46rem, 100%);
  background: #fff;
  display: flex;
  flex-direction: column;
  box-shadow: -8px 0 32px rgba(15, 23, 42, 0.2);
}

#agent-review-panel .ar-head {
  padding: 1.25rem 1.5rem 1rem;
  border-bottom: 1px solid #e2e8f0;
}
#agent-review-panel h2 {
  margin: 0 0 0.35rem;
  font-size: 1.15rem;
  color: #0f172a;
}
#agent-review-panel h2:focus-visible {
  outline: 2px solid #1e40af;
  outline-offset: 3px;
}
#agent-review-panel .ar-sub {
  margin: 0 0 0.5rem;
  font-size: 0.9rem;
  color: #334155;
}
#agent-review-panel .ar-ask {
  margin: 0;
  font-size: 0.85rem;
  color: #64748b;
  font-style: italic;
}

#agent-review-panel .ar-body {
  flex: 1;
  overflow-y: auto;
  padding: 1rem 1.5rem;
}

#agent-review-panel .ar-step {
  margin-bottom: 1.5rem;
  padding-bottom: 1.25rem;
  border-bottom: 1px solid #f1f5f9;
}
#agent-review-panel .ar-step:last-child {
  border-bottom: 0;
}
#agent-review-panel .ar-step h3 {
  margin: 0 0 0.5rem;
  font-size: 0.98rem;
  color: #0f172a;
}
/* A removal reads as a removal. Same shape as the new badge, opposite colour,
   because a reviewer scanning a list of steps should be able to tell the two
   apart without reading a word of the diff. */
#agent-review-panel .ar-gone {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  background: #fee2e2;
  color: #7f1d1d;
  padding: 0.1rem 0.4rem;
  border-radius: 3px;
  vertical-align: middle;
}

#agent-review-panel .ar-new {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  background: #dcfce7;
  color: #14532d;
  padding: 0.1rem 0.4rem;
  border-radius: 3px;
  vertical-align: middle;
}
#agent-review-panel .ar-step-blocked {
  opacity: 0.75;
}
#agent-review-panel .ar-blocked {
  margin: 0 0 0.5rem;
  font-size: 0.85rem;
  color: #92400e;
  background: #fef3c7;
  border-left: 3px solid #b45309;
  padding: 0.4rem 0.6rem;
}

/* The diff scrolls inside itself; the page never scrolls sideways. */
#agent-review-panel .ar-diff {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.86rem;
  display: block;
  overflow-x: auto;
}
#agent-review-panel .ar-diff th,
#agent-review-panel .ar-diff td {
  text-align: left;
  padding: 0.4rem 0.6rem;
  border-bottom: 1px solid #f1f5f9;
  vertical-align: top;
}
#agent-review-panel .ar-diff thead th {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: #64748b;
  border-bottom: 1px solid #e2e8f0;
}
#agent-review-panel .ar-diff tbody th {
  font-weight: 600;
  color: #334155;
  white-space: nowrap;
}
#agent-review-panel .ar-before {
  color: #7f1d1d;
  background: #fef2f2;
}
#agent-review-panel .ar-after {
  color: #14532d;
  background: #f0fdf4;
}
#agent-review-panel .ar-arrow {
  color: #94a3b8;
  padding: 0.4rem 0.2rem;
}
#agent-review-panel .ar-empty {
  color: #94a3b8;
  font-style: italic;
}

#agent-review-panel .ar-locked .ar-after {
  background: #f8fafc;
  color: #64748b;
  text-decoration: line-through;
}
#agent-review-panel .ar-lock {
  display: inline-block;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  color: #7c2d12;
  background: #ffedd5;
  border: 1px solid #c2410c;
  padding: 0.1rem 0.35rem;
  border-radius: 3px;
}
#agent-review-panel .ar-lockwhy {
  display: block;
  font-size: 0.75rem;
  color: #78350f;
  margin-top: 0.2rem;
  max-width: 18rem;
}

#agent-review-panel .ar-link {
  font-size: 0.82rem;
  color: #1e40af;
}

#agent-review-panel .ar-foot {
  padding: 0.9rem 1.5rem;
  border-top: 1px solid #e2e8f0;
  display: flex;
  gap: 0.6rem;
  justify-content: flex-end;
  align-items: center;
  background: #f8fafc;
}
#agent-review-panel .ar-stale {
  margin: 0;
  padding: 0.75rem 1.25rem;
  border-top: 1px solid #fcd34d;
  background: #fffbeb;
  color: #78350f;
  font-size: 0.88rem;
}
#agent-review-panel .ar-stale p {
  margin: 0 0 0.35rem;
  font-weight: 600;
}
#agent-review-panel .ar-stale ul {
  margin: 0;
  padding-left: 1.2rem;
}
#agent-review-panel .ar-settled {
  margin: 0 auto 0 0;
  font-size: 0.85rem;
  color: #475569;
}
#agent-review-panel .ar-btn {
  font: inherit;
  font-size: 0.88rem;
  padding: 0.5rem 0.95rem;
  border-radius: 6px;
  border: 1px solid #cbd5e1;
  background: #fff;
  color: #334155;
  cursor: pointer;
}
#agent-review-panel .ar-btn:hover {
  background: #f1f5f9;
}
#agent-review-panel .ar-approve {
  background: #1e40af;
  border-color: #1e40af;
  color: #fff;
  font-weight: 600;
}
#agent-review-panel .ar-approve:hover {
  background: #1d4ed8;
}
#agent-review-panel .ar-btn:disabled {
  opacity: 0.6;
  cursor: default;
}
#agent-review-panel .ar-btn:focus-visible {
  outline: 2px solid #0f172a;
  outline-offset: 2px;
}

.ar-sr {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

@media (max-width: 640px) {
  #agent-review-panel .ar-sheet {
    width: 100%;
  }
}

@media (prefers-reduced-motion: reduce) {
  #agent-review-panel * {
    transition: none !important;
    animation: none !important;
  }
}

/*
 * What else a step sets in motion.
 *
 * Rendered above the record link, in the same warning register as a blocked
 * step, because it changes the meaning of Approve: a reviewer who reads only
 * the diff of a new matter's own fields has not seen the seventeen tasks that
 * come with it.
 */
#agent-review-panel .ar-also {
  margin: 0.5rem 0 0.6rem;
  padding: 0.5rem 0.7rem 0.5rem 1.6rem;
  background: #eff6ff;
  border-left: 3px solid #1e40af;
  font-size: 0.85rem;
  color: #1e3a8a;
}
#agent-review-panel .ar-also li {
  margin: 0.1rem 0;
}

/* Editable review fields.
 *
 * Review that can only say yes or no is not review, so the fields review is
 * actually for - the wording and the recipient - are inputs. They are styled
 * to look editable at a glance: a text box that reads like static text invites
 * someone to approve wording they meant to change. */
#agent-review-panel .ar-input {
  width: 100%;
  box-sizing: border-box;
  font: inherit;
  color: inherit;
  padding: 6px 8px;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  background: #fff;
}
#agent-review-panel .ar-input:focus {
  outline: 2px solid #2563eb;
  outline-offset: 1px;
  border-color: #2563eb;
}
#agent-review-panel .ar-textarea {
  min-height: 8.5em;
  line-height: 1.45;
  resize: vertical;
  white-space: pre-wrap;
}
#agent-review-panel .ar-other {
  margin-top: 6px;
}
#agent-review-panel tr.ar-editable > th {
  vertical-align: top;
  padding-top: 12px;
}
/* The arrow is decoration between two static values; against an input it
   just crowds the field. */
#agent-review-panel tr.ar-editable .ar-arrow {
  opacity: 0.35;
  vertical-align: top;
  padding-top: 12px;
}

/* THE LETTER, AT THE WIDTH OF THE SHEET.
 *
 * A textarea is rendered as its own full-width row rather than inside the
 * AFTER cell (see agent-review.js). The cell was about 150px wide in a 46rem
 * panel, which is what the body of a client letter was edited through. The
 * narrow grid is right for one-line fields and wrong for this one. */
#agent-review-panel .ar-wide-label > th {
  padding-bottom: 0.15rem;
  border-bottom: 0;
}
#agent-review-panel .ar-wide-cell {
  background: #f0fdf4;
  padding: 0.35rem 0.6rem 0.7rem;
}
#agent-review-panel .ar-wide-cell .ar-textarea {
  /* Tall enough to hold a whole short letter without scrolling, and still
   * resizable for a long one. */
  min-height: 14em;
}

/* A commit that failed, said inside the sheet (P6-D5). */
#agent-review-panel .ar-failed {
  margin: 0;
  padding: 0.75rem 1.25rem;
  border-top: 1px solid #fca5a5;
  background: #fef2f2;
  color: #7f1d1d;
  font-size: 0.88rem;
}
#agent-review-panel .ar-failed p {
  margin: 0 0 0.35rem;
  font-weight: 600;
}
#agent-review-panel .ar-failed ul {
  margin: 0;
  padding-left: 1.2rem;
}

/*
 * The way back to a change set left waiting (P6-D15). Bottom centre, clear of
 * the assistant and Help buttons at the bottom right, and under the sheet.
 */
#agent-review-waiting {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  z-index: 9995;
  max-width: calc(100% - 200px);
  padding: 0.55rem 1.1rem;
  border: 1px solid #1e40af;
  border-radius: 999px;
  background: #1e40af;
  color: #fff;
  font: 600 0.88rem/1.2 -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  box-shadow: 0 6px 18px rgba(15, 23, 42, 0.25);
  cursor: pointer;
}
#agent-review-waiting:hover {
  background: #1d4ed8;
}
#agent-review-waiting:focus-visible {
  outline: 3px solid #0f172a;
  outline-offset: 2px;
}
#agent-review-waiting[hidden] {
  display: none;
}
@media (max-width: 480px) {
  #agent-review-waiting {
    left: 16px;
    transform: none;
    max-width: calc(100% - 120px);
    white-space: normal;
  }
}
