/* v16.67 · Journal Form yang lebih intuitif
   Hanya tampilan form journal: status simpan, tombol Tutup / Batal / Simpan yang jelas, progres 4 bagian,
   penanda "terakhir", dan dialog konfirmasi. Dimuat paling akhir. Logika data tidak diubah.
   Membatalkan: hapus <link href="journal-form-ux.css"> dan <script src="journal-form-ux.js">. */

#form-section {
  --jf-gold: #d4af37; --jf-gold-t: #e7c85a;
  --jf-ok: #34d399; --jf-warn: #fbbf24; --jf-bad: #fb7185;
  --jf-line: rgba(255,255,255,.10); --jf-soft: rgba(255,255,255,.06); --jf-mute: #9ca3af;
}
body.light #form-section {
  --jf-gold: #a07c14; --jf-gold-t: #7a5c08;
  --jf-ok: #047857; --jf-warn: #92400e; --jf-bad: #be123c;
  --jf-line: rgba(0,0,0,.12); --jf-soft: rgba(0,0,0,.05); --jf-mute: #6b7280;
}

/* ---------- Header: judul + status simpan | Tutup ---------- */
#jw-card > .jf-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.jf-status { display: flex; align-items: center; gap: 8px; margin-top: 4px; font-size: 12px; line-height: 1.35; color: var(--jf-mute); min-height: 18px; }
.jf-status span { overflow-wrap: anywhere; }
.jf-dot { flex: none; width: 8px; height: 8px; border-radius: 50%; background: currentColor; opacity: .55; }
.jf-status[data-state="unsaved"] { color: var(--jf-warn); }
.jf-status[data-state="unsaved"] .jf-dot { opacity: 1; animation: jfPulse 1.4s ease-in-out infinite; }
.jf-status[data-state="draft"] { color: var(--jf-ok); }
.jf-status[data-state="draft"] .jf-dot { opacity: 1; }
.jf-status[data-state="saving"] { color: var(--jf-gold-t); }
.jf-status[data-state="saving"] .jf-dot { opacity: 1; background: none; border: 2px solid currentColor; border-right-color: transparent; animation: jfSpin .7s linear infinite; }
.jf-status[data-state="error"], .jf-status[data-state="draftfail"] { color: var(--jf-bad); font-weight: 600; }
.jf-status[data-state="error"] .jf-dot, .jf-status[data-state="draftfail"] .jf-dot { opacity: 1; }
@keyframes jfPulse { 50% { opacity: .35; } }
@keyframes jfSpin { to { transform: rotate(360deg); } }

