/* ==========================================================================
   PENAP — Sistem Absensi Apel Pagi · PN Biak
   Institutional design system: deep navy + gold, serif headings, Inter UI
   ========================================================================== */

:root {
  --navy: #0f2038;
  --navy-2: #16324f;
  --primary: #1f4e8c;
  --primary-600: #18406f;
  --accent: #b8912e;
  --accent-soft: #f5ead0;
  --ink: #1a2332;
  --muted: #5d6a7c;
  --border: #e3e8ef;
  --bg: #f3f5f9;
  --surface: #ffffff;
  --success: #1c7c4f;
  --success-bg: #e4f4ec;
  --danger: #bf3b31;
  --danger-bg: #fdecea;
  --warning: #a06a12;
  --warning-bg: #fbf3df;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow-sm: 0 1px 2px rgba(15, 32, 56, .05), 0 1px 3px rgba(15, 32, 56, .06);
  --shadow-md: 0 2px 6px rgba(15, 32, 56, .06), 0 12px 30px rgba(15, 32, 56, .09);
  --font-sans: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --font-serif: 'Source Serif 4', Georgia, 'Times New Roman', serif;
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.55 var(--font-sans);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1, h2, h3, h4 { color: var(--navy); font-weight: 700; letter-spacing: -.01em; }
p { margin: 0; }
a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-600); }

/* --------------------------------------------------------------------------
   Navigation
   -------------------------------------------------------------------------- */
nav {
  position: sticky;
  top: 0;
  z-index: 50;
  height: 66px;
  background: #fff;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 max(24px, calc((100% - 1120px) / 2));
}

.brand { display: flex; flex-direction: column; line-height: 1.12; }
.brand-mark {
  font-family: var(--font-serif);
  font-weight: 700;
  font-size: 20px;
  color: var(--navy);
  letter-spacing: .04em;
  display: flex;
  align-items: center;
  gap: 9px;
}
.brand-dot {
  width: 9px; height: 9px; border-radius: 2px;
  background: var(--accent); display: inline-block;
}
.brand-sub {
  font-size: 11.5px;
  color: var(--muted);
  letter-spacing: .02em;
  margin-top: 2px;
}
.nav-right { display: flex; align-items: center; gap: 16px; }
.user { color: var(--muted); font-size: 14px; font-weight: 500; }

/* Lonceng notifikasi */
.notif-bell {
  position: relative; display: inline-flex; align-items: center; justify-content: center;
  width: 38px; height: 38px; border-radius: 50%; color: var(--navy);
  background: #fff; border: 1px solid var(--border); text-decoration: none;
  transition: background .15s, border-color .15s;
}
.notif-bell:hover { background: var(--accent-soft); border-color: var(--accent); }
.notif-bell svg { width: 19px; height: 19px; }
.notif-badge {
  position: absolute; top: -4px; right: -4px; min-width: 18px; height: 18px;
  padding: 0 5px; border-radius: 9px; background: var(--danger); color: #fff;
  font-size: 10.5px; font-weight: 700; line-height: 18px; text-align: center;
  border: 2px solid #fff; box-sizing: content-box;
}

