/* ==========================================================
   photobox.css (FINAL) — Namespaced under .pb-mode (Option A)
   ========================================================== */

.pb-mode {
  --pb-accent: #0c8a39;
  --pb-bg-left: #071427;
  --pb-bg-center: #0f2a44;
  --pb-bg-right: #0b2030;
  --pb-yellow: #ffbf00;
  --pb-white: #ffffff;
  font-family: 'Trebuchet MS';
  box-sizing: border-box;
}

/* ensure isolation: only reset what photobox needs */
.pb-mode * {
  box-sizing: inherit;
}

/* layout: 3 columns */
.pb-mode .photo-box-wrapper {
  width: 100%;
  margin-top: 20px;

  min-height: calc(100vh - 60px);
  height: auto;
  overflow-y: auto;
  
  align-items: stretch;
  padding: 10px;
  display: grid;
  grid-template-columns: 1.6fr 0.6fr 1fr;
  /* kanan lebih lega */
  gap: 10px;
  align-items: stretch;
  /* 🔑 INI KUNCI UTAMA */
}

/* ==========================================================
   FIX FINAL: TEMPLATE SCROLL LOCK (NON-DESTRUCTIVE)
   ========================================================== */

/* 1️⃣ Pastikan kolom TIDAK ikut memanjang */
.pb-mode .pb-left,
.pb-mode .pb-center,
.pb-mode .pb-right {
  min-height: 0;
  /* 🔑 WAJIB untuk scroll */
}

/* 2️⃣ Paksa pb-center jadi flex container yang benar */
.pb-mode .pb-center {
  display: flex;
  flex-direction: column;
  height: 100%;
}

/* 3️⃣ OVERRIDE pb-template-list lama */
.pb-mode .pb-template-list {
  flex: 1;
  /* 🔑 ambil sisa tinggi */
  min-height: 0;
  /* 🔑 wajib */
  overflow-y: auto !important;
  overflow-x: hidden;
}

/* 4️⃣ Pastikan ID template LIST TIDAK auto height */
.pb-mode #pb4_templateList,
.pb-mode #pb6_templateList,
.pb-mode #pb8_templateList {
  height: 100%;
  max-height: 100%;
}

/* LEFT - camera */
.pb-mode .pb-left {
  background: var(--pb-bg-left);
  padding: 14px;
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  position: relative;
  overflow: hidden;
  min-height: 420px;
}

.pb-mode .pb-left video {
  width: 100%;
  height: 380px;
  border-radius: 10px;
  object-fit: cover;
  background: var(--pb-bg-left);
  display: block;
}

.pb-mode .pb-left video.portrait {
  /* transform: rotate(0deg); */
  object-fit: contain;
  width: 100%;
  height: auto;
  object-fit: contain;
}

.pb-mode .pb-counter {
  position: absolute;
  left: 50%;
  top: 32%;
  transform: translateX(-50%);
  font-size: 3.6rem;
  font-weight: 800;
  color: var(--pb-white);
  background: rgba(0, 0, 0, 0.45);
  padding: 6px 12px;
  border-radius: 10px;
  display: none;
  z-index: 50;
}

.pb-mode .pb-btn-jepret,
.pb-mode .take-btn {
  padding: 10px 18px;
  background: var(--pb-accent);
  color: #fff;
  border: none;
  border-radius: 10px;
  font-weight: 700;
  cursor: pointer;
}

.pb-mode .pb-btn-text {
  padding: 10px 18px;
  background: var(--pb-bg-left);
  color: #ffffff;
  border: none;
  border-radius: 10px;
  font-weight: 700;
  cursor: pointer;
}

/* ========================================================= */
/* thumbnail strip - UBAH KE 2 KOLOM */
.pb-mode .pb-result-track,
.pb-mode .thumb-track {
  display: grid;
  grid-template-columns: repeat(2, 1fr); /* SEKARANG 2 BARIS TURUN KEBAWAH */
  gap: 10px;
  padding: 5px;
  overflow: visible;
}

.pb-mode .pb-result-track img {
  width: 100%;
  height: auto; /* Biarkan proporsional */
  aspect-ratio: 3/3; /* Atau sesuaikan dengan rasio foto Mas */
  object-fit: cover;
  border-radius: 6px;
  cursor: pointer;
  border: 2px solid transparent;
  transition: all 0.15s ease;
}

/* Efek saat terpilih */
.pb-mode .pb-result-track img.selected {
  border: 3px solid var(--pb-accent);
  box-shadow: 0 0 10px rgba(12, 138, 57, 0.6);
  transform: scale(1.05);
}



/* CENTER - template list (vertical, slim) */
.pb-mode .pb-center {
  background: var(--grid-scale);
  color: #ffffff;
  padding: 12px;
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: stretch;
  height: 100%;
  box-shadow: #00ffaa;
}

.pb-mode .tpl-scroll {
  width: 100%;
  padding: 8px;
  background: rgba(0, 0, 0, 0.25);
  color: #fff;
  border: none;
  border-radius: 8px;
  cursor: pointer;
}

.pb-mode .pb-template-list {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  padding: 6px;
  overflow: visible;
  max-height: none;
}

