/* ==========================================================================
   Presensi Kanti Kita — style.css
   Struktur: 1) Token  2) Reset  3) Frame ponsel  4) Komponen  5) Layar  6) Responsif
   ========================================================================== */

/* 1) TOKEN ---------------------------------------------------------------- */
:root {
  color-scheme: dark;

  /* warna dasar */
  --page: #1c1c1c;
  --bg: #0a1226;
  --bg2: #0f1b38;
  --card: #121f3d;
  --line: #1d2c52;
  --tx: #eef2ff;
  --mut: #7f8db3;

  /* warna aksi & status */
  --pri: #2563eb;
  --pri-soft: #60a5fa;
  --ok: #22c55e;
  --ok-soft: #4ade80;
  --warn: #f59e0b;
  --warn-soft: #fbbf24;
  --bad: #ef4444;
  --bad-soft: #f87171;
  --mut-soft: var(--mut);

  /* latar transparan untuk tag/ikon */
  --ok-bg: #22c55e22;
  --warn-bg: #f59e0b22;
  --mut-bg: #7f8db326;
  --bad-bg: #ef444422;

  /* bentuk */
  --r-sm: 12px;
  --r-md: 14px;
  --r-lg: 18px;
  --r-xl: 24px;

  --font: "Plus Jakarta Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

/* 2) RESET ---------------------------------------------------------------- */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
}

html,
body {
  height: 100%;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--page);
  color: var(--tx);
  font-family: var(--font);
  -webkit-tap-highlight-color: transparent;
}

button,
input,
select {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
}

svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

h1 {
  font-size: 20px;
}

/* Fokus keyboard yang terlihat */
:focus-visible {
  outline: 2px solid var(--pri-soft);
  outline-offset: 2px;
}

/* 3) FRAME PONSEL --------------------------------------------------------- */
.phone {
  position: relative;
  display: flex;
  flex-direction: column;
  width: 390px;
  height: 810px;
  max-height: 96vh;
  max-height: 96dvh;
  overflow: hidden;
  background: var(--bg);
  border: 7px solid #0b0f1d;
  border-radius: 46px;
  box-shadow: 0 0 0 2px #2a3558, 0 30px 80px #000a;
}

.notch {
  position: absolute;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  width: 104px;
  height: 28px;
  background: #000;
  border-radius: 20px;
}

.status {
  flex: none;
  display: flex;
  justify-content: space-between;
  align-items: center;
  height: 44px;
  padding: 6px 28px 0;
  font-size: 13px;
  font-weight: 700;
}

#scr {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 6px 20px 16px;
  scrollbar-width: none;
}

#scr::-webkit-scrollbar {
  display: none;
}

.nav {
  flex: none;
  display: flex;
  justify-content: space-around;
  align-items: center;
  height: 62px;
  margin: 0 20px 18px;
  background: var(--bg2);
  border: 1px solid var(--line);
  border-radius: 20px;
}

.nav button {
  display: grid;
  place-items: center;
  width: 52px;
  height: 44px;
  background: none;
  border: 0;
  border-radius: var(--r-md);
  color: var(--mut);
}

.nav button.on {
  background: #1e3a8a88;
  color: var(--pri-soft);
}

.toast {
  position: absolute;
  left: 50%;
  bottom: 96px;
  transform: translateX(-50%);
  width: max-content;
  max-width: calc(100% - 32px);
  padding: 10px 16px;
  background: #e2e8f0;
  color: #0b1220;
  border-radius: var(--r-sm);
  font-size: 12px;
  font-weight: 700;
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}

.toast.show {
  opacity: 1;
}

/* 4) KOMPONEN ------------------------------------------------------------- */

/* Utilitas teks */
.mut {
  color: var(--mut);
}

.sm {
  font-size: 11px;
}

/* Kartu */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
}

/* Tombol utama */
.btn {
  width: 100%;
  height: 48px;
  background: var(--pri);
  border: 0;
  border-radius: var(--r-md);
  color: #fff;
  font-size: 14px;
  font-weight: 700;
}

.btn:active {
  transform: scale(0.98);
}

