/* agent-chat.css: the agent core's chat parts (js/agent-chat.js) inside the
   eDash bot sheet and on the Operations > Surat page.

   Every size and radius reads a token (--type-*-size, --r-*), per
   scripts/check-type-roles.py. The glass stays on the chrome the sheet
   already paints (DESIGN.md: glass is chrome, never content): tool chips
   carry the landing's chip rim, while charts, draft previews and confirm
   cards are flat opaque surfaces, because they are content. */

.ac-bubble { display: flex; flex-direction: column; gap: 6px; max-width: 92%; }
.ac-text:empty { display: none; }
.ac-wait { color: var(--muted, #5B6B75); font-size: var(--type-caption-size); }
.ac-wait::after { content: " ..."; }
.ac-note { color: var(--muted, #5B6B75); font-size: var(--type-caption-size); margin: 2px 0 0; }
.eb-bubble.is-error { border-color: var(--danger, #B42318); }

/* Tool chips: glass chips, the landing's rim on a light tint. */
.ac-tools { display: flex; flex-wrap: wrap; gap: 4px; }
.ac-tools:empty { display: none; }
.ac-chip {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 8px;
  border-radius: var(--r-chip);
  font-size: var(--type-chip-size);
  color: var(--primary-dark, #0B4F54);
  background: var(--primary-soft, #E4F1F1);
  box-shadow: var(--gl-chip-rim, inset 0 1px 0 rgba(255, 255, 255, .35));
  border: 1px solid var(--border, #E7EDEE);
}
.ac-chip.is-denied, .ac-chip.is-error { color: var(--danger, #B42318); background: var(--danger-soft, #FDECEA); }
.ac-chip i { font-size: var(--type-caption-size); }

.ac-extras { display: flex; flex-direction: column; gap: 8px; }
.ac-extras:empty { display: none; }

/* Charts are content: flat and opaque. */
.ac-chart { margin: 0; padding: 8px; background: var(--surface, #fff); border: 1px solid var(--border, #E7EDEE); border-radius: var(--r-ctl); }
.ac-chart-title { font-size: var(--type-label-size); font-weight: 600; color: var(--ink, #25343F); margin-bottom: 4px; }
.ac-chart-box { position: relative; height: 180px; }
.ac-chart-cap { font-size: var(--type-caption-size); color: var(--muted, #5B6B75); margin: 4px 0 0; }

.ac-confirm, .ac-map {
  padding: 8px 10px;
  background: var(--surface-alt, #F4F8F8);
  border: 1px solid var(--border-strong, #CFDCDD);
  border-radius: var(--r-ctl);
}
.ac-confirm p, .ac-map p { margin: 0 0 6px; font-size: var(--type-body-size); }
.ac-result { color: var(--primary-dark, #0B4F54); font-weight: 600; }
.ac-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.ac-btn {
  border: 1px solid var(--border-strong, #CFDCDD);
  background: var(--surface, #fff);
  color: var(--ink, #25343F);
  border-radius: var(--r-ctl);
  padding: 6px 12px;
  font-family: inherit;
  font-size: var(--type-button-size);
  font-weight: 600;
  cursor: pointer;
}
.ac-btn.is-primary { background: var(--gl-action, #0B7A82); border-color: transparent; color: #fff; box-shadow: var(--gl-action-rim, none); }
.ac-btn:disabled { opacity: .6; cursor: default; }

/* The draft panel: a flat document preview. */
.ac-draft {
  display: flex; flex-direction: column; gap: 6px;
  padding: 10px 12px;
  background: var(--surface, #fff);
  border-top: 1px solid var(--border, #E7EDEE);
}
.ac-draft[hidden] { display: none; }
.ac-draft-head { display: flex; justify-content: space-between; align-items: baseline; font-size: var(--type-card-title-size); }
.ac-draft-state { font-size: var(--type-caption-size); color: var(--muted, #5B6B75); }
.ac-draft-missing { margin: 0; padding-left: 18px; color: var(--warning, #B54708); font-size: var(--type-caption-size); }
.ac-draft-missing:empty { display: none; }
.ac-draft-preview {
  margin: 0;
  max-height: 220px;
  overflow: auto;
  white-space: pre-wrap;
  font-family: inherit;
  font-size: var(--type-caption-size);
  line-height: 1.45;
  padding: 8px;
  background: var(--surface-alt, #F4F8F8);
  border-radius: var(--r-ctl);
}

/* The bot sheet grows when it carries a draft (desktop only). */
@media (min-width: 901px) {
  .eb-sheet.has-draft { width: min(520px, calc(100vw - 32px)); }
}
.eb-draft-host { flex: none; max-height: 45%; overflow: auto; }

/* ---------------------------------------------------------------- the Surat page */

.sr-head { margin-bottom: 16px; max-width: 760px; }
.sr-head h1 { margin: 0; font-size: var(--type-page-title-size); font-weight: var(--type-page-title-weight); line-height: var(--type-page-title-lh); color: var(--ink, #25343F); }
.sr-head p { margin: 6px 0 0; color: var(--muted, #5B6B75); font-size: var(--type-body-size); }

.sr-root { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; align-items: start; }
@media (max-width: 1000px) { .sr-root { grid-template-columns: minmax(0, 1fr); } }
.sr-card {
  background: var(--surface, #fff);
  border: 1px solid var(--border, #E7EDEE);
  border-radius: var(--r-card);
  display: flex; flex-direction: column;
  min-height: 0;
}
.sr-card-head { padding: 12px 14px; border-bottom: 1px solid var(--border, #E7EDEE); }
.sr-card-head h2 { margin: 0; font-size: var(--type-section-head-size); }
.sr-card-head p { margin: 4px 0 0; color: var(--muted, #5B6B75); font-size: var(--type-caption-size); }
.sr-chat { height: min(70vh, 720px); }
.sr-chat .eb-log { flex: 1; overflow: auto; padding: 12px; display: flex; flex-direction: column; gap: 8px; }
.sr-chat .eb-form { display: flex; gap: 8px; padding: 10px 12px; border-top: 1px solid var(--border, #E7EDEE); }
.sr-chat .eb-form textarea {
  flex: 1; resize: vertical; min-height: 44px; max-height: 200px;
  border: 1px solid var(--border, #E7EDEE); border-radius: var(--r-ctl);
  padding: 8px 10px; font-family: inherit; font-size: var(--type-body-size);
  background: var(--surface, #fff); color: inherit;
}
.sr-side .ac-draft { border-top: 0; }
.sr-side .ac-draft-preview { max-height: 60vh; font-size: var(--type-body-size); }
.sr-empty { padding: 14px; color: var(--muted, #5B6B75); font-size: var(--type-body-size); }
.sr-saved { list-style: none; margin: 0; padding: 0 14px 12px; display: flex; flex-direction: column; gap: 4px; }
.sr-saved button { width: 100%; text-align: left; }
.sr-rules { margin: 0; padding: 0 14px 12px 30px; font-size: var(--type-caption-size); color: var(--muted, #5B6B75); }

:root[data-theme="dark"] .ac-chip { color: var(--primary-soft, #E4F1F1); background: rgba(255, 255, 255, .06); border-color: rgba(255, 255, 255, .12); }

/* ---------------------------------------------------------------- the Drafting workspace
   (pages/drafting.html, js/drafting.js). Documents are content: flat and
   opaque, never glass. The preview reads like the PDF: English left,
   Bahasa Indonesia right, stacked on a phone. */

.dr-work-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; flex-wrap: wrap; }
.dr-work-tools { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.dr-check { display: inline-flex; align-items: flex-start; gap: 6px; font-size: var(--type-caption-size); color: var(--ink, #25343F); }
.dr-check input { margin-top: 2px; }
.dr-list { list-style: none; margin: 0; padding: 8px 14px; display: flex; flex-direction: column; gap: 4px; max-height: 220px; overflow: auto; border-bottom: 1px solid var(--border, #E7EDEE); }
.dr-item {
  width: 100%; display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px 8px; text-align: left;
  padding: 6px 8px; background: var(--surface, #fff); border: 1px solid var(--border, #E7EDEE); border-radius: var(--r-ctl);
  font-family: inherit; font-size: var(--type-body-size); color: var(--ink, #25343F); cursor: pointer;
}
.dr-item.is-on { border-color: var(--primary, #0F6A71); background: var(--primary-soft, #E4F1F1); }
.dr-item-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.dr-item .ac-note { grid-column: 1 / -1; margin: 0; }
.dr-status {
  display: inline-block; padding: 1px 8px; border-radius: var(--r-chip); font-size: var(--type-chip-size); font-weight: 600;
  background: var(--surface-alt, #F4F8F8); color: var(--muted, #5B6B75); border: 1px solid var(--border, #E7EDEE); white-space: nowrap;
}
.dr-status.is-sent, .dr-status.is-viewed { background: var(--primary-soft, #E4F1F1); color: var(--primary-dark, #0B4F54); }
.dr-status.is-counterparty_signed, .dr-status.is-countersigned { background: #FFF4D6; color: #7A5300; }
.dr-status.is-completed { background: #E3F4E8; color: #1D6B3A; }
.dr-status.is-change_requested { background: #FDECEA; color: #9A2A1F; }
.dr-status.is-voided { text-decoration: line-through; }

.dr-doc { display: flex; flex-direction: column; gap: 8px; padding: 12px 14px; border-bottom: 1px solid var(--border, #E7EDEE); }
.dr-doc[hidden] { display: none; }
.dr-doc-top { display: flex; gap: 8px; align-items: center; }
.dr-title { flex: 1; min-width: 0; font-family: inherit; font-size: var(--type-card-title-size); font-weight: 600; padding: 6px 8px; border: 1px solid var(--border, #E7EDEE); border-radius: var(--r-ctl); background: var(--surface, #fff); color: var(--ink, #25343F); }
.dr-banner { margin: 0; padding: 6px 10px; border-radius: var(--r-ctl); background: #FFF4D6; color: #6B4A00; font-size: var(--type-caption-size); }
.dr-banner.is-test { background: #FDECEA; color: #8A2318; font-weight: 600; }
.dr-banner[hidden] { display: none; }
.dr-tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border, #E7EDEE); overflow-x: auto; }
.dr-tab { border: 0; background: none; padding: 6px 10px; font-family: inherit; font-size: var(--type-button-size); color: var(--muted, #5B6B75); cursor: pointer; border-bottom: 2px solid transparent; }
.dr-tab.is-on { color: var(--ink, #25343F); border-bottom-color: var(--primary, #0F6A71); font-weight: 600; }
.dr-pane[hidden] { display: none; }

.dr-preview { max-height: 62vh; overflow: auto; padding: 12px; background: var(--surface, #fff); border: 1px solid var(--border, #E7EDEE); border-radius: var(--r-ctl); font-size: var(--type-caption-size); line-height: 1.5; color: var(--ink, #25343F); }
.dr-p-row.dr-p-title { margin-bottom: 12px; text-align: center; border-top: 0; }
.dr-p-title > div { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.dr-p-title b { font-size: var(--type-card-title-size); text-transform: uppercase; }
.dr-p-title span { color: var(--muted, #5B6B75); }
.dr-p-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; padding: 6px 0; border-top: 1px dashed var(--border, #E7EDEE); }
.dr-p-row.is-edited { box-shadow: inset 3px 0 0 var(--warning, #E3A21A); padding-left: 8px; }
.dr-p-col h4 { margin: 0 0 4px; font-size: var(--type-label-size); }
.dr-p-col p { margin: 0 0 6px; }
.dr-p-sigs { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; margin-top: 12px; }
.dr-p-sig { display: flex; flex-direction: column; gap: 2px; }
.dr-p-line { display: block; height: 36px; border-bottom: 1px solid var(--muted, #5B6B75); margin-bottom: 4px; }
.dr-p-signed { color: #1D6B3A; font-weight: 600; }
.dr-ph { background: #FFF4D6; color: #6B4A00; padding: 0 2px; border-radius: var(--r-chip); }
@media (max-width: 640px) { .dr-p-row, .dr-p-sigs { grid-template-columns: minmax(0, 1fr); } }

.dr-form { display: grid; gap: 8px; }
.dr-field { display: flex; flex-direction: column; gap: 3px; font-size: var(--type-label-size); color: var(--ink, #25343F); }
.dr-field input, .dr-field textarea, .dr-clause textarea {
  font-family: inherit; font-size: var(--type-body-size); padding: 6px 8px; border: 1px solid var(--border, #E7EDEE);
  border-radius: var(--r-ctl); background: var(--surface, #fff); color: var(--ink, #25343F); width: 100%; box-sizing: border-box;
}
.dr-field-short input { max-width: 120px; }
.dr-sub { margin: 10px 0 4px; font-size: var(--type-label-size); }
.dr-cp { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; font-size: var(--type-caption-size); }
.dr-cp li { display: flex; justify-content: space-between; gap: 10px; }
.dr-clause { border: 1px solid var(--border, #E7EDEE); border-radius: var(--r-ctl); padding: 8px; margin: 0 0 8px; }
.dr-clause legend { font-size: var(--type-label-size); font-weight: 600; padding: 0 4px; }
.dr-clause-cols { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 8px; margin-bottom: 6px; }
@media (max-width: 640px) { .dr-clause-cols { grid-template-columns: minmax(0, 1fr); } }
.dr-versions, .dr-events { margin: 0; padding-left: 18px; display: flex; flex-direction: column; gap: 4px; font-size: var(--type-caption-size); }
.dr-versions li { display: flex; justify-content: space-between; gap: 8px; align-items: center; }
.dr-events li span { display: block; }
.dr-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.ac-btn.is-danger { color: var(--danger, #D64545); }
.dr-panel { padding: 10px; border: 1px solid var(--border-strong, #CFDCDD); border-radius: var(--r-ctl); background: var(--surface-alt, #F4F8F8); display: flex; flex-direction: column; gap: 8px; }
.dr-panel[hidden] { display: none; }
.dr-pad { display: block; width: 100%; height: 140px; background: var(--surface, #fff); border: 1px dashed var(--border-strong, #CFDCDD); border-radius: var(--r-ctl); margin: 4px 0; touch-action: none; }
.dr-msg.is-error, .is-error { color: var(--danger, #D64545); }
:root[data-theme="dark"] .dr-ph, :root[data-theme="dark"] .dr-banner { background: rgba(227, 162, 26, .16); color: #F2D28A; }
:root[data-theme="dark"] .dr-banner.is-test { background: rgba(214, 69, 69, .18); color: #F4B4B4; }
:root[data-theme="dark"] .dr-status.is-completed { background: rgba(29, 107, 58, .25); color: #A6E3BC; }
:root[data-theme="dark"] .dr-status.is-counterparty_signed, :root[data-theme="dark"] .dr-status.is-countersigned { background: rgba(227, 162, 26, .16); color: #F2D28A; }
:root[data-theme="dark"] .dr-status.is-change_requested { background: rgba(214, 69, 69, .18); color: #F4B4B4; }