.pb-mode .pb-template-list img {
  width: 100%;
  border-radius: 8px;
  cursor: pointer;
  border: 3px solid transparent;
}

.pb-mode .pb-template-list img.selected {
  outline: 4px solid rgba(0, 0, 0, 0.12);
}

/* RIGHT - template preview + grid */
.pb-mode .pb-right {
  background: var(--grid-scale);
  padding: 12px;
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  align-items: stretch;
  height: 100%;
}

/* template image top-most */
.pb-mode .template-frame .template-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  z-index: 30;
  pointer-events: none;
}

/* UBAH UKURAN FRAME GRID DI SINI */
.pb-mode .template-frame {
  width: 100%;
  aspect-ratio: 10.3 / 15.4;
  /* compact 4R-ish */
  background: var(--pb-white);
  border-radius: 12px;
  position: relative;
  overflow: hidden;
  flex: 0 0 auto;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.45);
}

/* GRID CONTROL VARIABLES (AMAN) DISINI TEMPAT MENGATUR TEMPAT SEMUA SLOT GRID */
/* PB4 ====================================================== */
.pb-mode .template-frame .grid-layer.grid-4 {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  grid-auto-rows: auto;
  /* 🔑 WAJIB */
  gap: 0px;
  /* jarak antar slot */
  padding: 0;
  --grid-scale: 1.0;
  /* JANGAN PERNAH DIUBAH */
  --grid-x: -1px;
  /* JANGAN PERNAH DIUBAH */
  --grid-y: 5px;
  /* JANGAN PERNAH DIUBAH */
  transform:
    translate(var(--grid-x), var(--grid-y)) scale(var(--grid-scale));
  transform-origin: top center;
}

.pb-mode .grid-layer.grid-4 .canvas-slot {
  aspect-ratio: 3 / 4;
  /* JANGAN PERNAH DIUBAH */
}

/* PB6 ====================================================== */
/* PB6 GRID */
.pb-mode .template-frame .grid-layer.grid-6 {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  grid-auto-rows: auto;
  --grid-scale: 0.97;
  /* JANGAN PERNAH DIUBAH */
  --grid-x: -7px;
  /* JANGAN PERNAH DIUBAH */
  --grid-y: 42px;
  /* JANGAN PERNAH DIUBAH */
  transform:
    translate(var(--grid-x), var(--grid-y)) scale(var(--grid-scale));
  transform-origin: top center;
}

/* SLOT SHAPE */
.pb-mode .grid-layer.grid-6 .canvas-slot {
  aspect-ratio: 4 / 3.1;
  /* JANGAN PERNAH DIUBAH */
  border-radius: 0;
}


/* PB8 ====================================================== */
.pb-mode .template-frame .grid-layer.grid-8 {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  grid-auto-rows: auto;
  --grid-scale: 0.949;
  /* JANGAN PERNAH DIUBAH */
  --grid-x: -10px;
  /* JANGAN PERNAH DIUBAH */
  --grid-y: 41px;
  /* JANGAN PERNAH DIUBAH */
  transform:
    translate(var(--grid-x), var(--grid-y)) scale(var(--grid-scale));
  transform-origin: top center;
}

/* SLOT SHAPE */
.pb-mode .grid-layer.grid-8 .canvas-slot {
  aspect-ratio: 5 / 2.95;
  /* JANGAN PERNAH DIUBAH */
  border-radius: 0;
}

/* ========================== */
.pb-mode .canvas-slot img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* ======== EDIT UKURAN DAN SKALA SLOT GRID == END */

/* actions */
.pb-mode .pb-actions,
.pb-mode .action-row {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.pb-mode .act-btn {
  padding: 12px;
  background: var(--pb-accent);
  color: #fff;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  font-weight: 700;
}

.pb-mode .act-btn-print {
  padding: 12px;
  background: var(--pb-yellow);
  color: #fff;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  font-weight: 700;
}

.pb-mode .pb-actions .act-btn {
  flex: 1;
  /* bagi rata kiri-kanan */
  text-align: center;
}

.pb-mode .pb-actions .act-btn-print {
  flex: 1;
  /* bagi rata kiri-kanan */
  text-align: center;
}

/* camera modal */
.pb-mode .camera-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 99999;
}

.pb-mode .cam-inner {
  width: 100%;
  max-width: 420px;
  background: #fff;
  padding: 14px;
  border-radius: 10px;
}

.pb-mode #camList {
  max-height: 260px;
  overflow-y: auto;
  padding: 6px;
  background: #f6f7f9;
  border-radius: 8px;
}

/* responsive compact */
@media (max-width:1100px) {
  .pb-mode .photo-box-wrapper {
    grid-template-columns: 1fr;
    height: auto;
  }

  .pb-mode .pb-left video {
    height: 480px;
  }

  .pb-mode .template-frame {
    aspect-ratio: 3/4;
    height: 360px;
  }

  .pb-mode .pb-template-list {
    max-height: 160px;
    display: flex;
    flex-direction: row;
    overflow-x: auto;
    gap: 8px;
  }
}

/* small polish */
.pb-mode .template-frame::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  box-shadow: inset 0 6px 20px rgba(0, 0, 0, 0.08);
  z-index: 40;
}

