/* ============================================================
   Photobooth - Modern UI (4R Landscape edition)
   Theme: black/white + neon accents
   ============================================================ */
:root {
  --bg: #0a0a0a;
  --surface: #141414;
  --surface-2: #1d1d1d;
  --text: #ffffff;
  --text-dim: #a0a0a0;
  --border: #2a2a2a;
  --accent: #00f0ff;
  --accent-2: #ff3df0;
  --danger: #ff5c5c;
  --radius: 16px;
  --shadow: 0 10px 30px rgba(0,0,0,.4);
}

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0;
  background: var(--bg); color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  height: 100%;
}

body.booth {
  background:
    radial-gradient(1200px 600px at 80% -20%, rgba(0,240,255,0.15), transparent 60%),
    radial-gradient(1000px 600px at -10% 110%, rgba(255,61,240,0.12), transparent 60%),
    var(--bg);
  overflow: hidden;
}

/* ===== Layout / Stage ===== */
#app { width: 100vw; height: 100vh; position: relative; }

.screen {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  padding: 16px;
  animation: fadein .35s ease;
  overflow: auto;
}
.screen[hidden] { display: none; }

@keyframes fadein {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: none; }
}

/* ===== Welcome ===== */
.welcome-card {
  width: min(820px, 96vw);
  max-height: calc(100vh - 32px);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px 32px;
  box-shadow: var(--shadow);
  text-align: center;
  overflow-y: auto;
}
.brand-logo {
  display: flex; justify-content: center;
  margin: 4px 0 8px;
}
.brand-logo img {
  width: clamp(120px, 18vw, 180px);
  height: auto; display: block;
  filter: drop-shadow(0 0 14px rgba(0,240,255,.45));
}
.logo {
  font-size: clamp(36px, 5vw, 56px);
  font-weight: 900;
  letter-spacing: 6px;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  -webkit-background-clip: text; background-clip: text;
  color: transparent;
  margin-bottom: 4px;
  line-height: 1;
}
.logo span { color: var(--text); -webkit-text-fill-color: var(--text); background: none; }
.tagline { color: var(--text-dim); margin: 4px 0 22px; font-size: 14px; }

.form-row { margin: 16px 0; text-align: left; }
.form-row > label {
  display: block;
  color: var(--text-dim);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 2px;
  margin-bottom: 8px;
}

/* ----- Layout picker ----- */
.layout-picker {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}
.layout-card {
  border: 2px solid transparent;
  background: var(--surface-2);
  border-radius: 12px;
  padding: 10px;
  cursor: pointer;
  transition: transform .15s ease, border-color .15s ease;
  color: var(--text);
}
.layout-card:hover { transform: translateY(-2px); }
.layout-card.active {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(0,240,255,0.15);
}
.layout-card span {
  display: block; margin-top: 8px;
  font-size: 13px; font-weight: 600;
}
.layout-thumb {
  position: relative;
  width: 100%;
  aspect-ratio: 3 / 2;
  background: #fff;
  border-radius: 6px;
  overflow: hidden;
}
.layout-thumb .cell {
  position: absolute;
  background: linear-gradient(135deg, #d0d6df, #a6acba);
  border-radius: 3px;
}
/* layout 3: 1 atas tengah, 2 bawah */
.layout-3 .c1 { left: 34%;  top: 4%;  width: 32%;   height: 46%; }
.layout-3 .c2 { left: 2.7%; top: 54%; width: 45.3%; height: 42%; }
.layout-3 .c3 { left: 52%;  top: 54%; width: 45.3%; height: 42%; }
/* layout 4: 2x2 grid */
.layout-4 .c1 { left: 2.7%; top: 4%;  width: 45.3%; height: 42%; }
.layout-4 .c2 { left: 52%;  top: 4%;  width: 45.3%; height: 42%; }
.layout-4 .c3 { left: 2.7%; top: 54%; width: 45.3%; height: 42%; }
.layout-4 .c4 { left: 52%;  top: 54%; width: 45.3%; height: 42%; }
/* layout 5: 2 atas (kiri-tengah) + 3 bawah */
.layout-5 .c1 { left: 2.7%; top: 4%;  width: 38.7%; height: 42%; }
.layout-5 .c2 { left: 44%;  top: 4%;  width: 38.7%; height: 42%; }
.layout-5 .c3 { left: 2.7%; top: 54%; width: 29.3%; height: 42%; }
.layout-5 .c4 { left: 34.7%;top: 54%; width: 29.3%; height: 42%; }
.layout-5 .c5 { left: 66.7%;top: 54%; width: 29.3%; height: 42%; }

/* ----- Frame picker ----- */
.frame-picker {
  display: flex; gap: 10px; flex-wrap: wrap;
  max-height: 220px; overflow-y: auto;
  padding: 4px;
}
.frame-thumb {
  width: 130px; min-height: 110px;
  background: var(--surface-2);
  border: 2px solid transparent;
  border-radius: 12px;
  padding: 6px;
  cursor: pointer;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  transition: transform .15s ease, border-color .15s ease;
  color: var(--text);
}
.frame-thumb[hidden] { display: none !important; }
.frame-thumb:hover { transform: translateY(-2px); }
.frame-thumb.active { border-color: var(--accent); box-shadow: 0 0 0 4px rgba(0,240,255,0.15); }
.frame-thumb img { max-width: 100%; max-height: 70px; object-fit: contain; }
.frame-thumb span { color: var(--text-dim); font-size: 11px; margin-top: 6px; text-align: center; }
.thumb-empty {
  width: 110px; height: 70px; border: 1px dashed var(--border);
  border-radius: 6px; display: flex; align-items: center; justify-content: center;
  color: var(--text-dim); font-size: 11px; text-align: center;
}

/* ===== Buttons ===== */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 8px; cursor: pointer; user-select: none;
  font-family: inherit; font-weight: 700;
  border-radius: 999px; padding: 12px 24px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  text-decoration: none; font-size: 14px;
  transition: transform .1s ease, box-shadow .15s ease, background .15s ease;
}
.btn:hover { transform: translateY(-1px); }
.btn-primary {
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  color: #000; border-color: transparent;
  box-shadow: 0 8px 20px rgba(0,240,255,0.25);
}
.btn-ghost { background: transparent; }
.btn-xl { padding: 14px 30px; font-size: 16px; margin-top: 8px; }
.btn-sm { padding: 8px 14px; font-size: 12px; }

