/* ==========================================
   E-Rekomendasi Penelitian - Design System
   Kesbangpol Kabupaten Fakfak
   ========================================== */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

/* --- CSS Variables --- */
:root {
  --primary: #0D2137;
  --primary-dark: #091828;
  --primary-light: #1A3A5C;
  --secondary: #1E5FA6;
  --secondary-light: #2E7BC4;
  --accent: #C9A84C;
  --accent-light: #E5C96E;
  --bg: #F0F2F5;
  --bg-card: #FFFFFF;
  --text: #0F172A;
  --text-secondary: #64748B;
  --text-on-dark: #FFFFFF;
  --success: #16A34A;
  --warning: #F59E0B;
  --danger: #DC2626;
  --info: #2563EB;
  --border: #E2E8F0;
  --muted: #F1F5F9;
  --radius: 8px;
  --radius-lg: 12px;
  --shadow: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.06);
  --shadow-md: 0 4px 6px rgba(0,0,0,.07), 0 2px 4px rgba(0,0,0,.06);
  --shadow-lg: 0 10px 15px rgba(0,0,0,.1), 0 4px 6px rgba(0,0,0,.05);
  --transition: 200ms ease;
  --sidebar-w: 260px;
  --header-h: 64px;
  --font: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

/* --- Reset --- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; scroll-behavior: smooth; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--secondary); text-decoration: none; }
a:hover { color: var(--secondary-light); }
img { max-width: 100%; display: block; }
button, input, select, textarea { font-family: inherit; font-size: inherit; }

/* --- Layout Shell --- */
.app-layout { display: flex; min-height: 100vh; }

/* Sidebar */
.sidebar {
  position: fixed; top: 0; left: 0; bottom: 0;
  width: var(--sidebar-w);
  background: linear-gradient(180deg, var(--primary) 0%, var(--primary-dark) 100%);
  color: var(--text-on-dark);
  display: flex; flex-direction: column;
  z-index: 100;
  transition: transform .3s ease;
  overflow-y: auto;
}
.sidebar-brand {
  padding: 24px 20px;
  display: flex; align-items: center; gap: 12px;
  border-bottom: 1px solid rgba(255,255,255,.1);
}
.sidebar-brand img { width: 44px; height: 44px; border-radius: 8px; }
.sidebar-brand-text h2 { font-size: 18px; font-weight: 700; letter-spacing: .5px; }
.sidebar-brand-text small { font-size: 11px; opacity: .7; }

.sidebar-nav { padding: 12px 0; flex: 1; }
.nav-item {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 24px;
  color: rgba(255,255,255,.7);
  font-size: 14px; font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
  border-left: 3px solid transparent;
}
.nav-item:hover { background: rgba(255,255,255,.08); color: #fff; }
.nav-item.active {
  background: rgba(255,255,255,.12);
  color: #fff;
  border-left-color: var(--accent);
}
.nav-item svg { width: 20px; height: 20px; flex-shrink: 0; }

.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid rgba(255,255,255,.1);
  font-size: 12px; opacity: .5; text-align: center;
}

/* Main Content */
.main-content {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex; flex-direction: column;
  min-height: 100vh;
}

/* Header */
.topbar {
  height: var(--header-h);
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 24px;
  position: sticky; top: 0; z-index: 50;
  box-shadow: var(--shadow);
}
.topbar-left { display: flex; align-items: center; gap: 16px; }
.topbar-left h1 { font-size: 18px; font-weight: 700; color: var(--text); }
.topbar-right { display: flex; align-items: center; gap: 16px; }
.topbar-user {
  display: flex; align-items: center; gap: 10px;
  padding: 6px 12px; border-radius: var(--radius);
  background: var(--muted);
}
.topbar-user-avatar {
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--primary); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 14px;
}
.topbar-user-info { font-size: 13px; }
.topbar-user-info strong { display: block; font-size: 14px; }
.topbar-user-info span { color: var(--text-secondary); font-size: 12px; }

.btn-menu-toggle {
  display: none; background: none; border: none;
  cursor: pointer; padding: 8px; border-radius: var(--radius);
}
.btn-menu-toggle:hover { background: var(--muted); }
.btn-menu-toggle svg { width: 24px; height: 24px; }

/* Page Content */
.page-content { padding: 24px; flex: 1; }

/* --- Cards --- */
.card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  overflow: hidden;
}
.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.card-header h3 { font-size: 16px; font-weight: 600; }
.card-body { padding: 20px; }