/* Halaman notifikasi */
.notif-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.notif-header form { margin: 0; }
.notif-list { display: grid; gap: 10px; }
.notif-item-form { margin: 0; }
.notif-item {
  width: 100%; display: flex; align-items: flex-start; gap: 12px; text-align: left;
  padding: 15px 16px; border-radius: var(--radius); border: 1px solid var(--border);
  background: #fff; box-shadow: var(--shadow-sm); font: inherit; cursor: pointer;
  transition: border-color .15s, box-shadow .15s, background .15s;
}
.notif-item:hover { border-color: var(--primary); box-shadow: var(--shadow-md); }
.notif-item.unread { background: #f7faff; border-color: #cfe0f5; }
.notif-dot {
  flex: 0 0 8px; width: 8px; height: 8px; margin-top: 7px; border-radius: 50%;
  background: var(--border);
}
.notif-item.unread .notif-dot { background: var(--primary); }
.notif-item.tipe-success .notif-dot { background: var(--success); }
.notif-item.tipe-danger .notif-dot { background: var(--danger); }
.notif-item.tipe-warning .notif-dot { background: var(--warning); }
.notif-item.tipe-rekap .notif-dot { background: var(--accent); }
.notif-body { flex: 1; min-width: 0; display: grid; gap: 3px; }
.notif-judul { font-weight: 600; font-size: 14.5px; color: var(--ink); }
.notif-pesan { font-size: 13.5px; color: var(--muted); line-height: 1.55; overflow-wrap: anywhere; }
.notif-time { font-size: 11.5px; color: #93a0b1; }
.notif-item.unread .notif-judul { color: var(--primary-600); }
.notif-arrow { align-self: center; color: var(--muted); font-size: 15px; }
.notif-empty { text-align: center; padding: 44px 24px; }
.notif-empty-icon { font-size: 40px; margin-bottom: 10px; }
.notif-empty h3 { margin: 0 0 6px; font-family: var(--font-serif); color: var(--ink); }
.notif-empty p { margin: 0; color: var(--muted); font-size: 13.5px; }

/* --------------------------------------------------------------------------
   Layout
   -------------------------------------------------------------------------- */
main {
  max-width: 1120px;
  margin: 0 auto;
  padding: 40px 24px 64px;
}

.page-container { max-width: 1120px; margin: 0 auto; }
.page-container.narrow { max-width: 720px; }

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 500;
  margin-bottom: 20px;
}
.back-link:hover { color: var(--primary); }

.page-header { margin-bottom: 26px; }
.page-header h1 { font-family: var(--font-serif); font-size: 30px; margin: 0 0 6px; }
.page-header p { color: var(--muted); font-size: 14px; }
.page-header h2 { font-family: var(--font-serif); font-size: 22px; margin: 0; }

.page-toolbar { display: flex; justify-content: flex-end; margin: -8px 0 18px; }

/* --------------------------------------------------------------------------
   Buttons
   -------------------------------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 0;
  border-radius: var(--radius-sm);
  background: var(--primary);
  color: #fff;
  padding: 11px 20px;
  font: 600 14px var(--font-sans);
  cursor: pointer;
  transition: background .15s ease, transform .05s ease, box-shadow .15s ease;
  box-shadow: var(--shadow-sm);
  line-height: 1.2;
}
.btn:hover { background: var(--primary-600); color: #fff; }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.btn.outline {
  background: #fff;
  color: var(--primary);
  border: 1px solid #c3d2e8;
  box-shadow: none;
  padding: 9px 16px;
}
.btn.outline:hover { background: #f4f7fb; color: var(--primary-600); border-color: var(--primary); }

.btn.full { width: 100%; }

.btn[disabled], .btn:disabled { opacity: .55; cursor: not-allowed; }

/* --------------------------------------------------------------------------
   Cards
   -------------------------------------------------------------------------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
  box-shadow: var(--shadow-sm);
}

.info-card {
  margin-top: 22px;
  background: #eef3fb;
  border: 1px solid #dbe6f4;
  border-radius: var(--radius);
  padding: 20px 22px;
  color: #29436b;
}
.info-card h3 { margin: 0 0 10px; font-size: 15px; }
.info-card ul { margin: 0; padding-left: 20px; line-height: 1.8; }
.info-card li { margin: 4px 0; }
.info-card strong { color: var(--navy); }

/* --------------------------------------------------------------------------
   Alerts
   -------------------------------------------------------------------------- */
.alert {
  padding: 13px 16px;
  border-radius: var(--radius-sm);
  margin-bottom: 18px;
  font-size: 14px;
  font-weight: 500;
  border: 1px solid transparent;
}
.alert.success { background: var(--success-bg); color: var(--success); border-color: #c5e8d5; }
.alert.error   { background: var(--danger-bg);  color: var(--danger);  border-color: #f4cfcc; }
.alert.warning { background: var(--warning-bg); color: var(--warning); border-color: #efe0bd; }
.alert.info    { background: #eef3fb; color: var(--primary); border-color: #dbe6f4; }

/* --------------------------------------------------------------------------
   Forms
   -------------------------------------------------------------------------- */
.form-group { margin-bottom: 18px; }
.form-group label {
  display: block;
  font-weight: 600;
  margin-bottom: 7px;
  font-size: 13px;
  color: var(--navy);
}
.form-group input,
.form-group select,
.form-group textarea,
.search-row input {
  width: 100%;
  border: 1px solid #d5dce6;
  border-radius: var(--radius-sm);
  padding: 11px 13px;
  font: 15px var(--font-sans);
  color: var(--ink);
  background: #fff;
  outline: none;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus,
.search-row input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(31, 78, 140, .13);
}
.form-group textarea { resize: vertical; min-height: 88px; }

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.form-actions { margin-top: 8px; }

.search-row { display: flex; align-items: flex-end; gap: 14px; flex-wrap: wrap; }
.search-row label { font-weight: 600; font-size: 13px; color: var(--navy); }
.search-row input { max-width: 200px; }
.search-row .btn { padding: 11px 18px; }

/* --------------------------------------------------------------------------
   Dashboard header + action cards
   -------------------------------------------------------------------------- */
.dashboard-header { margin-bottom: 28px; }
.dashboard-header h1 { font-family: var(--font-serif); font-size: 30px; margin: 0 0 6px; }
.dashboard-header p { color: var(--muted); }

.actions-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 18px;
}
.actions-grid.admin { grid-template-columns: repeat(3, 1fr); }

.action-card {
  display: flex;
  flex-direction: column;
  gap: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  color: var(--ink);
  transition: border-color .18s ease, transform .18s ease, box-shadow .18s ease;
  box-shadow: var(--shadow-sm);
}
.action-card:hover {
  border-color: #c2d2ea;
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  color: var(--ink);
}
.action-card .icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 46px; height: 46px;
  border-radius: 10px;
  background: var(--accent-soft);
  color: #8a6a1c;
  margin-bottom: 10px;
}
.action-card .icon svg { width: 24px; height: 24px; }
.action-card h3 { margin: 0; font-size: 16px; color: var(--navy); }
.action-card p { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.5; }

/* --------------------------------------------------------------------------
   Tables
   -------------------------------------------------------------------------- */
.table-wrap { overflow-x: auto; padding: 0; }
.table-header { padding: 18px 22px; border-bottom: 1px solid var(--border); font-weight: 600; }

table { width: 100%; border-collapse: collapse; min-width: 620px; }
th, td {
  text-align: left;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
  vertical-align: middle;
}
th {
  background: #fafbfd;
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .05em;
  font-weight: 600;
  white-space: nowrap;
}
tbody tr { transition: background .12s ease; }
tbody tr:hover { background: #f8fafc; }
tr:last-child td { border-bottom: 0; }
td a { color: var(--primary); font-weight: 500; }
td small { color: var(--muted); }

.badge {
  display: inline-block;
  padding: 5px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}
.badge.success { background: var(--success-bg); color: var(--success); }
.badge.danger  { background: var(--danger-bg);  color: var(--danger); }
.badge.pending { background: var(--warning-bg); color: var(--warning); }

.empty, .empty-state { text-align: center; color: var(--muted); padding: 38px 20px; }
.empty-text { color: var(--muted); }

/* --------------------------------------------------------------------------
   Print header (laporan)
   -------------------------------------------------------------------------- */
.print-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}
.print-info { color: var(--muted); line-height: 1.7; font-size: 14px; }
.print-info strong { color: var(--navy); }
.print-actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }

/* --------------------------------------------------------------------------
   Camera widget (absen)
   -------------------------------------------------------------------------- */
.camera-box { padding: 20px; }
.camera-preview {
  height: 380px;
  border-radius: 10px;
  background: #0d141f;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}
.camera-placeholder { text-align: center; color: #c7d2df; padding: 20px; }
.camera-placeholder .icon {
  font-size: 44px; margin-bottom: 10px; display: block;
}
.camera-placeholder p { margin: 0 0 4px; font-weight: 500; }
.camera-placeholder small { color: #8293a6; }
#video, #photoPreview { width: 100%; height: 100%; object-fit: cover; display: none; }
#canvas { display: none; }
.camera-controls { text-align: center; padding: 18px 0 4px; display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.camera-controls .btn { margin: 0; }
.file-note { font-size: 12px; color: var(--muted); margin: 8px 0 20px; }

.geo-blocked {
  min-height: 300px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
}
.geo-blocked .geo-icon {
  font-size: 46px;
  margin-bottom: 12px;
  display: block;
}
.geo-blocked p { font-weight: 600; color: var(--danger); margin: 0 0 6px; font-size: 16px; }
.geo-blocked small { color: var(--muted); }

/* Absen wajib dari HP */
.device-blocked { text-align: center; padding: 14px 8px 6px; }
.device-blocked .device-icon { font-size: 52px; line-height: 1; margin-bottom: 10px; }
.device-blocked h2 { font-size: 20px; margin: 0 0 10px; color: var(--ink); }
.device-blocked p { margin: 0 auto 14px; max-width: 44ch; color: var(--muted); line-height: 1.6; }
.device-blocked ul { text-align: left; max-width: 42ch; margin: 0 auto 14px; padding-left: 20px; color: var(--muted); line-height: 1.75; }
.device-blocked ul strong { color: var(--ink); }
.device-blocked small { display: block; max-width: 46ch; margin: 0 auto; color: var(--muted); font-size: 12px; line-height: 1.6; }

/* --------------------------------------------------------------------------
   Map (pengaturan)
   -------------------------------------------------------------------------- */
.map-wrap { margin-bottom: 8px; }
.mini-map {
  height: 300px;
  border-radius: 10px;
  border: 1px solid var(--border);
  z-index: 0;
}
.map-actions { margin-top: 10px; }
.map-actions .btn { font-size: 13px; }

/* --------------------------------------------------------------------------
   Toggle switch
   -------------------------------------------------------------------------- */
.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 16px 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 22px;
}
.toggle-row h3 { font-size: 15px; margin: 0 0 4px; }
.switch { position: relative; display: inline-block; width: 50px; height: 28px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider {
  position: absolute; cursor: pointer; inset: 0;
  background: #cbd5df; border-radius: 28px; transition: .25s;
}
.slider:before {
  position: absolute; content: ""; height: 22px; width: 22px;
  left: 3px; top: 3px; background: #fff; border-radius: 50%;
  transition: .25s; box-shadow: 0 1px 2px rgba(0,0,0,.18);
}
.switch input:checked + .slider { background: var(--primary); }
.switch input:checked + .slider:before { transform: translateX(22px); }

/* --------------------------------------------------------------------------
   Login (split-screen)
   -------------------------------------------------------------------------- */
.login-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1fr 1fr;
}

.login-brand-panel {
  background: linear-gradient(160deg, #0d1b30 0%, #1a3457 100%);
  color: #fff;
  display: flex;
  align-items: center;
  padding: 64px;
  position: relative;
  overflow: hidden;
}
.login-brand-panel::after {
  content: "";
  position: absolute;
  right: -120px; bottom: -120px;
  width: 340px; height: 340px;
  border-radius: 50%;
  border: 1px solid rgba(200, 162, 39, .28);
}
.login-brand-panel::before {
  content: "";
  position: absolute;
  right: -60px; bottom: -60px;
  width: 190px; height: 190px;
  border-radius: 50%;
  border: 1px solid rgba(200, 162, 39, .4);
}
.login-brand-inner { position: relative; z-index: 1; max-width: 420px; }
.login-brand-mark {
  font-family: var(--font-serif);
  font-weight: 700;
  font-size: 34px;
  letter-spacing: .05em;
  color: #f0d9a0;
  margin-bottom: 18px;
}
.login-brand-sub { font-size: 14px; color: rgba(255,255,255,.65); letter-spacing: .04em; text-transform: uppercase; }
.login-brand-inner h2 {
  font-family: var(--font-serif);
  font-size: 30px;
  color: #fff;
  margin: 12px 0 16px;
  line-height: 1.25;
}
.login-brand-desc { color: rgba(255,255,255,.72); font-size: 15px; line-height: 1.7; }

.login-form-panel {
  background: var(--surface);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 24px;
}
.login-card { width: 100%; max-width: 400px; }
.login-header { margin-bottom: 26px; }
.login-header h1 { font-family: var(--font-serif); font-size: 28px; margin: 0 0 6px; }
.login-header p { color: var(--muted); }
.login-foot { text-align: center; color: var(--muted); font-size: 13px; margin-top: 22px; }

/* ganti-password reuses centered card on authed pages */
.login-container { max-width: 440px; margin: 2vh auto; }

/* --------------------------------------------------------------------------
   Responsive
   -------------------------------------------------------------------------- */
@media (max-width: 900px) {
  .login-shell { grid-template-columns: 1fr; }
  .login-brand-panel { display: none; }
}

@media (max-width: 700px) {
  main { padding: 26px 16px 48px; }
  nav { padding: 0 16px; }
  .user { display: none; }
  .brand-sub { display: none; }
  .actions-grid, .actions-grid.admin { grid-template-columns: 1fr; }
  .dashboard-header h1, .page-header h1 { font-size: 25px; }
  .card, .login-card { padding: 22px; }
  .camera-preview { height: 300px; }
  .form-row { grid-template-columns: 1fr; gap: 0; }
  .search-row { align-items: stretch; flex-direction: column; }
  .search-row input { max-width: none; }
  .print-header { align-items: flex-start; flex-direction: column; }
}

/* --------------------------------------------------------------------------
   Print
   -------------------------------------------------------------------------- */
@media print {
  nav, .back-link, .search-box, .page-toolbar, .btn { display: none !important; }
  body, main { background: #fff !important; padding: 0 !important; }
  .page-container { max-width: none !important; }
  .card { box-shadow: none; border: 1px solid #ddd; padding: 8px; }
  .table-wrap { overflow: visible; }
  table { min-width: 0 !important; width: 100% !important; }
  tr, td, th { break-inside: avoid; page-break-inside: avoid; }
  th { background: #eee !important; color: #000 !important; }
  .badge {
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
    border: 1px solid currentColor;
  }
  .badge.success { color: #1c7c4f !important; background: #e4f4ec !important; }
  .badge.danger  { color: #bf3b31 !important; background: #fdecea !important; }
}