/* =========================================================
   E-Office Desa - Design System (Public, Admin, & Print)
   ========================================================= */
:root {
  --primary: #0f766e;
  --primary-dark: #115e59;
  --primary-light: #ccfbf1;
  --primary-soft: #f0fdfa;
  --secondary: #0284c7;
  --dark: #0f172a;
  --sidebar-bg: #0b2524;
  --sidebar-hover: #133b39;
  --text: #1e293b;
  --muted: #64748b;
  --border: #e2e8f0;
  --bg: #f4f7f8;
  --surface: #ffffff;
  --success: #15803d;
  --success-bg: #dcfce7;
  --warning: #b45309;
  --warning-bg: #fef3c7;
  --info: #0369a1;
  --info-bg: #e0f2fe;
  --danger: #b91c1c;
  --danger-bg: #fee2e2;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 3px rgba(15, 23, 42, 0.06), 0 4px 16px rgba(15, 23, 42, 0.04);
  --shadow-lg: 0 10px 30px rgba(15, 23, 42, 0.1);
}

*, *::before, *::after { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: 'Segoe UI', system-ui, -apple-system, BlinkMacSystemFont, Roboto, sans-serif;
  color: var(--text);
  background: var(--bg);
  line-height: 1.6;
  font-size: 15px;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

.container {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 20px;
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.18s ease;
  text-decoration: none !important;
  line-height: 1.2;
}
.btn:disabled { opacity: 0.6; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-secondary { background: #fff; color: var(--text); border-color: var(--border); }
.btn-secondary:hover { background: #f8fafc; border-color: #cbd5e1; }
.btn-outline-light { background: rgba(255,255,255,0.12); color: #fff; border-color: rgba(255,255,255,0.35); }
.btn-outline-light:hover { background: rgba(255,255,255,0.22); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #991b1b; }
.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn-lg { padding: 13px 24px; font-size: 15px; }

/* ---------- Badges ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}
.badge-success { background: var(--success-bg); color: var(--success); }
.badge-warning { background: var(--warning-bg); color: var(--warning); }
.badge-info { background: var(--info-bg); color: var(--info); }
.badge-primary { background: var(--primary-light); color: var(--primary-dark); }
.badge-danger { background: var(--danger-bg); color: var(--danger); }
.badge-neutral { background: #e2e8f0; color: #334155; }

/* ---------- Alerts / Flash ---------- */
.alert {
  padding: 13px 16px;
  border-radius: var(--radius-sm);
  margin-bottom: 18px;
  border-left: 4px solid;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  font-size: 14px;
}
.alert-success { background: var(--success-bg); border-color: var(--success); color: #14532d; }
.alert-error { background: var(--danger-bg); border-color: var(--danger); color: #7f1d1d; }
.alert-info { background: var(--info-bg); border-color: var(--info); color: #0c4a6e; }
.alert-close { background: none; border: none; font-size: 18px; cursor: pointer; color: inherit; opacity: 0.7; line-height: 1; }

/* ---------- Cards & Surfaces ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.card-title { margin: 0; font-size: 16px; font-weight: 700; color: var(--dark); }
.card-body { padding: 20px; }

/* ---------- Forms ---------- */
.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}
.form-group { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.form-grid .form-group { margin-bottom: 0; }
.form-group.full { grid-column: 1 / -1; }
.form-label { font-size: 13px; font-weight: 600; color: var(--dark); }
.form-label .req { color: var(--danger); }
.form-control {
  width: 100%;
  padding: 10px 13px;
  border: 1px solid #cbd5e1;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-family: inherit;
  color: var(--text);
  background: #fff;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.form-control:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.14);
}
textarea.form-control { min-height: 88px; resize: vertical; }
.form-hint { font-size: 12px; color: var(--muted); }

/* ---------- Public Navbar & Hero ---------- */
.public-topbar {
  background: var(--sidebar-bg);
  color: #cbd5e1;
  font-size: 12.5px;
  padding: 7px 0;
}
.public-topbar .container {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.public-navbar {
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 40;
}
.public-navbar .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 70px;
  gap: 16px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--dark);
  text-decoration: none !important;
}
.brand-mark {
  width: 42px;
  height: 42px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--primary), #0d9488);
  color: #fff;
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 17px;
  box-shadow: 0 4px 12px rgba(15, 118, 110, 0.25);
}
.brand-text strong { display: block; font-size: 16px; line-height: 1.2; color: var(--dark); }
.brand-text span { display: block; font-size: 12px; color: var(--muted); }
.nav-links { display: flex; align-items: center; gap: 22px; }
.nav-links a { font-weight: 600; font-size: 14px; color: var(--text); }
.nav-links a:hover { color: var(--primary); text-decoration: none; }

.hero {
  background: linear-gradient(135deg, #063835 0%, #0f766e 60%, #0d9488 100%);
  color: #fff;
  padding: 58px 0 68px;
  position: relative;
  overflow: hidden;
}
.hero::after {
  content: '';
  position: absolute;
  right: -120px;
  top: -120px;
  width: 420px;
  height: 420px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255,255,255,0.12), transparent 70%);
  pointer-events: none;
}
.hero-grid {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr;
  gap: 32px;
  align-items: center;
}
.hero-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: rgba(255,255,255,0.14);
  border: 1px solid rgba(255,255,255,0.22);
  padding: 5px 13px;
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 600;
  margin-bottom: 16px;
}
.hero h1 {
  margin: 0 0 14px;
  font-size: clamp(26px, 3.6vw, 40px);
  line-height: 1.2;
  font-weight: 800;
}
.hero p {
  margin: 0 0 24px;
  color: rgba(255,255,255,0.88);
  font-size: 16px;
  max-width: 600px;
}
.hero-actions { display: flex; gap: 12px; flex-wrap: wrap; }
.hero-stats-card {
  background: rgba(255,255,255,0.1);
  border: 1px solid rgba(255,255,255,0.2);
  backdrop-filter: blur(8px);
  border-radius: 16px;
  padding: 22px;
}
.hero-stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
  margin-top: 14px;
}
.hero-stat-item {
  background: rgba(255,255,255,0.12);
  padding: 14px;
  border-radius: 10px;
}
.hero-stat-item .num { font-size: 24px; font-weight: 800; display: block; line-height: 1.1; }
.hero-stat-item .lbl { font-size: 12px; opacity: 0.85; }

.section { padding: 54px 0; }
.section-alt { background: #fff; border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.section-head { margin-bottom: 28px; display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; }
.section-head h2 { margin: 0 0 6px; font-size: 24px; color: var(--dark); }
.section-head p { margin: 0; color: var(--muted); font-size: 14.5px; }

.services-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
}
.service-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  transition: transform 0.15s, box-shadow 0.15s, border-color 0.15s;
}
.service-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
  border-color: #99f6e4;
}
.service-cat {
  font-size: 11.5px;
  font-weight: 700;
  color: var(--primary);
  text-transform: uppercase;
  letter-spacing: 0.4px;
}
.service-card h3 { margin: 6px 0 8px; font-size: 17px; color: var(--dark); }
.service-card p { margin: 0 0 12px; font-size: 13.5px; color: var(--muted); }
.service-req {
  background: #f8fafc;
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 12.5px;
  color: #334155;
  margin-bottom: 16px;
}
.service-req ul { margin: 4px 0 0; padding-left: 18px; }
.service-footer { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding-top: 12px; border-top: 1px solid var(--border); }

/* ---------- Tracking Timeline ---------- */
.track-box {
  background: linear-gradient(180deg, var(--primary-soft), #fff);
  border: 1px solid #99f6e4;
  border-radius: var(--radius);
  padding: 24px;
}
.timeline {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin: 18px 0;
}
.timeline-step {
  padding: 12px;
  border-radius: 10px;
  background: #f1f5f9;
  border: 1px solid var(--border);
  text-align: center;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--muted);
}
.timeline-step.active {
  background: var(--primary-soft);
  border-color: var(--primary);
  color: var(--primary-dark);
}
.timeline-step.done {
  background: var(--success-bg);
  border-color: #86efac;
  color: var(--success);
}

/* ---------- Login Page ---------- */
.login-wrapper {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1.05fr 0.95fr;
  background: #fff;
}
.login-aside {
  background: linear-gradient(155deg, #062b29 0%, #0f766e 65%, #0d9488 100%);
  color: #fff;
  padding: 48px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}
.login-main {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 24px;
  background: var(--bg);
}
.login-card {
  width: 100%;
  max-width: 430px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 32px;
  box-shadow: var(--shadow-lg);
}
.demo-accounts {
  margin-top: 20px;
  padding: 14px;
  border-radius: 10px;
  background: #f8fafc;
  border: 1px dashed #cbd5e1;
  font-size: 12.5px;
}
.demo-btn-row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }

/* ---------- Admin Layout ---------- */
.admin-shell {
  display: flex;
  min-height: 100vh;
}
.admin-sidebar {
  width: 260px;
  background: var(--sidebar-bg);
  color: #e2e8f0;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}
.sidebar-brand {
  padding: 20px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  display: flex;
  align-items: center;
  gap: 12px;
}
.sidebar-brand strong { display: block; color: #fff; font-size: 15px; }
.sidebar-brand span { display: block; color: #94a3b8; font-size: 11.5px; }
.sidebar-nav { padding: 14px 12px; flex: 1; display: flex; flex-direction: column; gap: 4px; }
.sidebar-section {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: #64748b;
  padding: 12px 12px 4px;
  font-weight: 700;
}
.sidebar-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 8px;
  color: #cbd5e1;
  font-size: 14px;
  font-weight: 500;
  text-decoration: none !important;
  transition: background 0.15s, color 0.15s;
}
.sidebar-link:hover { background: var(--sidebar-hover); color: #fff; }
.sidebar-link.active { background: var(--primary); color: #fff; font-weight: 600; }
.sidebar-count {
  background: rgba(255,255,255,0.16);
  color: #fff;
  font-size: 11px;
  padding: 2px 7px;
  border-radius: 999px;
}
.sidebar-footer {
  padding: 14px 16px;
  border-top: 1px solid rgba(255,255,255,0.08);
  font-size: 12.5px;
}
.admin-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.admin-topbar {
  background: #fff;
  border-bottom: 1px solid var(--border);
  padding: 14px 26px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.admin-content { padding: 26px; flex: 1; }

/* ---------- KPI & Tables ---------- */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 22px;
}
.kpi-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow);
}
.kpi-label { font-size: 13px; color: var(--muted); font-weight: 600; }
.kpi-value { font-size: 28px; font-weight: 800; color: var(--dark); margin: 4px 0; line-height: 1.1; }
.kpi-sub { font-size: 12px; color: var(--muted); }

.table-wrap { width: 100%; overflow-x: auto; }
table.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}
table.table th, table.table td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
}
table.table th {
  background: #f8fafc;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--muted);
  font-weight: 700;
}
table.table tr:hover td { background: #fafcfd; }

.filter-bar {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}

/* ---------- Modal ---------- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 100;
}
.modal-backdrop.open { display: flex; }
.modal-dialog {
  background: #fff;
  border-radius: 14px;
  width: 100%;
  max-width: 640px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
}

/* ---------- Footer ---------- */
.public-footer {
  background: var(--sidebar-bg);
  color: #cbd5e1;
  padding: 34px 0;
  font-size: 13.5px;
}

/* ---------- Print Official Letter (cetak_surat.php) ---------- */
.letter-sheet {
  width: 210mm;
  min-height: 297mm;
  margin: 20px auto;
  background: #fff;
  padding: 18mm 22mm;
  box-shadow: var(--shadow-lg);
  font-family: 'Times New Roman', Times, serif;
  color: #000;
  line-height: 1.55;
  font-size: 12pt;
}
.kop-surat {
  display: flex;
  align-items: center;
  gap: 16px;
  border-bottom: 4px double #000;
  padding-bottom: 10px;
  margin-bottom: 18px;
}
.kop-logo {
  width: 68px;
  height: 68px;
  border: 2px solid #000;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-weight: bold;
  font-size: 13pt;
  flex-shrink: 0;
}
.kop-text { flex: 1; text-align: center; }
.kop-text h2, .kop-text h3, .kop-text p { margin: 0; }
.kop-text .instansi { font-size: 13pt; font-weight: bold; text-transform: uppercase; }
.kop-text .desa { font-size: 16pt; font-weight: bold; text-transform: uppercase; }
.kop-text .alamat { font-size: 9.5pt; }
.surat-judul { text-align: center; margin: 16px 0 20px; }
.surat-judul h4 { margin: 0; font-size: 13pt; text-decoration: underline; text-transform: uppercase; }
.surat-judul p { margin: 2px 0 0; font-size: 11pt; }
.surat-bio { width: 100%; border-collapse: collapse; margin: 12px 0 16px; }
.surat-bio td { padding: 3px 4px; vertical-align: top; }
.ttd-wrap { margin-top: 34px; display: flex; justify-content: flex-end; }
.ttd-box { width: 270px; text-align: center; }
.ttd-space { height: 74px; }

@media print {
  body { background: #fff !important; }
  .no-print { display: none !important; }
  .letter-sheet {
    box-shadow: none !important;
    margin: 0 !important;
    width: auto !important;
    min-height: auto !important;
    padding: 12mm 16mm !important;
  }
}

/* ---------- Responsive ---------- */
@media (max-width: 960px) {
  .hero-grid, .login-wrapper, .services-grid, .kpi-grid { grid-template-columns: 1fr; }
  .login-aside { display: none; }
  .admin-shell { flex-direction: column; }
  .admin-sidebar { width: 100%; }
  .form-grid, .timeline { grid-template-columns: 1fr; }
  .nav-links { display: none; }
}