/* ===== Capture ===== */
.capture-wrap {
  position: relative;
  width: min(1100px, 100%);
  height: min(720px, 90vh);
  border-radius: var(--radius);
  overflow: hidden;
  background: #000;
  box-shadow: var(--shadow);
}
#video {
  position: absolute; inset: 0;
  width: 100%; height: 100%; object-fit: cover;
  transform: scaleX(-1);   /* mirror preview */
}

.countdown {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: clamp(140px, 22vw, 320px);
  font-weight: 900;
  color: #fff;
  text-shadow: 0 0 40px rgba(0,240,255,0.7), 0 0 80px rgba(255,61,240,0.5);
  animation: pop 1s ease;
}
@keyframes pop {
  0%   { transform: scale(.5); opacity: 0; }
  20%  { transform: scale(1.15); opacity: 1; }
  60%  { transform: scale(1); }
  100% { transform: scale(0.9); opacity: 0; }
}

.flash {
  position: absolute; inset: 0;
  background: #fff; opacity: 0; pointer-events: none;
}
.flash.fire { animation: flash .35s ease; }
@keyframes flash { 0% { opacity: 0; } 30% { opacity: 1; } 100% { opacity: 0; } }

.hud {
  position: absolute; left: 0; right: 0; top: 0;
  display: flex; justify-content: space-between;
  padding: 16px;
  pointer-events: none;
}
.hud > * { pointer-events: auto; }
.hud-pill {
  display: inline-flex; align-items: center; gap: 8px;
  background: rgba(0,0,0,0.6); backdrop-filter: blur(8px);
  border: 1px solid var(--border);
  border-radius: 999px; padding: 8px 14px;
  font-size: 13px; color: var(--text);
}
.dot { width: 8px; height: 8px; background: var(--accent); border-radius: 50%; box-shadow: 0 0 8px var(--accent); }

.thumb-strip {
  position: absolute; bottom: 16px; left: 50%; transform: translateX(-50%);
  display: flex; gap: 10px;
}
.thumb-strip .thumb {
  width: 80px; height: 54px; border-radius: 8px;
  background: var(--surface-2); border: 1px solid var(--border);
  overflow: hidden;
}
.thumb-strip .thumb img { width: 100%; height: 100%; object-fit: cover; }
.thumb-strip .thumb.empty { background: rgba(255,255,255,0.04); }

/* ===== Review ===== */
.review-card {
  width: min(1100px, 96vw);
  max-height: calc(100vh - 32px);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 24px;
  box-shadow: var(--shadow);
  overflow-y: auto;
}
.review-card h2 { margin: 0 0 4px; font-size: 22px; }
.review-card p  { margin: 0 0 14px; font-size: 13px; }

.strip-preview {
  position: relative;
  width: 100%;
  aspect-ratio: 3 / 2;
  max-width: 880px;
  margin: 0 auto 16px;
  background: #fff;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 6px 18px rgba(0,0,0,.35);
}
.strip-preview .frame-bg {
  position: absolute; inset: 0;
  width: 100%; height: 100%; object-fit: fill;
  z-index: 2; pointer-events: none;
}
.strip-preview.no-frame {
  background: #fff;
}
.preview-cell {
  position: absolute;
  border: 0; padding: 0; margin: 0; background: transparent;
  cursor: pointer;
  z-index: 1;
  border-radius: 4px;
  overflow: hidden;
  transition: transform .15s ease;
}
.preview-cell img {
  width: 100%; height: 100%; object-fit: cover; display: block;
}
.preview-cell .cell-overlay {
  position: absolute; inset: 0;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  flex-direction: column; gap: 6px;
  font-size: 12px; font-weight: 700;
  opacity: 0;
  transition: opacity .15s ease;
}
.preview-cell:hover .cell-overlay { opacity: 1; }
.preview-cell .ic { font-size: 28px; }

