/* ============================================
   LAPORAN PERJALANAN DINAS RIIL — styles.css
   ============================================ */

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

:root {
  --primary: #6366f1;
  --primary-light: #818cf8;
  --primary-dark: #4f46e5;
  --secondary: #a5b4fc;
  --surface: #ffffff;
  --surface-2: #f8f9ff;
  --surface-3: #f1f3ff;
  --border: #e2e5f5;
  --border-focus: #6366f1;
  --text-1: #1e1b4b;
  --text-2: #4b4e6d;
  --text-3: #9196c0;
  --success: #10b981;
  --danger: #ef4444;
  --shadow-sm: 0 1px 3px rgba(99,102,241,.08), 0 1px 2px rgba(0,0,0,.04);
  --shadow-md: 0 4px 16px rgba(99,102,241,.12), 0 2px 6px rgba(0,0,0,.06);
  --shadow-lg: 0 8px 32px rgba(99,102,241,.14), 0 4px 12px rgba(0,0,0,.08);
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --font: 'Plus Jakarta Sans', system-ui, sans-serif;
  --header-h: 60px;
  --mobile-nav-h: 64px;
  --form-w: 380px;
  --transition: .18s cubic-bezier(.4,0,.2,1);
}

html { font-size: 15px; scroll-behavior: smooth; }
body {
  font-family: var(--font);
  background: var(--surface-2);
  color: var(--text-1);
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}

