/* ============================================================
   SIPENJAGA PPPK-PW - Stylesheet
   Desain modern sidebar, mobile-first, PWA-ready
   ============================================================ */

/* Reset & Base */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --primary:   #1a5276;
  --primary-d: #154360;
  --primary-l: #2e86c1;
  --accent:    #e67e22;
  --accent-d:  #ca6f1e;
  --success:   #27ae60;
  --danger:    #c0392b;
  --warning:   #f39c12;
  --info:      #2980b9;
  --gray-100:  #f8f9fa;
  --gray-200:  #e9ecef;
  --gray-300:  #dee2e6;
  --gray-500:  #adb5bd;
  --gray-700:  #495057;
  --gray-900:  #212529;
  --sidebar-w: 270px;
  --topbar-h:  56px;
  --radius:    8px;
  --shadow:    0 2px 8px rgba(0,0,0,.12);
  --shadow-lg: 0 4px 20px rgba(0,0,0,.18);
  --trans:     .2s ease;
}
html { font-size: 14px; scroll-behavior: smooth; }
body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--gray-100);
  color: var(--gray-900);
  min-height: 100vh;
}
a { color: var(--primary); text-decoration: none; }
svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; vertical-align: middle; }

/* ============================================================
   SIDEBAR
   ============================================================ */
.sidebar {
  position: fixed; top: 0; left: 0;
  width: var(--sidebar-w); height: 100vh;
  background: linear-gradient(160deg, var(--primary-d) 0%, var(--primary) 60%, var(--primary-l) 100%);
  color: #fff;
  display: flex; flex-direction: column;
  z-index: 1000;
  transform: translateX(-100%);
  transition: transform var(--trans);
  overflow-y: auto;
  overflow-x: hidden;
}
.sidebar.open { transform: translateX(0); box-shadow: var(--shadow-lg); }

@media (min-width: 992px) {
  .sidebar { transform: translateX(0); box-shadow: none; }
  .sidebar-overlay { display: none !important; }
  .topbar { left: var(--sidebar-w); }
  .main-content { margin-left: var(--sidebar-w); }
}

.sidebar-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 999;
}
.sidebar-overlay.show { display: block; }

.sidebar-header {
  display: flex; align-items: center; gap: 10px;
  padding: 18px 16px 14px;
  border-bottom: 1px solid rgba(255,255,255,.15);
}
.sidebar-title { font-size: 1rem; font-weight: 700; line-height: 1.2; }
.sidebar-subtitle { font-size: .72rem; opacity: .7; }
.sidebar-close {
  margin-left: auto; background: none; border: none;
  color: #fff; font-size: 1.2rem; cursor: pointer;
  padding: 4px 8px; border-radius: 4px;
  display: none;
}
@media (max-width: 991px) { .sidebar-close { display: block; } }

.sidebar-user {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 16px;
  background: rgba(0,0,0,.15);
}
.sidebar-user-avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--accent);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 1rem; flex-shrink: 0;
}
.sidebar-user-name { font-size: .85rem; font-weight: 600; }
.sidebar-user-role { font-size: .72rem; opacity: .7; text-transform: capitalize; }

