/* ============================================
   ALFA R3 — Design System
   Powered By.ADt82
   ============================================ */

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

:root {
  --red:        #E3000B;
  --red-dark:   #B5000A;
  --red-light:  #FF1A22;
  --yellow:     #FFD400;
  --yellow-dark:#D4AF00;
  --bg:         #F5F5F5;
  --bg-card:    #FFFFFF;
  --text:       #222222;
  --text-muted: #666666;
  --success:    #2ECC71;
  --warning:    #F39C12;
  --error:      #E74C3C;
  --border:     #E0E0E0;
  --shadow:     0 2px 12px rgba(0,0,0,0.08);
  --shadow-lg:  0 8px 32px rgba(0,0,0,0.12);
  --radius:     12px;
  --radius-sm:  8px;
  --font-display: 'Barlow Condensed', sans-serif;
  --font-body:    'Barlow', sans-serif;
}

/* === RESET === */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
}
img, video { max-width: 100%; display: block; }
button { cursor: pointer; border: none; background: none; font-family: inherit; }
input, select, textarea { font-family: inherit; }
a { text-decoration: none; color: inherit; }

/* === TOPBAR === */
.topbar {
  background: var(--red);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  height: 56px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 8px rgba(227,0,11,0.3);
}
.topbar-logo {
  font-family: var(--font-display);
  font-size: 26px;
  font-weight: 800;
  letter-spacing: 1px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.topbar-logo span.r3 {
  background: var(--yellow);
  color: var(--red-dark);
  padding: 1px 7px;
  border-radius: 4px;
  font-size: 22px;
}
.topbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 13px;
}
.topbar-time {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 600;
  opacity: 0.9;
}

/* === BOTTOM NAV === */
.bottom-nav {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  background: #fff;
  border-top: 1px solid var(--border);
  display: flex;
  z-index: 100;
  box-shadow: 0 -2px 12px rgba(0,0,0,0.08);
}
.bottom-nav a {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 8px 4px 10px;
  font-size: 10px;
  font-weight: 500;
  color: var(--text-muted);
  transition: color 0.2s;
  gap: 4px;
}
.bottom-nav a.active, .bottom-nav a:hover { color: var(--red); }
.bottom-nav a.active .nav-icon { background: rgba(227,0,11,0.1); }
.nav-icon {
  width: 36px; height: 36px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
  font-size: 20px;
}

/* === PAGE LAYOUT === */
.page {
  padding: 16px 16px 90px;
  max-width: 480px;
  margin: 0 auto;
}
.page-title {
  font-family: var(--font-display);
  font-size: 28px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 4px;
}
.page-subtitle {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 20px;
}

/* === CARDS === */
.card {
  background: var(--bg-card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  margin-bottom: 14px;
}
.card-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}
.card-icon {
  width: 40px; height: 40px;
  border-radius: 10px;
  background: rgba(227,0,11,0.1);
  display: flex; align-items: center; justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
}
.card-title {
  font-family: var(--font-display);
  font-size: 17px;
  font-weight: 700;
}
.card-subtitle { font-size: 12px; color: var(--text-muted); }

