/* =========================================
   1. VARIABEL & RESET DASAR
   ========================================= */
:root {
  --bg: #faf6f2;
  --card: #fff;
  --ink: #2a1618;
  --mute: #7a6a66;
  --wine: #8f1d21;
  --gold: #b8893b;
  --sage: #5f7f62;
  --line: #eadfd8;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.45 Figtree, system-ui, sans-serif;
  padding-bottom: 80px; /* Ruang untuk bottom nav */
  -webkit-font-smoothing: antialiased;
}

h1, .num { font-family: Fraunces, Georgia, serif; font-weight: 600; }
input, select, textarea, button { font-family: inherit; }

/* =========================================
   2. HEADER
   ========================================= */
header {
  background: var(--wine);
  color: #fff;
  padding: calc(18px + env(safe-area-inset-top)) 18px 22px;
  text-align: center;
  position: relative;
}
header h1 { margin: 0; font-size: 22px; }
header small { opacity: .85; display: block; margin-top: 4px; }
.hbtns {
  position: absolute;
  top: calc(18px + env(safe-area-inset-top));
  right: 12px;
  display: flex;
  gap: 6px;
}
.hbtns button {
  background: none;
  border: 1px solid rgba(255, 255, 255, 0.4);
  color: #fff;
  border-radius: 8px;
  padding: 4px 10px;
  font: inherit;
  cursor: pointer;
  transition: background 0.2s;
}
.hbtns button:active { background: rgba(255, 255, 255, 0.2); }
.couple {
  font: italic 600 15px Fraunces, Georgia, serif;
  margin: 3px 0 6px;
  opacity: .95;
}
.badge {
  display: inline-block;
  font-size: 12px;
  padding: 2px 9px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.2);
  margin-top: 6px;
}

/* =========================================
   3. LAYOUT UTAMA (Main, Card, Grid)
   ========================================= */
main { padding: 14px; max-width: 640px; margin: auto; }
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px;
  margin-bottom: 12px;
}
.row { display: flex; gap: 10px; justify-content: space-between; align-items: center; }
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.mute { color: var(--mute); font-size: 13px; }

/* =========================================
   4. FORM INPUT
   ========================================= */
input[type=text], input[type=number], input[type=date], input[type=search], select {
  width: 100%;
  padding: 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font: inherit;
  background: #fff;
  margin-top: 4px;
}
input:focus, select:focus {
  outline: 2px solid var(--gold);
  border-color: transparent;
}

/* =========================================
   5. MENU UTAMA
   ========================================= */
.menu-title {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .08em;
  color: var(--mute);
  margin: 16px 4px 10px;
  text-transform: uppercase;
}
.menu-item {
  display: flex;
  gap: 14px;
  align-items: center;
  padding: 16px 14px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  margin-bottom: 10px;
  text-decoration: none;
  color: var(--ink);
  transition: background 0.1s;
}
.menu-item:active { background: #fdf6f0; }
.menu-icon {
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  border-radius: 12px;
  flex-shrink: 0;
}
.menu-text { flex: 1; }
.menu-text b { display: block; font-size: 16px; margin-bottom: 2px; }
.menu-text small { color: var(--mute); font-size: 13px; line-height: 1.3; display: block; }
.menu-arrow { color: #ccc; font-size: 24px; font-family: Arial, sans-serif; margin-left: 8px; }

/* =========================================
   6. TOMBOL UPDATE PWA
   ========================================= */
.update-btn {
  width: 100%;
  padding: 12px;
  border-radius: 12px;
  border: 1px solid var(--line);
  font: 600 14px Figtree, sans-serif;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  margin-bottom: 20px;
  transition: all 0.2s ease;
  cursor: pointer;
}

/* State jika sudah versi terbaru */
.update-btn.is-latest {
  background: var(--bg);
  color: var(--mute);
  border-color: var(--line);
}
.update-btn.is-latest:active { background: #eee; }

/* State jika ada update */
.update-btn.has-update {
  background: var(--sage);
  color: #fff;
  border-color: var(--sage);
  box-shadow: 0 4px 12px rgba(95, 127, 98, 0.3);
  animation: pulse-update 2s infinite;
}
.update-btn.has-update:active { background: #4a654c; }

.update-btn:disabled {
  opacity: 0.7;
  cursor: not-allowed;
  animation: none;
}

@keyframes pulse-update {
  0% { box-shadow: 0 0 0 0 rgba(95, 127, 98, 0.4); }
  70% { box-shadow: 0 0 0 10px rgba(95, 127, 98, 0); }
  100% { box-shadow: 0 0 0 0 rgba(95, 127, 98, 0); }
}

/* =========================================
   7. BOTTOM NAVIGATION
   ========================================= */
nav {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  display: flex;
  background: #fff;
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
  z-index: 100;
}
nav button {
  flex: 1;
  padding: 10px 0;
  border: 0;
  background: none;
  font: 600 12px Figtree, sans-serif;
  color: var(--mute);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  cursor: pointer;
}
nav button.on {
  color: var(--wine);
  box-shadow: inset 0 3px var(--wine);
}
nav button .ic { font-size: 19px; line-height: 1; }

/* =========================================
   8. TOAST (Notifikasi Melayang)
   ========================================= */
#st {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--ink);
  color: #fff;
  padding: 8px 16px;
  border-radius: 20px;
  font-size: 13px;
  display: none;
  z-index: 9999;
  box-shadow: 0 4px 12px rgba(0,0,0,0.25);
}

/* =========================================
   9. STYLING SLIP PDF & PRINT
   ========================================= */
.slip {
  background: #fff;
  color: #000;
  border: 1px solid #b6b6b6;
  padding: 16px 18px 14px;
  font-family: Arial, Helvetica, sans-serif;
  font-size: 13px;
  line-height: 1.45;
  border-radius: 4px;
  width: 100%;
}
.slip h3 { margin: 0; text-align: center; font-size: 15px; letter-spacing: .02em; }
.slip h4 {
  margin: 2px 0 12px;
  text-align: center;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: .04em;
  padding-bottom: 8px;
  border-bottom: 1px solid #999;
}
.slip .per { font-size: 12px; color: #333; margin-bottom: 10px; }
.slip table { width: 100%; border-collapse: collapse; min-width: 0; }
.slip td { padding: 2.5px 0; vertical-align: top; }
.slip td:first-child { width: 60%; }
.slip td:last-child { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.slip tr.t td {
  border-top: 1.5px solid #000;
  padding-top: 7px;
  margin-top: 4px;
  font-weight: 700;
  font-size: 13.5px;
}
.slip .ttd { margin-top: 26px; text-align: center; font-size: 12px; }
.slip .ttd .line {
  margin-top: 42px;
  border-top: 1px solid #000;
  display: inline-block;
  padding-top: 3px;
  min-width: 140px;
}
.slip .ttd .lbl { margin-bottom: 4px; color: #333; }

/* Pengaturan saat tombol Print ditekan */
@media print {
  body * { visibility: hidden; }
  #pdfRenderHost, #pdfRenderHost * { visibility: visible; }
  #pdfRenderHost { 
    position: absolute; 
    left: 0; 
    top: 0; 
    width: 100%; 
    opacity: 1 !important; 
    z-index: 9999 !important; 
  }
  .slip { border: none; page-break-after: always; }
}