/* ============== */
.pb-mode .pb-canvas {
  position: relative;
}

.pb-mode .pb-template {
  position: absolute;
  inset: 0;
  z-index: 4;
  /* TEMPLATE DI ATAS */
  pointer-events: none;
}

.pb-mode .pb-grid {
  position: absolute;
  inset: 0;
  z-index: 3;
  /* GRID DI BAWAH TEMPLATE */
}

.pb-mode button:disabled {
  opacity: .55;
  cursor: not-allowed;
}

/* jepret disabled */
.pb-mode .pb-btn-jepret:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  filter: grayscale(0.6);
}


@keyframes slotPulse {
  0% {
    box-shadow: 0 0 0 rgba(12, 138, 57, 0);
  }

  50% {
    box-shadow: 0 0 14px rgba(12, 138, 57, 0.75);
  }

  100% {
    box-shadow: 0 0 0 rgba(12, 138, 57, 0);
  }
}

/* === CAMERA STATUS INDICATOR === */
.pb-mode .pb-cam-status {
  display: none;
  align-items: center;
  gap: 6px;
  font-size: 0.72rem;
  font-weight: 700;
  color: #bfffd8;
  margin-top: 4px;
  user-select: none;
}

.pb-mode .pb-cam-status .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #ff2c2c;
  box-shadow: 0 0 8px rgba(44, 255, 136, 0.8);
  animation: camBlink 1.6s infinite;
}

@keyframes camBlink {

  0%,
  100% {
    opacity: 1;
  }

  50% {
    opacity: 0.4;
  }
}

/* ===============================
   TEMPLATE GRID (2 kolom, turun)
   =============================== */

.pb-mode #pb4_templateList,
.pb-mode #pb6_templateList,
.pb-mode #pb8_templateList {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  padding: 6px;
  overflow-y: auto;
  /* ✅ scroll aktif */
  overflow-x: hidden;
  max-height: 100%;
}

/* === HIDE SCROLLBAR (BUT KEEP SCROLL) === */
.pb-mode #pb4_templateList::-webkit-scrollbar,
.pb-mode #pb6_templateList::-webkit-scrollbar,
.pb-mode #pb8_templateList::-webkit-scrollbar {
  width: 0px;
  height: 0px;
}

.pb-mode #pb4_templateList,
.pb-mode #pb6_templateList,
.pb-mode #pb8_templateList {
  scrollbar-width: none;
  /* Firefox */
  -ms-overflow-style: none;
  /* IE / Edge legacy */
}

/* ukuran thumbnail template */
.pb-mode #pb4_templateList img,
.pb-mode #pb6_templateList img,
.pb-mode #pb8_templateList img {
  width: 100%;
  height: auto;
  border-radius: 10px;
  cursor: pointer;
  opacity: 0.85;
  transition: all 0.2s ease;
}

/* hover */
.pb-mode #pb4_templateList img:hover,
.pb-mode #pb6_templateList img:hover,
.pb-mode #pb8_templateList img:hover {
  opacity: 1;
  transform: scale(1.03);
}

/* selected */
.pb-mode #pb4_templateList img.selected,
.pb-mode #pb6_templateList img.selected,
.pb-mode #pb8_templateList img.selected {
  outline: 2px solid var(--pb-accent);
  box-shadow: 0 0 10px rgba(12, 138, 57, 0.6);
  opacity: 1;
}

.pb-mode .grid-layer {
  flex: 1;
}

/* === LOCK SCROLL WHEN PHOTOBOX ACTIVE === */
html.pb-lock,
body.pb-lock {
  height: 100%;
  overflow: hidden;
}

/* === ACTION BUTTONS: CETAK & QR SIDE BY SIDE === */
.pb-mode .pb-actions {
  flex-direction: row;
  /* dari column → row */
  gap: 10px;
}

/* === FULLSCREEN CAPTURE OVERLAY KAMERA KETIKA KLIK TOMBOL JEPRET === */
#pbCaptureOverlay {
  position: fixed;
  inset: 0;
  background: #000;
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 999999;
}

#pbCaptureOverlay video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* PROSES HITUNG MUNDUR KETIKA PROSES JEPRET */
#pbCaptureOverlay .pb-capture-counter {
  position: absolute;
  font-size: 6rem;
  font-weight: 900;
  color: #fff;
  padding: 20px 36px;
  border-radius: 16px;
  z-index: 10;

  /* 🔥 ANIMASI */
  animation: pbCountBeat 1s ease-in-out infinite;
  text-shadow:
    0 0 18px rgba(255, 255, 255, 0.45),
    0 0 36px rgba(255, 255, 255, 0.25);

  transform-origin: center;
}

@keyframes pbCountBeat {
  0% {
    transform: scale(1);
    opacity: 0.65;
  }

  30% {
    transform: scale(1.25);
    opacity: 1;
  }

  60% {
    transform: scale(0.95);
    opacity: 0.9;
  }

  100% {
    transform: scale(1);
    opacity: 0.65;
  }
}



/* flash effect */
#pbCaptureOverlay .pb-flash {
  position: absolute;
  inset: 0;
  background: white;
  opacity: 0;
  z-index: 20;
  pointer-events: none;
}