#btn-cancel-form.jf-close { display: inline-flex; align-items: center; gap: 8px; flex: none; min-height: 38px; padding: 0 16px 0 12px; border: 1px solid var(--jf-line); background: var(--jf-soft); opacity: 1; font-size: 13px; font-weight: 600; border-radius: 999px; cursor: pointer; }
#btn-cancel-form.jf-close:hover { border-color: rgba(212,175,55,.45); }
#btn-cancel-form.jf-close:focus-visible, .jf-cancel:focus-visible, .jf-quick:focus-visible, .jf-reuse button:focus-visible { outline: 2px solid rgba(212,175,55,.8); outline-offset: 2px; }
@media (max-width: 380px) { #jf-close-text { display: none; } #btn-cancel-form.jf-close { padding: 0 12px; } }

/* ---------- Progres 4 bagian ---------- */
.jw-bars { grid-template-columns: repeat(4, 1fr) !important; }
.jw-count { align-items: center; flex-wrap: wrap; row-gap: 4px; }
.jw-count-l { display: inline-flex; align-items: baseline; flex-wrap: wrap; }
.jf-ready { display: inline-flex; align-items: center; gap: 8px; font-size: 12px; font-weight: 600; color: var(--jf-mute); }
.jf-ready.is-ready { color: var(--jf-ok); }
.jf-quick { appearance: none; min-height: 32px; padding: 0 12px; border-radius: 999px; font-size: 12px; font-weight: 600; color: var(--jf-gold-t); background: rgba(212,175,55,.12); border: 1px solid rgba(212,175,55,.45); cursor: pointer; -webkit-tap-highlight-color: transparent; }
.jf-quick:hover { background: rgba(212,175,55,.2); }
.jf-quick[hidden] { display: none; }
.jw-chip.is-missing::before { background: var(--jf-bad); }
.jw-chip.is-missing b { color: var(--jf-bad); }
.jw-chip.is-done::before { background: var(--jf-gold); opacity: .8; }
.jw-req { font-size: 12px; font-weight: 600; color: var(--jf-gold-t); border: 1px solid rgba(212,175,55,.5); border-radius: 999px; padding: 1px 8px; }

/* ---------- Footer: Batal | Kembali | Lanjut / Simpan ---------- */
.jw-foot { align-items: stretch; }
.jf-cancel { appearance: none; flex: none; padding: 0 16px; border-radius: 16px; font-size: 13px; font-weight: 600; color: var(--jf-bad); background: transparent; border: 1px solid transparent; cursor: pointer; transition: background .2s, border-color .2s; }
.jf-cancel:hover { background: rgba(251,113,133,.1); border-color: rgba(251,113,133,.35); }
.jw-foot .jw-btn-back { padding-left: 16px; padding-right: 16px; }
@media (max-width: 400px) { .jf-cancel { padding: 0 12px; font-size: 13px; } .jw-foot { gap: 8px; } }

/* ---------- "Input terakhir" ---------- */
.jf-last { position: relative; }
.jf-last::after { content: attr(data-jf-last); position: absolute; top: -8px; right: 8px; padding: 1px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; letter-spacing: 0; text-transform:none; background: rgba(212,175,55,.95); color: #1a1405; pointer-events: none; line-height: 1.5; }
.jf-reuse { margin: 0; }
.jf-reuse button { appearance: none; width: 100%; display: flex; align-items: center; gap: 12px; text-align: left; padding: 12px 16px; border-radius: 16px; background: rgba(212,175,55,.08); border: 1px dashed rgba(212,175,55,.5); color: inherit; cursor: pointer; -webkit-tap-highlight-color: transparent; transition: background .2s; }
.jf-reuse button:hover { background: rgba(212,175,55,.15); }
.jf-reuse svg { flex: none; color: var(--jf-gold-t); }
.jf-reuse b { display: block; font-size: 13px; color: var(--jf-gold-t); }
.jf-reuse small { display: block; font-size: 12px; color: var(--jf-mute); margin-top: 1px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.jf-slot:empty { display: none; }
.jf-slot .tsum-fld { margin-top: 0; }

/* ---------- Dialog konfirmasi ---------- */
.jf-dlg-ov { position: fixed; inset: 0; z-index: 90; display: flex; align-items: center; justify-content: center; padding: 16px; background: rgba(0,0,0,.55); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); animation: jfFade .18s ease both; }
.jf-dlg-ov[hidden] { display: none; }
.jf-dlg { width: min(420px, 100%); border-radius: 24px; padding: 24px 20px 20px; background: #1d1e22; color: #f3f4f6; border: 1px solid rgba(255,255,255,.12); box-shadow: 0 24px 64px -16px rgba(0,0,0,.7); animation: jfPop .26s cubic-bezier(.2,.9,.3,1.1) both; }
body.light .jf-dlg { background: #fffdf7; color: #1f1b0d; border-color: rgba(0,0,0,.1); }
.jf-dlg h3 { font-size: 17px; font-weight: 600; }
.jf-dlg p { font-size: 13px; line-height: 1.5; color: #9ca3af; margin-top: 8px; }
body.light .jf-dlg p { color: #6b7280; }
.jf-dlg-act { display: flex; flex-direction: column; gap: 8px; margin-top: 20px; }
.jf-dlg-act button { appearance: none; min-height: 46px; padding: 0 16px; border-radius: 16px; font-size: 15px; font-weight: 700; cursor: pointer; border: 1px solid transparent; -webkit-tap-highlight-color: transparent; }
.jf-dlg-act .is-primary { background: linear-gradient(165deg, #f6dc80, #d6b13a 55%, #b08a20); color: #1a1405; }
.jf-dlg-act .is-secondary { background: rgba(255,255,255,.07); border-color: rgba(255,255,255,.16); color: inherit; }
body.light .jf-dlg-act .is-secondary { background: rgba(0,0,0,.05); border-color: rgba(0,0,0,.14); }
.jf-dlg-act .is-danger { background: transparent; color: #fb7185; border-color: rgba(251,113,133,.4); }
body.light .jf-dlg-act .is-danger { color: #be123c; border-color: rgba(190,18,60,.35); }
.jf-dlg-act button:focus-visible { outline: 2px solid rgba(212,175,55,.9); outline-offset: 2px; }
@keyframes jfFade { from { opacity: 0; } }
@keyframes jfPop { from { opacity: 0; transform: translateY(10px) scale(.97); } }

@media (prefers-reduced-motion: reduce) {
  .jf-status .jf-dot, .jf-dlg, .jf-dlg-ov { animation: none !important; }
}
@media (forced-colors: active) {
  .jf-dot { background: CanvasText; } .jf-last::after { border: 1px solid CanvasText; }
}
