@import url("https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@500;600;700&family=Inter:wght@400;500;600&family=JetBrains+Mono:wght@500;600&display=swap");

:root {
  --navy: #0f172a;
  --navy-soft: #16213a;
  --teal: #ef3340;
  --teal-dark: #c8102e;
  --amber: #f59e0b;
  --red: #c8102e;
  --ink: #1e293b;
  --paper: #f8fafc;
  --line: #e2e8f0;
  --muted: #64748b;
  --font-display: "Space Grotesk", "Inter", system-ui, sans-serif;
  --font-body: "Inter", system-ui, -apple-system, sans-serif;
  --font-mono: "JetBrains Mono", "SFMono-Regular", Consolas, monospace;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  min-height: 100%;
  background: #650816;
  font-family: var(--font-body);
  color: var(--ink);
  -webkit-tap-highlight-color: transparent;
}

button {
  font-family: inherit;
}

.app-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background:
    radial-gradient(
      circle at 15% 0%,
      rgba(255, 255, 255, 0.12),
      transparent 38%
    ),
    linear-gradient(145deg, #7a091b 0%, #b10f2e 52%, #5d0715 100%);
}

/* ---------- HEADER ---------- */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px;
  color: #fff;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}
.brand-badge {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  overflow: hidden;
  border-radius: 11px;
  background: #050505 url("icons/icon-192.png") center/cover no-repeat;
  color: transparent;
  font-size: 0;
  box-shadow: 0 8px 20px rgba(53, 0, 10, 0.25);
}
.brand-badge::after {
  content: "";
  color: var(--red);
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 700;
}
.brand h1 {
  font-family: var(--font-display);
  font-size: 16px;
  letter-spacing: 0.02em;
  line-height: 1.1;
}
.brand p {
  font-size: 11px;
  color: rgba(255, 255, 255, 0.7);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-top: 2px;
}
.clock {
  font-family: var(--font-mono);
  font-size: 14px;
  color: #fff;
  background: rgba(255, 255, 255, 0.12);
  padding: 6px 10px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.25);
}

/* ---------- STAGE ---------- */
.stage {
  flex: 1;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 8px 16px 24px;
}

.screen {
  display: none;
  width: 100%;
  max-width: 420px;
}
.screen.active {
  display: block;
  animation: rise 0.35s ease;
}
#screen-login {
  margin: auto 0;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.card {
  background: var(--paper);
  border-radius: 20px;
  padding: 26px 22px 28px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.35);
}

.card h2 {
  font-family: var(--font-display);
  font-size: 21px;
  color: var(--navy);
  margin-bottom: 6px;
}
.login-brand {
  text-align: center;
  margin-bottom: 24px;
}
.login-logo {
  display: grid;
  place-items: center;
  width: 76px;
  height: 76px;
  margin: 0 auto 13px;
  border-radius: 24px;
  background: #050505 url("icons/icon-192.png") center/cover no-repeat;
  color: #fff;
  font-family: var(--font-display);
  font-size: 0;
  font-weight: 700;
  letter-spacing: -0.04em;
  box-shadow: 0 14px 28px rgba(200, 16, 46, 0.28);
}
.login-app-name {
  font-family: var(--font-display);
  color: var(--navy);
  font-size: 22px;
  font-weight: 700;
}
.login-company {
  margin-top: 2px;
  color: var(--red);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
#screen-login .card {
  border-top: 5px solid var(--red);
  box-shadow: 0 28px 70px rgba(45, 0, 8, 0.42);
}
#screen-login .card h2,
#screen-login .muted {
  text-align: center;
}
.muted {
  color: var(--muted);
  font-size: 13.5px;
  line-height: 1.5;
  margin-bottom: 18px;
}

/* ---------- FIELDS ---------- */
.field {
  display: block;
  margin-bottom: 14px;
  color: var(--navy);
  font-size: 13px;
  font-weight: 600;
}
.field span {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--ink);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.field input {
  width: 100%;
  padding: 13px 14px;
  border-radius: 12px;
  border: 1.5px solid var(--line);
  font-size: 15px;
  background: #fff;
  color: var(--ink);
  outline: none;
  transition: border-color 0.15s;
}
.field input:focus {
  border-color: var(--teal);
}