/* === SLOT EDIT CONTROLS === */
.pb-mode .slot-controls {
  position: absolute;
  bottom: 6px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 6px;
  z-index: 50;
}

.pb-mode .slot-controls button {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: none;
  background: rgba(0, 0, 0, 0.65);
  color: #fff;
  font-size: 16px;
  font-weight: 800;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;

  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.45);
}

.pb-mode .slot-controls button:hover {
  background: var(--pb-accent);
}

.pb-mode .slot-controls button:active {
  transform: scale(0.92);
}

/* EFEK KAMERA MIRROR */
/* === CAMERA BAR (STATUS + MIRROR) === */
.pb-mode .pb-cam-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 6px;
}

/* mirror toggle */
.pb-mode .pb-mirror-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.75rem;
  font-weight: 700;
  color: #e8fdf0;
  cursor: pointer;
  user-select: none;
}

.pb-mode .pb-mirror-toggle input {
  accent-color: var(--pb-accent);
  cursor: pointer;
}

/* ===============================
   GLOBAL CAMERA MIRROR (FINAL)
   =============================== */

body.pb-mirror-on .pb-left video,
body.pb-mirror-on #pbCaptureOverlay video {
  transform: scaleX(-1);
}

/* EFEK TEKS DI BAWAH FOTO THUMBNAIL */
.pb-mode .pb-hint-text {
  margin-top: 6px;
  font-size: 0.72rem;
  font-weight: 600;
  color: #bfffd8;
  text-align: center;
  opacity: 0;
  transition: opacity .18s ease;
  user-select: none;
}

.pb-mode .pb-hint-text.show {
  opacity: 1;
}

/* POPUP MENAMPILKAN KETERANGAN SESI */
.pb-popup {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999999;
}

.pb-popup-inner {
  background: var(--pb-accent);
  padding: 22px;
  border-radius: 14px;
  width: 380px;
  text-align: center;
  color: #fff;
  box-shadow: 0 0 30px rgba(0, 0, 0, .6);
}

.pb-popup-inner button {
  margin-top: 16px;
  padding: 10px 20px;
  border-radius: 10px;
  border: none;
  background: var(--pb-accent);
  color: #fff;
  font-weight: 700;
  cursor: pointer;
}

/* === SESSION TIMER (FINAL) === */
.pb-mode .pb-timer {
  position: absolute;
  top: 18px;
  left: 18px;
  font-size: 2.0rem;
  font-weight: 800;
  color: #bfffd8;
  background: rgb(0, 0, 0);
  padding: 3px 5px;
  border-radius: 8px;
  z-index: 60;
}

.pb-mode .pb-timer.warning {
  color: #ff2c2c;
  animation: pbBlink 1s infinite;
}

@keyframes pbBlink {

  0%,
  100% {
    opacity: 1;
  }

  50% {
    opacity: 0.4;
  }
}

/* === SESSION END MESSAGE (INSIDE CAMERA) === */
.pb-mode .pb-session-end-msg {
  position: absolute;
  top: 40%;
  left: 37%;
  transform: translate(-50%, -50%);
  width: 90%;
  max-width: 460px;

  background: rgba(0, 0, 0, 0.72);
  color: #ffffff;
  padding: 18px 20px;
  border-radius: 14px;

  text-align: center;
  z-index: 55;
  /* di atas video, di bawah counter */
  pointer-events: none;
  /* 🔑 tidak mengganggu klik */
}

.pb-mode .pb-session-end-msg h2 {
  margin: 0 0 10px;
  font-size: 1.6rem;
  font-weight: 900;
  color: #ffcc33;
}

.pb-mode .pb-session-end-msg p {
  font-size: 0.9rem;
  margin-bottom: 8px;
}

.pb-mode .pb-session-end-msg ol {
  text-align: left;
  margin: 0;
  padding-left: 18px;
  font-size: 0.9rem;
}

/* ===============================
   POPUP QR & PRINT
=============================== */
.pb-popup {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 20px rgba(0, 255, 255, .25);
}

.pb-popup-inner {
  background: #111;
  padding: 20px;
  border-radius: 14px;
  text-align: center;
  max-width: 100vw;
  box-shadow: 0 0 20px rgba(0, 255, 255, .25);
}

.pb-print-preview {
  max-width: 100%;
  margin: 12px 0;
  box-shadow: 0 0 20px rgba(0, 255, 255, .25);
}

/* ===============================
   TRANSFORM HANDLES (FIXED)
================================ */
.pb-mode .tf-handle {
  position: absolute;
  width: 16px;
  height: 16px;
  background: var(--pb-bg-center);
  border-radius: 50%;
  z-index: 20;
  pointer-events: auto;
}

/* ==========================================================
   HIDE HANDLES UNTUK EXPORT / PRINT
   ========================================================== */
.pb-mode .tf-handle.hide-ui {
  display: none !important;
}

/* POSISI HANDLE */
.pb-mode .tf-handle.tl {
  top: -8px;
  left: -8px;
}

.pb-mode .tf-handle.tr {
  top: -8px;
  right: -8px;
}

.pb-mode .tf-handle.bl {
  bottom: -8px;
  left: -8px;
}

.pb-mode .tf-handle.br {
  bottom: -8px;
  right: -8px;
}

