/* ============================================================
   style.css — Absensi PWA  |  Mobile-first design
   ============================================================ */

/* RESET & BASE */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --primary:        #1976D2;
  --primary-dark:   #1256A0;
  --primary-light:  #E3F2FD;
  --success:        #2E7D32;
  --success-light:  #E8F5E9;
  --danger:         #C62828;
  --danger-light:   #FFEBEE;
  --warning:        #F57F17;
  --warning-light:  #FFFDE7;
  --gray-50:        #FAFAFA;
  --gray-100:       #F5F5F5;
  --gray-200:       #EEEEEE;
  --gray-400:       #BDBDBD;
  --gray-600:       #757575;
  --gray-800:       #424242;
  --gray-900:       #212121;
  --white:          #FFFFFF;
  --radius-sm:      6px;
  --radius-md:      10px;
  --radius-lg:      16px;
  --radius-xl:      24px;
  --shadow-sm:      0 1px 3px rgba(0,0,0,.08);
  --shadow-md:      0 4px 12px rgba(0,0,0,.10);
  --shadow-lg:      0 8px 24px rgba(0,0,0,.12);
  --transition:     .2s ease;
  --font:           'Segoe UI', system-ui, -apple-system, sans-serif;
}

html { font-size: 16px; -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font);
  background: var(--gray-100);
  color: var(--gray-900);
  min-height: 100vh;
  line-height: 1.5;
}

/* ── LAYOUT ── */
.app-shell {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  background: var(--white);
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
}

.topbar {
  background: var(--primary);
  color: var(--white);
  padding: 14px 16px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
}
.topbar h1 { font-size: 17px; font-weight: 600; }
.topbar .topbar-sub { font-size: 12px; opacity: .82; }
.topbar-right { text-align: right; }

.content { flex: 1; padding: 16px; overflow-y: auto; }

/* ── BOTTOM NAV ── */
.bottom-nav {
  display: flex;
  background: var(--white);
  border-top: 1px solid var(--gray-200);
  position: sticky;
  bottom: 0;
}
.bottom-nav a {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 10px 6px;
  color: var(--gray-600);
  text-decoration: none;
  font-size: 10px;
  font-weight: 500;
  transition: color var(--transition);
}
.bottom-nav a svg { width: 22px; height: 22px; }
.bottom-nav a.active, .bottom-nav a:hover { color: var(--primary); }

/* ── CARD ── */
.card {
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-lg);
  padding: 16px;
  margin-bottom: 14px;
  box-shadow: var(--shadow-sm);
}
.card-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--gray-600);
  text-transform: uppercase;
  letter-spacing: .04em;
  margin-bottom: 12px;
}

/* ── STATUS BADGE ── */
.badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 20px;
}
.badge-success  { background: var(--success-light);  color: var(--success); }
.badge-danger   { background: var(--danger-light);   color: var(--danger); }
.badge-warning  { background: var(--warning-light);  color: var(--warning); }
.badge-primary  { background: var(--primary-light);  color: var(--primary-dark); }
.badge-gray     { background: var(--gray-200);       color: var(--gray-800); }

/* ── BUTTON ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 20px;
  border: none;
  border-radius: var(--radius-md);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  text-decoration: none;
  width: 100%;
}
.btn:active { transform: scale(.97); }
.btn-primary  { background: var(--primary);  color: var(--white); }
.btn-primary:hover  { background: var(--primary-dark); }
.btn-success  { background: var(--success);  color: var(--white); }
.btn-danger   { background: var(--danger);   color: var(--white); }
.btn-outline  {
  background: transparent;
  border: 1.5px solid var(--primary);
  color: var(--primary);
}
.btn-sm { padding: 8px 14px; font-size: 13px; width: auto; border-radius: var(--radius-sm); }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ── FORM ── */
.form-group { margin-bottom: 14px; }
.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--gray-800);
  margin-bottom: 6px;
}
.form-control {
  width: 100%;
  padding: 11px 14px;
  border: 1.5px solid var(--gray-200);
  border-radius: var(--radius-md);
  font-size: 15px;
  font-family: var(--font);
  transition: border-color var(--transition);
  background: var(--white);
  color: var(--gray-900);
}
.form-control:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(25,118,210,.12);
}

/* ── ALERT ── */
.alert {
  padding: 12px 14px;
  border-radius: var(--radius-md);
  font-size: 14px;
  margin-bottom: 14px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
}
.alert-success { background: var(--success-light); color: var(--success); }
.alert-danger  { background: var(--danger-light);  color: var(--danger); }
.alert-warning { background: var(--warning-light); color: var(--warning); }
.alert-info    { background: var(--primary-light); color: var(--primary-dark); }
.alert svg { width: 18px; height: 18px; flex-shrink: 0; margin-top: 1px; }