.error-text {
  color: var(--red);
  font-size: 13px;
  margin: -6px 0 12px;
  min-height: 0;
}
.account-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  margin-bottom: 20px;
  background: #fff;
  border: 1.5px solid var(--line);
  border-radius: 14px;
}
.account-card img {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--line);
  object-fit: cover;
}
.account-card div {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.account-card b {
  font-size: 14px;
  color: var(--navy);
}
.account-card span {
  font-size: 12px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---------- BUTTONS ---------- */
.btn-primary {
  width: 100%;
  padding: 15px;
  border: none;
  border-radius: 12px;
  background: var(--teal-dark);
  color: #fff;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  margin-top: 6px;
  transition:
    transform 0.12s,
    background 0.15s,
    opacity 0.2s;
}
.btn-primary:active {
  transform: scale(0.98);
}
.btn-primary:disabled {
  background: #cbd5e1;
  color: #94a3b8;
  cursor: not-allowed;
}
.btn-ghost {
  width: 100%;
  padding: 13px;
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  margin-top: 6px;
}
.btn-ghost:active {
  opacity: 0.6;
}
.btn-checkout {
  width: 100%;
  padding: 15px;
  border: 1.5px solid var(--teal-dark);
  border-radius: 12px;
  background: #fff;
  color: var(--teal-dark);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  margin-top: 10px;
}
.btn-history {
  width: 100%;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  color: var(--navy);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  margin-top: 10px;
}

/* ---------- HISTORY ---------- */
.history-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}
.history-header .muted {
  margin-bottom: 16px;
}
.history-count {
  display: grid;
  place-items: center;
  min-width: 34px;
  height: 34px;
  padding: 0 9px;
  border-radius: 17px;
  background: rgba(200, 16, 46, 0.1);
  color: var(--red);
  font-weight: 700;
}
.history-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 55vh;
  overflow: auto;
  padding-right: 2px;
}
.history-item {
  padding: 13px 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
}
.history-item-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 5px;
}
.history-item strong {
  font-size: 14px;
}
.history-item time,
.history-item span {
  font-size: 12px;
  color: var(--muted);
}
.history-in {
  color: #15803d;
}
.history-out {
  color: var(--red);
}
.history-empty {
  padding: 28px 16px;
  border: 1px dashed var(--line);
  border-radius: 14px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
  text-align: center;
}

/* ---------- LOCATION / RADAR ---------- */
.radar {
  position: relative;
  width: 120px;
  height: 120px;
  margin: 6px auto 20px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.radar-ring {
  position: absolute;
  width: 100%;
  height: 100%;
  border: 2px solid var(--teal);
  border-radius: 50%;
  opacity: 0.35;
  animation: pulse 1.8s ease-out infinite;
}
.radar-ring::before {
  content: "";
  position: absolute;
  inset: 20px;
  border: 2px solid var(--teal);
  border-radius: 50%;
  opacity: 0.5;
}
.radar-dot {
  width: 14px;
  height: 14px;
  background: var(--amber);
  border-radius: 50%;
  box-shadow: 0 0 0 6px rgba(245, 158, 11, 0.25);
  transition:
    background 0.3s,
    box-shadow 0.3s;
}
.radar-dot.ok {
  background: var(--teal);
  box-shadow: 0 0 0 6px rgba(20, 184, 166, 0.25);
}
.radar-dot.bad {
  background: var(--red);
  box-shadow: 0 0 0 6px rgba(239, 68, 68, 0.25);
}
@keyframes pulse {
  0% {
    transform: scale(0.6);
    opacity: 0.6;
  }
  100% {
    transform: scale(1.15);
    opacity: 0;
  }
}

.readout {
  background: var(--navy);
  border-radius: 14px;
  padding: 14px 16px;
  margin-bottom: 16px;
}
.readout-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 0;
  font-size: 13px;
  color: #94a3b8;
}
.readout-row + .readout-row {
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}
.readout-row b {
  font-family: var(--font-mono);
  color: #fff;
  font-size: 13.5px;
}

