/* ============ PHOTOBOOTH - STYLE (vui nhộn, kiểu sticker/cartoon) ============ */
* { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --ink: #33272a;
  --bg: #fff6e9;
  --panel: #fffdf7;
  --panel2: #fff0f5;
  --border: #33272a;
  --text: #33272a;
  --muted: #7a6a70;
  --primary: #f25d9c;
  --sun: #ffd23f;
  --mint: #7ccfb2;
  --sky: #8ecbff;
  --peach: #ffe1a8;
  --danger: #e5484d;
  --ok: #2f9e77;
  --warn: #e8a013;
  --radius: 16px;
  --shadow: 4px 4px 0 var(--ink);
}
body {
  font-family: "Baloo 2", "Segoe UI", system-ui, sans-serif;
  background:
    radial-gradient(#ffd9a8 12%, transparent 13%) 0 0/46px 46px,
    radial-gradient(#ffc2d9 12%, transparent 13%) 23px 23px/46px 46px,
    var(--bg);
  color: var(--text);
  min-height: 100vh;
}
.hidden { display: none !important; }
.error-msg { color: var(--danger); margin-top: 10px; font-size: 14px; font-weight: 700; }
.hint { color: var(--muted); font-size: 13px; margin-top: 6px; font-weight: 600; }

/* Buttons - nút bấm lồi, đè xuống khi bấm */
.btn {
  border: 3px solid var(--border); border-radius: 14px; cursor: pointer;
  padding: 9px 18px; font-size: 15px; font-weight: 800;
  color: var(--ink); background: var(--sun);
  box-shadow: 0 4px 0 var(--border);
  transition: transform .06s, box-shadow .06s, background .12s;
  text-decoration: none; display: inline-block;
  font-family: inherit;
}
.btn:hover { background: #ffe27a; }
.btn:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--border); }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: #ff7bb0; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #f26b6f; }
.btn-outline { background: var(--panel); }
.btn-outline:hover { background: var(--peach); }
.btn-big { padding: 15px; font-size: 20px; width: 100%; border-radius: 18px; box-shadow: 0 6px 0 var(--border); }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.btn-row .btn { flex: 1; font-size: 13px; padding: 7px 6px; }

/* Screens */
.screen { display: none; min-height: 100vh; flex-direction: column; }
.screen.active { display: flex; }

/* Login */
#screen-login, #admin-login { align-items: center; justify-content: center; }
.login-box {
  position: relative;
  background: var(--panel); padding: 40px; border-radius: 24px;
  width: min(420px, 92vw); text-align: center;
  border: 3px solid var(--border);
  box-shadow: 8px 8px 0 var(--border);
}
.login-box h1 {
  display: inline-block; font-size: 24px; margin-bottom: 10px;
  background: var(--sky); border: 3px solid var(--border); border-radius: 12px;
  padding: 4px 18px; transform: rotate(-2deg); box-shadow: var(--shadow);
}
.login-box p { color: var(--muted); margin-bottom: 20px; font-weight: 700; }
.login-box input {
  width: 100%; padding: 13px; font-size: 18px; text-align: center; font-weight: 800;
  border-radius: 12px; border: 3px solid var(--border); letter-spacing: 3px;
  background: var(--panel); color: var(--text); margin-bottom: 14px; text-transform: uppercase;
  outline: none; font-family: inherit;
}
.login-box input:focus { background: #fffbe8; }
.admin-link { display: inline-block; margin-top: 18px; color: var(--muted); font-size: 13px; font-weight: 700; }
.admin-link:hover { color: var(--primary); }

/* Topbar */
.topbar {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 22px; background: var(--panel);
  border-bottom: 3px solid var(--border);
  gap: 12px; flex-wrap: wrap;
}
.topbar-brand {
  display: flex; align-items: center; gap: 12px; min-width: 0;
  flex: 1 1 auto;
}
.brand-logo {
  display: block; height: 40px; width: auto; flex-shrink: 0;
}
.brand-shop {
  font-size: 15px; font-weight: 800; color: var(--primary);
  border: 2px solid var(--border); background: var(--peach);
  border-radius: 10px; padding: 4px 12px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  max-width: min(280px, 40vw);
  box-shadow: 2px 2px 0 var(--border);
}
.session-info { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.chip {
  background: var(--panel2); border: 2px solid var(--border); color: var(--ink);
  border-radius: 10px; padding: 5px 14px;
  font-size: 14px; font-weight: 800;
}
.chip-code { letter-spacing: 2px; font-family: monospace; background: var(--sun); }
.chip-timer.warn { background: #ffd6dc; }
.chip-timer.ok { background: #d8f5e9; }

.login-logo {
  display: block; width: min(200px, 70%); height: auto; margin: 0 auto 10px;
}
.login-shop {
  margin: 0 0 8px; font-size: 16px; font-weight: 800; color: var(--primary);
}

/* Capture screen */
.capture-main { display: flex; gap: 18px; padding: 18px 22px; flex: 1; flex-wrap: wrap; }
.camera-wrap {
  flex: 1 1 420px; position: relative; background: #4a3d44;
  border-radius: var(--radius); overflow: hidden; min-height: 340px;
  align-self: flex-start; aspect-ratio: 4/3; max-height: 70vh;
  border: 3px solid var(--border);
  box-shadow: 6px 6px 0 var(--border);
}
#camera-preview { width: 100%; height: 100%; object-fit: contain; }
.countdown-overlay {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  font-size: 140px; font-weight: 800; color: var(--sun);
  -webkit-text-stroke: 4px var(--ink);
  pointer-events: none;
}
.flash {
  position: absolute; inset: 0; background: #fff; opacity: 0; pointer-events: none;
  transition: opacity .3s;
}
.flash.on { opacity: .9; transition: none; }

.capture-side { flex: 0 1 300px; display: flex; flex-direction: column; gap: 10px; }
.capture-side h3, .studio-photos h3, .tool-panel h3, .filmstrip h3 {
  font-size: 14px; color: var(--ink); text-transform: uppercase; letter-spacing: 1px;
  margin-bottom: 6px; font-weight: 800;
  display: inline-block; background: var(--peach); border: 2px solid var(--border);
  border-radius: 8px; padding: 2px 10px; transform: rotate(-1deg);
}
select, input[type="text"], input[type="number"], input[type="password"] {
  width: 100%; padding: 10px; border-radius: 12px; border: 3px solid var(--border);
  background: var(--panel); color: var(--text); font-size: 15px; outline: none;
  font-family: inherit; font-weight: 600;
}
select:focus, input[type="text"]:focus, input[type="number"]:focus, input[type="password"]:focus {
  background: #fffbe8;
}
.capture-side .btn-big { margin-top: auto; }

.filter-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 7px; }
.filter-grid button {
  padding: 8px 6px; font-size: 13px; border-radius: 10px; cursor: pointer;
  border: 2px solid var(--border); background: var(--panel); color: var(--ink); font-weight: 700;
  box-shadow: 0 3px 0 var(--border);
  transition: transform .06s, box-shadow .06s, background .12s;
  font-family: inherit;
}
.filter-grid button:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--border); }
.filter-grid button.active { background: var(--sun); }

/* Bộ lọc màu LUT (kiểu VSCO) */
.panel-label { font-size: 13px; color: var(--muted); font-weight: 700; margin: 10px 0 4px; }
.lut-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 7px; }
.lut-grid button {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 6px 4px; font-size: 11px; border-radius: 10px; cursor: pointer;
  border: 2px solid var(--border); background: var(--panel); color: var(--ink); font-weight: 700;
  box-shadow: 0 3px 0 var(--border); font-family: inherit;
  transition: transform .06s, box-shadow .06s, border-color .12s;
}
.lut-grid button:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--border); }
.lut-grid button img {
  width: 100%; aspect-ratio: 3/4; object-fit: cover; border-radius: 6px;
  background: var(--border); display: block; min-height: 30px;
}
.lut-grid button[data-lut=""] img { display: none; }
.lut-grid button.active { border-color: var(--ink); box-shadow: 0 3px 0 var(--ink); }
.lut-grid button span { text-align: center; line-height: 1.2; }