/* ICON ROTATE */
.pb-mode .tf-handle.rot::before {
  content: '↺';
  font-size: 18px;
  color: var(--pb-bg-center);
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
}

.pb-mode .tf-handle.rot {
  position: absolute;
  top: -36px;
  left: 50%;
  transform: translateX(-50%);
  width: 22px;
  height: 22px;
  background: transparent;
  cursor: grab;
}

/* SEMUA TENTANG EDITING GRID SLOT-TRANSFORM ========================*/
.pb-mode .slot-transform {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
}

.pb-mode .slot-inner {
  position: absolute;
  left: 50%;
  top: 50%;
  transform-origin: center center;
}

.pb-mode .slot-transform img {
  object-fit: cover;
  pointer-events: none;
}

/* Outline */
/* === MICRO ACTIVE SLOT INDICATOR (FINAL SAFE) === */
.pb-mode .slot-transform.active::after {
  content: '';
  position: absolute;
  inset: 30px;
  /* 🔑 LEBIH MASUK */
  border: 1px dashed rgba(0, 255, 136, 0.75);
  border-radius: 4px;
  /* 🔑 LEBIH KECIL */
  pointer-events: none;
  z-index: 2;
}


/* .pb-mode .slot-transform.active::after {
  display: none !important;
} */

/* TOUCHSCREEN */
.slot-transform {
  touch-action: none;
  transform-origin: center center;
}

.pb-mode .slot-inner img {
  display: block;
  width: auto;
  height: auto;
  max-width: none;
  max-height: none;
  pointer-events: none;
}

/* SEMUA TENTANG CANVAS-SLOT =======================================*/
.pb-mode .canvas-slot {
  position: relative;
  overflow: hidden;
  touch-action: none;

  background: #111;
  z-index: 3;

  transition:
    /* transform 0.22s ease, */
    box-shadow 0.22s ease,
    border-color 0.22s ease;
}

.pb-mode .template-frame .canvas-slot {
  background: rgba(255, 255, 255, 0.12);
  border-radius: 0px;
  border: 2px dashed rgba(255, 255, 255, 0.18);

  /* aspect-ratio: 3 / 4; */
  width: 100%;
  height: auto;

  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  position: relative;
}

.pb-mode .template-frame .canvas-slot .slot-placeholder {
  color: #fff;
  font-weight: 700;
  text-align: center;
  /* padding: 8px; */
}

.pb-mode .canvas-slot:hover {
  border-color: var(--pb-yellow);
  background: rgba(255, 255, 255, 0.18);
}

/* slot terisi */
.pb-mode .canvas-slot.filled {
  border-style: solid;
  border-color: var(--pb-accent);
  background: #000;
}

/* SLOT GRID AKTIF KETIKA MEMILIH HASIL FOTO*/
.pb-mode .canvas-slot.active {
  outline: 1px solid var(--pb-accent);
  outline-offset: -20px;
}

/* slot hover (ready state) */
.pb-mode .canvas-slot:hover {
  border-color: var(--pb-accent);
  box-shadow: 0 0 12px rgba(12, 138, 57, 0.45);
  background: rgba(12, 138, 57, 0.08);
}

/* slot filled */
.pb-mode .canvas-slot.filled {
  border: 1px solid rgba(255, 255, 255, 0.6);
  background: transparent;
  box-shadow: none;
}

.pb-mode .canvas-slot img.slot-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;

  transform-origin: center center;
  cursor: grab;
  user-select: none;
  will-change: transform;
}

.pb-mode .canvas-slot img.slot-img:active {
  cursor: grabbing;
}

/* === PULSE SLOT KOSONG (UX GUIDE) === */
.pb-mode .canvas-slot.pulse {
  animation: slotPulse 1.0s ease-in-out infinite;
  border-color: var(--pb-accent);
}

@keyframes slotPulseSafe {
  0% {
    box-shadow: 0 0 0 rgba(12, 138, 57, 0);
  }

  50% {
    box-shadow: 0 0 18px rgba(12, 138, 57, .8);
  }

  100% {
    box-shadow: 0 0 0 rgba(12, 138, 57, 0);
  }
}

.pb-mode .canvas-slot.pulse {
  animation: slotPulseSafe 1s infinite;
}

/* SLOT INDICATOR SAAT FOTO DIPILIH (BELUM MASUK SLOT) */
.pb-mode .canvas-slot.pulse {
  position: relative;
}

/* kotak indikator kecil di tengah slot */
.pb-mode .canvas-slot.pulse::after {
  content: '';
  position: absolute;
  inset: 18%;
  border: 2px dashed var(--pb-accent);
  border-radius: 8px;
  pointer-events: none;
  opacity: 0.9;
}

/* ======================================================== */
.ui-only {
  pointer-events: auto;
}

@media print {
  .ui-only {
    display: none !important;
  }
}

/* PROGRESS BAR */
.pb-progress {
  position: absolute;
  bottom: 200px;
  left: 50%;
  transform: translateX(-50%);
  width: 520px;
  background: #111;
  border-radius: 12px;
  padding: 12px 14px;
  box-shadow: 0 0 20px rgba(0, 255, 255, .25);
  z-index: 9999999999;
  font-family: 'Trebuchet MS';
}

