/* ============================================================
   APLIKASI CRUD PELAYANAN — Kelurahan Adiarsa Timur
   ============================================================ */
* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --green: #10b981;
    --green-dark: #0d9668;
    --slate: #0f172a;
    --slate-2: #1e293b;
    --slate-3: #334155;
    --bg: #f1f5f9;
    --border: #e2e8f0;
    --danger: #dc2626;
    --text: #0f172a;
    --muted: #64748b;
}

/* ===== Dashboard grafik (donut) ===== */
.dash-group { background: #fff; border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; margin-bottom: 12px; }
.dash-group-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 8px; flex-wrap: wrap; }
.dash-group-head h3 { margin: 0; font-size: 13px; display: flex; align-items: center; gap: 6px; }
.dash-group-no { display: inline-flex; width: 18px; height: 18px; border-radius: 50%; background: var(--green); color: #fff; font-size: 10px; font-weight: 700; align-items: center; justify-content: center; }
.dash-body { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; }
.donut-wrap { position: relative; width: 128px; height: 128px; flex: 0 0 auto; }
.donut { width: 100%; height: 100%; display: block; }
.donut-bg { fill: none; stroke: var(--bg); stroke-width: 20; }
.donut-seg { fill: none; stroke-width: 20; cursor: pointer; transition: opacity .15s ease; }
.donut-seg:hover { opacity: .75; }
.donut-center { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; pointer-events: none; }
.donut-total { font-size: 16px; font-weight: 800; color: var(--text); line-height: 1.1; }
.donut-label { font-size: 9px; color: var(--muted); text-transform: uppercase; letter-spacing: 1px; margin-top: 2px; }
.donut-legend { flex: 1; min-width: 200px; display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 6px 14px; }
.legend-item { display: flex; align-items: center; gap: 6px; font-size: 11.5px; }
.legend-dot { width: 8px; height: 8px; border-radius: 50%; flex: 0 0 auto; }
.legend-label { flex: 1; color: var(--text); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.legend-val { color: var(--muted); font-variant-numeric: tabular-nums; }
.legend-val em { font-style: normal; color: var(--green-dark); font-weight: 700; margin-left: 4px; }
.dash-chips { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 8px; margin-top: 10px; }
.chip-link { display: flex; align-items: center; gap: 8px; padding: 6px 10px; background: var(--bg); border: 1px solid var(--border); border-radius: 9px; text-decoration: none; color: var(--text); transition: all .15s ease; }
.chip-link:hover { border-color: var(--green); background: rgba(16,185,129,.06); transform: translateY(-1px); }
.chip-icon { font-size: 14px; }
.chip-label { flex: 1; font-size: 11.5px; font-weight: 600; }
.chip-count { font-size: 10.5px; font-weight: 700; color: var(--green-dark); background: rgba(16,185,129,.12); padding: 1px 7px; border-radius: 99px; }
@media (max-width: 640px) {
    .dash-group { padding: 10px; }
    .donut-wrap { width: 108px; height: 108px; }
}

body {
    font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
    line-height: 1.5;
}

a { color: var(--green-dark); text-decoration: none; }

/* ---------- LOGIN ---------- */
.login-body {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--slate) 0%, #1e3a5f 100%);
}
.login-card {
    width: 380px;
    max-width: 92vw;
    background: #fff;
    border-radius: 14px;
    padding: 36px 32px;
    box-shadow: 0 20px 50px rgba(0,0,0,.35);
    text-align: center;
}
.login-logo { margin-bottom: 12px; }
.login-logo img { width: 96px; height: auto; }
.login-card h1 { font-size: 18px; color: var(--slate); margin-bottom: 2px; }
.login-sub { color: var(--muted); font-size: 13px; margin-bottom: 22px; }
.login-card .form-control { text-align: left; }
.login-hint { margin-top: 18px; font-size: 12px; color: var(--muted); }
.login-hint a.btn { padding: 6px 22px; font-size: 13px; }

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

.sidebar {
    width: 250px;
    background: var(--slate);
    color: #cbd5e1;
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; bottom: 0; left: 0;
    overflow-y: auto;
}
.sidebar-brand {
    display: flex; align-items: center; gap: 10px;
    padding: 18px 16px;
    border-bottom: 1px solid rgba(255,255,255,.08);
    text-decoration: none;
}
.sidebar-brand:hover .brand-name { color: #93c5fd; }
.brand-logo { height: 38px; width: auto; border-radius: 8px; display: block; background: #fff; padding: 3px; box-shadow: 0 1px 4px rgba(0,0,0,.25); }
.brand-icon { font-size: 26px; }
.brand-name { font-weight: 700; color: #fff; font-size: 13px; letter-spacing: .5px; }
.brand-sub { font-size: 11px; color: #94a3b8; }

.sidebar-nav { flex: 1; padding: 10px 0; }
.nav-link {
    display: block;
    padding: 9px 18px;
    color: #f1f5f9;
    font-size: 13.5px;
    font-weight: 600;
    border-left: 3px solid transparent;
    text-transform: uppercase;
    letter-spacing: .3px;
}
.nav-link:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav-link.active { background: rgba(16,185,129,.15); color: #34d399; border-left-color: var(--green); }

/* Grup dropdown sidebar */
.nav-group { margin: 2px 0; }
.nav-group-btn {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 10px 18px;
    background: none;
    border: none;
    cursor: pointer;
    font-family: inherit;
    font-size: 11.5px;
    letter-spacing: 1px;
    color: #e2e8f0;
    font-weight: 600;
    text-transform: uppercase;
    text-align: left;
}
.nav-group-btn:hover { color: #fff; background: rgba(255,255,255,.06); }
.nav-caret { font-size: 11px; transition: transform .18s ease; }
.nav-group.open .nav-caret { transform: rotate(180deg); }
.nav-sub { display: none; padding: 2px 0 8px; }
.nav-group.open .nav-sub { display: block; }
.nav-sub-link {
    display: block;
    padding: 7px 16px 7px 32px;
    color: #e2e8f0;
    font-size: 12.5px;
    text-decoration: none;
    border-left: 3px solid transparent;
}
.nav-sub-link:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav-sub-link.active { background: rgba(16,185,129,.15); color: #34d399; border-left-color: var(--green); }

.sidebar-foot { padding: 14px 16px; border-top: 1px solid rgba(255,255,255,.08); }
.user-chip { font-size: 13px; color: #e2e8f0; margin-bottom: 10px; text-align: center; }

.main { margin-left: 250px; flex: 1; display: flex; flex-direction: column; min-height: 100vh; background: linear-gradient(rgba(255,255,255,.9), rgba(255,255,255,.9)), url('bg-dashboard.jpg') center/cover fixed; }

.topbar {
    background: #fff;
    border-bottom: 1px solid var(--border);
    padding: 16px 28px;
    display: flex; align-items: center; justify-content: space-between;
}
.page-title { font-size: 19px; font-weight: 700; }
.topbar-right { display: flex; align-items: center; gap: 10px; }

.content { padding: 24px 28px; flex: 1; }

.app-footer {
    padding: 14px 28px;
    font-size: 12px;
    color: var(--muted);
    border-top: 1px solid var(--border);
    background: #fff;
}

/* ---------- COMPONENTS ---------- */
.metrics { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; margin-bottom: 20px; }
.metric {
    background: #fff; border: 1px solid var(--border); border-radius: 12px;
    padding: 18px 20px;
}
.metric-value { font-size: 26px; font-weight: 800; color: var(--green-dark); }
.metric-label { font-size: 12.5px; color: var(--muted); margin-top: 2px; }

.section-note { color: var(--muted); margin: 4px 0 14px; font-size: 13px; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; }
.card-link { color: inherit; }
.card {
    background: #fff; border: 1px solid var(--border); border-radius: 12px;
    padding: 16px; display: flex; align-items: center; gap: 12px;
    transition: transform .12s ease, box-shadow .12s ease;
}
.card:hover { transform: translateY(-2px); box-shadow: 0 8px 20px rgba(15,23,42,.08); }
.card-icon { font-size: 26px; }
.card-body { flex: 1; }
.card-title { font-weight: 700; font-size: 14px; }
.card-sub { font-size: 12px; color: var(--muted); }
.card-arrow { color: var(--green); font-size: 18px; }

.panel {
    background: #fff; border: 1px solid var(--border); border-radius: 12px;
    padding: 18px 20px; margin-bottom: 18px;
}
.panel-narrow { max-width: 760px; }
.panel-title {
    font-weight: 700; font-size: 15px;
    padding-bottom: 12px; margin-bottom: 14px;
    border-bottom: 1px solid var(--border);
    display: flex; align-items: center; gap: 8px;
}

.toolbar {
    display: flex; align-items: center; justify-content: space-between;
    gap: 12px; margin-bottom: 16px; flex-wrap: wrap;
}
.search-form { display: flex; gap: 8px; flex: 1; max-width: 520px; }

.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th, .table td { padding: 9px 10px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
.table th { background: #f8fafc; font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .4px; white-space: nowrap; }
.table th a { color: var(--muted); }
.table th a:hover { color: var(--green-dark); }
.table tbody tr:hover { background: #f8fafc; }
.table-bare th { background: none; text-transform: none; letter-spacing: 0; color: var(--slate); }
.empty { text-align: center; color: var(--muted); padding: 30px !important; }

.actions { white-space: nowrap; }

/* Kolom Aksi selalu terlihat (sticky kanan) saat tabel di-scroll horizontal */
.table th:last-child, .table td:last-child { position: sticky; right: 0; background: #fff; z-index: 2; box-shadow: -2px 0 0 var(--border); }
.table th:last-child { background: #f8fafc; z-index: 3; }
.table tbody tr:hover td:last-child { background: #f8fafc; }

.pager { display: flex; align-items: center; gap: 10px; margin-top: 14px; flex-wrap: wrap; }
.pager-info { font-size: 13px; color: var(--muted); }
.pager-jump { display: flex; align-items: center; gap: 6px; }
.pager-jump .form-control { width: 74px; padding: 6px 8px; }
.pager-jump .btn { white-space: nowrap; }

/* ---------- FORM ---------- */
.form-group { margin-bottom: 14px; }
.form-label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 5px; }
.req { color: var(--danger); }
.form-control {
    width: 100%;
    padding: 9px 12px;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    font-size: 14px;
    background: #fff;
    color: var(--text);
}
.form-control:focus { outline: none; border-color: var(--green); box-shadow: 0 0 0 3px rgba(16,185,129,.15); }
.form-actions { display: flex; gap: 10px; margin-top: 18px; }

/* ---------- BUTTON ---------- */
.btn {
    display: inline-block;
    padding: 9px 16px;
    border-radius: 8px;
    border: 1px solid transparent;
    font-size: 13.5px;
    font-weight: 600;
    cursor: pointer;
    background: transparent;
    color: var(--text);
    transition: background .12s ease;
}
.btn-primary { background: #2563eb; color: #fff; }
.btn-primary:hover { background: #1d4ed8; }
.btn-green { background: var(--green); color: #fff; }
.btn-green:hover { background: var(--green-dark); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #b91c1c; }
.btn-outline { border-color: #cbd5e1; background: #fff; }
.btn-outline:hover { background: #f1f5f9; }
.btn-sm { padding: 4px 10px; font-size: 12.5px; }
.btn-block { width: 100%; }
.disabled { opacity: .45; pointer-events: none; }

/* ---------- ALERT / BADGE ---------- */
.alert {
    padding: 12px 14px;
    border-radius: 10px;
    margin-bottom: 14px;
    font-size: 13.5px;
}
.alert-success { background: #ecfdf5; color: #065f46; border: 1px solid #a7f3d0; }
.alert-danger { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }

.badge {
    display: inline-block;
    background: #e2e8f0;
    color: var(--slate);
    font-size: 11.5px;
    font-weight: 700;
    padding: 3px 10px;
    border-radius: 99px;
}
.badge-green { background: #d1fae5; color: #065f46; }

/* ===== Sidebar toggle button (hamburger) ===== */
.sidebar-toggle {
    display: none;
    background: none; border: none; cursor: pointer;
    padding: 8px; border-radius: 8px;
    flex-direction: column; gap: 4px; align-items: center; justify-content: center;
    width: 38px; height: 38px;
    transition: background .15s;
}
.sidebar-toggle:hover { background: var(--bg); }
.sidebar-toggle span {
    display: block; width: 20px; height: 2px; background: var(--text);
    border-radius: 2px; transition: all .25s ease;
}
.sidebar-toggle.active span:nth-child(1) { transform: translateY(6px) rotate(45deg); }
.sidebar-toggle.active span:nth-child(2) { opacity: 0; }
.sidebar-toggle.active span:nth-child(3) { transform: translateY(-6px) rotate(-45deg); }

/* ===== Sidebar overlay ===== */
.sidebar-overlay {
    display: none; position: fixed; inset: 0; z-index: 999;
    background: rgba(0,0,0,.45); backdrop-filter: blur(2px);
    transition: opacity .25s;
}
.sidebar-overlay.active { display: block; }

.topbar-left { display: flex; align-items: center; gap: 10px; }

@media (max-width: 900px) {
    .sidebar-toggle { display: flex; }
    .sidebar {
        position: fixed; z-index: 1000;
        left: 0; top: 0; bottom: 0;
        width: 260px;
        transform: translateX(-100%);
        transition: transform .28s ease;
    }
    .sidebar.open { transform: translateX(0); }
    .main { margin-left: 0; }
    .app { flex-direction: column; }
    .topbar { padding: 12px 16px; }
    .content { padding: 16px; }
    .page-title { font-size: 15px; }
    .badge { font-size: 10px; padding: 2px 8px; }
    .login-card { width: 92vw; max-width: 380px; padding: 28px 20px; }
    .metrics { grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; }
    .metric { padding: 14px; }
    .metric-value { font-size: 22px; }
    .grid { grid-template-columns: 1fr; }
    .panel { padding: 14px; }
    .table-wrap { margin: 0 -14px; padding: 0 14px; }
    .form-actions { flex-direction: column; }
    .form-actions .btn { width: 100%; justify-content: center; }
    .toolbar { flex-direction: column; align-items: stretch; }
    .search-form { max-width: 100%; }
    .dash-body { flex-direction: column; }
    .donut-legend { min-width: 0; grid-template-columns: 1fr; }
    .pdf-popup { width: 98vw; height: 80vh; border-radius: 8px; }
    .pdf-popup-footer { flex-direction: column; align-items: stretch; text-align: center; }
    .pdf-popup-actions { justify-content: center; }
}
@media (max-width: 480px) {
    .topbar-right .badge { display: none; }
    .content { padding: 12px 10px; }
    .metrics { grid-template-columns: 1fr 1fr; }
    .donut-wrap { width: 130px; height: 130px; }
    .donut-total { font-size: 20px; }
    .chip-link { padding: 8px 10px; }
    .login-card { padding: 24px 16px; }
    .login-card h1 { font-size: 16px; }
}

/* ===== Lightbox (zoom foto) ===== */
.lb-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.86); display: none; align-items: center; justify-content: center; z-index: 99999; padding: 24px; }
.lb-overlay.active { display: flex; }
.lb-box { position: relative; max-width: 92vw; max-height: 92vh; display: flex; flex-direction: column; align-items: center; }
.lb-img { max-width: 92vw; max-height: 82vh; object-fit: contain; border-radius: 10px; box-shadow: 0 12px 48px rgba(0,0,0,.6); background: #fff; }
.lb-caption { color: #fff; margin-top: 12px; font-size: .95rem; text-align: center; }
.lb-close { position: fixed; top: 18px; right: 24px; width: 44px; height: 44px; border-radius: 50%; border: none; background: rgba(255,255,255,.18); color: #fff; font-size: 1.3rem; cursor: pointer; transition: background .15s; }
.lb-close:hover { background: rgba(255,255,255,.35); }
img { cursor: default; }
.card img, .table img, .form-stack img { cursor: zoom-in; }

/* ===== Thumbnail KTP (kolom berkas) ===== */
.thumb-ktp{width:64px;height:40px;object-fit:cover;border:1px solid var(--border);border-radius:4px;display:block;background:#fff}
.thumb-wrap:hover .thumb-ktp{opacity:.8}

/* ===== Ikon link website (favicon) ===== */
.link-icon{width:16px;height:16px;object-fit:contain;margin-right:6px;vertical-align:-3px;border-radius:3px}

/* ===== Modal PDF (Surat Izin) ===== */
.pdf-popup-overlay { position: fixed; top: 0; left: 0; right: 0; bottom: 0; width: 100%; height: 100%; background: rgba(0,0,0,.55); z-index: 9999; display: none; align-items: center; justify-content: center; }
.pdf-popup { background: #fff; border-radius: 10px; width: min(920px, 94vw); height: min(88vh, 92vh); display: flex; flex-direction: column; overflow: hidden; box-shadow: 0 10px 50px rgba(0,0,0,.35); font-family: Arial, sans-serif; }
.pdf-popup-header { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px; border-bottom: 1px solid #e5e7eb; }
.pdf-popup-title { font-weight: 700; font-size: 17px; color: #1f2937; }
.pdf-popup-close { font-size: 26px; color: #9ca3af; cursor: pointer; line-height: 1; padding: 0 4px; }
.pdf-popup-close:hover { color: #374151; }
.pdf-popup-tabs { padding: 0 18px; border-bottom: 1px solid #e5e7eb; }
.pdf-popup-tabs .tab { display: inline-block; padding: 8px 2px 10px; border-bottom: 2px solid #b45309; font-size: 14px; font-weight: 600; color: #1f2937; }
.pdf-popup-body { flex: 1; background: #525659; min-height: 0; }
.pdf-popup-body iframe { width: 100%; height: 100%; border: 0; display: block; }
.pdf-popup-footer { padding: 12px 18px; border-top: 1px solid #e5e7eb; display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.pdf-popup-berkas { display: flex; align-items: center; gap: 6px; font-family: Arial, sans-serif; font-size: 13px; }
.pdf-popup-actions { display: flex; gap: 10px; }
