@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700;800&display=swap');

:root {
  --bg: #0b0a14;
  --bg2: #151226;
  --card: rgba(255,255,255,.06);
  --card-strong: rgba(255,255,255,.1);
  --border: rgba(255,255,255,.12);
  --text: #f7f5ff;
  --muted: #a9a4c4;
  --primary: #8b5cf6;
  --primary2: #ec4899;
  --accent: #22d3ee;
  --success: #34d399;
  --danger: #fb7185;
  --radius: 22px;
  --shadow: 0 20px 60px rgba(0,0,0,.45);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; min-height: 100%; }
body {
  font-family: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
  color: var(--text);
  background:
    radial-gradient(1000px 600px at 12% -10%, rgba(139,92,246,.32), transparent 60%),
    radial-gradient(900px 600px at 100% 100%, rgba(236,72,153,.22), transparent 60%),
    linear-gradient(160deg, var(--bg), var(--bg2));
  background-attachment: fixed;
  min-height: 100vh;
}
a { color: var(--accent); text-decoration: none; }
button, input, select, textarea { font: inherit; }
img { max-width: 100%; display: block; }

.app { max-width: 1180px; margin: 0 auto; padding: 24px; min-height: 100vh; display: flex; flex-direction: column; }
.app.compact { max-width: 1280px; }

.topbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 26px; }
.brand { display: flex; align-items: center; gap: 12px; font-weight: 800; letter-spacing: -.02em; font-size: 20px; }
.brand img { width: 38px; height: 38px; border-radius: 11px; box-shadow: 0 8px 20px rgba(139,92,246,.4); }
.brand small { display: block; font-size: 11px; font-weight: 600; color: var(--muted); letter-spacing: .14em; text-transform: uppercase; }
.topbar .links { display: flex; gap: 8px; flex-wrap: wrap; }

