/* Ragam UI Kit — komponen: Struk Belanja (.rk-struk)
   Printer mencetak struk baris demi baris, total menghitung naik,
   lalu tombol unduh & cetak (window.print hanya untuk kertas struk). */
.rk-struk {
  --s-mono: ui-monospace, "SFMono-Regular", "JetBrains Mono", Menlo, Consolas, monospace;
  --s-lebar: min(100%, 340px);
  /* kertas termal selalu terang di semua tema (realistis), tinta gelap */
  --s-kertas: #fffdf9;
  --s-tinta: #1d1b24;
  --s-tinta-2: #55515f;
  --s-garis: color-mix(in srgb, var(--rg-text) 22%, transparent);
  container-type: inline-size;
  color: var(--rg-text);
  padding: clamp(8px, 2vw, 24px) 0;
  display: grid;
  justify-items: center;
}
.rk-struk *, .rk-struk *::before, .rk-struk *::after { box-sizing: border-box; }

.rk-struk__meja {
  width: min(100%, 520px);
  padding: clamp(16px, 4vw, 30px) clamp(12px, 4vw, 30px) clamp(16px, 3vw, 24px);
  border-radius: var(--rg-radius);
  background: var(--rg-glass);
  -webkit-backdrop-filter: blur(var(--rg-blur)) saturate(140%);
  backdrop-filter: blur(var(--rg-blur)) saturate(140%);
  border: 1px solid var(--rg-border);
  box-shadow: var(--rg-shadow);
  display: grid;
  justify-items: center;
}