.sidebar-menu {
  list-style: none; padding: 8px 0; flex: 1;
}
.sidebar-menu li a {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 18px;
  color: rgba(255,255,255,.85);
  font-size: .875rem;
  transition: background var(--trans), color var(--trans);
  border-left: 3px solid transparent;
  position: relative;
}
.sidebar-menu li a:hover { background: rgba(255,255,255,.1); color: #fff; }
.sidebar-menu li a.active {
  background: rgba(255,255,255,.18);
  color: #fff; font-weight: 600;
  border-left-color: var(--accent);
}
.sidebar-menu li a svg { flex-shrink: 0; opacity: .8; }
.sidebar-menu li a.active svg { opacity: 1; }
.sidebar-section {
  padding: 12px 18px 4px;
  font-size: .65rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: .08em;
  color: rgba(255,255,255,.45);
}
.badge {
  margin-left: auto;
  background: var(--accent); color: #fff;
  font-size: .65rem; font-weight: 700;
  min-width: 18px; height: 18px;
  border-radius: 9px; padding: 0 5px;
  display: flex; align-items: center; justify-content: center;
}

/* ============================================================
   TOPBAR
   ============================================================ */
.topbar {
  position: fixed; top: 0; left: 0; right: 0;
  height: var(--topbar-h);
  background: var(--primary);
  color: #fff;
  display: flex; align-items: center;
  padding: 0 16px;
  gap: 12px;
  z-index: 900;
  box-shadow: 0 2px 6px rgba(0,0,0,.2);
  transition: left var(--trans);
}
.topbar-menu-btn {
  background: none; border: none; cursor: pointer;
  display: flex; flex-direction: column; gap: 4px; padding: 6px;
}
.topbar-menu-btn span {
  display: block; width: 22px; height: 2px;
  background: #fff; border-radius: 2px;
  transition: var(--trans);
}
@media (min-width: 992px) { .topbar-menu-btn { display: none; } }
.topbar-title { font-size: .95rem; font-weight: 600; flex: 1; }
.topbar-right { font-size: .75rem; opacity: .8; white-space: nowrap; }
.topbar-date { display: none; }
@media (min-width: 480px) { .topbar-date { display: inline; } }

/* ============================================================
   MAIN CONTENT
   ============================================================ */
.main-content {
  padding-top: calc(var(--topbar-h) + 16px);
  padding-left: 16px; padding-right: 16px; padding-bottom: 80px;
  min-height: 100vh;
  transition: margin-left var(--trans);
}
@media (min-width: 992px) {
  .main-content { padding-left: 24px; padding-right: 24px; padding-bottom: 32px; }
}

/* ============================================================
   CARDS & GRID
   ============================================================ */
.card {
  background: #fff; border-radius: var(--radius);
  box-shadow: var(--shadow); margin-bottom: 16px; overflow: hidden;
}
.card-header {
  padding: 14px 16px;
  border-bottom: 1px solid var(--gray-200);
  display: flex; align-items: center; justify-content: space-between;
  gap: 8px;
}
.card-title { font-size: .95rem; font-weight: 600; color: var(--primary); }
.card-body { padding: 16px; }
.card-footer {
  padding: 10px 16px;
  border-top: 1px solid var(--gray-200);
  background: var(--gray-100);
}

.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.grid-4 { grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); }

/* Stat Cards */
.stat-card {
  background: #fff; border-radius: var(--radius);
  padding: 16px; box-shadow: var(--shadow);
  display: flex; align-items: center; gap: 12px;
  border-left: 4px solid var(--primary);
}
.stat-card.accent  { border-left-color: var(--accent); }
.stat-card.success { border-left-color: var(--success); }
.stat-card.warning { border-left-color: var(--warning); }
.stat-card.danger  { border-left-color: var(--danger); }
.stat-icon {
  width: 44px; height: 44px; border-radius: 50%;
  background: var(--gray-100);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; color: var(--primary);
}
.stat-card.accent  .stat-icon { color: var(--accent); }
.stat-card.success .stat-icon { color: var(--success); }
.stat-card.warning .stat-icon { color: var(--warning); }
.stat-card.danger  .stat-icon { color: var(--danger); }
.stat-value { font-size: 1.5rem; font-weight: 700; line-height: 1; }
.stat-label { font-size: .75rem; color: var(--gray-700); margin-top: 2px; }

/* ============================================================
   FORMS
   ============================================================ */
