/* ===== Detail profil: header, viewer zoom/pan, tab lembar, cetak ===== */

#detail {
  position: fixed; inset: 0; z-index: 40; display: none; flex-direction: column;
  background: var(--paper);
}
#detail.open { display: flex; }
#detail:fullscreen { background: var(--paper); }

.d-head { display: flex; align-items: center; gap: 10px; padding: 10px 16px;
  background: var(--surface); border-bottom: 1px solid var(--line); }
.d-back { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center;
  background: var(--surface-2); flex: none; }
.d-back svg { width: 18px; height: 18px; }
.d-id { display: flex; align-items: center; gap: 10px; min-width: 0; flex: 1; }

/* nomor kotak = elemen paling menonjol di halaman detail */
.kotak-big {
  flex: none; background: var(--wood); color: var(--gold-2);
  font-family: var(--font-display); font-weight: 700; font-size: 20px; letter-spacing: 1.5px;
  padding: 7px 13px; border-radius: 10px; line-height: 1;
}
.d-title { min-width: 0; }
.d-title b { display: block; font-size: 14px; line-height: 1.3; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.d-title span { font-size: 11.5px; color: var(--gold-3); font-weight: 700; }
/* keterangan revisi (isi "Revisi : <tgl> <ket>" sheet terakhir, skema v2) */
.d-title span.revnote { display: block; font-size: 10.5px; font-weight: 500;
  color: var(--gold-3); opacity: 0.85; white-space: nowrap; overflow: hidden;
  text-overflow: ellipsis; max-width: 100%; }
.d-iconbtn { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center;
  background: var(--surface-2); flex: none; }
.d-iconbtn svg { width: 17px; height: 17px; }

.d-warn { background: var(--warn-bg); border-bottom: 1px solid var(--warn-line);
  color: var(--warn); font-size: 12.5px; font-weight: 600; padding: 9px 16px; }

.d-scalebar { position: relative; background: #40351f; border-bottom: 1px solid #715a2c;
  color: #f3d489; font-size: 11.5px; line-height: 1.45; padding: 7px 34px 7px 14px; }
.d-scalebar b { color: #f3d489; }
.d-scalebar.closed { display: none; }
.scale-x { position: absolute; right: 4px; top: 50%; transform: translateY(-50%);
  width: 26px; height: 26px; border-radius: 7px; font-size: 16px; color: #f3d489; }

/* ---- viewer ---- */
.d-body { flex: 1; overflow-y: auto; display: flex; flex-direction: column; min-height: 0; }
.stage-wrap { position: relative; flex: 1 0 auto; min-height: 46vh; overflow: hidden;
  background: #232529; touch-action: none; }
.stage { position: absolute; inset: 0; display: grid; place-items: center; }
.stage img { user-select: none; -webkit-user-drag: none; will-change: transform;
  box-shadow: 0 6px 24px rgba(0, 0, 0, .4); border-radius: 3px;
  transform-origin: center center; }
.stage svg { box-shadow: 0 6px 24px rgba(0, 0, 0, .4); border-radius: 3px; }
.stage .noimg { color: var(--champ); font-size: 13px; padding: 20px; text-align: center; }

.zoomctl { position: absolute; top: 10px; right: 10px; display: flex; align-items: center; gap: 4px;
  background: rgba(20, 21, 23, .88); border-radius: 999px; padding: 4px 8px; }
.zoomctl button { width: 30px; height: 30px; border-radius: 999px; color: #f2e7cf;
  display: grid; place-items: center; font-size: 17px; font-weight: 700; }
.zoomctl button svg { width: 15px; height: 15px; }
.zoomctl button:active { background: rgba(242, 231, 207, .18); }
.zoomctl span { color: #f2e7cf; font-size: 12px; font-weight: 700; min-width: 34px; text-align: center; }
.stage-hint { position: absolute; left: 50%; bottom: 12px; transform: translateX(-50%);
  background: rgba(20, 21, 23, .88); color: #e6e6e6; font-size: 11.5px; padding: 6px 12px;
  border-radius: 999px; pointer-events: none; white-space: nowrap; transition: opacity .3s; max-width: 94vw;
  overflow: hidden; text-overflow: ellipsis; }

/* ---- tab lembar (hanya GB: Depan/Belakang; tab kelompok Desain dihapus) ---- */
.sheet-tabs { display: flex; gap: 7px; overflow-x: auto; padding: 10px 16px 12px;
  background: var(--surface); border-top: 1px solid var(--line); scrollbar-width: thin; }
.stab { flex: none; border: 1px solid var(--line); background: var(--surface); border-radius: 11px;
  padding: 7px 11px; text-align: left; min-width: 92px; position: relative; }
.stab b { display: block; font-size: 12px; color: var(--ink); }
.stab small { display: block; font-size: 10px; color: var(--ink-faint); margin-top: 2px; }
.stab .revdot { position: absolute; top: 7px; right: 8px; width: 8px; height: 8px; border-radius: 50%; }
.revdot.new { background: var(--ok); }
.revdot.old { background: #e5a50a; }
.stab.on { border-color: var(--gold-2); background: #40351f; box-shadow: 0 0 0 2px rgba(212, 175, 55, .22); }
.stab .side { display: inline-block; font-size: 9.5px; font-weight: 800; letter-spacing: .5px;
  color: var(--gold-2); background: #40351f; border-radius: 5px; padding: 1px 6px; margin-bottom: 3px; }

/* ---- aksi & info ---- */
.d-actions { display: flex; gap: 9px; padding: 4px 16px 8px; background: var(--surface); }
.act { flex: 1; display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  border-radius: 12px; padding: 11px 14px; font-size: 13px; font-weight: 700; }
.act svg { width: 16px; height: 16px; flex: none; }
.act-print { background: var(--wood); color: var(--champ); }
.act-print:active { background: #3a2c17; }
.act-save { background: var(--surface-2); color: var(--ink-soft); border: 1px solid var(--line); }
.act-save:disabled { opacity: .55; cursor: default; }

.d-info { background: var(--surface); border-top: 1px solid var(--line); padding: 10px 16px 16px; }
.d-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.d-chips .chip { font-size: 11px; }

/* ---- modal pratinjau cetak ---- */
.modal { position: fixed; inset: 0; z-index: 60; background: rgba(26, 19, 8, .55);
  display: flex; flex-direction: column; }
.modal[hidden] { display: none; }
.m-bar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  background: var(--surface); border-bottom: 1px solid var(--line); padding: 10px 16px; }
.m-title { min-width: 0; }
.m-title b { display: block; font-size: 14px; }
.m-title span { font-size: 11px; color: var(--ink-faint); }
.m-note { flex: 1; min-width: 200px; font-size: 11.5px; color: var(--warn); font-weight: 600; }
.m-btns { display: flex; gap: 8px; }
.m-btns .act { flex: none; padding: 9px 16px; }
#print-root { flex: 1; overflow: auto; padding: 18px; background: #232529; }

/* halaman cetak (tampil di pratinjau & saat dicetak) */
.p-page { background: #fff; color: #000; width: 297mm; max-width: 100%; margin: 0 auto 18px;
  aspect-ratio: 297 / 210; display: flex; flex-direction: column;
  box-shadow: 0 3px 14px rgba(0, 0, 0, .4); overflow: hidden; }
.p-img { flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; padding: 4mm; }
.p-img img { width: 100%; height: 100%; object-fit: contain; }
.p-foot { flex: none; font-size: 10px; color: #333; padding: 0 6mm 3mm;
  display: flex; justify-content: space-between; gap: 8mm; font-family: Arial, Helvetica, sans-serif; }

@media (max-width: 640px) {
  .d-head { padding: 8px 12px; }
  .kotak-big { font-size: 16px; padding: 6px 10px; letter-spacing: 1px; }
  .sheet-tabs, .d-actions, .d-info { padding-left: 12px; padding-right: 12px; }
  .sheet-tabs { padding-top: 8px; }
  .act { font-size: 12px; padding: 10px 10px; }
  #print-root { padding: 10px; }
  .p-page { width: 100%; }
  .stage-wrap { min-height: 42vh; }
}

/* ===== mode cetak: hanya halaman pratinjau yang tampil ===== */
@page { size: A4 landscape; margin: 0; }
@media print {
  body { background: #fff; }
  #app, #detail, #toast-root, .m-bar, .d-scalebar { display: none !important; }
  #print-modal { position: static; inset: auto; background: none; z-index: auto; display: block !important; }
  #print-modal[hidden] { display: none !important; }
  #print-root { overflow: visible; padding: 0; background: none; }
  .p-page { width: 297mm; height: 210mm; max-width: none; margin: 0; box-shadow: none;
    break-after: page; page-break-after: always; aspect-ratio: auto; }
  .p-page:last-child { break-after: auto; page-break-after: auto; }
}