.btn.alt {
  background: var(--card);
  border: 1px solid var(--line);
}

/* Header layar */
.top {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 40px;
  margin-bottom: 16px;
}

.top h2 {
  flex: 1;
  text-align: center;
  font-size: 16px;
}

/* Tombol ikon */
.ib {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  color: var(--tx);
}

/* Avatar */
.av {
  flex: none;
  display: grid;
  place-items: center;
  background: var(--pri);
  border-radius: 50%;
  color: #fff;
  font-weight: 800;
}

/* Tag status */
.tag {
  padding: 4px 10px;
  border-radius: 8px;
  font-size: 10px;
  font-weight: 700;
  white-space: nowrap;
}

.t-ok {
  background: var(--ok-bg);
  color: var(--ok-soft);
}

.t-warn {
  background: var(--warn-bg);
  color: var(--warn-soft);
}

.t-mut {
  background: var(--mut-bg);
  color: var(--mut);
}

.t-bad {
  background: var(--bad-bg);
  color: var(--bad-soft);
}

/* Baris item & ikon */
.item {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
  padding: 12px 14px;
}

.item b {
  display: block;
  font-size: 13px;
}

.ico {
  flex: none;
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 11px;
}

/* Form */
.lbl {
  display: block;
  margin: 16px 0 6px;
  color: var(--mut);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.6px;
}

.inp {
  display: block;
  width: 100%;
  height: 46px;
  padding: 0 14px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  color: var(--tx);
  font-size: 13px;
  font-weight: 500;
}

input.inp:read-only {
  color: var(--mut);
}

/* Menu (daftar item dalam satu kartu) */
.menu {
  overflow: hidden;
}

.menu .item {
  margin: 0;
  background: none;
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  cursor: pointer;
}

.menu .item:last-child {
  border-bottom: 0;
}

/* 5) LAYAR ---------------------------------------------------------------- */