.pb-progress.hidden {
  display: none;
}

.pb-progress-text {
  color: #0ff;
  font-size: 13px;
  margin-bottom: 6px;
  text-align: center;
}

.pb-progress-bar {
  width: 100%;
  height: 8px;
  background: #222;
  border-radius: 6px;
  overflow: hidden;
}

.pb-progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #0ff, #00ffaa);
  transition: width .4s ease;
}

/* =============================================================================== */
#pbInterShotOverlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 99998;
  backdrop-filter: blur(6px);
}

.pb-inter-inner {
  text-align: center;
  color: #fff;
}

.pb-inter-text {
  font-size: 22px;
  font-weight: 600;
  opacity: .9;
  margin-bottom: 10px;
}

.pb-inter-count {
  font-size: 64px;
  font-weight: 800;
  letter-spacing: 2px;
  animation: pbCountPulse 1s ease-in-out infinite;
}

@keyframes pbCountPulse {
  0% {
    transform: scale(1);
    opacity: 0.7;
  }

  50% {
    transform: scale(1.25);
    opacity: 1;
  }

  100% {
    transform: scale(1);
    opacity: 0.7;
  }
}

.pb-inter-progress {
  font-size: 14px;
  opacity: .8;
  margin-bottom: 6px;
  letter-spacing: .5px;
}

/* ======================================================================= */
/* ==========================================================
   PB GRID SIZE LOCK (AMAN)
   ========================================================== */
.pb-mode .template-frame {
  flex-shrink: 0;      /* ⛔ JANGAN PERNAH MENGECIL */
  max-width: 100%;     /* aman */
}


/* ==========================================================
   PB GRID SIZE LOCK — FINAL SAFE
   ========================================================== */
.pb-mode .template-frame {
  flex-shrink: 0;
}

.pb-mode .pb-right,
 .pb-mode .pb-center,
 .pb-mode .pb-left {
  height: auto;
}


/* === CAPTURE ACTIONS (AMBIL FOTO + SELANJUTNYA) === */
.pb-mode .pb-capture-actions {
  display: flex;
  gap: 10px;
  margin-top: 8px;
}

.pb-mode .pb-capture-actions button {
  flex: 1;
}

.pb-mode .pb-btn-next {
  padding: 10px 18px;
  background: orange;
  color: #fff;
  border: none;
  border-radius: 10px;
  font-weight: 700;
  cursor: pointer;
}

/* ====================CSS MAPING ====================================================== */
/* =========================================
   1. WRAPPER (PUSAT KENDALI)
========================================= */
.pb-mode .photo-box-wrapper {
  display: flex;
  justify-content: center;
  align-items: center;    /* Center di PC */
  min-height: 100vh;
  width: 100%;
  position: relative;
  overflow-y: auto;       /* WAJIB agar HP bisa scroll */
  padding: 40px 10px;
  box-sizing: border-box;
}

/* =========================================
   2. PANEL BASE (OPACITY ONLY - GRID AMAN)
========================================= */
.pb-mode .pb-left,
.pb-mode .pb-center,
.pb-mode .pb-right {
  /* Hilangkan top:50% & transform agar tidak potong atas di HP */
  position: absolute; 
  opacity: 0;
  pointer-events: none;
  z-index: 10;
  transition: opacity 0.3s ease;
  
  /* Cara Center paling aman tanpa merusak Slot Grid */
  margin-left: auto;
  margin-right: auto;
  left: 0;
  right: 0;
}

/* UKURAN PANEL PB-RIGHT, PB-CENTER, DAN PB-LEFT */
.pb-mode .pb-left { max-width: 960px; }
.pb-mode .pb-center { 
    max-width: 1000px; 
    min-width: 0 !important; /* 🔑 KUNCI ANTI-JEBOL: Paksa kotak berhenti melebar */
    width: 100%;
}
.pb-mode .pb-right { max-width: 380px; }

/* =========================================
   3. STATE AKTIF (OPACITY 1)
========================================= */
.pb-mode.pb-state-entry .pb-left,
.pb-mode.pb-state-capture .pb-left,
.pb-mode.pb-state-template .pb-center,
.pb-mode.pb-state-edit .pb-right,
.pb-mode.pb-state-print .pb-right {
  opacity: 1;
  pointer-events: auto;
  z-index: 100;
}

/* =========================================
   4. TEMPLATE LIST (MEMANJANG)
========================================= */
/* =========================================
   TEMPLATE LIST (1 BARIS MEMANJANG KE KANAN)
========================================= */
.pb-mode .pb-template-list {
  display: flex !important;
  flex-direction: row !important;  /* Paksa sejajar ke kanan */
  flex-wrap: nowrap !important;    /* Larang turun ke baris baru */
  gap: 15px;                       /* Jarak antar gambar template */
  overflow-x: auto !important;     /* Aktifkan scroll horizontal */
  width: 100%;
  padding: 10px 5px;
  border-radius: 8px;
  
  /* Sembunyikan Scrollbar untuk Firefox & IE/Edge */
  scrollbar-width: none; 
  -ms-overflow-style: none; 
  -webkit-overflow-scrolling: touch; /* Biar scroll di HP mulus */
}