.screen { display: none; flex: 1; flex-direction: column; animation: fade .35s ease; }
.screen.active { display: flex; }
@keyframes fade { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.hero { text-align: center; padding: 40px 0 24px; }
.hero h1 { font-size: clamp(38px, 6vw, 76px); line-height: 1.05; margin: 0 0 14px; letter-spacing: -.045em; }
.hero h1 em { font-style: normal; background: linear-gradient(100deg, #c4b5fd, #f9a8d4, #67e8f9); -webkit-background-clip: text; background-clip: text; color: transparent; }
.hero p { color: var(--muted); font-size: 17px; max-width: 560px; margin: 0 auto; line-height: 1.6; }

.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 22px; backdrop-filter: blur(18px); box-shadow: var(--shadow); }
.card.strong { background: var(--card-strong); }
.card h2, .card h3 { margin: 0 0 12px; letter-spacing: -.02em; }
.muted { color: var(--muted); }
.center { text-align: center; }
.stack { display: flex; flex-direction: column; gap: 16px; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.grid { display: grid; gap: 16px; }
.grid.cols-2 { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.grow { flex: 1; }
.hidden { display: none !important; }

.btn {
  appearance: none; border: 1px solid var(--border); background: rgba(255,255,255,.07); color: var(--text);
  padding: 13px 20px; border-radius: 14px; font-weight: 700; cursor: pointer; transition: .18s ease;
  display: inline-flex; align-items: center; justify-content: center; gap: 9px; min-height: 48px;
}
.btn:hover { transform: translateY(-2px); background: rgba(255,255,255,.13); }
.btn:active { transform: translateY(0); }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; }
.btn-primary { border: 0; background: linear-gradient(110deg, var(--primary), var(--primary2)); box-shadow: 0 12px 30px rgba(139,92,246,.35); }
.btn-primary:hover { box-shadow: 0 16px 36px rgba(139,92,246,.5); }
.btn-success { border: 0; background: linear-gradient(110deg, #059669, var(--success)); color: #042b20; }
.btn-danger { border-color: rgba(251,113,133,.4); color: var(--danger); }
.btn-lg { min-height: 64px; padding: 18px 34px; font-size: 19px; border-radius: 18px; }
.btn-block { width: 100%; }
.btn-sm { min-height: 36px; padding: 7px 12px; font-size: 13px; border-radius: 10px; }

.badge { display: inline-flex; align-items: center; gap: 6px; padding: 5px 11px; border-radius: 999px; font-size: 12px; font-weight: 700; background: rgba(255,255,255,.09); border: 1px solid var(--border); }
.badge.ok { background: rgba(52,211,153,.14); color: var(--success); border-color: rgba(52,211,153,.3); }
.badge.warn { background: rgba(251,191,36,.14); color: #fcd34d; border-color: rgba(251,191,36,.3); }
.badge.err { background: rgba(251,113,133,.14); color: var(--danger); border-color: rgba(251,113,133,.3); }

.template-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px; }
.template-card { position: relative; cursor: pointer; border: 2px solid transparent; border-radius: 18px; overflow: hidden; background: rgba(255,255,255,.05); transition: .2s; }
.template-card:hover { transform: translateY(-3px); }
.template-card.selected { border-color: var(--primary2); box-shadow: 0 0 0 4px rgba(236,72,153,.16); }
.template-card .thumb { height: 132px; display: grid; place-items: center; background: linear-gradient(145deg, rgba(139,92,246,.28), rgba(236,72,153,.16)); }
.template-card .thumb div { width: 58px; height: 82px; border: 3px solid rgba(255,255,255,.7); border-radius: 6px; background: repeating-linear-gradient(180deg, rgba(255,255,255,.12) 0 22px, transparent 22px 26px); }
.template-card .meta { padding: 10px 12px; font-size: 13px; font-weight: 700; }
.template-card .meta small { display: block; color: var(--muted); font-weight: 500; margin-top: 2px; }

.qr-box { background: #fff; padding: 14px; border-radius: 18px; display: inline-block; box-shadow: 0 16px 40px rgba(0,0,0,.35); }
.qr-box img { width: min(290px, 62vw); height: auto; }
.pay-card { display: grid; grid-template-columns: minmax(0,1fr) auto; gap: 28px; align-items: center; }
@media (max-width: 720px) { .pay-card { grid-template-columns: 1fr; justify-items: center; text-align: center; } }
.pay-timer { font-variant-numeric: tabular-nums; font-size: 15px; letter-spacing: .04em; }
.pay-timer.warn { background: rgba(251,191,36,.18); color: #fcd34d; border-color: rgba(251,191,36,.4); }
.pay-timer.err { background: rgba(251,113,133,.16); color: var(--danger); border-color: rgba(251,113,133,.4); }
.time-left { font-variant-numeric: tabular-nums; font-size: 14px; letter-spacing: .04em; }
.time-left.warn { background: rgba(251,191,36,.18); color: #fcd34d; border-color: rgba(251,191,36,.4); }
.time-left.err { background: rgba(251,113,133,.16); color: var(--danger); border-color: rgba(251,113,133,.4); }

.camera-stage { position: relative; border-radius: 22px; overflow: hidden; background: #05050a; aspect-ratio: 4/3; display: grid; place-items: center; border: 1px solid var(--border); }
.camera-stage video, .camera-stage .shot-preview { width: 100%; height: 100%; object-fit: cover; }
.camera-stage .shot-preview { position: absolute; inset: 0; }
.camera-stage .mirror { transform: scaleX(-1); }
.countdown { position: absolute; inset: 0; z-index: 4; display: grid; place-items: center; background: rgba(6,5,14,.72); backdrop-filter: blur(3px); font-size: clamp(90px, 18vw, 190px); font-weight: 800; color: #fff; text-shadow: 0 0 50px rgba(236,72,153,.8); }
.countdown.tick { animation: tick .5s ease-out; }
@keyframes tick { 0% { transform: scale(1.35); opacity: .4; } 100% { transform: scale(1); opacity: 1; } }
.flash { position: absolute; inset: 0; z-index: 6; background: #fff; opacity: 0; pointer-events: none; }
.flash.fire { animation: camflash .45s ease-out; }
@keyframes camflash { 0% { opacity: 0; } 10% { opacity: 1; } 100% { opacity: 0; } }
.stage-caption { position: absolute; bottom: 14px; left: 14px; right: 14px; display: flex; justify-content: space-between; gap: 10px; pointer-events: none; }
.stage-caption .badge { background: rgba(0,0,0,.55); backdrop-filter: blur(8px); }

.slots { display: flex; gap: 10px; justify-content: center; margin: 16px 0; flex-wrap: wrap; }
.slot { width: 74px; height: 56px; border-radius: 12px; border: 2px dashed rgba(255,255,255,.22); display: grid; place-items: center; font-size: 12px; font-weight: 800; color: var(--muted); overflow: hidden; }
.slot.done { border-style: solid; border-color: var(--success); }
.slot.done img { width: 100%; height: 100%; object-fit: cover; }
.slot.current { border-color: var(--primary2); box-shadow: 0 0 0 4px rgba(236,72,153,.14); color: #f9a8d4; }

/* Hasil: foto di kiri, QR & link di kanan */
.result-wrap { width: 100%; max-width: 1060px; margin: 0 auto; }
.result-layout { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(260px, .85fr); gap: 30px; align-items: center; }
.result-photo { display: flex; justify-content: center; min-width: 0; }
.result-img { width: auto; max-width: 100%; max-height: min(68vh, 720px); border-radius: 18px; box-shadow: 0 24px 70px rgba(0,0,0,.55); }
.result-side { display: flex; flex-direction: column; align-items: center; gap: 14px; text-align: center; }
.result-side .qr-box img { width: min(230px, 48vw); }
.result-actions { justify-content: center; margin-top: 26px; }
@media (max-width: 860px) {
  .result-layout { grid-template-columns: 1fr; gap: 20px; }
  .result-img { max-height: 52vh; }
  .result-side .qr-box img { width: min(230px, 62vw); }
}

.spinner { width: 62px; height: 62px; border-radius: 50%; border: 5px solid rgba(255,255,255,.14); border-top-color: var(--primary2); animation: spin 1s linear infinite; margin: 0 auto 20px; }
@keyframes spin { to { transform: rotate(360deg); } }

.toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%) translateY(120px); background: #1c1730; border: 1px solid var(--border); padding: 13px 20px; border-radius: 14px; box-shadow: var(--shadow); z-index: 999; transition: .3s cubic-bezier(.2,.8,.2,1); max-width: min(92vw, 520px); font-size: 14px; }
.toast.show { transform: translateX(-50%) translateY(0); }
.toast.err { border-color: rgba(251,113,133,.5); }
.toast.ok { border-color: rgba(52,211,153,.5); }

/* ---------------- Admin ---------------- */
.admin-shell { display: grid; grid-template-columns: 230px 1fr; gap: 22px; align-items: start; }
@media (max-width: 820px) { .admin-shell { grid-template-columns: 1fr; } }
.side { position: sticky; top: 20px; }
.side .btn { width: 100%; justify-content: flex-start; margin-bottom: 6px; }
.side .btn.active { background: linear-gradient(110deg, rgba(139,92,246,.4), rgba(236,72,153,.3)); border-color: rgba(236,72,153,.45); }
.admin-panel { display: none; }
.admin-panel.active { display: block; }
.stat { padding: 16px; border-radius: 16px; background: rgba(255,255,255,.05); border: 1px solid var(--border); }
.stat .label { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .1em; font-weight: 700; }
.stat .value { font-size: 22px; font-weight: 800; margin-top: 6px; word-break: break-all; }

label.field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 700; color: var(--muted); }
input, select, textarea {
  background: rgba(0,0,0,.28); border: 1px solid var(--border); color: var(--text);
  border-radius: 11px; padding: 11px 13px; outline: none; width: 100%;
}
input:focus, select:focus, textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(139,92,246,.18); }
textarea { min-height: 150px; resize: vertical; font-family: ui-monospace, SFMono-Regular, monospace; font-size: 12px; line-height: 1.5; }
input[type=checkbox] { width: 20px; height: 20px; accent-color: var(--primary); }
.check-field { display: flex; align-items: center; gap: 10px; font-size: 14px; font-weight: 600; }

table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 11px 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .08em; }
tbody tr:hover { background: rgba(255,255,255,.035); }
.table-wrap { overflow-x: auto; }

.tpl-editor { display: grid; grid-template-columns: minmax(0,1fr) minmax(0,1fr); gap: 18px; }
@media (max-width: 900px) { .tpl-editor { grid-template-columns: 1fr; } }
.tpl-item { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 14px; border: 1px solid var(--border); border-radius: 13px; background: rgba(255,255,255,.04); }
.login-wrap { max-width: 420px; margin: 12vh auto; }

/* ---------------- Gallery & share ---------------- */
.gallery-grid { columns: 4 240px; column-gap: 16px; }
.gallery-grid figure { margin: 0 0 16px; break-inside: avoid; position: relative; border-radius: 16px; overflow: hidden; background: rgba(255,255,255,.05); border: 1px solid var(--border); }
.gallery-grid img { width: 100%; cursor: zoom-in; transition: .25s; }
.gallery-grid img:hover { transform: scale(1.03); }
.lightbox { position: fixed; inset: 0; background: rgba(4,3,10,.92); z-index: 1000; display: none; place-items: center; padding: 24px; backdrop-filter: blur(10px); }
.lightbox.active { display: grid; }
.lightbox img { max-height: 88vh; max-width: 92vw; border-radius: 14px; }
.lightbox button { position: absolute; top: 18px; right: 18px; }
.share-img { width: min(460px, 100%); margin: 8px auto 22px; border-radius: 18px; box-shadow: 0 24px 70px rgba(0,0,0,.5); }

/* ---------------- Cek foto & retake bebas ---------------- */
.review-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; width: 100%; }
.review-card { display: flex; flex-direction: column; gap: 10px; align-items: center; padding: 12px; border: 1px solid var(--border); border-radius: 16px; background: rgba(255,255,255,.05); }
.review-thumb { width: 100%; aspect-ratio: 3/4; border-radius: 11px; overflow: hidden; background: rgba(0,0,0,.3); display: grid; place-items: center; }
.review-thumb img { width: 100%; height: 100%; object-fit: cover; }
.review-thumb span { font-size: 12px; color: var(--muted); }
.review-meta { display: flex; align-items: center; justify-content: space-between; width: 100%; gap: 8px; font-size: 13px; }
.review-card .btn { width: 100%; }

/* Foto mentah yang ikut dibagikan di layar hasil */
.raw-strip { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; margin-top: 22px; }
.raw-item { width: 92px; padding: 6px; border: 1px solid var(--border); border-radius: 12px; background: rgba(255,255,255,.05); text-align: center; font-size: 11px; font-weight: 700; }
.raw-item img { width: 100%; aspect-ratio: 4/3; object-fit: cover; border-radius: 8px; }
.raw-item span { display: block; margin-top: 5px; color: var(--muted); }

/* ---------------- Wizard template visual (PNG lubang + drag & scale) ---------------- */
.builder-steps { display: grid; grid-template-columns: minmax(280px, .8fr) minmax(320px, 1.2fr); gap: 18px; align-items: start; }
@media (max-width: 900px) { .builder-steps { grid-template-columns: 1fr; } }
.builder-canvas { position: relative; width: min(340px, 100%); aspect-ratio: 1 / 3; margin: 0 auto; overflow: hidden; border: 1px solid var(--border); border-radius: 12px; touch-action: none; background-color: #fff; background-image: linear-gradient(45deg, #ececec 25%, transparent 25%), linear-gradient(-45deg, #ececec 25%, transparent 25%), linear-gradient(45deg, transparent 75%, #ececec 75%), linear-gradient(-45deg, transparent 75%, #ececec 75%); background-size: 16px 16px; background-position: 0 0, 0 8px, 8px -8px, -8px 0; }
.builder-canvas > img { width: 100%; height: 100%; object-fit: fill; pointer-events: none; }
.builder-slot { position: absolute; border: 2px solid #22d3ee; background: linear-gradient(135deg, rgba(139,92,246,.45), rgba(236,72,153,.35)); border-radius: 6px; cursor: grab; display: grid; place-items: center; font-weight: 800; font-size: 13px; color: #fff; text-shadow: 0 1px 3px #000; }
.builder-slot.selected { border-color: #fcd34d; box-shadow: 0 0 0 3px rgba(252,211,77,.35); }
.builder-slot .handle { position: absolute; right: -8px; bottom: -8px; width: 20px; height: 20px; border-radius: 6px; background: #fcd34d; border: 2px solid #111; cursor: nwse-resize; }
.builder-slots { display: flex; gap: 8px; flex-wrap: wrap; }
.builder-slots .btn.active { background: var(--primary); color: #fff; border-color: transparent; }
.builder-thumb { flex: 1; min-width: 120px; padding: 8px; border-radius: 10px; border: 1px solid var(--border); background: rgba(255,255,255,.05); text-align: center; font-size: 12px; cursor: pointer; }
.builder-thumb.active { border-color: #fcd34d; color: #fcd34d; }
.builder-thumb img { width: 100%; height: 70px; object-fit: cover; border-radius: 6px; margin-bottom: 5px; }

/* ---------------- Gerbang PIN (akses privat) ---------------- */
.pin-card { width: min(430px, 100%); margin: 0 auto; padding: 34px 26px; text-align: center; }
.pin-lock { font-size: 44px; line-height: 1; margin-bottom: 10px; filter: drop-shadow(0 8px 18px rgba(139,92,246,.45)); }
.pin-card .field { text-align: left; }
.pin-card input[type="password"] { letter-spacing: .35em; text-align: center; font-size: 20px; font-weight: 800; }
.pin-error { min-height: 20px; margin: 12px 0 0; color: var(--danger); font-size: 13px; font-weight: 600; }

@media print {
  body { background: #fff !important; }
  body * { visibility: hidden !important; }
  #print-image, #print-image * { visibility: visible !important; }
  #print-image { display: block !important; position: fixed !important; inset: 0 !important; width: 100% !important; max-width: none !important; max-height: none !important; height: auto !important; margin: 0 !important; border-radius: 0 !important; box-shadow: none !important; }
}
