/* ============================================================
   EMS / Attendance System - Modern Theme
   Built on Bootstrap 5.3 + Bootstrap Icons
   ============================================================ */

:root {
  --bs-primary: #4f46e5;
  --bs-primary-rgb: 79, 70, 229;
  --brand-grad: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
  --surface: #ffffff;
  --surface-2: #f6f7fb;
  --border-soft: #eceef3;
  --text-muted: #6b7280;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .04);
  --shadow-md: 0 4px 12px rgba(16, 24, 40, .08);
  --shadow-lg: 0 12px 32px rgba(16, 24, 40, .12);
  --radius: 14px;
}

* { -webkit-tap-highlight-color: transparent; }

html { scroll-behavior: smooth; }

body {
  background: var(--surface-2);
  color: #111827;
  font-family: "Inter", "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
}

/* ---------- Navbar ---------- */
.app-navbar {
  background: var(--brand-grad);
  box-shadow: var(--shadow-md);
  padding: .5rem 1rem;
}
.app-navbar .navbar-brand {
  font-weight: 700;
  letter-spacing: .2px;
  display: flex;
  align-items: center;
  gap: .5rem;
  white-space: nowrap;
}
.app-navbar .navbar-brand .brand-dot {
  width: 30px; height: 30px;
  background: rgba(255,255,255,.18);
  border-radius: 9px;
  display: grid; place-items: center;
  font-size: 1.05rem;
}
/* Allow the nav list to WRAP to multiple rows on desktop so all items stay
   visible instead of overflowing off-screen. */