/* Chế độ chụp: thủ công / tự động */
.mode-switch { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.mode-switch button {
  padding: 9px 6px; font-size: 14px; font-weight: 800; color: var(--ink);
  border: 2px solid var(--border); border-radius: 10px; background: var(--panel);
  cursor: pointer; box-shadow: 0 3px 0 var(--border); font-family: inherit;
  transition: transform .06s, box-shadow .06s, background .12s;
}
.mode-switch button:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--border); }
.mode-switch button.active { background: var(--sun); }

/* Cột ảnh đã chụp - bên trái màn hình chụp */
.filmstrip {
  flex: 0 1 150px; display: flex; flex-direction: column;
  align-self: flex-start; min-height: 200px;
  max-height: 70vh; /* bằng chiều cao tối đa của khung camera -> cuộn trong cột */
}
.filmstrip-list {
  display: flex; flex-direction: column; gap: 10px;
  overflow-y: auto; padding: 8px 6px 8px 2px; flex: 1; min-height: 120px;
  scrollbar-width: thin; scrollbar-color: var(--primary) #ffe9f2;
}
.filmstrip-list::-webkit-scrollbar { width: 10px; }
.filmstrip-list::-webkit-scrollbar-track { background: #ffe9f2; border-radius: 8px; }
.filmstrip-list::-webkit-scrollbar-thumb {
  background: var(--primary); border-radius: 8px; border: 2px solid #ffe9f2;
}
.filmstrip-list img {
  width: 100%; height: auto; max-width: 140px; border-radius: 10px;
  border: 3px solid var(--border); cursor: pointer;
  box-shadow: 3px 3px 0 var(--border); display: block;
}
.filmstrip-list img:nth-child(2n) { transform: rotate(2deg); }
.filmstrip-list img:nth-child(2n-1) { transform: rotate(-2deg); }

/* Studio */
.studio-main { display: flex; gap: 16px; padding: 18px 22px; flex: 1; min-height: 0; flex-wrap: wrap; }
.studio-photos { flex: 0 1 190px; overflow-y: auto; max-height: calc(100vh - 140px); }
.studio-photo-list { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.studio-photo-list .thumb {
  position: relative; border-radius: 12px; overflow: hidden; cursor: pointer;
  border: 3px solid var(--border); aspect-ratio: 3/4; background: #4a3d44;
  box-shadow: 3px 3px 0 var(--border);
}
.studio-photo-list .thumb:nth-child(2n) { transform: rotate(1.6deg); }
.studio-photo-list .thumb:nth-child(2n-1) { transform: rotate(-1.6deg); }
.studio-photo-list .thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.studio-photo-list .thumb.selected { border-color: var(--primary); box-shadow: 3px 3px 0 var(--primary); }
.studio-photo-list .thumb .slot-badge {
  position: absolute; top: 5px; left: 5px; background: var(--sun);
  border: 2px solid var(--border); color: var(--ink);
  font-weight: 800; font-size: 11px; padding: 1px 8px; border-radius: 8px;
}
.studio-photo-list .thumb.dragging { opacity: .4; }
.studio-photo-list .thumb.unpicked { filter: grayscale(.9); opacity: .55; }
.studio-photo-list .thumb .tick {
  position: absolute; top: 5px; right: 5px;
  width: 26px; height: 26px; border-radius: 50%;
  border: 2px solid var(--border); background: var(--panel);
  color: transparent; font-size: 15px; font-weight: 800; line-height: 1;
  cursor: pointer; font-family: inherit; padding: 0;
  box-shadow: 2px 2px 0 rgba(51,39,42,.4);
}
.studio-photo-list .thumb .tick.on {
  background: var(--mint); color: var(--ink);
}
.studio-photo-list .thumb .zoom-btn {
  position: absolute; bottom: 5px; right: 5px;
  width: 26px; height: 26px; border-radius: 50%;
  border: 2px solid var(--border); background: var(--sun);
  color: var(--ink); font-size: 14px; font-weight: 800; line-height: 1;
  cursor: pointer; font-family: inherit; padding: 0;
  box-shadow: 2px 2px 0 rgba(51,39,42,.4);
}
.studio-canvas-wrap {
  flex: 1 1 380px; display: flex; flex-direction: column; align-items: center; justify-content: center;
  background: repeating-conic-gradient(#ffeedd 0% 25%, #fff8ee 0% 50%) 50%/26px 26px;
  border-radius: var(--radius); padding: 14px; min-height: 320px;
  border: 3px solid var(--border); box-shadow: 6px 6px 0 var(--border);
  gap: 8px;
}
.collage-stage {
  position: relative; display: inline-block; max-width: 100%; line-height: 0;
}
#collage-canvas {
  display: block;
  max-width: 100%; max-height: calc(100vh - 170px);
  border-radius: 8px; border: 3px solid var(--border); background: #fff;
}
.collage-slot-marks {
  position: absolute; inset: 0; pointer-events: none; z-index: 2;
}
.collage-slot-drop {
  position: absolute;
  pointer-events: auto;
  box-sizing: border-box;
  border: 2px dashed transparent;
  border-radius: 8px;
}
.collage-slot-drop.drag-over {
  border-color: var(--primary);
  background: rgba(255, 120, 160, 0.18);
}
.collage-slot-mark {
  position: absolute;
  pointer-events: none;
  transform: translate(-100%, 0);
  margin: 4px 4px 0 0;
  min-width: 1.6em; height: 1.6em; padding: 0 .35em;
  display: flex; align-items: center; justify-content: center;
  background: var(--sun); color: var(--ink);
  border: 2px solid var(--border); border-radius: 999px;
  font-weight: 800; font-size: clamp(11px, 2.2vw, 15px);
  box-shadow: 2px 2px 0 rgba(51,39,42,.35);
  line-height: 1;
}
.collage-slot-mark.empty {
  background: var(--panel); color: var(--muted); opacity: .9;
}
.studio-tools { flex: 0 1 280px; display: flex; flex-direction: column; gap: 12px; overflow-y: auto; max-height: calc(100vh - 140px); }
.tool-panel { background: var(--panel); border-radius: var(--radius); padding: 14px; border: 3px solid var(--border); }
.tool-panel label { display: block; font-size: 13px; color: var(--muted); margin: 10px 0 4px; font-weight: 700; }
.layout-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.layout-grid-frames { grid-template-columns: repeat(2, 1fr); }
.layout-btn {
  border: 2px solid var(--border); background: var(--panel); border-radius: 12px;
  cursor: pointer; padding: 6px; color: var(--ink); box-shadow: 0 3px 0 var(--border);
  transition: transform .06s, box-shadow .06s; font-family: inherit;
}
.layout-btn:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--border); }
.layout-btn.active { background: var(--sun); }
.layout-btn .mini { display: grid; gap: 2px; height: 44px; }
.layout-btn .mini div { background: var(--primary); border-radius: 4px; }
.layout-btn span { display: block; font-size: 11px; text-align: center; margin-top: 4px; color: var(--muted); font-weight: 700; }
input[type="range"] { width: 100%; accent-color: var(--primary); }
input[type="color"] { width: 100%; height: 36px; border: none; background: none; cursor: pointer; }