/* ── LOGIN PAGE ── */
.login-wrapper {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: linear-gradient(160deg, var(--primary) 0%, #1565C0 100%);
  padding: 24px;
}
.login-box {
  background: var(--white);
  border-radius: var(--radius-xl);
  padding: 32px 24px;
  width: 100%;
  max-width: 380px;
  box-shadow: var(--shadow-lg);
}
.login-logo {
  text-align: center;
  margin-bottom: 24px;
}
.login-logo .logo-icon {
  width: 64px;
  height: 64px;
  background: var(--primary-light);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 12px;
}
.login-logo .logo-icon svg { width: 34px; height: 34px; color: var(--primary); }
.login-logo h2 { font-size: 22px; font-weight: 700; color: var(--gray-900); }
.login-logo p  { font-size: 13px; color: var(--gray-600); margin-top: 2px; }

/* ── KAMERA / SELFIE ── */
.kamera-box {
  background: var(--gray-900);
  border-radius: var(--radius-lg);
  overflow: hidden;
  position: relative;
  aspect-ratio: 4/3;
  margin-bottom: 12px;
}
#videoEl, #canvasEl {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
#canvasEl { display: none; }
.kamera-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  color: var(--white);
  gap: 8px;
  font-size: 14px;
  background: rgba(0,0,0,.45);
}
.kamera-overlay svg { width: 40px; height: 40px; opacity: .7; }
.snap-btn {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: var(--white);
  border: 4px solid rgba(255,255,255,.5);
  margin: 0 auto;
  cursor: pointer;
  transition: transform var(--transition);
}
.snap-btn:active { transform: scale(.9); }
.foto-preview {
  width: 100%;
  border-radius: var(--radius-md);
  margin-bottom: 12px;
  display: none;
  border: 2px solid var(--success);
}

/* ── GPS STATUS ── */
.gps-status {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--gray-600);
  padding: 10px 12px;
  background: var(--gray-100);
  border-radius: var(--radius-md);
  margin-bottom: 12px;
}
.gps-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--gray-400);
  flex-shrink: 0;
}
.gps-dot.ok      { background: var(--success); }
.gps-dot.error   { background: var(--danger); }
.gps-dot.loading { background: var(--warning); animation: pulse 1.2s infinite; }

/* ── REKAP TABLE ── */
.rekap-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.rekap-table th {
  background: var(--primary-light);
  color: var(--primary-dark);
  padding: 10px 8px;
  text-align: left;
  font-weight: 600;
  border-bottom: 2px solid var(--primary);
  white-space: nowrap;
}
.rekap-table td {
  padding: 10px 8px;
  border-bottom: 1px solid var(--gray-200);
  vertical-align: middle;
}
.rekap-table tr:last-child td { border-bottom: none; }
.rekap-table tr:hover td { background: var(--gray-50); }

/* ── STAT GRID ── */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-bottom: 14px;
}
.stat-card {
  background: var(--gray-50);
  border-radius: var(--radius-md);
  padding: 14px 12px;
  text-align: center;
  border: 1px solid var(--gray-200);
}
.stat-card .stat-num {
  font-size: 28px;
  font-weight: 700;
  line-height: 1.1;
  color: var(--primary);
}
.stat-card .stat-label {
  font-size: 11px;
  color: var(--gray-600);
  margin-top: 4px;
  font-weight: 500;
}

/* ── HISTORY ITEM ── */
.history-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--gray-200);
}
.history-item:last-child { border-bottom: none; }
.history-date {
  min-width: 44px;
  text-align: center;
  background: var(--primary-light);
  color: var(--primary-dark);
  border-radius: var(--radius-sm);
  padding: 6px 4px;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.2;
}
.history-info { flex: 1; }
.history-info .h-nama { font-size: 14px; font-weight: 500; }
.history-info .h-time { font-size: 12px; color: var(--gray-600); margin-top: 2px; }

/* ── PROFIL ── */
.profil-avatar {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: var(--primary);
  color: var(--white);
  font-size: 26px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 12px;
  flex-shrink: 0;
}

/* ── LOADING SPINNER ── */
.spinner {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 2.5px solid rgba(255,255,255,.4);
  border-top-color: var(--white);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}

/* ── TOAST ── */
#toast {
  position: fixed;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--gray-900);
  color: var(--white);
  padding: 12px 20px;
  border-radius: var(--radius-xl);
  font-size: 14px;
  z-index: 9999;
  opacity: 0;
  transition: all .3s ease;
  max-width: 320px;
  text-align: center;
  pointer-events: none;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ── TAB ── */
.tabs {
  display: flex;
  border-bottom: 2px solid var(--gray-200);
  margin-bottom: 16px;
}
.tab-btn {
  flex: 1;
  padding: 10px;
  background: none;
  border: none;
  font-size: 13px;
  font-weight: 600;
  color: var(--gray-600);
  cursor: pointer;
  border-bottom: 3px solid transparent;
  margin-bottom: -2px;
  transition: all var(--transition);
}
.tab-btn.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

/* ── ANIMATIONS ── */
@keyframes spin  { to { transform: rotate(360deg); } }
@keyframes pulse { 0%,100% { opacity:1; } 50% { opacity:.4; } }

/* ── SCROLLBAR ── */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-thumb { background: var(--gray-400); border-radius: 4px; }

/* ── RESPONSIVE ── */
@media (min-width: 480px) {
  .app-shell { border-radius: var(--radius-xl); margin-top: 16px; min-height: auto; }
}