/* --- HEADER --- */
.app-header {
  position: sticky; top: 0; z-index: 100;
  height: var(--header-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}
.header-inner {
  max-width: 1600px; margin: 0 auto; height: 100%;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 16px; gap: 12px;
}
.header-brand { display: flex; align-items: center; gap: 10px; min-width: 0; flex-shrink: 0; }
.brand-icon {
  width: 34px; height: 34px; flex-shrink: 0; color: var(--primary);
  background: var(--surface-3); border-radius: var(--radius-md);
  padding: 6px; border: 1px solid var(--border);
}
.brand-title { font-size: .9rem; font-weight: 700; color: var(--text-1); white-space: nowrap; }
.brand-sub { font-size: .68rem; color: var(--text-3); white-space: nowrap; }

/* --- TAB BAR (in header) --- */
.tab-bar {
  display: flex; align-items: center; gap: 4px;
  background: var(--surface-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 3px;
  flex-shrink: 0;
}
.tab-btn {
  display: inline-flex; align-items: center; gap: 6px;
  font-family: var(--font); font-size: .75rem; font-weight: 600;
  color: var(--text-3); background: transparent;
  border: none; border-radius: 7px;
  padding: 5px 12px; cursor: pointer;
  transition: background var(--transition), color var(--transition), box-shadow var(--transition);
  white-space: nowrap;
}
.tab-btn svg { width: 13px; height: 13px; flex-shrink: 0; }
.tab-btn:hover { color: var(--primary); background: rgba(99,102,241,.08); }
.tab-btn.active {
  color: var(--primary); background: var(--surface);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
}

/* --- HEADER ACTIONS --- */
.header-actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.tab-actions { display: none; align-items: center; gap: 8px; }
.tab-actions.active { display: flex; }

/* --- BADGES --- */
.save-badge {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: .7rem; font-weight: 600; color: var(--success);
  background: #d1fae5; border: 1px solid #6ee7b7;
  border-radius: 99px; padding: 3px 9px;
  opacity: 0; transition: opacity var(--transition);
}
.save-badge.visible { opacity: 1; }
.save-badge svg { width: 8px; height: 8px; }

/* --- BUTTONS --- */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  font-family: var(--font); font-size: .8rem; font-weight: 600;
  padding: 6px 12px; border-radius: var(--radius-sm);
  border: 1.5px solid transparent; cursor: pointer;
  transition: background var(--transition), border-color var(--transition), box-shadow var(--transition), opacity var(--transition);
  white-space: nowrap; user-select: none;
}
.btn svg { width: 14px; height: 14px; flex-shrink: 0; }
.btn-sm { padding: 4px 9px; font-size: .74rem; }

.btn-primary { background: var(--primary); color: #fff; border-color: var(--primary-dark); }
.btn-primary:hover { background: var(--primary-dark); box-shadow: 0 4px 12px rgba(99,102,241,.35); }
.btn-primary:active { opacity: .88; }

.btn-secondary { background: #2563eb; color: #fff; border-color: #1d4ed8; }
.btn-secondary:hover { background: #1d4ed8; box-shadow: 0 4px 12px rgba(37,99,235,.35); }
.btn-secondary:active { opacity: .88; }

.btn-outline { background: transparent; color: var(--text-2); border-color: var(--border); }
.btn-outline:hover { background: var(--surface-3); border-color: var(--primary-light); color: var(--primary); }

.btn-block { width: 100%; justify-content: center; }
.btn-icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 28px; height: 28px; background: transparent;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  cursor: pointer; color: var(--text-2);
  transition: background var(--transition), color var(--transition);
}
.btn-icon svg { width: 14px; height: 14px; }
.btn-icon:hover { background: var(--surface-3); color: var(--primary); border-color: var(--primary-light); }

/* --- MAIN LAYOUT --- */
.app-main { flex: 1; display: flex; height: calc(100dvh - var(--header-h)); overflow: hidden; }

/* --- TAB PANELS --- */
.tab-panel { display: none; width: 100%; height: 100%; }
.tab-panel.active { display: flex; }

/* --- PANEL FORM --- */
.panel-form {
  width: var(--form-w); min-width: var(--form-w); max-width: var(--form-w);
  background: var(--surface); border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  overflow-y: auto; overflow-x: hidden;
}
.panel-form-inner { padding: 18px; display: flex; flex-direction: column; gap: 2px; min-height: 100%; }

/* --- FORM SECTIONS --- */
.form-section-header { display: flex; align-items: center; gap: 8px; margin: 4px 0; }
.section-chip {
  font-size: .68rem; font-weight: 700; color: var(--primary);
  background: var(--surface-3); border: 1px solid #c7d2fe;
  border-radius: 99px; padding: 3px 9px;
  letter-spacing: .04em; text-transform: uppercase;
}
.form-divider { height: 1px; background: var(--border); margin: 10px 0 6px; }

/* --- FIELD GROUP --- */
.field-group { display: flex; flex-direction: column; gap: 4px; margin-bottom: 8px; }
.field-label { font-size: .76rem; font-weight: 600; color: var(--text-2); display: flex; align-items: center; gap: 4px; }
.field-required { color: var(--danger); font-size: .85rem; }
.field-input {
  font-family: var(--font); font-size: .83rem; color: var(--text-1);
  background: var(--surface); border: 1.5px solid var(--border);
  border-radius: var(--radius-sm); padding: 7px 10px; width: 100%;
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none; -webkit-appearance: none;
}
.field-input::placeholder { color: var(--text-3); }
.field-input:hover { border-color: var(--secondary); }
.field-input:focus { border-color: var(--border-focus); box-shadow: 0 0 0 3px rgba(99,102,241,.15); background: #fafbff; }
.field-textarea { resize: vertical; min-height: 52px; line-height: 1.55; }
.field-textarea--tall { min-height: 110px; }
.field-hint { font-size: .68rem; color: var(--text-3); }

/* --- TRANSPORT ITEM ROWS --- */
.transport-item {
  background: var(--surface-3); border: 1px solid var(--border);
  border-radius: var(--radius-md); padding: 10px;
  margin-bottom: 8px; display: flex; flex-direction: column; gap: 6px;
  position: relative;
}
.transport-item-header { display: flex; align-items: center; justify-content: space-between; }
.transport-item-num { font-size: .7rem; font-weight: 700; color: var(--primary); }
.btn-remove-item {
  background: none; border: none; cursor: pointer;
  color: var(--text-3); padding: 2px; border-radius: 4px;
  display: flex; align-items: center; transition: color var(--transition);
}
.btn-remove-item:hover { color: var(--danger); }
.btn-remove-item svg { width: 15px; height: 15px; }

/* --- FORM ACTIONS MOBILE --- */
.form-actions-mobile { display: none; flex-direction: column; gap: 8px; margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--border); }

/* --- PANEL PREVIEW --- */
.panel-preview { flex: 1; display: flex; flex-direction: column; background: #e8eaf6; overflow: hidden; position: relative; }
.preview-toolbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 6px 14px; background: var(--surface);
  border-bottom: 1px solid var(--border); height: 42px; flex-shrink: 0;
}
.preview-label { display: flex; align-items: center; gap: 6px; font-size: .76rem; font-weight: 600; color: var(--text-2); }
.preview-label svg { width: 14px; height: 14px; color: var(--primary); }
.preview-toolbar-right { display: flex; align-items: center; gap: 6px; }
.zoom-level { font-size: .73rem; font-weight: 700; color: var(--text-2); min-width: 36px; text-align: center; }
.preview-canvas { flex: 1; overflow: auto; display: flex; align-items: flex-start; justify-content: center; padding: 24px 20px 40px; }

/* --- A4 PAGE --- */
.a4-page {
  width: 813px; min-height: 1247px;
  background: #fff;
  box-shadow: var(--shadow-lg), 0 0 0 1px rgba(0,0,0,.06);
  border-radius: 2px;
  transform-origin: top center;
  transition: transform var(--transition);
  padding: 75.6px;
  font-family: 'Times New Roman', Times, serif;
  font-size: 12pt; line-height: 1.6; color: #000;
  flex-shrink: 0;
}
.a4-placeholder {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 14px; height: 100%; min-height: 500px; color: var(--text-3); text-align: center;
}
.a4-placeholder svg { width: 72px; height: 72px; opacity: .6; }
.a4-placeholder p { font-size: .82rem; line-height: 1.6; font-family: var(--font); }

/* --- PREVIEW LOADING --- */
.preview-loading {
  position: absolute; inset: 0; background: rgba(232,234,246,.7);
  backdrop-filter: blur(4px);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; z-index: 10;
}
.preview-loading p { font-size: .78rem; color: var(--text-2); font-family: var(--font); }
.preview-loading[hidden] { display: none; }
.spinner { width: 30px; height: 30px; border: 3px solid var(--border); border-top-color: var(--primary); border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* --- MOBILE NAV --- */
.mobile-nav { display: none; position: fixed; bottom: 0; left: 0; right: 0; height: var(--mobile-nav-h); background: var(--surface); border-top: 1px solid var(--border); z-index: 200; }
.mobile-nav-btn { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; border: none; background: transparent; color: var(--text-3); font-family: var(--font); font-size: .63rem; font-weight: 600; cursor: pointer; transition: color var(--transition); }
.mobile-nav-btn svg { width: 20px; height: 20px; }
.mobile-nav-btn.active { color: var(--primary); }

/* ─────────────────────────────────────
   TAB 1 — LAPORAN PERJALANAN DINAS
   A4 Document Styles
───────────────────────────────────── */
.doc-header { text-align: center; margin-bottom: 16pt; }
.doc-title { font-size: 14pt; font-weight: bold; text-transform: uppercase; text-decoration: underline; letter-spacing: .04em; }

.doc-id-table { width: 100%; border-collapse: collapse; margin-bottom: 10pt; font-size: 12pt; }
.doc-id-table td { padding: 2pt 4pt; vertical-align: top; line-height: 1.5; }
.doc-id-label { width: 110pt; font-weight: bold; white-space: nowrap; }
.doc-id-sep { width: 14pt; text-align: center; }
.doc-separator { border: none; border-top: 4px double #000; margin: 10pt 0 12pt; }
.doc-body-table { width: 100%; border-collapse: collapse; font-size: 12pt; }
.doc-body-table td { padding: 2pt 4pt; vertical-align: top; line-height: 1.55; }
.doc-rom { width: 22pt; white-space: nowrap; vertical-align: top; }
.doc-body-label { width: 120pt; font-weight: bold; white-space: nowrap; vertical-align: top; }
.doc-body-sep { width: 14pt; text-align: center; vertical-align: top; }
.doc-row-gap { height: 6pt; }
.doc-penutup-text { margin-top: 10pt; margin-left: 26pt; text-align: justify; font-size: 12pt; line-height: 1.55; }
.doc-sign-block { display: inline-block; min-width: 160pt; text-align: center; font-size: 12pt; }
.doc-sign-space { height: 56pt; }
.doc-sign-name { display: inline-block; min-width: 140pt; text-align: center; text-decoration: underline; }
.doc-sign-nip { font-size: 11pt; margin-top: 2pt; }

/* ─────────────────────────────────────
   TAB 2 — DAFTAR PENGELUARAN RIIL
   A4 Document Styles
───────────────────────────────────── */
.kop-wrapper { display: flex; align-items: center; gap: 14pt; margin-bottom: 8pt; }
.kop-logo { width: 60pt; height: 78pt; flex-shrink: 0; object-fit: contain; }
.kop-text { flex: 1; text-align: center; }
.kop-instansi { font-size: 13pt; font-weight: bold; letter-spacing: .01em; }
.kop-badan { font-size: 16pt; font-weight: bold; line-height: 1.15; margin-top: 1pt; }
.kop-alamat { font-size: 10pt; font-weight: bold; margin-top: 4pt; line-height: 1.5; }
.kop-alamat u { text-decoration: underline; }
.kop-divider-top { border: none; border-top: 3px solid #000; margin: 5pt 0 1pt; }
.kop-divider-bot { border: none; border-top: 1px solid #000; margin: 0 0 12pt; }

.riil-title { text-align: center; font-size: 13pt; font-weight: bold; text-decoration: underline; margin-bottom: 10pt; letter-spacing: .04em; text-transform: uppercase; }
.riil-opening { font-size: 12pt; margin-bottom: 8pt; }

.riil-id-table { width: 100%; border-collapse: collapse; margin-bottom: 10pt; font-size: 12pt; }
.riil-id-table td { padding: 1pt 4pt; vertical-align: top; line-height: 1.55; }
.riil-id-label { width: 100pt; white-space: nowrap; }
.riil-id-sep { width: 14pt; text-align: center; }

.riil-body-p { font-size: 12pt; text-align: justify; margin-bottom: 8pt; line-height: 1.6; }

.riil-transport-table { width: 100%; border-collapse: collapse; margin-bottom: 10pt; font-size: 11.5pt; }
.riil-transport-table th, .riil-transport-table td { border: 1px solid #000; padding: 4pt 6pt; vertical-align: top; }
.riil-transport-table th { background: #f5f5f5; text-align: center; font-weight: bold; }
.riil-transport-table .col-no { width: 28pt; text-align: center; }
.riil-transport-table .col-jml { width: 90pt; text-align: right; }
.riil-transport-table .row-total td { font-weight: bold; }
.riil-transport-table .row-total .col-uraian { text-align: right; font-weight: bold; }

.riil-sign-table { width: 100%; border-collapse: collapse; margin-top: 18pt; font-size: 11.5pt; }
.riil-sign-table td { vertical-align: top; padding: 2pt 0; }
.riil-sign-col { width: 50%; text-align: center; }
.riil-sign-space { height: 50pt; }
.riil-sign-name { font-weight: bold; text-decoration: underline; }
.riil-sign-pangkat { font-size: 11pt; }
.riil-sign-nip { font-size: 11pt; }

/* --- PRINT --- */
@media print {
  @page { size: 21.5cm 33cm; margin: 0; }
  body > * { display: none !important; }
}

/* --- SCROLLBARS --- */
.panel-form::-webkit-scrollbar, .preview-canvas::-webkit-scrollbar { width: 5px; height: 5px; }
.panel-form::-webkit-scrollbar-track, .preview-canvas::-webkit-scrollbar-track { background: transparent; }
.panel-form::-webkit-scrollbar-thumb, .preview-canvas::-webkit-scrollbar-thumb { background: #c7d2fe; border-radius: 99px; }
.panel-form::-webkit-scrollbar-thumb:hover, .preview-canvas::-webkit-scrollbar-thumb:hover { background: var(--primary-light); }

/* --- RESPONSIVE --- */
@media (max-width: 900px) { :root { --form-w: 300px; } .brand-sub { display: none; } .save-badge { display: none; } }

@media (max-width: 680px) {
  .app-main { flex-direction: column; height: calc(100dvh - var(--header-h) - var(--mobile-nav-h)); }
  .tab-panel.active { flex-direction: column; }
  .panel-form { width: 100%; min-width: 0; max-width: 100%; border-right: none; height: 100%; display: none; }
  .panel-form.mobile-active { display: flex; }
  .panel-preview { height: 100%; display: none; }
  .panel-preview.mobile-active { display: flex; }
  .form-actions-mobile { display: flex; }
  .mobile-nav { display: flex; }
  .tab-btn span { display: none; }
  .preview-canvas { padding: 12px 8px 20px; }
  .a4-page { width: 320px; min-height: 453px; padding: 30px; }
  .tab-bar { gap: 2px; padding: 2px; }
  .tab-btn { padding: 5px 8px; }
}