.app-navbar .navbar-nav {
  flex-wrap: wrap;
  row-gap: 2px;
}
.app-navbar .nav-link {
  color: rgba(255,255,255,.85) !important;
  border-radius: 8px;
  padding: .4rem .65rem !important;
  margin: 1px 1px;
  font-weight: 500;
  font-size: .9rem;
  display: flex;
  align-items: center;
  gap: .4rem;
  white-space: nowrap;
  transition: background .15s, color .15s;
}
.app-navbar .nav-link:hover { background: rgba(255,255,255,.14); color: #fff !important; }
.app-navbar .nav-link.active { background: rgba(255,255,255,.22); color: #fff !important; }
.app-navbar .nav-link i { font-size: 1rem; }

.app-navbar .navbar-toggler {
  border-color: rgba(255,255,255,.35);
  padding: .35rem .55rem;
}
.app-navbar .navbar-toggler:focus { box-shadow: 0 0 0 3px rgba(255,255,255,.25); }

/* Make sure the right-side user chip aligns with the brand row, not the
   wrapping nav. Push it to its own line on small desktops if needed. */
.app-navbar .navbar-collapse { align-items: flex-end; }

.user-chip {
  display: flex; align-items: center; gap: .5rem;
  background: rgba(255,255,255,.16);
  padding: .3rem .7rem .3rem .35rem;
  border-radius: 999px;
  color: #fff;
  font-weight: 500;
  font-size: .9rem;
}
.user-chip .avatar {
  width: 30px; height: 30px; border-radius: 50%;
  background: rgba(255,255,255,.25);
  display: grid; place-items: center;
  font-weight: 700; font-size: .8rem;
}

/* ---------- Layout ---------- */
.app-container { max-width: 1200px; margin: 0 auto; padding: 1.1rem; }
.page-head { margin-bottom: 1.1rem; }
.page-head h1, .page-head h3 {
  margin: 0; font-weight: 700; font-size: 1.4rem;
  display: flex; align-items: center; gap: .5rem;
}
.page-head .sub { color: var(--text-muted); font-size: .9rem; margin-top: .2rem; }

/* ---------- Cards ---------- */
.card {
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  background: var(--surface);
}
.card-header {
  background: #fff;
  border-bottom: 1px solid var(--border-soft);
  font-weight: 600;
  border-radius: var(--radius) var(--radius) 0 0 !important;
  padding: .85rem 1.1rem;
}
.card-body { padding: 1.1rem; }

/* ---------- Stat cards ---------- */
.stat-card {
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 1.1rem 1.2rem;
  box-shadow: var(--shadow-sm);
  display: flex; align-items: center; gap: 1rem;
  height: 100%;
  transition: transform .15s, box-shadow .15s;
}
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.stat-card .ico {
  width: 50px; height: 50px; border-radius: 12px;
  display: grid; place-items: center; font-size: 1.4rem; color: #fff;
  flex-shrink: 0;
}
.stat-card .num { font-size: 1.6rem; font-weight: 700; line-height: 1; }
.stat-card .lbl { color: var(--text-muted); font-size: .82rem; margin-top: .25rem; }
.ico-indigo { background: linear-gradient(135deg,#4f46e5,#7c3aed); }
.ico-green   { background: linear-gradient(135deg,#10b981,#059669); }
.ico-rose    { background: linear-gradient(135deg,#f43f5e,#e11d48); }
.ico-amber   { background: linear-gradient(135deg,#f59e0b,#d97706); }
.ico-sky     { background: linear-gradient(135deg,#0ea5e9,#2563eb); }
.ico-slate   { background: linear-gradient(135deg,#64748b,#334155); }

/* ---------- Buttons ---------- */
.btn { border-radius: 10px; font-weight: 600; }
.btn-lg { border-radius: 12px; }
.btn-primary { background: var(--bs-primary); border-color: var(--bs-primary); }
.btn-primary:hover { background: #4338ca; border-color: #4338ca; }
.btn-soft { background: #eef2ff; color: #4338ca; border: 1px solid #e0e7ff; }
.btn-soft:hover { background: #e0e7ff; color: #3730a3; }

/* ---------- Punch UI ---------- */
.punch-stage {
  position: relative;
  border-radius: var(--radius);
  overflow: hidden;
  background: #111827;
  aspect-ratio: 3/4;
  max-height: 60vh;
  width: 100%;
  margin: 0 auto;
  box-shadow: var(--shadow-lg);
}
.punch-stage video, .punch-stage canvas {
  width: 100%; height: 100%; object-fit: cover; display: block;
}
.punch-overlay {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; justify-content: space-between;
  padding: 1rem;
  pointer-events: none;
  background: linear-gradient(to bottom, rgba(0,0,0,.45) 0%, rgba(0,0,0,0) 25%, rgba(0,0,0,0) 70%, rgba(0,0,0,.55) 100%);
  color: #fff;
}
.punch-tag {
  align-self: flex-start;
  background: rgba(0,0,0,.45);
  border: 1px solid rgba(255,255,255,.2);
  padding: .3rem .7rem; border-radius: 999px;
  font-size: .78rem; font-weight: 600;
  display: flex; align-items: center; gap: .4rem;
  backdrop-filter: blur(4px);
}
.gps-pill {
  align-self: flex-start;
  background: rgba(0,0,0,.45);
  border: 1px solid rgba(255,255,255,.2);
  padding: .35rem .7rem; border-radius: 999px;
  font-size: .76rem; font-weight: 600;
  display: inline-flex; align-items: center; gap: .4rem;
  backdrop-filter: blur(4px);
}
.gps-dot { width: 9px; height: 9px; border-radius: 50%; background: #f59e0b; box-shadow: 0 0 0 0 rgba(245,158,11,.6); animation: gpspulse 1.4s infinite; }
.gps-dot.ok { background: #22c55e; animation: none; }
.gps-dot.err { background: #ef4444; animation: none; }
@keyframes gpspulse { 0%{box-shadow:0 0 0 0 rgba(245,158,11,.5)} 70%{box-shadow:0 0 0 8px rgba(245,158,11,0)} 100%{box-shadow:0 0 0 0 rgba(245,158,11,0)} }

.punch-capture-btn {
  position: absolute; bottom: 18px; left: 50%; transform: translateX(-50%);
  width: 74px; height: 74px; border-radius: 50%;
  background: #fff; border: 4px solid rgba(255,255,255,.85);
  box-shadow: 0 0 0 4px rgba(255,255,255,.25), var(--shadow-lg);
  display: grid; place-items: center; color: #111827; font-size: 1.6rem;
  cursor: pointer; pointer-events: auto;
  transition: transform .1s;
}
.punch-capture-btn:active { transform: translateX(-50%) scale(.94); }
.punch-capture-btn:disabled { opacity: .5; cursor: not-allowed; }

.punch-switch {
  position: absolute; top: 14px; right: 14px;
  background: rgba(0,0,0,.45); border: 1px solid rgba(255,255,255,.25);
  color: #fff; border-radius: 10px; padding: .4rem .55rem;
  font-size: 1.1rem; pointer-events: auto; cursor: pointer; backdrop-filter: blur(4px);
}

.punch-big {
  width: 100%; border-radius: 16px; padding: 1.1rem;
  font-size: 1.15rem; font-weight: 700; letter-spacing: .3px;
  display: flex; align-items: center; justify-content: center; gap: .6rem;
  box-shadow: var(--shadow-md);
  border: none; transition: transform .08s, box-shadow .15s;
}
.punch-big:active { transform: scale(.98); }
.punch-big.in  { background: linear-gradient(135deg,#10b981,#059669); color: #fff; }
.punch-big.out { background: linear-gradient(135deg,#f43f5e,#e11d48); color: #fff; }
.punch-big:disabled { opacity: .6; }

/* timeline */
.timeline { list-style: none; padding: 0; margin: 0; }
.timeline li { display: flex; gap: .8rem; padding: .6rem 0; border-bottom: 1px solid var(--border-soft); }
.timeline li:last-child { border-bottom: none; }
.timeline .tl-dot {
  width: 34px; height: 34px; border-radius: 10px; flex-shrink: 0;
  display: grid; place-items: center; color: #fff; font-size: .95rem;
}
.tl-in  { background: linear-gradient(135deg,#10b981,#059669); }
.tl-out { background: linear-gradient(135deg,#f43f5e,#e11d48); }
.timeline .tl-main { font-weight: 600; line-height: 1.2; }
.timeline .tl-sub { color: var(--text-muted); font-size: .82rem; }

/* ---------- Tables ---------- */
.table { margin-bottom: 0; vertical-align: middle; }
.table thead th {
  font-size: .76rem; text-transform: uppercase; letter-spacing: .5px;
  color: var(--text-muted); font-weight: 700;
  border-bottom: 1px solid var(--border-soft);
  background: #fbfbfe;
}
.table td { border-color: var(--border-soft); padding: .7rem .8rem; }
.table-striped > tbody > tr:nth-of-type(odd) > * { background: #fafbff; }

.badge-soft-success { background:#d1fae5; color:#065f46; }
.badge-soft-danger  { background:#ffe4e6; color:#9f1239; }
.badge-soft-warning { background:#fef3c7; color:#92400e; }
.badge-soft-info    { background:#e0f2fe; color:#075985; }
.badge-soft-secondary { background:#eef2f7; color:#374151; }

/* ---------- Forms ---------- */
.form-label { font-weight: 600; font-size: .85rem; margin-bottom: .35rem; }
.form-control, .form-select { border-radius: 10px; border-color: #d8dbe5; padding: .6rem .8rem; }
.form-control:focus, .form-select:focus { border-color: var(--bs-primary); box-shadow: 0 0 0 3px rgba(79,70,229,.15); }

/* ---------- Misc ---------- */
.text-muted-2 { color: var(--text-muted) !important; }
.cursor-pointer { cursor: pointer; }
.divider { height: 1px; background: var(--border-soft); margin: 1rem 0; }
.empty-state { text-align: center; padding: 2.5rem 1rem; color: var(--text-muted); }
.empty-state i { font-size: 2.6rem; opacity: .5; display: block; margin-bottom: .5rem; }

@media (max-width: 575.98px) {
  .app-container { padding: .8rem; }
  .page-head h1, .page-head h3 { font-size: 1.2rem; }
  .app-navbar .nav-link { margin: 2px 0; }
  .stat-card .num { font-size: 1.35rem; }
}

/* When the collapsed mobile menu opens, stack items full-width with labels */
@media (max-width: 991.98px) {
  .app-navbar .navbar-nav { flex-direction: column; width: 100%; }
  .app-navbar .nav-link { width: 100%; }
  .app-navbar .navbar-collapse { align-items: stretch; }
}
