/* ============================================================
   paper.css — XyStudio.Tch Legals
   Tampilan murni seperti kertas dokumen.
   Font sistem biasa. Tanpa navbar, tanpa tombol cetak.
   RESPONSIF: semua device & resolusi + mode embed (?embed=1).
   ============================================================ */

:root {
  --ink: #1d2130;
  --ink-soft: #3d4254;
  --muted: #767b8c;
  --rule: #d9dce6;
  --accent: #4f46e5;
  --paper: #ffffff;
  --bg: #e9ebf1;
  --paper-max: 820px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }

html, body { max-width: 100%; overflow-x: hidden; }

body {
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial,
    'Noto Sans', 'Noto Sans Arabic', 'Noto Sans CJK', 'Noto Sans Thai', sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.8;
  font-size: 16px;
  padding: 28px 14px;
  padding-top: max(28px, env(safe-area-inset-top, 0px));
  padding-bottom: max(28px, env(safe-area-inset-bottom, 0px));
  -webkit-tap-highlight-color: transparent;
  min-height: 100vh;
  min-height: 100dvh;
}

.paper {
  width: 100%;
  max-width: var(--paper-max);
  margin: 0 auto;
  background: var(--paper);
  padding: clamp(24px, 6vw, 68px);
  position: relative;
  padding-bottom: 118px;
  box-shadow: 0 6px 30px rgba(20, 22, 40, 0.14);
  border-radius: 0;
}

.paper-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  padding-bottom: 14px;
  border-bottom: 2px solid var(--ink);
}
.paper-brand { font-weight: 700; letter-spacing: 2px; font-size: 13.5px; color: var(--ink); overflow-wrap: anywhere; }
.paper-tools { display: flex; align-items: center; }

/* dropdown bahasa */
.lang-drop { position: relative; }
.lang-drop summary {
  list-style: none;
  cursor: pointer;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink-soft);
  border: 1px solid var(--rule);
  padding: 8px 12px;
  border-radius: 0;
  user-select: none;
  -webkit-user-select: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.lang-drop summary::-webkit-details-marker { display: none; }
.lang-drop[open] summary { border-color: var(--accent); color: var(--accent); }
.lang-menu {
  position: absolute;
  top: calc(100% + 8px);
  left: auto;
  right: 0;
  z-index: 300;
  width: max-content;
  min-width: 200px;
  max-width: min(320px, calc(100vw - 24px));
  max-height: min(60vh, 400px);
  overflow-y: auto;
  overflow-x: hidden;
  background: #fff;
  border: 1px solid var(--rule);
  border-radius: 0;
  box-shadow: 0 14px 40px rgba(20, 22, 40, 0.18);
  padding: 8px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2px;
}
[dir="rtl"] .lang-menu { left: 0; right: auto; }
.lang-item { font-size: 13px; color: var(--ink-soft); text-decoration: none; padding: 9px 10px; border-radius: 0; }
.lang-item:hover { background: rgba(79, 70, 229, 0.08); color: var(--accent); text-decoration: none; }
.lang-item.active { background: rgba(79, 70, 229, 0.1); color: var(--accent); font-weight: 600; }

.paper-title {
  text-align: center;
  font-size: clamp(23px, 4vw, 30px);
  font-weight: 700;
  line-height: 1.4;
  margin: 30px 0 6px;
  letter-spacing: -0.2px;
  overflow-wrap: break-word;
}
.paper-subtitle { text-align: center; color: var(--muted); font-size: 14px; margin-bottom: 8px; }
.paper-meta {
  text-align: center;
  color: var(--muted);
  font-size: 12.5px;
  margin-bottom: 24px;
  overflow-wrap: break-word;
}
.paper-rule { border: none; border-top: 1px solid var(--rule); margin: 24px 0; }

.paper h2 {
  font-size: 18px;
  font-weight: 700;
  color: var(--ink);
  margin: 26px 0 12px;
  padding-bottom: 5px;
  border-bottom: 1px solid var(--rule);
}
.paper h2:first-of-type { margin-top: 6px; }

.paper p { color: var(--ink-soft); text-align: justify; margin-bottom: 14px; overflow-wrap: break-word; }
.paper ul { margin: 0 0 16px 28px; }
.paper li { color: var(--ink-soft); margin-bottom: 8px; text-align: justify; overflow-wrap: break-word; }
.paper li::marker { color: var(--accent); }

[dir="rtl"] .paper ul { margin-left: 0; margin-right: 28px; }
[dir="rtl"] .paper p, [dir="rtl"] .paper li { text-align: right; }
[dir="rtl"] .paper-meta, [dir="rtl"] .paper-title, [dir="rtl"] .paper-subtitle { text-align: center; }

