/* ===== PackRecorder — app.css ===== */
:root {
  --pr-primary: #0d6efd;
  --pr-primary-dark: #084298;
  --pr-success: #198754;
  --pr-danger: #dc3545;
  --pr-warn: #ffc107;
  --pr-bg: #f4f6fb;
  --pr-card: #ffffff;
  --pr-text: #1a2236;
  --pr-muted: #6b7385;
  --pr-border: #e3e7ef;
}

* { -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }
body {
  background: var(--pr-bg);
  color: var(--pr-text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  overscroll-behavior-y: contain;
}

/* App shell layout — native-app feel */
#app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
.app-topbar {
  position: sticky; top: 0; z-index: 1030;
  background: linear-gradient(135deg, var(--pr-primary), var(--pr-primary-dark));
  color: #fff;
  box-shadow: 0 2px 10px rgba(13,110,253,.18);
}
.app-topbar .brand { font-weight: 700; letter-spacing: -.02em; }
.app-topbar .brand i { color: #ffd; }
.app-main { flex: 1 1 auto; padding: 1rem; max-width: 720px; width: 100%; margin: 0 auto; }
.app-bottombar {
  position: sticky; bottom: 0; z-index: 1030;
  background: var(--pr-card);
  border-top: 1px solid var(--pr-border);
  display: none;
}
.app-bottombar.show { display: block; }
.app-bottombar .nav-pills { display: flex; justify-content: space-around; padding: .35rem; }
.app-bottombar .nav-link {
  flex: 1 1 0; text-align: center; color: var(--pr-muted);
  border-radius: .6rem; padding: .4rem .2rem; font-size: .72rem; line-height: 1.1;
}
.app-bottombar .nav-link i { font-size: 1.25rem; display: block; margin-bottom: .15rem; }
.app-bottombar .nav-link.active { color: var(--pr-primary); background: rgba(13,110,253,.08); }

/* Cards */
.pr-card {
  background: var(--pr-card); border: 1px solid var(--pr-border);
  border-radius: 1rem; box-shadow: 0 1px 3px rgba(16,24,40,.04);
}
.pr-card .card-body { padding: 1.1rem 1.2rem; }
.pr-stat {
  background: var(--pr-card); border: 1px solid var(--pr-border); border-radius: 1rem;
  padding: 1rem; text-align: center;
}
.pr-stat .num { font-size: 1.6rem; font-weight: 700; line-height: 1.1; color: var(--pr-primary); }
.pr-stat .label { font-size: .75rem; color: var(--pr-muted); text-transform: uppercase; letter-spacing: .04em; }
.pr-stat.success .num { color: var(--pr-success); }
.pr-stat.warn .num { color: var(--pr-warn); }
.pr-stat.danger .num { color: var(--pr-danger); }

/* Buttons */
.btn-pr { background: var(--pr-primary); color:#fff; border:none; border-radius:.7rem; font-weight:600; }
.btn-pr:hover, .btn-pr:focus { background: var(--pr-primary-dark); color:#fff; }
.btn-pr:disabled { opacity:.6; }

/* Forms */
.form-control, .form-select { border-radius: .6rem; }
.form-control:focus, .form-select:focus {
  border-color: var(--pr-primary); box-shadow: 0 0 0 .2rem rgba(13,110,253,.18);
}

/* Scan / record stage */
.scan-stage {
  position: relative; width: 100%; aspect-ratio: 4/3;
  background: #000; border-radius: 1rem; overflow: hidden;
  display: flex; align-items: center; justify-content: center;
}
.scan-stage video { width: 100%; height: 100%; object-fit: cover; }
.scan-overlay {
  position: absolute; inset: 0; pointer-events: none;
  display: flex; align-items: center; justify-content: center;
}
.scan-frame {
  width: 85%; height: 45%; border: 3px solid rgba(255,255,255,.85);
  border-radius: .5rem; box-shadow: 0 0 0 100vmax rgba(0,0,0,.32);
  position: relative;
}
.scan-frame::before, .scan-frame::after {
  content: ""; position: absolute; left: -3px; right: -3px; height: 3px;
  background: var(--pr-success); box-shadow: 0 0 8px var(--pr-success);
}
.scan-frame::before { top: 0; }
.scan-frame::after { bottom: 0; animation: scanline 2.2s ease-in-out infinite; }
@keyframes scanline { 0%,100% { transform: translateY(0); } 50% { transform: translateY(calc(100% + 6px)); } }
.scan-hint { position: absolute; bottom: .6rem; left: 0; right: 0; text-align: center; color: #fff; font-size: .8rem; text-shadow: 0 1px 3px #000; }

/* Recording pill */
.rec-pill {
  display: inline-flex; align-items: center; gap: .4rem;
  background: rgba(220,53,69,.12); color: var(--pr-danger);
  border: 1px solid rgba(220,53,69,.3); border-radius: 999px; padding: .25rem .7rem; font-size: .8rem; font-weight: 600;
}
.rec-pill .dot { width: 9px; height: 9px; background: var(--pr-danger); border-radius: 50%; animation: pulse 1s ease-in-out infinite; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .35; } }

/* Recording controls */
.rec-controls { display: flex; gap: .6rem; justify-content: center; margin-top: .8rem; }
.rec-btn {
  width: 4.5rem; height: 4.5rem; border-radius: 50%; border: none;
  background: var(--pr-danger); color: #fff; font-size: 1.4rem; display:flex; align-items:center; justify-content:center;
  box-shadow: 0 4px 14px rgba(220,53,69,.4); transition: transform .15s;
}
.rec-btn:hover { transform: scale(1.04); }
.rec-btn.stop { background: var(--pr-text); box-shadow: 0 4px 14px rgba(0,0,0,.3); }
.rec-btn:disabled { opacity:.5; }

/* Resi badge */
.resi-badge {
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  background: rgba(13,110,253,.1); color: var(--pr-primary);
  padding: .15rem .5rem; border-radius: .4rem; font-size: .85rem; font-weight: 600;
}

/* Status badges */
.badge-soft { font-weight: 600; padding: .3rem .55rem; border-radius: .4rem; font-size: .72rem; }
.badge-pending  { background: #fff3cd; color: #664d03; }
.badge-uploading{ background: #cfe2ff; color: #084298; }
.badge-uploaded { background: #d1e7dd; color: #0a3622; }
.badge-failed   { background: #f8d7da; color: #58151c; }
.badge-queued   { background: #e2e3e5; color: #41464b; }

/* List items */
.riwayat-item { display:flex; gap:.8rem; padding:.75rem .2rem; border-bottom:1px solid var(--pr-border); align-items:center; }
.riwayat-item:last-child { border-bottom: none; }
.riwayat-item .thumb { width:64px; height:48px; border-radius:.5rem; background:#e9ecef; display:flex; align-items:center; justify-content:center; color:var(--pr-muted); flex-shrink:0; overflow:hidden; }
.riwayat-item .thumb video { width:100%; height:100%; object-fit:cover; }
.riwayat-item .meta { flex:1; min-width:0; }
.riwayat-item .meta .resi { font-weight:600; font-family: ui-monospace, monospace; }
.riwayat-item .meta .sub { font-size:.78rem; color:var(--pr-muted); }

/* Toasts container */
#toastContainer { position: fixed; top: .8rem; right: .8rem; z-index: 1080; max-width: 360px; }

/* Empty state */
.empty-state { text-align:center; padding: 2.5rem 1rem; color: var(--pr-muted); }
.empty-state i { font-size: 3rem; opacity:.4; display:block; margin-bottom:.5rem; }

/* Loading spinner overlay */
.pr-loading { position: fixed; inset:0; background: rgba(255,255,255,.7); z-index:1090; display:flex; align-items:center; justify-content:center; }
.pr-loading .spinner-border { width:3rem; height:3rem; color: var(--pr-primary); }

/* Login */
.login-wrap { min-height: 100vh; display:flex; align-items:center; justify-content:center; padding: 1.5rem; background: linear-gradient(135deg, var(--pr-primary), var(--pr-primary-dark)); }
.login-card { width:100%; max-width: 400px; border-radius:1.2rem; box-shadow:0 20px 60px rgba(0,0,0,.25); }
.login-card .brand-logo { width:64px; height:64px; border-radius:1rem; background:var(--pr-primary); color:#fff; display:flex; align-items:center; justify-content:center; font-size:1.8rem; margin:0 auto; }

/* Settings rows */
.setting-row { display:flex; justify-content:space-between; align-items:center; padding:.85rem .2rem; border-bottom:1px solid var(--pr-border); }
.setting-row:last-child { border-bottom:none; }
.setting-row .label { font-weight:500; }
.setting-row .label small { display:block; font-weight:400; color:var(--pr-muted); font-size:.78rem; }

/* Queue badge */
.queue-badge { position: absolute; top: .4rem; right: .4rem; }

/* Utilities */
.text-mono { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; }
.cursor-pointer { cursor: pointer; }
.fw-700 { font-weight: 700; }

/* Responsive tweaks */
@media (min-width: 768px) {
  .app-bottombar { display: none !important; }
  .app-main { padding: 1.5rem; }
}
@media (max-width: 575.98px) {
  .app-main { padding: .75rem; padding-bottom: 5rem; }
  .pr-stat .num { font-size: 1.35rem; }
}