/* Sembunyikan Scrollbar untuk Chrome, Safari, dan Opera */
.pb-mode .pb-template-list::-webkit-scrollbar {
  display: none;
}

/* Ukuran Gambar Template agar proporsional */
.pb-mode .pb-template-list img { 
  flex: 0 0 auto !important;       /* Pastikan gambar tidak gepeng tergencet */
  height: 380px !important;        /* Tinggi template (Bisa disesuaikan selera Mas Jeri) */
  width: auto !important; 
  border-radius: 8px;
  cursor: pointer;
  border: 3px solid transparent;
  transition: transform 0.2s ease, border-color 0.2s ease;
}

/* Efek saat gambar template disentuh/hover */
.pb-mode .pb-template-list img:hover { 
  transform: scale(1.05);
  border-color: var(--pb-yellow, #ffbf00); /* Warna garis saat disorot */
}

/* =========================================
   5. KHUSUS MODE HP (ANTI POTONG)
========================================= */
@media (max-width: 768px) {
  .pb-mode .photo-box-wrapper {
    /* Biar tidak potong atas, kita paksa nempel atas di HP */
    align-items: flex-start; 
    padding-top: 20px;
  }

  .pb-mode .pb-left,
  .pb-mode .pb-center,
  .pb-mode .pb-right {
    /* Ubah ke relative HANYA saat aktif agar HP tahu tinggi halamannya */
    position: relative;
    top: 0;
    margin-bottom: 50px;
  }
}


/* =========================================
  TOMBOL PILIH TEMPLATE DAN RESET EDIT
========================================= */
/* =========================================
   TOMBOL PILIH TEMPLATE & AKSI (DENGAN TEKS)
========================================= */
/* Container ditarik sedikit lebih ke kiri agar teksnya muat */
.pb-mode .pb-floating-buttons {
    position: absolute;
    left: -175px; 
    top: 10px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    z-index: 150;
    align-items: flex-end; /* Memastikan tombol tetap rata menempel di kanan */
}

/* Bungkus untuk Teks + Tombol */
.pb-mode .pb-btn-wrapper {
    display: flex;
    align-items: center;
    gap: 12px;
    justify-content: flex-end;
    cursor: pointer;
}

/* Desain Teks Keterangan Minimalis */
.pb-mode .pb-btn-label {
    background: rgba(0, 0, 0, 0.65);
    color: #fff;
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 13px;
    letter-spacing: 0.5px;
    white-space: nowrap;
    border: 1px solid rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(4px);
    transition: all 0.3s ease;
    opacity: 0.85;
}

/* Base Style Tombol Bulat */
.pb-mode .pb-btn-float {
    width: 45px;
    height: 45px;
    border-radius: 50%;
    border: 3px solid #ffffff;
    background: var(--pb-bg-right);
    color: #ffffff;
    font-size: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 8px rgba(0,0,0,0.3);
    transition: all 0.3s ease;
}

/* Efek Nyala Saat Teks/Tombol Disentuh */
.pb-mode .pb-btn-wrapper:hover .pb-btn-label {
    background: var(--pb-accent, #0c8a39);
    border-color: var(--pb-accent, #0c8a39);
    opacity: 1;
    transform: scale(1.05);
}

.pb-mode .pb-btn-wrapper:hover .pb-btn-float {
    background: #f0f0f0;
    transform: scale(1.1);
    color: var(--pb-accent, #0c8a39);
    border-color: #f0f0f0;
}

/* Garis Pembatas antar Grup */
.pb-mode .pb-floating-divider {
    width: 30px;
    height: 1px;
    background: rgba(255, 255, 255, 0.2);
    margin: 4px 8px 4px 0;
}

/* Penyesuaian untuk Layar HP */
@media (max-width: 768px) {
    .pb-mode .pb-floating-buttons {
        left: 10px;
        align-items: flex-start; /* Geser rata kiri di HP */
    }
    .pb-mode .pb-btn-wrapper {
        flex-direction: row-reverse; /* Teks pindah ke sebelah kanan tombol */
    }
    .pb-mode .pb-btn-float {
        width: 40px;
        height: 40px;
        font-size: 18px;
    }
}


/* =========================================
   EFEK FILTER FOTO (KANAN PB-RIGHT)
========================================= */
.pb-mode .pb-filter-container {
    position: absolute;
    right: -140px; /* Nangkring di luar sebelah kanan pb-right */
    top: -21px;
    width: 140px;
    height: 102%;
    display: flex;
    flex-direction: column;
    z-index: 100;
}

.pb-mode .pb-filter-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    overflow-y: auto;
    padding: 5px;
    scrollbar-width: none;
    -ms-overflow-style: none;
}
.pb-mode .pb-filter-list::-webkit-scrollbar { display: none; }

.pb-mode .pb-filter-item {
    background: rgba(0, 0, 0, 0.4);
    border: 2px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    padding: 6px;
    cursor: pointer;
    transition: transform 0.2s, border-color 0.2s;
    text-align: center;
    color: #fff;
    font-size: 12px;
    font-weight: bold;
}

.pb-mode .pb-filter-item:hover {
    transform: scale(1.05);
    border-color: var(--pb-yellow);
    background: rgba(0, 0, 0, 0.8);
}

.pb-mode .pb-filter-item img {
    width: 100%;
    height: 100px;
    object-fit: cover;
    border-radius: 6px;
    margin-bottom: 4px;
    pointer-events: none;
}

/* RESPONSIVE HP: Pindah ke bawah tombol aksi dan jadi mendatar */
@media (max-width: 768px) {
    .pb-mode .pb-filter-container {
        position: relative;
        right: 0;
        width: 100%;
        height: auto;
        margin-top: 15px;
        background: rgba(0,0,0,0.2);
        padding: 10px;
        border-radius: 12px;
    }
    .pb-mode .pb-filter-list {
        flex-direction: row;
        overflow-x: auto;
        overflow-y: hidden;
        padding-bottom: 5px;
    }
    .pb-mode .pb-filter-item {
        flex: 0 0 90px; /* Lebar kotak efek di HP */
    }
    .pb-mode .pb-filter-item img {
        height: 80px;
    }
}


/* TOMBOL GANTI KAMERA===================================================== */
/* Pastikan pembungkusnya relative agar tombol bisa menempel di pojok */
.pb-left {
    position: relative; 
}

/* Styling Tombol Switch Kamera */
.pb-btn-switch-cam {
    position: absolute;
    top: 5px;
    right: 5px;
    background: rgba(0, 0, 0, 0.6);
    color: white;
    border: 2px solid #fff;
    border-radius: 50%;
    width: 48px;
    height: 48px;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    z-index: 50; /* Selalu di atas video */
    transition: all 0.3s ease;
    box-shadow: 0 4px 6px rgba(0,0,0,0.3);
}

.pb-btn-switch-cam:hover {
    background: #ff007a; /* Warna Neon khas Photobooth */
    transform: scale(1.1);
    border-color: #ff007a;
}

/* Styling untuk list tombol kamera di dalam Popup */
.cam-option-btn {
    background: #2a2a2a;
    color: #fff;
    border: 1px solid #555;
    padding: 12px;
    border-radius: 8px;
    text-align: left;
    cursor: pointer;
    transition: 0.2s;
    font-size: 14px;
}
.cam-option-btn:hover {
    background: #ff007a;
    border-color: #ff007a;
}


/* =========================================
   STYLING POPUP BUMERANG
========================================= */
#pbBumerangModal {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.85);
    z-index: 99999; /* Pastikan paling atas */
    display: flex;
    justify-content: center;
    align-items: center;
    backdrop-filter: blur(5px);
}

.bumerang-modal-content {
    background: #222;
    padding: 20px;
    border-radius: 16px;
    text-align: center;
    position: relative;
    width: 90%;
    max-width: 380px; /* Pas untuk video rasio potret */
    box-shadow: 0 10px 40px rgba(0,0,0,0.6);
    border: 2px solid #444;
}

#closeBumerangBtn {
    position: absolute;
    top: -15px; right: -15px;
    background: #ff4757; color: white;
    border: none; width: 36px; height: 36px;
    border-radius: 50%; font-weight: bold; font-size: 1rem;
    cursor: pointer; box-shadow: 0 4px 10px rgba(255, 71, 87, 0.4);
    transition: transform 0.2s;
}

#closeBumerangBtn:active {
    transform: scale(0.9);
}

