/* DOKUMEN — the app chrome around an invoice / nota (doc-ui.jsx). The document's own look comes
   entirely from doc-render.js inside the iframe; nothing here styles the paper. */

.doc-viewer { padding: 16px; place-items: stretch; }
.doc-viewer-card { width: 100%; max-width: 1080px; margin: 0 auto; height: 100%; display: flex; flex-direction: column; background: var(--canvas); border: 1px solid var(--border); border-radius: var(--r-lg); box-shadow: var(--shadow-lg); overflow: hidden; }

.doc-toolbar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 12px 14px; background: var(--surface); border-bottom: 1px solid var(--border); }
.doc-toolbar-t { flex: 1 1 200px; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.doc-toolbar-t b { font-size: 15px; font-weight: 800; color: var(--green-900); }
.doc-toolbar-t span { font-size: 12.5px; color: var(--text-mut); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.doc-toolbar-a { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.doc-viewer-body { flex: 1; min-height: 0; display: flex; overflow: hidden; }
.doc-viewer-paper { flex: 1; min-width: 0; overflow: auto; padding: 20px; }
.doc-frame-box { width: 100%; display: flex; justify-content: center; }
.doc-frame-fit { position: relative; overflow: hidden; flex: none; border-radius: 6px; box-shadow: var(--shadow-md); background: #fff; }
.doc-frame { position: absolute; top: 0; left: 0; border: 0; display: block; background: #fff; transform-origin: 0 0; }
.doc-loading { display: flex; align-items: center; justify-content: center; gap: 8px; padding: 60px 0; color: var(--text-mut); font-size: 13px; }

.doc-opts-panel { flex: 0 0 320px; overflow: auto; padding: 16px; background: var(--surface); border-right: 1px solid var(--border); }
.doc-opts-h { font-size: 14px; font-weight: 800; color: var(--green-900); }
.doc-opts-foot { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
.doc-opts .fld { width: 100%; box-sizing: border-box; }

.doc-switch { display: flex; align-items: flex-start; gap: 10px; margin-top: 14px; cursor: pointer; }
.doc-switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.doc-switch-ui { flex: none; width: 38px; height: 22px; border-radius: 999px; background: var(--border); position: relative; transition: background .15s; margin-top: 1px; }
.doc-switch-ui::after { content: ''; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: var(--shadow-sm); transition: transform .15s; }
.doc-switch input:checked + .doc-switch-ui { background: var(--green-700); }
.doc-switch input:checked + .doc-switch-ui::after { transform: translateX(16px); }
.doc-switch input:focus-visible + .doc-switch-ui { outline: 2px solid var(--green-600); outline-offset: 2px; }
.doc-switch b { display: block; font-size: 13px; color: var(--text); }
.doc-switch small { display: block; font-size: 12px; color: var(--text-mut); margin-top: 2px; }

.doc-checks { display: flex; flex-direction: column; gap: 8px; }
.doc-check { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text); cursor: pointer; }

@media (max-width: 760px) {
  .doc-viewer { padding: 0; }
  .doc-viewer-card { border-radius: 0; border: 0; }
  .doc-viewer-body.editing { flex-direction: column; overflow: auto; }
  .doc-viewer-body.editing .doc-viewer-paper { overflow: visible; }
  .doc-opts-panel { flex: none; border-right: 0; border-bottom: 1px solid var(--border); overflow: visible; }
  .doc-viewer-paper { padding: 12px; }
  .doc-toolbar { padding: calc(10px + env(safe-area-inset-top)) 12px 10px; }
  .doc-toolbar-t { order: 0; }
  .doc-close { order: 1; }
  .doc-toolbar-a { order: 2; flex: 1 1 100%; }
}

.doc-toolbar .jp-icon { color: var(--text-mut); }
.doc-toolbar .jp-icon:hover { background: var(--card-soft); color: var(--text); }

/* Builders (Buat invoice / Buat nota) */
.doc-builder { max-width: 540px; }
.doc-picklist { margin-top: 10px; max-height: 280px; overflow: auto; border: 1px solid var(--border); border-radius: var(--r-sm); background: var(--card); }
.doc-pick { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-bottom: 1px solid var(--border-soft); cursor: pointer; }
.doc-pick:last-child { border-bottom: 0; }
.doc-pick.on { background: var(--mint-100); }
.doc-pick.off { opacity: .45; cursor: not-allowed; }
.doc-pick input { flex: none; }
.doc-pick-l { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.doc-pick-l b { font-size: 13px; font-weight: 600; color: var(--text); }
.doc-pick-l small, .doc-pick-r small { font-size: 11.5px; color: var(--text-mut); }
.doc-pick-r { flex: none; text-align: right; font-size: 13px; font-weight: 600; display: flex; flex-direction: column; }
.doc-pick-empty { padding: 16px 12px; font-size: 12.5px; color: var(--text-mut); text-align: center; }
.doc-collapse { margin-top: 14px; border: 1px solid var(--border); border-radius: var(--r-sm); padding: 0 12px; }
.doc-collapse-h { width: 100%; display: flex; align-items: center; justify-content: space-between; padding: 11px 0; font-size: 13px; font-weight: 700; color: var(--green-900); }
.doc-collapse-h[aria-expanded="true"] svg { transform: rotate(180deg); }
.doc-collapse .doc-opts { padding-bottom: 12px; }
.doc-dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--green-700); margin-left: 7px; vertical-align: 1px; }
.modal-head .doc-x { color: var(--text-mut); }
.modal-head .doc-x:hover { background: var(--card-soft); color: var(--text); }
.doc-head-acts { display: inline-flex; gap: 14px; align-items: center; }
.doc-type-badge { margin-left: 7px; font-size: 10.5px; padding: 1px 7px; }
.doc-type-badge.nota { background: var(--mint-100); color: var(--green-800); }
.doc-type-badge { margin-top: 0; }
.doc-type-badge.inv { background: var(--card-soft); color: var(--text-mut); }

/* Desain Invoice & Nota (mockup pengaturan-dokumen): form left, live preview right. */
.docset-screen { position: fixed; inset: 0; z-index: 220; background: rgba(6,51,79,.46); padding: 16px; display: flex; animation: airroFade .18s ease; }
.docset-screen > .doc-loading { margin: auto; background: var(--surface); border-radius: var(--r-md); padding: 24px 28px; }
.docset-card { position: relative; width: 100%; max-width: 1240px; margin: 0 auto; display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); box-shadow: var(--shadow-lg); overflow: hidden; }
.docset-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 14px 18px; border-bottom: 1px solid var(--border); }
.docset-head-t { flex: 1 1 220px; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.docset-head-t b { font-size: 16px; font-weight: 800; color: var(--green-900); }
.docset-head-t span { font-size: 12.5px; color: var(--text-mut); }
.docset-head-a { display: flex; gap: 8px; flex-wrap: wrap; }
.docset-head .jp-icon { color: var(--text-mut); }
.docset-head .jp-icon:hover { background: var(--card-soft); color: var(--text); }
.docset-err { margin: 10px 18px 0; }
.docset-hist { max-height: 220px; overflow: auto; padding: 10px 18px; border-bottom: 1px solid var(--border); background: var(--card-soft); display: flex; flex-direction: column; gap: 8px; }
.docset-hist-row { display: flex; flex-direction: column; gap: 1px; font-size: 12.5px; }
.docset-hist-row b { color: var(--text); }
.docset-hist-row span { color: var(--text-mut); word-break: break-word; }
.docset-hist-row small { color: var(--text-faint); font-size: 11.5px; }

.docset-body { flex: 1; min-height: 0; display: flex; }
.docset-form { flex: 0 0 380px; min-width: 0; overflow: auto; border-right: 1px solid var(--border); }
.docset-tabs { display: flex; gap: 2px; padding: 0 12px; border-bottom: 1px solid var(--border); overflow-x: auto; }
.docset-tab { flex: none; padding: 12px 10px; font-size: 13px; font-weight: 600; color: var(--text-mut); border-bottom: 2px solid transparent; white-space: nowrap; }
.docset-tab.on { color: var(--green-900); border-bottom-color: var(--green-800); }
.docset-apply { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; padding: 12px 16px 0; }
.docset-apply > span { font-size: 12.5px; color: var(--text-mut); margin-right: 4px; }
.docset-fields { padding: 4px 16px 20px; }
.docset-fld { margin-top: 12px; }
.docset-fld .fld { width: 100%; box-sizing: border-box; }
.docset-lbl { display: block; font-size: 12px; font-weight: 600; color: var(--text-mut); margin-bottom: 6px; }
.docset-sub { font-size: 13.5px; font-weight: 800; color: var(--green-900); margin-top: 16px; }
.docset-two { display: flex; gap: 10px; }
.docset-two > * { flex: 1; min-width: 0; }
.docset-img { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border: 1.5px dashed var(--border); border-radius: var(--r-sm); background: var(--card); }
.docset-img.on { background: var(--card-soft); }
.docset-img-th { flex: none; width: 44px; height: 44px; border-radius: 10px; background: var(--surface); border: 1px solid var(--border); display: grid; place-items: center; color: var(--text-faint); overflow: hidden; }
.docset-img-th img { max-width: 100%; max-height: 100%; object-fit: contain; }
.docset-img-t { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.docset-img-t b { font-size: 13px; color: var(--text); }
.docset-img-t small { font-size: 11.5px; color: var(--text-mut); }
.docset-img-a { flex: none; display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.docset-tgl { display: flex; align-items: center; gap: 12px; padding: 11px 0; border-bottom: 1px solid var(--border-soft); cursor: pointer; position: relative; }
.docset-tgl > span:first-child { flex: 1; min-width: 0; }
.docset-tgl b { display: block; font-size: 13px; font-weight: 500; color: var(--text); }
.docset-tgl small { display: block; font-size: 11.5px; color: var(--text-mut); margin-top: 1px; }
.docset-tgl input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.docset-tgl input:checked + .doc-switch-ui { background: var(--green-700); }
.docset-tgl input:checked + .doc-switch-ui::after { transform: translateX(16px); }
.docset-tgl input:focus-visible + .doc-switch-ui { outline: 2px solid var(--green-600); outline-offset: 2px; }
.docset-note { display: flex; gap: 8px; align-items: flex-start; margin-top: 14px; padding: 10px 12px; border-radius: var(--r-sm); background: var(--warn-bg); color: var(--warn); font-size: 12.5px; }
.docset-note svg { flex: none; margin-top: 1px; }
.docset-bank { margin-top: 12px; padding: 4px 12px 12px; border: 1px solid var(--border); border-radius: var(--r-sm); }
.docset-bank-h { display: flex; justify-content: space-between; align-items: center; padding-top: 8px; font-size: 12.5px; font-weight: 700; color: var(--green-900); }
.docset-fields > .btn { margin-top: 12px; }

.docset-preview { flex: 1; min-width: 0; overflow: auto; padding: 16px 20px 24px; background: var(--canvas); }
.docset-prev-toggle { display: none; }
.docset-papers { display: flex; align-items: center; justify-content: center; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; }
.docset-papers > span { font-size: 12.5px; color: var(--text-mut); margin-right: 4px; }
.docset-papers .cat-chip:disabled { opacity: .55; cursor: default; }
.docset-legend { display: flex; align-items: center; justify-content: center; gap: 8px; margin-top: 12px; font-size: 12.5px; color: var(--text-mut); }
.docset-legend i { width: 14px; height: 10px; border: 2px dashed #E8A317; border-radius: 3px; }
.docset-toast { position: absolute; left: 50%; bottom: 18px; transform: translateX(-50%); }

@media (max-width: 900px) {
  .docset-screen { padding: 0; }
  .docset-card { border-radius: 0; border: 0; }
  .docset-head { padding: calc(10px + env(safe-area-inset-top)) 12px 10px; }
  .docset-head-t { order: 0; }
  .docset-head .doc-close { order: 1; }
  .docset-head-a { order: 2; flex: 1 1 100%; }
  .docset-body { flex-direction: column; overflow: auto; }
  .docset-preview { order: -1; flex: none; overflow: visible; padding: 10px 12px 14px; border-bottom: 1px solid var(--border); }
  .docset-prev-toggle { display: flex; width: 100%; align-items: center; justify-content: space-between; padding: 4px 0 10px; font-size: 13px; font-weight: 700; color: var(--green-900); }
  .docset-prev-toggle[aria-expanded="true"] svg { transform: rotate(180deg); }
  .docset-form { flex: none; overflow: visible; border-right: 0; }
}
.docset-tabs { flex-wrap: wrap; overflow-x: visible; }
.docset-apply .cat-chip { padding: 6px 11px; }