/* Stat Cards */
.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 24px; }
.stat-card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  display: flex; align-items: center; gap: 16px;
  transition: all var(--transition);
}
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.stat-icon {
  width: 52px; height: 52px; border-radius: var(--radius);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.stat-icon svg { width: 26px; height: 26px; color: #fff; }
.stat-info h4 { font-size: 13px; font-weight: 500; color: var(--text-secondary); margin-bottom: 4px; }
.stat-info .stat-number { font-size: 28px; font-weight: 800; line-height: 1; }
.stat-info .stat-label { font-size: 12px; color: var(--text-secondary); margin-top: 4px; }

.charts-grid { display: grid; grid-template-columns: 2fr 1fr; gap: 16px; margin-bottom: 24px; }

/* --- Tables --- */
.table-container { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
thead th {
  background: var(--muted);
  padding: 12px 16px;
  text-align: left;
  font-size: 13px; font-weight: 600;
  color: var(--text-secondary);
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
}
tbody td {
  padding: 12px 16px;
  font-size: 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
tbody tr { transition: background var(--transition); }
tbody tr:hover { background: var(--muted); }

/* --- Badges --- */
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 12px; font-weight: 600;
  color: var(--badge-color, var(--text-secondary));
  background: color-mix(in srgb, var(--badge-color, var(--text-secondary)) 12%, transparent);
  white-space: nowrap;
}
.badge::before {
  content: '';
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--badge-color, var(--text-secondary));
}

/* --- Buttons --- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 20px;
  border-radius: var(--radius);
  font-size: 14px; font-weight: 600;
  border: none; cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
  text-decoration: none;
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }

.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-light); color: #fff; }
.btn-secondary { background: var(--secondary); color: #fff; }
.btn-secondary:hover { background: var(--secondary-light); color: #fff; }
.btn-success { background: var(--success); color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-warning { background: var(--warning); color: #fff; }
.btn-outline {
  background: transparent; color: var(--text);
  border: 1.5px solid var(--border);
}
.btn-outline:hover { background: var(--muted); border-color: var(--text-secondary); }
.btn-sm { padding: 6px 14px; font-size: 13px; }
.btn-lg { padding: 14px 28px; font-size: 16px; }
.btn-icon { padding: 8px; border-radius: var(--radius); }

/* --- Forms --- */
.form-group { margin-bottom: 18px; }
.form-label {
  display: block; font-size: 13px; font-weight: 600;
  color: var(--text); margin-bottom: 6px;
}
.form-label .required { color: var(--danger); margin-left: 2px; }
.form-control {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  font-size: 14px;
  background: var(--bg-card);
  transition: all var(--transition);
  color: var(--text);
}
.form-control:focus {
  outline: none;
  border-color: var(--secondary);
  box-shadow: 0 0 0 3px rgba(30,95,166,.15);
}
.form-control::placeholder { color: #94A3B8; }
.form-control.error { border-color: var(--danger); }
.form-hint { font-size: 12px; color: var(--text-secondary); margin-top: 4px; }
.form-error { font-size: 12px; color: var(--danger); margin-top: 4px; }

textarea.form-control { min-height: 100px; resize: vertical; }
select.form-control { cursor: pointer; }

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

/* File Upload */
.file-upload {
  border: 2px dashed var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  text-align: center;
  cursor: pointer;
  transition: all var(--transition);
  background: var(--muted);
}
.file-upload:hover { border-color: var(--secondary); background: rgba(30,95,166,.04); }
.file-upload svg { width: 40px; height: 40px; color: var(--text-secondary); margin: 0 auto 8px; }
.file-upload p { font-size: 14px; color: var(--text-secondary); }
.file-upload .file-name { font-size: 13px; color: var(--success); font-weight: 600; margin-top: 8px; }

/* Multi-step Form */
.steps-indicator {
  display: flex; align-items: center; justify-content: center;
  gap: 0; margin-bottom: 32px; padding: 0 20px;
}
.step-item {
  display: flex; align-items: center; gap: 8px;
  font-size: 14px; font-weight: 500;
  color: var(--text-secondary);
}
.step-item.active { color: var(--secondary); font-weight: 600; }
.step-item.completed { color: var(--success); }
.step-circle {
  width: 32px; height: 32px; border-radius: 50%;
  border: 2px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700;
  transition: all var(--transition);
}
.step-item.active .step-circle {
  background: var(--secondary); border-color: var(--secondary); color: #fff;
}
.step-item.completed .step-circle {
  background: var(--success); border-color: var(--success); color: #fff;
}
.step-line {
  width: 60px; height: 2px;
  background: var(--border);
  margin: 0 8px;
}
.step-line.completed { background: var(--success); }
.step-panel { display: none; animation: fadeIn .3s ease; }
.step-panel.active { display: block; }

/* --- Alerts --- */
.alert {
  padding: 14px 18px;
  border-radius: var(--radius);
  font-size: 14px;
  margin-bottom: 16px;
  display: flex; align-items: center; gap: 10px;
  animation: fadeIn .3s ease;
}
.alert-success { background: #DCFCE7; color: #166534; border: 1px solid #BBF7D0; }
.alert-danger { background: #FEE2E2; color: #991B1B; border: 1px solid #FECACA; }
.alert-warning { background: #FEF3C7; color: #92400E; border: 1px solid #FDE68A; }
.alert-info { background: #DBEAFE; color: #1E40AF; border: 1px solid #BFDBFE; }

/* --- Pagination --- */
.pagination {
  display: flex; align-items: center; justify-content: center;
  gap: 4px; margin-top: 20px;
}
.pagination a, .pagination span {
  padding: 8px 14px;
  border-radius: var(--radius);
  font-size: 13px; font-weight: 500;
  border: 1px solid var(--border);
  color: var(--text);
  transition: all var(--transition);
}
.pagination a:hover { background: var(--muted); color: var(--text); }
.pagination .active { background: var(--primary); color: #fff; border-color: var(--primary); }

/* --- Modal --- */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.5);
  display: none; align-items: center; justify-content: center;
  z-index: 200;
  animation: fadeIn .2s ease;
}
.modal-overlay.show { display: flex; }
.modal {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 90%; max-width: 520px;
  max-height: 90vh; overflow-y: auto;
  animation: slideUp .3s ease;
}
.modal-header {
  padding: 18px 24px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.modal-header h3 { font-size: 18px; font-weight: 700; }
.modal-close {
  background: none; border: none; cursor: pointer;
  width: 32px; height: 32px; border-radius: var(--radius);
  display: flex; align-items: center; justify-content: center;
}
.modal-close:hover { background: var(--muted); }
.modal-body { padding: 24px; }
.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  display: flex; justify-content: flex-end; gap: 10px;
}

/* --- Utility --- */
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-muted { color: var(--text-secondary); }
.text-sm { font-size: 13px; }
.mt-1 { margin-top: 8px; } .mt-2 { margin-top: 16px; } .mt-3 { margin-top: 24px; }
.mb-1 { margin-bottom: 8px; } .mb-2 { margin-bottom: 16px; } .mb-3 { margin-bottom: 24px; }
.flex { display: flex; } .items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-1 { gap: 8px; } .gap-2 { gap: 16px; }
.w-full { width: 100%; }
.hidden { display: none !important; }

/* --- Animations --- */
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: translateY(0); } }

/* --- Login Page --- */
.login-page {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 50%, #0a1929 100%);
  padding: 20px;
  position: relative; overflow: hidden;
}
.login-page::before {
  content: '';
  position: absolute; top: -50%; right: -20%;
  width: 600px; height: 600px;
  background: radial-gradient(circle, rgba(201,168,76,.15) 0%, transparent 70%);
  border-radius: 50%;
}
.login-page::after {
  content: '';
  position: absolute; bottom: -30%; left: -10%;
  width: 500px; height: 500px;
  background: radial-gradient(circle, rgba(30,95,166,.2) 0%, transparent 70%);
  border-radius: 50%;
}
.login-container {
  position: relative; z-index: 1;
  width: 100%; max-width: 420px;
}
.login-card {
  background: rgba(255,255,255,.97);
  border-radius: 16px;
  box-shadow: 0 20px 60px rgba(0,0,0,.3);
  overflow: hidden;
}
.login-header {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
  padding: 32px 28px;
  text-align: center; color: #fff;
}
.login-logo {
  width: 72px; height: 72px; margin: 0 auto 12px;
  background: rgba(255,255,255,.15);
  border-radius: 16px;
  display: flex; align-items: center; justify-content: center;
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255,255,255,.2);
}
.login-logo img { width: 48px; height: 48px; }
.login-header h1 { font-size: 22px; font-weight: 800; letter-spacing: 1px; }
.login-header p { font-size: 12px; opacity: .8; margin-top: 4px; line-height: 1.4; }
.login-body { padding: 28px; }
.login-body .form-group { margin-bottom: 20px; }
.login-body .btn { width: 100%; padding: 12px; font-size: 15px; }
.login-footer {
  padding: 16px 28px;
  background: var(--muted);
  text-align: center;
  font-size: 12px; color: var(--text-secondary);
}

/* --- Responsive --- */
@media (max-width: 1024px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .charts-grid { grid-template-columns: 1fr; }
}
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; }
  .btn-menu-toggle { display: flex; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .form-row { grid-template-columns: 1fr; }
  .topbar { padding: 0 16px; }
  .page-content { padding: 16px; }
}
@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr; }
  .stat-card { padding: 16px; }
  .stat-info .stat-number { font-size: 22px; }
}

/* --- Print --- */
@media print {
  .sidebar, .topbar, .btn, .pagination, .no-print { display: none !important; }
  .main-content { margin-left: 0; }
  .page-content { padding: 0; }
  body { background: #fff; }
}