/* Beranda: kartu jam & tombol clock in/out */
.hero {
  margin: 16px 0;
  padding: 18px;
  background: linear-gradient(135deg, #1d4ed8, #172554);
  border-radius: var(--r-xl);
  text-align: center;
}

.pill {
  display: inline-block;
  padding: 3px 12px;
  background: #ffffff22;
  border-radius: 20px;
  font-size: 10px;
  font-weight: 700;
}

.clk {
  margin: 10px 0 2px;
  font-size: 42px;
  font-weight: 800;
  letter-spacing: 1px;
  font-variant-numeric: tabular-nums;
}

.row2 {
  display: flex;
  gap: 10px;
}

.row2 > * {
  flex: 1;
  min-width: 0;
}

.cb {
  height: 44px;
  background: #ffffff14;
  border: 1px solid #ffffff2a;
  border-radius: var(--r-sm);
  color: #cbd5f5;
  font-size: 13px;
  font-weight: 700;
}

.cb.go {
  background: #15803d;
  border-color: #16a34a;
  color: #fff;
}

.cb:disabled {
  opacity: 0.45;
  cursor: default;
}

/* Beranda: foto clock in */
.shot {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-bottom: 14px;
  color: #bfdbfe;
  font-size: 11px;
  font-weight: 700;
}

.shot img {
  width: 32px;
  height: 32px;
  object-fit: cover;
  border: 2px solid #ffffff55;
  border-radius: 50%;
}

/* Kamera presensi */
.cam {
  position: relative;
  aspect-ratio: 4 / 5;
  overflow: hidden;
  background: #000;
  border: 1px solid var(--line);
  border-radius: var(--r-xl);
}

.cam-view {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

video.cam-view {
  transform: scaleX(-1); /* pratinjau seperti cermin */
}

.cam-guide {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 62%;
  height: 68%;
  transform: translate(-50%, -50%);
  border: 2px dashed #ffffff88;
  border-radius: 50%;
  pointer-events: none;
}

.cam-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  height: 100%;
  padding: 24px;
  color: var(--mut);
  font-size: 12px;
  line-height: 1.5;
  text-align: center;
}

.cam-empty svg {
  width: 36px;
  height: 36px;
}

.shutter {
  display: block;
  width: 64px;
  height: 64px;
  margin: 0 auto;
  background: #fff;
  border: 0;
  border-radius: 50%;
  box-shadow: 0 0 0 4px var(--bg), 0 0 0 6px var(--pri-soft);
}

.shutter:active {
  transform: scale(0.94);
}

/* Owner: dasbor, rekap, detail karyawan */
.item[role="button"] {
  cursor: pointer;
}

.item > div {
  min-width: 0;
}

.ib:disabled {
  opacity: 0.35;
  cursor: default;
}

.btn.ic {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

/* Pemilih bulan / hari */
.mbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.mbar b {
  font-size: 14px;
}

/* Kartu angka ringkasan */
.stat {
  padding: 12px 6px;
  text-align: center;
}

.stat b {
  display: block;
  font-size: 22px;
  font-weight: 800;
}

.stat span {
  font-size: 10px;
}

/* Progres kehadiran */
.bar {
  height: 8px;
  margin-top: 12px;
  background: #ffffff22;
  border-radius: 8px;
  overflow: hidden;
}

.bar > i {
  display: block;
  height: 100%;
  background: var(--ok-soft);
  border-radius: inherit;
}

/* Filter status (bisa digeser ke samping) */
.chips {
  display: flex;
  gap: 8px;
  margin: 0 -20px 12px;
  padding: 0 20px;
  overflow-x: auto;
  scrollbar-width: none;
}

.chips::-webkit-scrollbar {
  display: none;
}

.chip {
  flex: none;
  height: 36px;
  padding: 0 14px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 20px;
  color: var(--mut);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.chip.on {
  background: #1e3a8a88;
  border-color: var(--pri);
  color: var(--pri-soft);
}

/* Kartu identitas karyawan (detail) */
.who {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 16px;
  padding: 18px;
  background: linear-gradient(135deg, #1d4ed8, #172554);
}

/* 6) RESPONSIF & AKSESIBILITAS -------------------------------------------- */
@media (max-width: 480px) {
  body {
    display: block;
  }

  .phone {
    width: 100%;
    height: 100vh;
    height: 100dvh;
    max-height: none;
    padding-top: env(safe-area-inset-top, 0px);
    border: 0;
    border-radius: 0;
    box-shadow: none;
  }

  .notch,
  .status {
    display: none;
  }

  #scr {
    padding-top: 14px;
  }

  .nav {
    margin-bottom: calc(18px + env(safe-area-inset-bottom, 0px));
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition: none !important;
    animation: none !important;
  }
}

/* Foto presensi: thumbnail & perbesar */
.thumb {
  flex: none;
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 0;
  border-radius: 11px;
  overflow: hidden;
  background: var(--mut-bg);
  color: var(--mut);
}

button.thumb {
  cursor: pointer;
}

.thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.thumb svg {
  width: 18px;
  height: 18px;
}

.lightbox {
  position: absolute;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 12px;
  padding: 24px;
  background: #000d;
}

.lightbox img {
  max-width: 100%;
  max-height: 75%;
  border-radius: var(--r-sm);
}

/* 7) LOADING & ERROR STATE ------------------------------------------------- */
[hidden] {
  display: none !important;
}

.busy {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 12px;
  background: #0a1226cc;
  color: var(--tx);
  font-size: 12px;
  font-weight: 700;
  backdrop-filter: blur(2px);
}

.spinner {
  width: 34px;
  height: 34px;
  border: 3px solid #ffffff2a;
  border-top-color: var(--pri-soft);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.errbox {
  position: absolute;
  top: 58px;
  left: 14px;
  right: 14px;
  z-index: 25;
  display: grid;
  gap: 8px;
  padding: 14px;
  background: #3b1420;
  border: 1px solid var(--bad);
  border-radius: var(--r-md);
  box-shadow: 0 12px 30px #0008;
  font-size: 12px;
}

.errbox b {
  color: var(--bad-soft);
  font-size: 13px;
}

.errbox .mut {
  line-height: 1.5;
}

.errbox .row2 {
  margin-top: 4px;
}

.errbox .cb {
  height: 36px;
  font-size: 12px;
}