.status-pill {
  text-align: center;
  padding: 10px 12px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 16px;
  background: rgba(245, 158, 11, 0.12);
  color: #b45309;
  border: 1px solid rgba(245, 158, 11, 0.3);
}
.status-pill.ok {
  background: rgba(20, 184, 166, 0.12);
  color: var(--teal-dark);
  border-color: rgba(20, 184, 166, 0.35);
}
.status-pill.bad {
  background: rgba(239, 68, 68, 0.12);
  color: #b91c1c;
  border-color: rgba(239, 68, 68, 0.35);
}

/* ---------- CAMERA ---------- */
.card-camera {
  padding: 22px 18px 26px;
}
.camera-frame {
  position: relative;
  width: 100%;
  aspect-ratio: 3/4;
  background: #000;
  border-radius: 16px;
  overflow: hidden;
  margin-bottom: 18px;
}
.camera-frame video,
.camera-frame canvas {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transform: scaleX(-1); /* mirror preview seperti kamera depan pada umumnya */
}
.camera-frame canvas {
  transform: none;
} /* hasil akhir tidak dibalik */
#screen-preview .camera-frame {
  aspect-ratio: auto;
  min-height: 0;
  overflow: visible;
  background: transparent;
}
#screen-preview .camera-frame canvas {
  width: 100%;
  height: auto;
  max-height: none;
  object-fit: contain;
  border-radius: 16px;
  background: #000;
}
.camera-overlay {
  position: absolute;
  inset: 0;
  border: 2px dashed rgba(20, 184, 166, 0.6);
  border-radius: 16px;
  margin: 14px;
  pointer-events: none;
}

/* ---------- UPLOAD PROGRESS ---------- */
.progress-track {
  width: 100%;
  height: 14px;
  background: var(--line);
  border-radius: 20px;
  overflow: hidden;
  margin-bottom: 8px;
}
.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--teal), var(--teal-dark));
  border-radius: 20px;
  transition: width 0.25s ease;
}
.progress-percent {
  text-align: center;
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--muted);
}

/* ---------- SUCCESS / ERROR ---------- */
.success-icon,
.error-icon {
  font-size: 52px;
  text-align: center;
  margin-bottom: 6px;
}
.success-time {
  font-family: var(--font-mono);
  font-size: 34px;
  font-weight: 700;
  color: var(--teal-dark);
  text-align: center;
  margin-bottom: 8px;
}
.success-message {
  font-size: 13.5px;
  color: var(--ink);
  text-align: center;
  line-height: 1.5;
  margin-bottom: 16px;
}
#screen-success .card,
#screen-error .card {
  text-align: center;
}

.employee-card {
  display: flex;
  align-items: center;
  gap: 12px;
  text-align: left;
  background: #fff;
  border: 1.5px solid var(--line);
  border-radius: 14px;
  padding: 12px;
  margin-bottom: 14px;
}
.employee-photo {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--line);
  flex-shrink: 0;
}
.employee-photo:not([src]),
.employee-photo[src=""] {
  display: none;
}
.employee-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.employee-info b {
  font-size: 14.5px;
  color: var(--navy);
}
.employee-info span {
  font-size: 12px;
  color: var(--muted);
}

.success-quote {
  font-size: 12.5px;
  font-style: italic;
  color: var(--muted);
  text-align: center;
  padding: 10px 6px;
  border-top: 1px dashed var(--line);
  margin-bottom: 8px;
}

