:root {
  --brand-blue: #0d6efd;
  --brand-blue-dark: #0a58ca;
  --bg-soft: #f4f6f9;
  --sidebar-bg: #101a2e;
  --sidebar-active: #0d6efd;
}

* { box-sizing: border-box; }

body { background: var(--bg-soft); font-family: 'Segoe UI', system-ui, sans-serif; }

/* ============ LOGIN ============ */
.login-body {
  background: linear-gradient(135deg, #0d6efd 0%, #101a2e 100%);
  min-height: 100vh;
}
.login-card {
  width: 100%;
  max-width: 420px;
  border-radius: 16px;
}

/* ============ ADMIN LAYOUT ============ */
.app-wrapper { display: flex; min-height: 100vh; }

.sidebar {
  width: 260px;
  background: var(--sidebar-bg);
  color: #fff;
  position: fixed;
  top: 0; bottom: 0; left: 0;
  overflow-y: auto;
  z-index: 1030;
  transition: transform .25s ease;
}
.sidebar-brand {
  padding: 20px 18px;
  font-weight: 700;
  font-size: 1.05rem;
  display: flex;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid rgba(255,255,255,.08);
  white-space: nowrap;
  overflow: hidden;
}
.sidebar-brand span { overflow: hidden; text-overflow: ellipsis; flex: 1; }
.sidebar-nav { padding: 10px 0; }
.sidebar-nav .nav-link {
  color: rgba(255,255,255,.75);
  padding: 11px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: .9rem;
  border-left: 3px solid transparent;
  white-space: nowrap;
  overflow: hidden;
}
.sidebar-nav .nav-link i { font-size: 1.05rem; min-width: 20px; text-align: center; }
.sidebar-nav .nav-link:hover { background: rgba(255,255,255,.06); color: #fff; }
.sidebar-nav .nav-link.active {
  background: rgba(13,110,253,.15);
  color: #fff;
  border-left-color: var(--sidebar-active);
  font-weight: 600;
}

/* Tombol ciutkan/perluas sidebar (desktop) */
.sidebar-collapse-btn {
  background: rgba(255,255,255,.08);
  border: none;
  color: #fff;
  width: 28px;
  height: 28px;
  border-radius: 6px;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background .15s, transform .25s ease;
}
.sidebar-collapse-btn:hover { background: rgba(255,255,255,.18); }

.main-content { margin-left: 260px; flex: 1; display: flex; flex-direction: column; min-width: 0; transition: margin-left .25s ease; }

/* ============ SIDEBAR CIUT (icon-only) - DESKTOP ============ */
.app-wrapper.sidebar-collapsed .sidebar { width: 74px; }
.app-wrapper.sidebar-collapsed .sidebar-brand span,
.app-wrapper.sidebar-collapsed .sidebar-nav .nav-link span { display: none; }
.app-wrapper.sidebar-collapsed .sidebar-brand { justify-content: center; padding: 20px 10px; }
.app-wrapper.sidebar-collapsed .sidebar-brand > i { display: none; }
.app-wrapper.sidebar-collapsed .sidebar-collapse-btn { transform: rotate(180deg); }
.app-wrapper.sidebar-collapsed .sidebar-nav .nav-link { justify-content: center; padding: 12px 0; }
.app-wrapper.sidebar-collapsed .main-content { margin-left: 74px; }

/* Overlay untuk mobile saat sidebar terbuka */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.4);
  z-index: 1025;
}
.sidebar-overlay.show { display: block; }

.topbar {
  background: #fff;
  padding: 12px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid #e5e9f0;
  position: sticky;
  top: 0;
  z-index: 1020;
}

.page-content { padding: 22px; flex: 1; }

.stat-card {
  border-radius: 14px;
  border: none;
  box-shadow: 0 2px 10px rgba(0,0,0,.05);
  transition: transform .15s;
}
.stat-card:hover { transform: translateY(-3px); }
.stat-card-link { cursor: pointer; }
.stat-card-link:hover { box-shadow: 0 6px 18px rgba(13,110,253,.18); }
.stat-icon {
  width: 48px; height: 48px;
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.4rem;
}

/* ============ FOTO ABSEN (thumbnail & modal) ============ */
.attendance-thumb {
  width: 32px;
  height: 32px;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid #dfe4ec;
  cursor: pointer;
  transition: transform .15s;
}
.attendance-thumb:hover { transform: scale(1.2); border-color: var(--brand-blue); }

@media (max-width: 991.98px) {
  .sidebar { transform: translateX(-100%); width: 260px; }
  .sidebar.show { transform: translateX(0); }
  .main-content { margin-left: 0; }
  /* Di mobile, status "ciutkan" desktop tidak berlaku - sidebar tetap full width saat dibuka */
  .app-wrapper.sidebar-collapsed .sidebar { width: 260px; }
  .app-wrapper.sidebar-collapsed .sidebar-brand span,
  .app-wrapper.sidebar-collapsed .sidebar-nav .nav-link span { display: inline; }
  .app-wrapper.sidebar-collapsed .sidebar-brand { justify-content: flex-start; padding: 20px 18px; }
  .app-wrapper.sidebar-collapsed .sidebar-brand > i { display: inline-block; }
  .app-wrapper.sidebar-collapsed .sidebar-nav .nav-link { justify-content: flex-start; padding: 11px 20px; }
  .app-wrapper.sidebar-collapsed .main-content { margin-left: 0; }
}

/* ============ DARK MODE ============ */
[data-bs-theme="dark"] body,
body[data-bs-theme="dark"] { background: #12161f; }
[data-bs-theme="dark"] .topbar,
[data-bs-theme="dark"] .card { background: #1b2130 !important; color: #e7ecf3; }
[data-bs-theme="dark"] .page-content { color: #e7ecf3; }

/* ============ USER / MOBILE ATTENDANCE ============ */
.user-body { padding-bottom: 70px; }
.user-main { max-width: 560px; margin: 0 auto; }

.attendance-card {
  border-radius: 20px;
  border: none;
  box-shadow: 0 4px 18px rgba(0,0,0,.06);
}

.clock-display {
  font-size: 2.4rem;
  font-weight: 700;
  letter-spacing: 1px;
}

.gps-status-badge { font-size: .8rem; padding: 6px 12px; border-radius: 20px; }

/* ============ FOTO ABSEN - Riwayat Pegawai (kartu) ============ */
.history-thumb {
  width: 44px;
  height: 44px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid #dfe4ec;
  cursor: pointer;
  transition: transform .15s;
}
.history-thumb:hover { transform: scale(1.15); border-color: var(--brand-blue); }

.btn-attend {
  border-radius: 16px;
  padding: 16px;
  font-weight: 600;
  font-size: 1.05rem;
}

.bottom-nav {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  background: #fff;
  border-top: 1px solid #e5e9f0;
  z-index: 1040;
}
.bottom-nav-link {
  flex: 1;
  text-align: center;
  padding: 8px 0 6px;
  color: #8a94a6;
  font-size: .72rem;
  text-decoration: none;
}
.bottom-nav-link i { display: block; font-size: 1.3rem; margin-bottom: 2px; }
.bottom-nav-link.active { color: var(--brand-blue); font-weight: 600; }

.selfie-preview {
  width: 100%;
  max-width: 260px;
  border-radius: 14px;
  border: 2px dashed #c7d0dc;
}

.badge-status { font-size: .78rem; padding: .4em .7em; }

@media (max-width: 320px) {
  .clock-display { font-size: 1.9rem; }
}