/* ===== printer ===== */
.rk-struk__printer {
  position: relative;
  z-index: 2;
  width: calc(var(--s-lebar) + 36px);
  max-width: 100%;
  padding: 14px 18px 18px;
  border-radius: 22px 22px 14px 14px;
  background: linear-gradient(180deg, var(--rg-surface), var(--rg-surface-2));
  border: 1px solid var(--s-garis);
  box-shadow: 0 14px 30px -18px color-mix(in srgb, var(--rg-text) 55%, transparent), inset 0 1px 0 color-mix(in srgb, #fff 45%, transparent);
}
.rk-struk__printer-atas { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-size: .78rem; font-weight: 700; color: var(--rg-muted); }
.rk-struk__lampu {
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--rg-muted);
  transition: background .3s ease, box-shadow .3s ease;
}
.rk-struk.is-cetak .rk-struk__lampu { background: var(--rg-ok); box-shadow: 0 0 0 3px color-mix(in srgb, var(--rg-ok) 25%, transparent), 0 0 12px var(--rg-ok); animation: rk-struk-kedip .5s steps(2) infinite; }
.rk-struk.is-selesai .rk-struk__lampu { background: var(--rg-ok); }
.rk-struk__status { display: inline-flex; align-items: center; gap: 8px; font-variant-numeric: tabular-nums; }
.rk-struk__celah {
  height: 10px;
  margin-top: 12px;
  border-radius: 99px;
  background: color-mix(in srgb, var(--rg-text) 78%, var(--rg-bg));
  box-shadow: inset 0 2px 4px color-mix(in srgb, #000 50%, transparent);
}

/* ===== kertas ===== */
.rk-struk__jalur {
  position: relative;
  z-index: 1;
  width: var(--s-lebar);
  margin-top: -8px;
  height: var(--tinggi, 0px);
  overflow: hidden;
  transition: height .18s linear;
  filter: drop-shadow(0 10px 14px color-mix(in srgb, var(--rg-text) 18%, transparent));
}
.rk-struk.is-selesai .rk-struk__jalur { transition: height .35s ease; }
.rk-struk__kertas {
  position: relative;
  width: 100%;
  padding: 20px 18px 26px;
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--s-tinta) 10%, transparent), transparent 22px),
    var(--s-kertas);
  color: var(--s-tinta);
  font-family: var(--s-mono);
  font-size: .8rem;
  line-height: 1.55;
  /* tepi bawah bergerigi */
  -webkit-mask: linear-gradient(#000 0 0) top / 100% calc(100% - 8px) no-repeat, radial-gradient(circle at 6px 0, #000 6px, transparent 6.5px) bottom left / 12px 8px repeat-x;
  mask: linear-gradient(#000 0 0) top / 100% calc(100% - 8px) no-repeat, radial-gradient(circle at 6px 0, #000 6px, transparent 6.5px) bottom left / 12px 8px repeat-x;
}
.rk-struk__kertas::before { /* pita aksen di kepala struk */
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 6px;
  background: linear-gradient(90deg, var(--rg-accent), var(--rg-accent-2));
}
.rk-struk__baris {
  opacity: 0;
  transform: translateY(-6px);
  transition: opacity .25s ease, transform .25s ease;
}
.rk-struk__baris.is-tampil { opacity: 1; transform: none; }
.rk-struk__toko { text-align: center; }
.rk-struk__toko strong { display: block; font-size: 1rem; letter-spacing: .06em; }
.rk-struk__toko span { color: var(--s-tinta-2); display: block; }
.rk-struk__garis { border: 0; border-top: 1.5px dashed color-mix(in srgb, var(--s-tinta) 35%, transparent); margin: 10px 0; }
.rk-struk__dua { display: flex; justify-content: space-between; gap: 10px; }
.rk-struk__dua > :last-child { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.rk-struk__item-nama { font-weight: 700; margin-top: 5px; }
.rk-struk__item-rinci { color: var(--s-tinta-2); }
.rk-struk__total { font-size: 1.05rem; font-weight: 800; padding: 4px 0; }
.rk-struk__total output { font: inherit; }
.rk-struk__total { border-block: 1.5px solid var(--s-tinta); margin: 4px 0; }
.rk-struk__kaki { text-align: center; color: var(--s-tinta-2); }
.rk-struk__kaki b { color: var(--s-tinta); }
.rk-struk__kode { display: block; width: 100%; height: 40px; margin: 12px 0 2px; color: var(--s-tinta); }

/* ===== kontrol ===== */
.rk-struk__kontrol {
  margin-top: 20px;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  max-width: 100%;
}
.rk-struk__tombol {
  min-height: 42px;
  padding: 0 16px;
  border-radius: 999px;
  border: 1.5px solid var(--s-garis);
  background: var(--rg-surface);
  color: var(--rg-text);
  font: inherit;
  font-size: .88rem;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  transition: background .2s ease, transform .15s ease, box-shadow .2s ease;
  font-variant-numeric: tabular-nums;
}
.rk-struk__tombol:hover:not(:disabled) { border-color: var(--rg-accent); }
.rk-struk__tombol:active:not(:disabled) { transform: scale(.97); }
.rk-struk__tombol:focus-visible { outline: 2px solid var(--rg-accent); outline-offset: 2px; }
.rk-struk__tombol:disabled { opacity: .55; cursor: not-allowed; }
.rk-struk__tombol--utama {
  background: linear-gradient(135deg, var(--rg-accent), var(--rg-accent-2));
  color: var(--rg-accent-text);
  border-color: transparent;
  box-shadow: var(--rg-glow);
  min-width: 9.5em;
  justify-content: center;
}
.rk-struk__tombol--utama:hover:not(:disabled) { border-color: transparent; filter: brightness(1.06); }
.rk-struk__tombol--utama:disabled { opacity: 1; cursor: progress; }
.rk-struk__tombol[hidden] { display: none; }
.rk-struk__catatan { margin: 10px 0 0; font-size: .8rem; color: var(--rg-muted); text-align: center; }

@keyframes rk-struk-kedip { 50% { opacity: .35; } }

.rk-struk.is-reduced *, .rk-struk.is-reduced *::before, .rk-struk.is-reduced *::after {
  animation: none !important;
  transition-duration: .01ms !important;
}
@media (prefers-reduced-motion: reduce) {
  .rk-struk *, .rk-struk *::before, .rk-struk *::after { animation: none !important; transition-duration: .01ms !important; }
}
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .rk-struk__meja { background: var(--rg-surface); }
}
@media (prefers-reduced-transparency: reduce) {
  .rk-struk__meja { background: var(--rg-surface); backdrop-filter: none; -webkit-backdrop-filter: none; }
}

/* ===== cetak: hanya kertas struk ===== */
@media print {
  html.rk-struk-mencetak body * { visibility: hidden !important; }
  html.rk-struk-mencetak .rk-struk__kertas,
  html.rk-struk-mencetak .rk-struk__kertas * { visibility: visible !important; }
  html.rk-struk-mencetak .rk-struk__jalur { height: auto !important; overflow: visible !important; filter: none !important; }
  html.rk-struk-mencetak .rk-struk__kertas {
    position: fixed;
    left: 0;
    top: 0;
    width: 80mm;
    background: #fff !important;
    color: #000 !important;
    -webkit-mask: none;
    mask: none;
  }
  html.rk-struk-mencetak .rk-struk__kertas * { color: #000 !important; }
  html.rk-struk-mencetak .rk-struk__baris { opacity: 1 !important; transform: none !important; }
}