/* ---------- IOS API LOADING ---------- */
.api-loading {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(20, 0, 4, 0.22);
  -webkit-backdrop-filter: blur(10px) saturate(0.85);
  backdrop-filter: blur(10px) saturate(0.85);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition:
    opacity 0.2s ease,
    visibility 0.2s ease;
}
.api-loading.visible {
  opacity: 1;
  visibility: visible;
  pointer-events: all;
}
.ios-loader-card {
  width: 142px;
  min-height: 132px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  padding: 22px 16px;
  border: 1px solid rgba(255, 255, 255, 0.7);
  border-radius: 28px;
  background: rgba(255, 255, 255, 0.88);
  box-shadow: 0 24px 70px rgba(49, 0, 9, 0.3);
  -webkit-backdrop-filter: blur(22px) saturate(1.5);
  backdrop-filter: blur(22px) saturate(1.5);
}
.ios-spinner {
  width: 38px;
  height: 38px;
  border: 4px solid rgba(200, 16, 46, 0.16);
  border-top-color: var(--red);
  border-radius: 50%;
  animation: iosSpin 0.75s linear infinite;
}
.ios-loader-text {
  color: var(--navy);
  font-size: 13px;
  font-weight: 600;
  text-align: center;
  line-height: 1.35;
}
@keyframes iosSpin {
  to {
    transform: rotate(360deg);
  }
}

/* ---------- INSTALL PWA ---------- */
.install-app-button {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 9000;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  border: 1px solid rgba(255, 255, 255, 0.55);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.94);
  color: var(--red);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 14px 36px rgba(49, 0, 9, 0.32);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
}
.install-app-button[hidden] {
  display: none;
}
.install-app-icon {
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 7px;
  background: var(--red);
  color: #fff;
  font-size: 16px;
  line-height: 1;
}

/* ---------- FOOTER ---------- */
.app-footer {
  text-align: center;
  padding: 10px;
  font-size: 11px;
  color: #475569;
}

/* ---------- RESPONSIVE ---------- */
@media (min-width: 480px) {
  .stage {
    padding-top: 24px;
  }
}
@media (max-height: 700px) {
  .radar {
    width: 96px;
    height: 96px;
    margin-bottom: 14px;
  }
}

/* ---------- ERROR POPUP ---------- */
.error-popup {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(20, 0, 4, 0.4);
  -webkit-backdrop-filter: blur(10px) saturate(0.85);
  backdrop-filter: blur(10px) saturate(0.85);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.25s ease, visibility 0.25s ease;
}

.error-popup.visible {
  opacity: 1;
  visibility: visible;
  pointer-events: all;
}

.popup-card {
  width: 100%;
  max-width: 360px;
  background: var(--paper);
  border-radius: 24px;
  padding: 28px 24px;
  text-align: center;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.4);
  border-top: 5px solid var(--red);
  transform: scale(0.9) translateY(15px);
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.error-popup.visible .popup-card {
  transform: scale(1) translateY(0);
}

.popup-icon {
  width: 64px;
  height: 64px;
  margin: 0 auto 16px;
  background: rgba(200, 16, 46, 0.1);
  color: var(--red);
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 32px;
  box-shadow: inset 0 0 0 1px rgba(200, 16, 46, 0.15);
}

.popup-card h3 {
  font-family: var(--font-display);
  font-size: 19px;
  color: var(--navy);
  margin-bottom: 8px;
  font-weight: 700;
}

.popup-card p {
  font-size: 13.5px;
  color: var(--muted);
  line-height: 1.5;
  margin-bottom: 22px;
}

.popup-card .btn-primary {
  margin-top: 0;
  padding: 13px;
  border-radius: 12px;
  background: var(--red);
  color: #fff;
  font-size: 14.5px;
  box-shadow: 0 8px 20px rgba(200, 16, 46, 0.25);
  border: none;
  cursor: pointer;
  width: 100%;
  font-weight: 600;
  transition: background 0.15s, transform 0.12s;
}

.popup-card .btn-primary:active {
  transform: scale(0.98);
}

.popup-card .btn-primary:hover {
  background: var(--teal-dark);
}

/* ---------- SHAKE ANIMATION (login card) ---------- */
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  15%       { transform: translateX(-6px); }
  30%       { transform: translateX(6px); }
  45%       { transform: translateX(-5px); }
  60%       { transform: translateX(5px); }
  75%       { transform: translateX(-3px); }
  90%       { transform: translateX(3px); }
}
.shake {
  animation: shake 0.55s cubic-bezier(0.36, 0.07, 0.19, 0.97) both;
}

/* reset border merah saat user klik input lagi */
.field input:focus {
  border-color: var(--teal) !important;
}