.review-actions {
  display: flex; gap: 10px; justify-content: center;
  flex-wrap: wrap;
}

/* ===== Processing ===== */
.screen-processing { flex-direction: column; }
.spinner {
  width: 64px; height: 64px;
  border: 4px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin-bottom: 16px;
}
@keyframes spin { to { transform: rotate(360deg); } }

.muted { color: var(--text-dim); }

/* ===== Result ===== */
.screen-result { padding: 16px; }
.result-grid {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 20px;
  width: min(1200px, 100%);
  max-height: calc(100vh - 32px);
  align-items: stretch;
}
@media (max-width: 900px) {
  .result-grid { grid-template-columns: 1fr; max-height: none; }
}

.result-left, .result-right {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  overflow-y: auto;
}
.result-left {
  display: flex; flex-direction: column; align-items: center;
  text-align: center;
}
.result-left h2 { margin: 0 0 4px; font-size: 22px; }
.qrcode {
  background: #fff; padding: 12px; border-radius: 12px;
  width: 200px; height: 200px;
  display: flex; align-items: center; justify-content: center;
  margin: 12px auto 8px;
}
.qrcode img, .qrcode canvas { display: block; max-width: 100%; max-height: 100%; }

.result-actions {
  display: flex; gap: 8px; flex-wrap: wrap; justify-content: center;
}

.result-right {
  display: flex; align-items: center; justify-content: center;
}
.composite-img {
  max-width: 100%;
  max-height: calc(100vh - 80px);
  width: auto; height: auto;
  border-radius: 8px;
  box-shadow: 0 6px 20px rgba(0,0,0,.4);
}

/* ===== Fullscreen primer overlay ===== */
.fs-overlay {
  position: fixed; inset: 0; z-index: 9000;
  background: rgba(0,0,0,.92);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  animation: fadein .25s ease;
}
.fs-overlay[hidden] { display: none; }
.fs-card {
  text-align: center;
  padding: 40px 56px;
  border-radius: 24px;
  border: 2px solid var(--accent);
  background: rgba(20,24,30,0.98);
  box-shadow: 0 0 40px rgba(0,240,255,.5), 0 20px 60px rgba(0,0,0,.6);
  animation: pulse 2s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { box-shadow: 0 0 40px rgba(0,240,255,.5), 0 20px 60px rgba(0,0,0,.6); }
  50%      { box-shadow: 0 0 70px rgba(255,90,200,.5), 0 20px 60px rgba(0,0,0,.6); }
}
.fs-icon {
  font-size: 96px;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent;
  margin-bottom: 8px;
  line-height: 1;
}
.fs-card h2 {
  margin: 12px 0 6px;
  font-size: 32px; letter-spacing: 4px;
  color: #fff;
}
.fs-card p {
  margin: 0; color: var(--text-dim); font-size: 14px;
}

/* ===== Custom modal (replaces window.confirm) ===== */
.app-modal {
  position: fixed; inset: 0; z-index: 9500;
  background: rgba(0,0,0,.7);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: flex; align-items: center; justify-content: center;
  padding: 16px;
  animation: fadein .2s ease;
}
.app-modal[hidden] { display: none; }
.app-modal-card {
  width: min(440px, 100%);
  background: rgba(20,24,30,0.98);
  border: 1px solid var(--accent);
  border-radius: 18px;
  padding: 28px 32px;
  text-align: center;
  box-shadow: 0 0 40px rgba(0,240,255,.4), 0 18px 56px rgba(0,0,0,.7);
  animation: pop .25s cubic-bezier(.2,1.4,.4,1);
}
@keyframes pop {
  0%   { transform: scale(.85); opacity: 0; }
  100% { transform: scale(1);   opacity: 1; }
}
.app-modal-icon {
  font-size: 48px; line-height: 1; margin-bottom: 12px;
}
.app-modal-card h3 {
  margin: 0 0 8px; font-size: 22px; letter-spacing: 1px; color: #fff;
}
.app-modal-card p {
  margin: 0 0 22px; color: var(--text-dim); font-size: 14px; line-height: 1.5;
}
.app-modal-actions {
  display: flex; gap: 10px; justify-content: center; flex-wrap: wrap;
}
.app-modal-actions .btn { min-width: 110px; }

/* ===== Misc ===== */
.db-error {
  position: fixed; inset: 0; background: rgba(0,0,0,.85);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  z-index: 9999; padding: 32px; text-align: center;
}
.db-error h2 { color: var(--danger); }
.db-error code { background: var(--surface-2); padding: 2px 6px; border-radius: 4px; }