.form-group { margin-bottom: 14px; }
.form-label { display: block; font-size: .82rem; font-weight: 600; margin-bottom: 4px; color: var(--gray-700); }
.form-control {
  display: block; width: 100%;
  padding: 8px 12px; font-size: .88rem;
  border: 1.5px solid var(--gray-300); border-radius: 6px;
  background: #fff; color: var(--gray-900);
  transition: border-color var(--trans), box-shadow var(--trans);
  font-family: inherit;
}
.form-control:focus {
  outline: none; border-color: var(--primary-l);
  box-shadow: 0 0 0 3px rgba(46,134,193,.15);
}
.form-control[readonly] { background: var(--gray-100); }
.form-hint { font-size: .75rem; color: var(--gray-500); margin-top: 4px; }
.form-check { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.form-check input { width: 16px; height: 16px; cursor: pointer; }
.hari-checkboxes { display: flex; flex-wrap: wrap; gap: 8px; }
.hari-check {
  display: flex; align-items: center; gap: 6px;
  padding: 6px 12px; border: 1.5px solid var(--gray-300);
  border-radius: 20px; cursor: pointer; font-size: .82rem;
  transition: var(--trans); user-select: none;
}
.hari-check input { display: none; }
.hari-check:has(input:checked) { background: var(--primary); color: #fff; border-color: var(--primary); }

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 16px; font-size: .875rem; font-weight: 500;
  border: none; border-radius: 6px; cursor: pointer;
  transition: all var(--trans); font-family: inherit;
  text-decoration: none; white-space: nowrap;
}
.btn:active { transform: scale(.97); }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-d); }
.btn-accent { background: var(--accent); color: #fff; }
.btn-accent:hover { background: var(--accent-d); }
.btn-success { background: var(--success); color: #fff; }
.btn-danger  { background: var(--danger); color: #fff; }
.btn-warning { background: var(--warning); color: #fff; }
.btn-info    { background: var(--info); color: #fff; }
.btn-outline { background: transparent; border: 1.5px solid var(--gray-300); color: var(--gray-700); }
.btn-outline:hover { background: var(--gray-100); }
.btn-sm { padding: 5px 10px; font-size: .78rem; }
.btn-lg { padding: 11px 22px; font-size: 1rem; }
.btn-block { width: 100%; justify-content: center; }
.btn-wa { background: #25d366; color: #fff; }
.btn-wa:hover { background: #1da851; }

/* ============================================================
   TABLES
   ============================================================ */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; font-size: .85rem; }
thead th { background: var(--primary); color: #fff; padding: 10px 12px; text-align: left; font-weight: 600; white-space: nowrap; }
tbody tr:hover { background: #f0f5ff; }
tbody td { padding: 9px 12px; border-bottom: 1px solid var(--gray-200); }
tbody tr:last-child td { border-bottom: none; }
.table-striped tbody tr:nth-child(even) { background: var(--gray-100); }
.table-striped tbody tr:nth-child(even):hover { background: #f0f5ff; }

/* ============================================================
   BADGES / STATUS
   ============================================================ */
.pill {
  display: inline-flex; align-items: center;
  padding: 2px 10px; border-radius: 20px; font-size: .72rem; font-weight: 600;
}
.pill-primary { background: #d6eaf8; color: var(--primary); }
.pill-success { background: #d5f5e3; color: var(--success); }
.pill-danger  { background: #fadbd8; color: var(--danger); }
.pill-warning { background: #fdebd0; color: #a04000; }
.pill-info    { background: #d6eaf8; color: var(--info); }
.pill-gray    { background: var(--gray-200); color: var(--gray-700); }

/* ============================================================
   ALERTS
   ============================================================ */
.alert {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 14px; border-radius: 6px; margin-bottom: 14px; font-size: .875rem;
}
.alert button { background: none; border: none; cursor: pointer; font-size: 1.1rem; opacity: .6; }
.alert-success { background: #d5f5e3; color: #1e8449; border: 1px solid #a9dfbf; }
.alert-danger  { background: #fadbd8; color: #a93226; border: 1px solid #f1948a; }
.alert-warning { background: #fdebd0; color: #935116; border: 1px solid #f0b27a; }
.alert-info    { background: #d6eaf8; color: #1a5276; border: 1px solid #85c1e9; }

/* ============================================================
   MODAL
   ============================================================ */
.modal-backdrop {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,.5); z-index: 2000;
  align-items: center; justify-content: center; padding: 16px;
}
.modal-backdrop.show { display: flex; }
.modal {
  background: #fff; border-radius: var(--radius);
  width: 100%; max-width: 520px;
  box-shadow: var(--shadow-lg);
  max-height: 90vh; overflow-y: auto;
}
.modal-header {
  padding: 14px 16px; border-bottom: 1px solid var(--gray-200);
  display: flex; align-items: center; justify-content: space-between;
}
.modal-title { font-weight: 600; color: var(--primary); }
.modal-close { background: none; border: none; font-size: 1.2rem; cursor: pointer; opacity: .6; }
.modal-body { padding: 16px; }
.modal-footer { padding: 12px 16px; border-top: 1px solid var(--gray-200); display: flex; gap: 8px; justify-content: flex-end; }

/* ============================================================
   LOGIN PAGE
   ============================================================ */
.login-page {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, var(--primary-d) 0%, var(--primary-l) 100%);
  padding: 16px;
}
.login-card {
  background: #fff; border-radius: 12px;
  width: 100%; max-width: 380px;
  box-shadow: var(--shadow-lg); overflow: hidden;
}
.login-header {
  background: var(--primary); color: #fff;
  padding: 28px 24px 20px; text-align: center;
}
.login-logo { font-size: 2.5rem; margin-bottom: 6px; }
.login-title { font-size: 1.2rem; font-weight: 700; }
.login-subtitle { font-size: .78rem; opacity: .8; margin-top: 4px; }
.login-body { padding: 24px; }
.login-footer { text-align: center; padding: 12px 24px 20px; color: var(--gray-500); font-size: .75rem; }

/* ============================================================
   COPY TO WA BOX
   ============================================================ */
.wa-box {
  background: #f0faf4; border: 1.5px solid #a9dfbf;
  border-radius: var(--radius); padding: 12px;
  font-size: .82rem; white-space: pre-wrap; word-break: break-word;
  max-height: 240px; overflow-y: auto;
  font-family: 'Courier New', monospace;
}
.wa-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }

/* ============================================================
   FILTER BAR
   ============================================================ */
.filter-bar {
  display: flex; flex-wrap: wrap; gap: 8px;
  padding: 12px 16px; background: var(--gray-100);
  border-bottom: 1px solid var(--gray-200);
}
.filter-bar select, .filter-bar input {
  font-size: .82rem; padding: 6px 10px;
  border: 1.5px solid var(--gray-300); border-radius: 6px;
  background: #fff; flex: 1; min-width: 120px;
}

/* ============================================================
   EMPTY STATE
   ============================================================ */
.empty-state {
  text-align: center; padding: 40px 20px; color: var(--gray-500);
}
.empty-state svg { width: 48px; height: 48px; margin-bottom: 12px; opacity: .4; }
.empty-state p { font-size: .9rem; }

/* ============================================================
   PAGINATION
   ============================================================ */
.pagination { display: flex; gap: 4px; flex-wrap: wrap; padding: 8px 0; }
.pagination a, .pagination span {
  padding: 5px 10px; border-radius: 5px; font-size: .8rem;
  border: 1px solid var(--gray-300); color: var(--gray-700);
}
.pagination a:hover { background: var(--gray-200); }
.pagination .active { background: var(--primary); color: #fff; border-color: var(--primary); }

/* ============================================================
   HISTORY TIMELINE
   ============================================================ */
.timeline { position: relative; padding-left: 20px; }
.timeline::before { content:''; position:absolute; left:7px; top:0; bottom:0; width:2px; background:var(--gray-300); }
.timeline-item { position: relative; margin-bottom: 16px; }
.timeline-dot {
  position: absolute; left: -17px; top: 4px;
  width: 12px; height: 12px; border-radius: 50%;
  background: var(--primary); border: 2px solid #fff;
  box-shadow: 0 0 0 2px var(--primary);
}
.timeline-dot.success { background: var(--success); box-shadow: 0 0 0 2px var(--success); }
.timeline-dot.danger  { background: var(--danger);  box-shadow: 0 0 0 2px var(--danger); }
.timeline-date { font-size: .72rem; color: var(--gray-500); }
.timeline-text { font-size: .83rem; }

/* ============================================================
   RESPONSIVE UTILITIES
   ============================================================ */
.d-none { display: none !important; }
.text-center { text-align: center; }
.text-right  { text-align: right; }
.text-muted  { color: var(--gray-500); }
.text-sm     { font-size: .78rem; }
.fw-bold     { font-weight: 700; }
.mt-1 { margin-top: 4px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 16px; }
.mb-1 { margin-bottom: 4px; }
.mb-2 { margin-bottom: 8px; }
.mb-3 { margin-bottom: 16px; }
.gap-2 { gap: 8px; }
.flex { display: flex; }
.flex-wrap { flex-wrap: wrap; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }

/* Floating Action untuk mobile */
.fab {
  position: fixed; bottom: 20px; right: 20px;
  width: 52px; height: 52px; border-radius: 50%;
  background: var(--accent); color: #fff; border: none;
  font-size: 1.5rem; box-shadow: var(--shadow-lg);
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  z-index: 500; transition: var(--trans);
}
.fab:hover { transform: scale(1.08); }
@media (min-width: 992px) { .fab { display: none; } }

/* ============================================================
   PWA Install Banner
   ============================================================ */
#pwa-install-banner {
  display: none; position: fixed; bottom: 0; left: 0; right: 0;
  background: var(--primary); color: #fff;
  padding: 12px 16px; z-index: 600;
  align-items: center; gap: 10px;
  box-shadow: 0 -2px 10px rgba(0,0,0,.2);
}
#pwa-install-banner.show { display: flex; }
#pwa-install-banner p { flex: 1; font-size: .85rem; }