#bumerangLoading {
    color: #f1c40f;
    padding: 40px 0;
    font-weight: bold;
}

#pbBumerangVideo {
    width: 100%;
    border-radius: 8px;
    border: 1px solid #555;
    background: #000;
}


/* ============================================= */
/* =========================================
   ANIMASI INDIKATOR GESER TEMPLATE
========================================= */
.pb-mode .pb-swipe-indicator {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 12px;
    margin-top: 15px; /* Jarak dari kotak daftar template di atasnya */
    padding-bottom: 15px;
    color: rgba(0, 0, 0, 0.7); /* Warna putih semi-transparan yang elegan */
    font-size: 24px;
    font-weight: bold;
    letter-spacing: 2px;
    width: 100%;
}

.pb-mode .swipe-arrow {
    color: var(--pb-yellow, #ffbf00); /* Warna aksen sorot dari LENS BOX */
    font-size: 18px;
}

/* Mengatur gerak panah ke arah berlawanan */
.pb-mode .left-arrow {
    animation: swipe-bounce-left 1.5s infinite ease-in-out;
}

.pb-mode .right-arrow {
    animation: swipe-bounce-right 1.5s infinite ease-in-out;
}

/* Gerak maju-mundur mulus (kiri) */
@keyframes swipe-bounce-left {
    0%, 100% { transform: translateX(0); opacity: 0.3; }
    50% { transform: translateX(-6px); opacity: 1; }
}

/* Gerak maju-mundur mulus (kanan) */
@keyframes swipe-bounce-right {
    0%, 100% { transform: translateX(0); opacity: 0.3; }
    50% { transform: translateX(6px); opacity: 1; }
}


#pb-video-preview {
    object-fit: cover; /* Biar video memenuhi kotak tanpa distorsi */
    width: 100%;
    height: 100%;
    transform: scaleX(1); /* Pastikan tidak terbalik (mirror) kecuali diinginkan */
}