/* === STAT CARDS === */
.stat-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 16px;
}
.stat-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  text-align: center;
}
.stat-card.red   { background: var(--red); color: #fff; }
.stat-card.yellow{ background: var(--yellow); color: var(--text); }
.stat-card.green { background: var(--success); color: #fff; }
.stat-card.warn  { background: var(--warning); color: #fff; }
.stat-number {
  font-family: var(--font-display);
  font-size: 40px;
  font-weight: 800;
  line-height: 1;
}
.stat-label { font-size: 12px; font-weight: 500; margin-top: 4px; opacity: 0.85; }

/* === BUTTONS === */
.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 16px;
  border-radius: var(--radius);
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0.5px;
  transition: all 0.18s;
  touch-action: manipulation;
}
.btn-primary {
  background: var(--red);
  color: #fff;
  box-shadow: 0 4px 16px rgba(227,0,11,0.3);
}
.btn-primary:hover { background: var(--red-dark); transform: translateY(-1px); box-shadow: 0 6px 20px rgba(227,0,11,0.35); }
.btn-primary:active { transform: translateY(0); }
.btn-secondary {
  background: var(--yellow);
  color: var(--text);
  box-shadow: 0 4px 16px rgba(255,212,0,0.3);
}
.btn-secondary:hover { background: var(--yellow-dark); }
.btn-outline {
  background: transparent;
  color: var(--red);
  border: 2px solid var(--red);
}
.btn-outline:hover { background: rgba(227,0,11,0.06); }
.btn-sm {
  padding: 10px 16px;
  font-size: 14px;
  width: auto;
}
.btn:disabled { opacity: 0.5; pointer-events: none; }

/* === FORM === */
.form-group { margin-bottom: 14px; }
.form-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.form-control {
  width: 100%;
  padding: 13px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 15px;
  color: var(--text);
  background: #fff;
  transition: border-color 0.2s, box-shadow 0.2s;
  -webkit-appearance: none;
}
.form-control:focus {
  outline: none;
  border-color: var(--red);
  box-shadow: 0 0 0 3px rgba(227,0,11,0.12);
}
.form-select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%23666' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 14px center; padding-right: 36px; }

/* === CAMERA BOX === */
.camera-container {
  position: relative;
  background: #111;
  border-radius: var(--radius);
  overflow: hidden;
  aspect-ratio: 3/4;
  max-height: 380px;
}
.camera-container video {
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
  transform: scaleX(-1);
}
.camera-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}
/* Face guide oval */
.face-guide {
  width: 180px; height: 220px;
  border: 3px solid rgba(255,255,255,0.7);
  border-radius: 50%;
  position: relative;
  animation: pulse-guide 2s ease-in-out infinite;
}
@keyframes pulse-guide {
  0%,100% { border-color: rgba(255,255,255,0.6); box-shadow: 0 0 0 0 rgba(255,255,255,0.2); }
  50%      { border-color: rgba(255,212,0,0.9);   box-shadow: 0 0 0 12px rgba(255,212,0,0); }
}
.face-guide.detecting {
  border-color: var(--yellow);
  animation: pulse-detect 0.6s ease-in-out infinite alternate;
}
@keyframes pulse-detect {
  from { border-color: rgba(255,212,0,0.7); box-shadow: 0 0 0 0 rgba(255,212,0,0.3); }
  to   { border-color: #FFD400;             box-shadow: 0 0 0 16px rgba(255,212,0,0); }
}
.face-guide.success {
  border-color: var(--success);
  animation: none;
  box-shadow: 0 0 0 0 transparent;
}

/* Corner brackets */
.face-guide::before, .face-guide::after,
.face-bracket-bl, .face-bracket-br {
  content: '';
  position: absolute;
  width: 24px; height: 24px;
  border-color: var(--yellow);
  border-style: solid;
}
.face-guide::before  { top: -3px;    left: -3px;  border-width: 3px 0 0 3px;  border-radius: 4px 0 0 0; }
.face-guide::after   { top: -3px;    right: -3px; border-width: 3px 3px 0 0;  border-radius: 0 4px 0 0; }
.face-bracket-bl     { bottom: -3px; left: -3px;  border-width: 0 0 3px 3px;  border-radius: 0 0 0 4px; }
.face-bracket-br     { bottom: -3px; right: -3px; border-width: 0 3px 3px 0;  border-radius: 0 0 4px 0; }

/* Scan line */
.scan-line {
  position: absolute;
  left: 0; right: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--yellow), transparent);
  animation: scan 2s ease-in-out infinite;
  opacity: 0;
}
.face-guide.detecting + .scan-line,
.camera-container.scanning .scan-line { opacity: 1; }
@keyframes scan {
  0%   { top: 10%; }
  100% { top: 90%; }
}