.note {
  background: #eef0ff;
  border: 1px solid #d6d9fb;
  border-left: 4px solid var(--accent);
  border-radius: 0;
  padding: 13px 17px;
  margin: 18px 0;
  font-size: 15px;
  color: var(--ink-soft);
  overflow-wrap: break-word;
}
.note.warn { background: #fdf3e3; border-color: #f3ddb6; border-left-color: #b45309; }
[dir="rtl"] .note { border-left: 1px solid #d6d9fb; border-right: 4px solid var(--accent); }
[dir="rtl"] .note.warn { border-left-color: #f3ddb6; border-right-color: #b45309; }

.paper-foot { text-align: center; color: var(--muted); font-size: 12.5px; }
.paper-foot p { text-align: center; margin-bottom: 6px; }
.foot-note { opacity: 0.85; font-style: italic; }
.artifact { font-size: 11.5px; color: var(--muted); letter-spacing: 0.5px; }
.doc-links { font-size: 13px; line-height: 1.9; overflow-wrap: break-word; }
.paper p a, .paper li a, .note a { color: var(--accent); text-decoration: underline; word-break: break-all; }
.paper p a:hover, .paper li a:hover, .note a:hover { color: var(--accent-2); }
.doc-links a { color: var(--accent); text-decoration: none; }
.doc-links a:hover { text-decoration: underline; }
.doc-sep { color: var(--rule); }

/* ============ RESPONSIVE ============ */
@media (min-width: 1024px) { body { padding: 40px 24px; } }
@media (min-width: 641px) and (max-width: 1023px) { body { padding: 30px 16px; } }
@media (max-width: 640px) {
  body { padding: 0; font-size: 15.5px; }
  .paper { padding: 32px clamp(16px, 6vw, 26px) 28px; box-shadow: none; border-radius: 0; }
  .paper-title { margin-top: 24px; }
  .paper h2 { font-size: 17px; }
  .lang-menu {
    position: absolute;
    left: auto; right: 0;
    top: calc(100% + 8px);
    bottom: auto;
    width: max-content;
    max-width: calc(100vw - 24px);
    max-height: 60vh;
    grid-template-columns: 1fr;   /* satu kolom di mobile */
  }
  [dir="rtl"] .lang-menu { left: auto; right: 0; }
  .lang-drop summary { max-width: 96px; font-size: 12px; padding: 7px 10px; }
}
@media (max-width: 480px) {
  .paper { padding: 24px 14px 22px; }
  .paper-top { flex-direction: column; align-items: flex-start; gap: 8px; }
  .doc-links { font-size: 12px; }
}
@media (max-width: 360px) {
  .paper { padding: 18px 12px 16px; }

  .paper h2 { font-size: 16px; }
}
@media (max-height: 500px) and (orientation: landscape) {
  body { padding: 10px 8px; }
  .paper { padding: 20px clamp(16px, 4vw, 40px); }
  .paper-title { margin: 16px 0 4px; font-size: clamp(18px, 5vw, 26px); }
}

/* ============ MODE EMBED (iframe/WebView ?embed=1) ============ */
body.embed { background: transparent; padding: 0; min-height: 0; }
body.embed .paper { max-width: none; margin: 0; box-shadow: none; border-radius: 0; padding: 14px clamp(12px, 3vw, 24px); }


/* ============ BADGE, PROGRESS, QR ============ */
.app-badge {
  display: inline-block; font-size: 11.5px; font-weight: 700;
  letter-spacing: .5px; text-transform: uppercase;
  background: #eef0ff; color: var(--accent);
  border: 1px solid #d6d9fb; padding: 3px 10px; margin-bottom: 10px;
}
.progressbar {
  position: fixed; top: 0; left: 0; right: 0; height: 3px; z-index: 300; pointer-events: none;
}
.progressbar-fill { height: 100%; width: 0; background: var(--accent); transition: width .12s linear; }
.qr-wrap { text-align: center; margin: 10px 0; }
.qr-wrap img { width: 150px; height: 150px; border: 1px solid var(--rule); }
.qr-hint { font-size: 12px; color: var(--muted); margin-top: 6px; }

/* ============ SEARCH (docs) ============ */
.doc-search {
  width: 100%; border: 1px solid var(--rule); background: #fff; color: var(--ink);
  padding: 10px 12px; font-size: 14px; font-family: inherit; margin: 6px 0 14px;
}
.doc-search:focus { outline: none; border-color: var(--accent); }
body.embed .paper-top { border-bottom-color: var(--rule); }

/* ============ PAGINATION (bagian dokumen) ============ */
.docpage[hidden] { display: none !important; }
.pager {
  display: flex; align-items: center; justify-content: center;
  gap: 10px; flex-wrap: wrap;
  margin: 6px 0 20px; padding: 10px 12px;
  border: 1px solid var(--rule); background: #f8f9fc;
}
.pager-btn {
  border: 1px solid var(--rule); background: #fff; color: var(--ink-soft);
  padding: 8px 16px; font-size: 13px; font-weight: 700; cursor: pointer; font-family: inherit;
  border-radius: 0;
}
.pager-btn:hover { border-color: var(--accent); color: var(--accent); }
.pager-btn.ghost { background: transparent; }
.pager-info { font-size: 13px; color: var(--muted); font-weight: 600; }

/* ============ TOMBOL NAIK KE ATAS ============ */
.bttop {
  position: fixed; right: 18px; bottom: 84px; z-index: 250;
  width: 46px; height: 46px;
  border: 1px solid var(--rule); background: #fff; color: var(--ink-soft);
  font-size: 20px; cursor: pointer;
  box-shadow: 0 8px 24px rgba(20,22,40,.16);
  opacity: 0; pointer-events: none; transform: translateY(12px);
  transition: opacity .2s, transform .2s;
}
.bttop.show { opacity: 1; pointer-events: auto; transform: translateY(0); }
.bttop:hover { border-color: var(--accent); color: var(--accent); }
[dir="rtl"] .bttop { right: auto; left: 18px; }

/* feedback aktif (like/dislike terisi) */
.fb-btn.active { border-color: var(--accent); color: var(--accent); background: #eef0ff; }


/* ============ FORM INLINE LIKE/DISLIKE + GLOBE ============ */
.fb-inline {
  max-width: 560px; margin: 10px auto 4px; padding: 12px;
  border: 1px solid var(--rule); background: #f8f9fc;
  display: flex; flex-direction: column; gap: 8px;
}
.fb-inline .sheet-input { width: 100%; }
.fb-inline-foot { display: flex; align-items: center; gap: 10px; justify-content: flex-end; flex-wrap: wrap; }
.fb-inline-foot .fb-thanks { margin: 0 8px 0 0; color: var(--accent); font-size: 13px; font-weight: 600; }
.globe-ico { width: 16px; height: 16px; vertical-align: -3px; }
.lang-drop summary { display: inline-flex; align-items: center; gap: 5px; }
.caret { font-size: 10px; opacity: .7; }
/* ============ BOTTOM-SHEET (Report & Help) + COPYLINK ============ */
.sheet-ov { position: fixed; inset: 0; background: rgba(10,12,24,.5); z-index: 200; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 201;
  background: #fff; border-top: 2px solid var(--rule);
  padding: 16px 18px calc(18px + env(safe-area-inset-bottom, 0px));
  max-height: 82vh; overflow-y: auto;
  box-shadow: 0 -10px 40px rgba(20,22,40,.18);
}
.sheet-head { display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--rule); padding-bottom: 10px; margin-bottom: 12px; }
.sheet-title { font-size: 16px; font-weight: 700; }
.sheet-close { background: none; border: 1px solid var(--rule); width: 34px; height: 34px; cursor: pointer; font-size: 15px; color: var(--ink-soft); }
.sheet-close:hover { border-color: var(--accent); color: var(--accent); }
.sheet-desc { font-size: 13.5px; color: var(--muted); margin-bottom: 12px; }
.sheet-label { display: block; font-size: 12.5px; font-weight: 700; color: var(--ink-soft); margin: 10px 0 4px; }
.sheet-input { width: 100%; border: 1px solid var(--rule); background: #fff; color: var(--ink); padding: 9px 10px; font-size: 14px; font-family: inherit; border-radius: 0; }
.sheet-input:focus { outline: none; border-color: var(--accent); }
textarea.sheet-input { resize: vertical; }
.sheet-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 14px; }
.sheet-btn { border: 1px solid var(--rule); background: #fff; color: var(--ink-soft); padding: 10px 18px; font-size: 13.5px; font-weight: 700; cursor: pointer; font-family: inherit; border-radius: 0; }
.sheet-btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.sheet-btn:hover { opacity: .9; }
.copylink {
  border: 1px solid var(--rule); background: #fff; color: var(--ink-soft);
  padding: 7px 12px; font-size: 12.5px; cursor: pointer; font-family: inherit;
  display: inline-flex; align-items: center; gap: 6px; border-radius: 0;
}
.copylink svg { width: 14px; height: 14px; }
.copylink:hover { border-color: var(--accent); color: var(--accent); }


/* ============ SYNTAX HIGHLIGHT + COPY (panduan) ============ */
.codeblock { position: relative; margin: 6px 0 18px; }
.codeblock pre { margin: 0; padding: 34px 14px 12px; }
.copy-btn {
  position: absolute; top: 6px; right: 6px;
  font-size: 11px; font-weight: 700;
  padding: 4px 10px;
  border: 1px solid var(--rule); background: #fff; color: var(--ink-soft);
  cursor: pointer; font-family: inherit;
  transition: border-color .15s, color .15s;
}
.copy-btn:hover { border-color: var(--accent); color: var(--accent); }
.c { color: #6a737d; font-style: italic; }
.s { color: #b3261e; }
.k { color: #0550ae; font-weight: 600; }
.n { color: #953800; }
.t { color: #116329; font-weight: 600; }


/* ============ STAMP & TANDA TANGAN (semua dokumen) ============ */
/* ============ STAMP + TANDA TANGAN (sejajar dalam kotak/table) ============ */
.sig-img {
  display: block; height: 56px; width: auto; margin: 0 auto 2px;
  max-width: 100%; object-fit: contain;
}
.stamp-block {
  display: flex; align-items: center; justify-content: center;
  gap: 24px; flex-wrap: wrap;
  margin: 22px auto 18px; padding: 16px 22px;
  border: 1px solid var(--rule);
  max-width: 560px;
}
.stamp-seal { flex-shrink: 0; }
.stamp-svg { width: 96px; height: 96px; display: block; filter: drop-shadow(0 1px 1px rgba(0,0,0,0.2)); }
.stamp-sig { text-align: left; min-width: 220px; }
[dir="rtl"] .stamp-sig { text-align: right; }
.sig {
  font-family: 'Segoe Script', 'Brush Script MT', 'Snell Roundhand', 'Comic Sans MS', cursive;
  font-size: 30px; line-height: 1.15; color: var(--ink); margin-bottom: 2px;
}
.sig-printed { font-weight: 700; font-size: 14px; color: var(--ink); }
.sig-role { font-size: 12.5px; color: var(--muted); }
.sig-meta { font-size: 12px; color: var(--muted); margin-top: 6px; }

/* ============ FEEDBACK BAR (like/dislike/report/help) ============ */
.feedback {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  margin: 26px auto 8px; flex-wrap: wrap;
  max-width: 560px;
}
.fb-title { font-size: 13.5px; color: var(--muted); margin-right: 4px; }
.fb-btn {
  width: 42px; height: 42px;
  border: 1px solid var(--rule);
  background: #fff;
  color: #3d4254;
  cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  transition: transform .15s, border-color .15s, background .15s, color .15s;
}
.fb-btn svg { width: 20px; height: 20px; }
.fb-btn:hover { transform: scale(1.1); border-color: var(--accent); color: var(--accent); background: #f3f4ff; }

/* ============ TOAST ============ */
.toast {
  position: fixed; left: 50%; bottom: 24px;
  transform: translate(-50%, 20px);
  background: #1d2130; color: #fff;
  padding: 10px 18px; font-size: 13.5px;
  opacity: 0; pointer-events: none;
  transition: opacity .25s, transform .25s;
  z-index: 999; max-width: 90vw; text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ============ GAYA HALAMAN PANDUAN (docs) ============ */
table.guide { width:100%; border-collapse:collapse; margin:14px 0 20px; font-size:14px; }
table.guide th, table.guide td { border:1px solid var(--rule); padding:8px 10px; text-align:left; vertical-align:top; }
table.guide th { background:#f1f2f8; font-weight:700; }
code { background:#f1f2f8; padding:1px 5px; font-size:.92em; }
pre {
  background:#f6f7fb; border:1px solid var(--rule); padding:12px 14px;
  overflow-x:auto; font-size:13px; line-height:1.7; margin:6px 0 18px;
  white-space: pre-wrap; word-break: break-word;
}
.doc-grid { display:grid; grid-template-columns:repeat(auto-fill,minmax(190px,1fr)); gap:10px; margin:14px 0 22px; }
.doc-card {
  display:block; border:1px solid var(--rule); padding:10px 12px;
  color:var(--ink-soft); text-decoration:none; font-size:13.5px;
  background:#fff; line-height:1.6;
}
.doc-card:hover { border-color:var(--accent); color:var(--accent); }
.doc-card code { background:#eef0ff; }
.code-label { font-size:13px; font-weight:700; color:var(--ink); margin:16px 0 4px; }
.chips { display:flex; flex-wrap:wrap; gap:8px; margin:12px 0 20px; }
.chip {
  border:1px solid var(--rule); padding:7px 13px; font-size:13px;
  color:var(--ink-soft); text-decoration:none; background:#fff;
}
.chip:hover { border-color:var(--accent); color:var(--accent); }
.go {
  background:#eef0ff; border:1px solid #d6d9fb; border-left:4px solid var(--accent);
  padding:12px 16px; margin:16px 0; font-size:14px; overflow-wrap:break-word;
}
[dir="rtl"] .go { border-left:1px solid #d6d9fb; border-right:4px solid var(--accent); }