/* Khung chủ đề */
.theme-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.theme-btn {
  display: flex; align-items: center; gap: 8px;
  border: 2px solid var(--border); background: var(--panel); border-radius: 12px;
  cursor: pointer; padding: 8px 10px; color: var(--ink); font-size: 13px; font-weight: 800;
  box-shadow: 0 3px 0 var(--border);
  transition: transform .06s, box-shadow .06s, background .12s;
  font-family: inherit;
}
.theme-btn:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--border); }
.theme-btn.active { background: var(--sun); }
.theme-btn .theme-icon { font-size: 20px; }
.theme-btn.frame-btn { flex-direction: column; padding: 6px; gap: 4px; }
.frame-thumb { height: 64px; max-width: 100%; object-fit: contain; border-radius: 6px; background: #fff; }

/* Xem ảnh phóng to (lightbox) */
.lightbox {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(51,39,42,.92);
  display: flex; flex-direction: column;
}
.lightbox-bar {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 16px; color: #fff; font-weight: 800;
  background: rgba(0,0,0,.25);
}
.lightbox-bar #lightbox-label { flex: 1; font-size: 15px; }
.lightbox-bar button {
  border: 2px solid #fff; background: transparent; color: #fff;
  border-radius: 10px; padding: 6px 14px; font-size: 16px; font-weight: 800;
  cursor: pointer; font-family: inherit;
}
.lightbox-bar button:hover { background: #fff; color: var(--ink); }
.lightbox-stage {
  flex: 1; overflow: hidden; position: relative; cursor: grab;
  display: flex; align-items: center; justify-content: center;
}
.lightbox-stage:active { cursor: grabbing; }
#lightbox-img {
  max-width: 92vw; max-height: calc(100vh - 80px);
  border: 3px solid #fff; border-radius: 8px; background: #fff;
  transform-origin: center center;
  user-select: none; -webkit-user-drag: none;
  transition: transform .12s;
}
#lightbox-img.zooming { transition: none; }

/* Modal */
.modal {
  position: fixed; inset: 0; background: rgba(51,39,42,.45);
  display: flex; align-items: center; justify-content: center; z-index: 100;
}
.modal-box {
  background: var(--panel); padding: 34px; border-radius: 22px; text-align: center;
  width: min(400px, 90vw); border: 3px solid var(--border);
  box-shadow: 8px 8px 0 var(--border);
}
.modal-box h2 { margin-bottom: 10px; }
.modal-box p { color: var(--muted); margin-bottom: 20px; font-weight: 700; }
.modal-box-qr { width: min(440px, 92vw); }
.qr-wrap {
  display: flex; justify-content: center; margin: 0 auto 14px;
  padding: 12px; background: #fff; border: 3px solid var(--border); border-radius: 16px;
  width: fit-content;
}
.qr-code { width: 220px; height: 220px; line-height: 0; }
.qr-code img, .qr-code canvas { width: 220px !important; height: 220px !important; display: block; }
.qr-link {
  width: 100%; box-sizing: border-box; margin-bottom: 14px; padding: 10px 12px;
  border: 2px solid var(--border); border-radius: 10px; font-size: 12px;
  font-family: ui-monospace, monospace; background: var(--panel2);
}
.qr-page-nav { font-size: 14px; margin-bottom: 8px !important; }
.qr-actions { justify-content: center; flex-wrap: wrap; gap: 8px; }
#btn-qr-phone { margin-top: 10px; }

/* Admin */
.admin-body {
  background:
    radial-gradient(#ffd9a8 12%, transparent 13%) 0 0/46px 46px,
    radial-gradient(#ffc2d9 12%, transparent 13%) 23px 23px/46px 46px,
    var(--bg);
}
.admin-main { padding-bottom: 50px; }
.card { background: var(--panel); border-radius: var(--radius); margin: 16px 22px; padding: 20px; border: 3px solid var(--border); box-shadow: 5px 5px 0 var(--border); }
.create-form { display: flex; gap: 14px; flex-wrap: wrap; align-items: flex-end; }
.field { flex: 1; min-width: 160px; }
.field label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 5px; font-weight: 700; }
.table-wrap { overflow-x: auto; }
.code-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.code-table th, .code-table td { padding: 10px 12px; text-align: left; border-bottom: 2px solid #eadfd5; }
.code-table th { color: var(--muted); font-weight: 800; text-transform: uppercase; font-size: 12px; }
.code-table td code { font-family: monospace; font-size: 15px; letter-spacing: 1px; color: var(--primary); font-weight: 800; }
.badge { border: 2px solid var(--border); border-radius: 8px; padding: 3px 10px; font-size: 12px; font-weight: 800; }
.badge.active { background: #d8f5e9; }
.badge.in-use { background: #fff1c9; }
.badge.expired { background: #ffd6dc; }
.badge.used-up { background: var(--panel2); }
.code-table .btn { padding: 5px 10px; font-size: 12px; margin-right: 4px; box-shadow: 0 3px 0 var(--border); }

/* ---------- Khung A4 (quản trị + studio) ---------- */
.a4-picker { display: flex; flex-wrap: wrap; gap: 8px; }
.a4-pick { display: inline-flex; align-items: center; gap: 6px; background: var(--bg, #f5f5f5);
  border: 1px solid var(--border, #ddd); border-radius: 10px; padding: 6px 10px; font-size: 13px; font-weight: 700; }
.a4-pick input { width: 52px; }
.field-full { flex-basis: 100%; }
.layout-btn.locked { opacity: 0.75; cursor: not-allowed; }
.sheet-picker { margin-bottom: 8px; }
.sheet-picker b { font-size: 13px; color: var(--muted); }

/* ============ Màn đăng nhập quản trị — ghi chú & chip người dùng ============ */
.login-notes {
  margin-top: 18px;
  padding: 12px 14px;
  background: var(--panel2);
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  text-align: left;
  font-size: 13px;
  line-height: 1.5;
}
.login-notes b { color: var(--primary); }
.login-notes ul { margin: 6px 0 0; padding-left: 18px; }
.login-notes li { margin: 4px 0; }
.login-box form { text-align: left; }
.login-box input { width: 100%; margin-bottom: 10px; }
.who-chip {
  display: inline-block;
  padding: 6px 12px;
  background: var(--mint);
  border: 3px solid var(--border);
  border-radius: 999px;
  font-weight: 800;
  font-size: 13px;
  box-shadow: 0 3px 0 var(--border);
}