/* Status overlay */
.cam-status {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  padding: 12px;
  background: linear-gradient(transparent, rgba(0,0,0,0.7));
  color: #fff;
  text-align: center;
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 600;
}

/* === RESULT OVERLAYS === */
.result-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  opacity: 0;
  transition: opacity 0.3s;
  pointer-events: none;
}
.result-overlay.show { opacity: 1; }
.result-overlay.success-overlay { background: rgba(46,204,113,0.88); }
.result-overlay.error-overlay   { background: rgba(231,76,60,0.88); }
.result-icon {
  font-size: 64px;
  animation: pop-in 0.3s cubic-bezier(0.34,1.56,0.64,1);
}
@keyframes pop-in {
  from { transform: scale(0.3); opacity: 0; }
  to   { transform: scale(1);   opacity: 1; }
}
.result-text {
  font-family: var(--font-display);
  font-size: 24px;
  font-weight: 700;
  color: #fff;
  text-align: center;
}
.result-sub { font-size: 14px; color: rgba(255,255,255,0.85); text-align: center; }

/* === BADGES & STATUS === */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
}
.badge-success { background: rgba(46,204,113,0.15); color: #27ae60; }
.badge-warning { background: rgba(243,156,18,0.15); color: #d68910; }
.badge-error   { background: rgba(231,76,60,0.15);  color: #c0392b; }
.badge-info    { background: rgba(52,152,219,0.15); color: #2980b9; }

/* === PROGRESS BAR === */
.progress-wrap {
  background: var(--border);
  border-radius: 10px;
  height: 8px;
  overflow: hidden;
}
.progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--red), var(--yellow));
  border-radius: 10px;
  transition: width 0.4s ease;
}

/* === ALERT === */
.alert {
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 14px;
}
.alert-info    { background: rgba(52,152,219,0.1); border-left: 3px solid #3498db; color: #1a5276; }
.alert-success { background: rgba(46,204,113,0.1); border-left: 3px solid var(--success); color: #1e8449; }
.alert-warning { background: rgba(243,156,18,0.1); border-left: 3px solid var(--warning); color: #784212; }
.alert-error   { background: rgba(231,76,60,0.1);  border-left: 3px solid var(--error);   color: #922b21; }

/* === TABLE === */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th {
  background: var(--red);
  color: #fff;
  padding: 10px 12px;
  text-align: left;
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.5px;
}
td { padding: 10px 12px; border-bottom: 1px solid var(--border); }
tr:last-child td { border-bottom: none; }
tr:hover td { background: rgba(227,0,11,0.03); }

/* === AVATAR === */
.avatar {
  width: 44px; height: 44px;
  border-radius: 50%;
  background: var(--red);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 700;
  flex-shrink: 0;
}

/* === DIVIDER === */
.divider {
  height: 1px;
  background: var(--border);
  margin: 16px 0;
}
.divider-label {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin: 16px 0;
}
.divider-label::before, .divider-label::after {
  content: ''; flex: 1; height: 1px; background: var(--border);
}

/* === STEP INDICATOR === */
.steps {
  display: flex;
  align-items: center;
  gap: 0;
  margin-bottom: 24px;
}
.step {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  position: relative;
}
.step:not(:last-child)::after {
  content: '';
  position: absolute;
  top: 16px; left: 50%;
  width: 100%; height: 2px;
  background: var(--border);
  z-index: 0;
}
.step.done:not(:last-child)::after { background: var(--red); }
.step-num {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--border);
  color: var(--text-muted);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 700;
  position: relative;
  z-index: 1;
  transition: all 0.2s;
}
.step.active .step-num { background: var(--red); color: #fff; box-shadow: 0 0 0 4px rgba(227,0,11,0.2); }
.step.done .step-num   { background: var(--success); color: #fff; }
.step-label { font-size: 10px; font-weight: 600; color: var(--text-muted); text-align: center; }
.step.active .step-label { color: var(--red); }
.step.done .step-label   { color: var(--success); }

/* === SAMPLE COUNTER (Registrasi) === */
.sample-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
  margin: 12px 0;
}
.sample-dot {
  aspect-ratio: 1;
  border-radius: 6px;
  background: var(--border);
  display: flex; align-items: center; justify-content: center;
  font-size: 10px;
  transition: all 0.2s;
}
.sample-dot.captured { background: var(--success); color: #fff; }
.sample-dot.active   { background: var(--yellow); color: var(--text); animation: pulse-dot 0.5s ease-in-out infinite alternate; }
@keyframes pulse-dot { from { transform: scale(0.9); } to { transform: scale(1.1); } }

/* === SHIFT BADGE === */
.shift-tag {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 12px;
  border-radius: 20px;
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 700;
}
.shift-pagi   { background: rgba(255,212,0,0.2); color: #8a6d00; }
.shift-siang  { background: rgba(227,0,11,0.12);  color: var(--red-dark); }
.shift-malam  { background: rgba(52,73,94,0.12);  color: #2c3e50; }

/* === FOOTER POWERED BY === */
.powered-by {
  text-align: center;
  font-size: 11px;
  color: var(--text-muted);
  padding: 8px;
  opacity: 0.6;
  letter-spacing: 0.5px;
}

/* === LOADING SPINNER === */
.spinner {
  width: 24px; height: 24px;
  border: 3px solid rgba(255,255,255,0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* === TOAST === */
.toast-container {
  position: fixed;
  top: 70px; left: 50%;
  transform: translateX(-50%);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
  width: calc(100% - 32px);
  max-width: 448px;
}
.toast {
  background: var(--text);
  color: #fff;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 10px;
  animation: slide-down 0.3s ease;
  box-shadow: var(--shadow-lg);
}
.toast.success { background: var(--success); }
.toast.error   { background: var(--error); }
.toast.warning { background: var(--warning); color: var(--text); }
@keyframes slide-down {
  from { transform: translateY(-20px); opacity: 0; }
  to   { transform: translateY(0);     opacity: 1; }
}

/* === HERO BANNER === */
.hero-banner {
  background: var(--red);
  border-radius: var(--radius);
  padding: 20px;
  color: #fff;
  margin-bottom: 16px;
  position: relative;
  overflow: hidden;
}
.hero-banner::after {
  content: 'R3';
  position: absolute;
  right: -8px; top: -10px;
  font-family: var(--font-display);
  font-size: 120px;
  font-weight: 800;
  color: rgba(255,255,255,0.07);
  line-height: 1;
  pointer-events: none;
}
.hero-date {
  font-size: 13px;
  opacity: 0.8;
  margin-bottom: 4px;
}
.hero-name {
  font-family: var(--font-display);
  font-size: 28px;
  font-weight: 800;
  line-height: 1.1;
}
.hero-shift {
  margin-top: 10px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(255,255,255,0.15);
  padding: 5px 12px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 600;
}

/* === GPS INDICATOR === */
.gps-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #fff;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 13px;
  margin-bottom: 14px;
}
.gps-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--text-muted);
  flex-shrink: 0;
}
.gps-dot.ok      { background: var(--success); box-shadow: 0 0 0 3px rgba(46,204,113,0.2); }
.gps-dot.error   { background: var(--error); }
.gps-dot.loading { background: var(--warning); animation: pulse-dot 0.8s ease-in-out infinite alternate; }

/* === RESPONSIVE === */
@media (min-width: 480px) {
  .topbar { padding: 0 24px; }
  .page { padding: 24px 24px 100px; }
  .stat-number { font-size: 48px; }
}
@media (min-width: 768px) {
  .bottom-nav { display: none; }
  .sidebar {
    position: fixed;
    left: 0; top: 56px; bottom: 0;
    width: 220px;
    background: #fff;
    border-right: 1px solid var(--border);
    padding: 16px 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
  }
  .page { margin-left: 220px; max-width: none; padding: 24px; }
}
