/* ============================================================
   Sistem Informasi Desa — Main Stylesheet
   ============================================================ */

/* ── Reset & Base ─────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --hijau-tua:   #1a6b3c;
    --hijau:       #2d9e5f;
    --hijau-muda:  #4cbb7f;
    --hijau-pale:  #e8f5ee;
    --kuning:      #f5a623;
    --merah:       #e74c3c;
    --biru:        #3498db;
    --abu-gelap:   #2c3e50;
    --abu:         #7f8c8d;
    --abu-muda:    #ecf0f1;
    --putih:       #ffffff;
    --shadow:      0 2px 12px rgba(0,0,0,.10);
    --shadow-lg:   0 8px 30px rgba(0,0,0,.15);
    --radius:      10px;
    --radius-lg:   16px;
    --transition:  .25s ease;
}

html { scroll-behavior: smooth; }

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: #f4f6f9;
    color: var(--abu-gelap);
    line-height: 1.6;
    min-height: 100vh;
}

a { color: var(--hijau); text-decoration: none; transition: color var(--transition); }
a:hover { color: var(--hijau-tua); }

img { max-width: 100%; }

/* ── Scrollbar ────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--abu-muda); }
::-webkit-scrollbar-thumb { background: var(--hijau-muda); border-radius: 3px; }

/* ── Layout Wrapper ───────────────────────────────────────── */
.wrapper { display: flex; min-height: 100vh; }

/* ── Sidebar ──────────────────────────────────────────────── */
.sidebar {
    width: 260px;
    background: linear-gradient(180deg, var(--hijau-tua) 0%, #0f4a28 100%);
    color: var(--putih);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; left: 0;
    height: 100vh;
    z-index: 1000;
    transition: transform var(--transition);
    overflow-y: auto;
}

.sidebar-brand {
    padding: 1.5rem 1.25rem;
    border-bottom: 1px solid rgba(255,255,255,.15);
    display: flex;
    align-items: center;
    gap: .75rem;
}

.sidebar-brand .brand-icon {
    width: 44px; height: 44px;
    background: var(--hijau-muda);
    border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.4rem;
    flex-shrink: 0;
}

.sidebar-brand .brand-text h2 {
    font-size: .95rem;
    font-weight: 700;
    line-height: 1.2;
}

.sidebar-brand .brand-text small {
    font-size: .72rem;
    opacity: .75;
}

.sidebar-nav { flex: 1; padding: 1rem 0; }

.nav-section-title {
    font-size: .68rem;
    font-weight: 700;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: rgba(255,255,255,.5);
    padding: .75rem 1.25rem .25rem;
}

.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: .65rem 1.25rem;
    color: rgba(255,255,255,.85);
    font-size: .9rem;
    border-left: 3px solid transparent;
    transition: all var(--transition);
}

.sidebar-nav a:hover,
.sidebar-nav a.active {
    background: rgba(255,255,255,.12);
    color: var(--putih);
    border-left-color: var(--hijau-muda);
}

.sidebar-nav a .nav-icon { font-size: 1.1rem; width: 20px; text-align: center; }

.sidebar-footer {
    padding: 1rem 1.25rem;
    border-top: 1px solid rgba(255,255,255,.15);
    font-size: .8rem;
    opacity: .65;
    text-align: center;
}

/* ── Main Content ─────────────────────────────────────────── */
.main-content {
    margin-left: 260px;
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* ── Topbar ───────────────────────────────────────────────── */
.topbar {
    background: var(--putih);
    padding: .85rem 1.75rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: 0 1px 4px rgba(0,0,0,.08);
    position: sticky;
    top: 0;
    z-index: 100;
}

.topbar-left { display: flex; align-items: center; gap: 1rem; }

.btn-toggle-sidebar {
    background: none; border: none; cursor: pointer;
    font-size: 1.3rem; color: var(--abu-gelap);
    display: none;
}

.page-title { font-size: 1.1rem; font-weight: 600; color: var(--abu-gelap); }

.topbar-right { display: flex; align-items: center; gap: 1rem; }

.user-info {
    display: flex; align-items: center; gap: .6rem;
    font-size: .88rem;
}

.user-avatar {
    width: 36px; height: 36px;
    background: var(--hijau);
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    color: white; font-weight: 700; font-size: .9rem;
}

/* ── Page Content ─────────────────────────────────────────── */
.page-content { padding: 1.75rem; flex: 1; }

/* ── Cards ────────────────────────────────────────────────── */
.card {
    background: var(--putih);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.card-header {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--abu-muda);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .75rem;
}

.card-header h3 {
    font-size: 1rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: .5rem;
}

.card-body { padding: 1.25rem; }

/* ── Stat Cards ───────────────────────────────────────────── */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.25rem;
    margin-bottom: 1.75rem;
}

.stat-card {
    background: var(--putih);
    border-radius: var(--radius);
    padding: 1.25rem;
    box-shadow: var(--shadow);
    display: flex;
    align-items: center;
    gap: 1rem;
    border-left: 4px solid var(--hijau);
    transition: transform var(--transition), box-shadow var(--transition);
}

.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.stat-card.kuning { border-left-color: var(--kuning); }
.stat-card.biru   { border-left-color: var(--biru); }
.stat-card.merah  { border-left-color: var(--merah); }

.stat-icon {
    width: 52px; height: 52px;
    border-radius: var(--radius);
    display: flex; align-items: center; justify-content: center;
    font-size: 1.5rem;
    flex-shrink: 0;
}

.stat-card .stat-icon { background: var(--hijau-pale); }
.stat-card.kuning .stat-icon { background: #fff8e6; }
.stat-card.biru   .stat-icon { background: #e8f4fd; }
.stat-card.merah  .stat-icon { background: #fdecea; }

.stat-info .stat-value {
    font-size: 1.75rem;
    font-weight: 700;
    line-height: 1;
    color: var(--abu-gelap);
}

.stat-info .stat-label {
    font-size: .8rem;
    color: var(--abu);
    margin-top: .2rem;
}

/* ── Tables ───────────────────────────────────────────────── */
.table-responsive { overflow-x: auto; }

table {
    width: 100%;
    border-collapse: collapse;
    font-size: .88rem;
}

thead th {
    background: var(--hijau-pale);
    color: var(--hijau-tua);
    font-weight: 600;
    padding: .75rem 1rem;
    text-align: left;
    white-space: nowrap;
    border-bottom: 2px solid var(--hijau-muda);
}

tbody td {
    padding: .7rem 1rem;
    border-bottom: 1px solid var(--abu-muda);
    vertical-align: middle;
}

tbody tr:hover { background: #f9fffe; }
tbody tr:last-child td { border-bottom: none; }

/* ── Buttons ──────────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    padding: .5rem 1rem;
    border-radius: 6px;
    border: none;
    cursor: pointer;
    font-size: .875rem;
    font-weight: 500;
    transition: all var(--transition);
    text-decoration: none;
    white-space: nowrap;
}

.btn-primary   { background: var(--hijau);    color: white; }
.btn-primary:hover { background: var(--hijau-tua); color: white; }
.btn-secondary { background: var(--abu-muda); color: var(--abu-gelap); }
.btn-secondary:hover { background: #dde1e4; color: var(--abu-gelap); }
.btn-danger    { background: var(--merah);    color: white; }
.btn-danger:hover { background: #c0392b; color: white; }
.btn-warning   { background: var(--kuning);   color: white; }
.btn-warning:hover { background: #e09400; color: white; }
.btn-info      { background: var(--biru);     color: white; }
.btn-info:hover { background: #2980b9; color: white; }
.btn-sm { padding: .3rem .65rem; font-size: .8rem; }
.btn-lg { padding: .75rem 1.5rem; font-size: 1rem; }

/* ── Badges ───────────────────────────────────────────────── */
.badge {
    display: inline-block;
    padding: .25rem .6rem;
    border-radius: 20px;
    font-size: .75rem;
    font-weight: 600;
}

.badge-success { background: #d4edda; color: #155724; }
.badge-warning { background: #fff3cd; color: #856404; }
.badge-danger  { background: #f8d7da; color: #721c24; }
.badge-info    { background: #d1ecf1; color: #0c5460; }
.badge-secondary { background: var(--abu-muda); color: var(--abu); }

/* ── Forms ────────────────────────────────────────────────── */
.form-group { margin-bottom: 1rem; }

.form-label {
    display: block;
    font-size: .875rem;
    font-weight: 500;
    margin-bottom: .35rem;
    color: var(--abu-gelap);
}

.form-control {
    width: 100%;
    padding: .55rem .85rem;
    border: 1.5px solid #d1d5db;
    border-radius: 6px;
    font-size: .9rem;
    color: var(--abu-gelap);
    background: white;
    transition: border-color var(--transition), box-shadow var(--transition);
    font-family: inherit;
}

.form-control:focus {
    outline: none;
    border-color: var(--hijau);
    box-shadow: 0 0 0 3px rgba(45,158,95,.15);
}

select.form-control { cursor: pointer; }
textarea.form-control { resize: vertical; min-height: 100px; }

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
}

/* ── Alerts / Flash ───────────────────────────────────────── */
.alert {
    padding: .85rem 1.1rem;
    border-radius: var(--radius);
    margin-bottom: 1rem;
    display: flex;
    align-items: flex-start;
    gap: .6rem;
    font-size: .9rem;
}

.alert-success { background: #d4edda; color: #155724; border: 1px solid #c3e6cb; }
.alert-error   { background: #f8d7da; color: #721c24; border: 1px solid #f5c6cb; }
.alert-warning { background: #fff3cd; color: #856404; border: 1px solid #ffeeba; }
.alert-info    { background: #d1ecf1; color: #0c5460; border: 1px solid #bee5eb; }

/* ── Pagination ───────────────────────────────────────────── */
.pagination {
    display: flex;
    align-items: center;
    gap: .35rem;
    flex-wrap: wrap;
    margin-top: 1rem;
}

.pagination a, .pagination span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px; height: 34px;
    border-radius: 6px;
    font-size: .85rem;
    border: 1px solid #d1d5db;
    color: var(--abu-gelap);
    transition: all var(--transition);
}

.pagination a:hover { background: var(--hijau-pale); border-color: var(--hijau); color: var(--hijau); }
.pagination .active { background: var(--hijau); color: white; border-color: var(--hijau); }
.pagination .disabled { opacity: .4; pointer-events: none; }

/* ── Search Bar ───────────────────────────────────────────── */
.search-bar {
    display: flex;
    gap: .5rem;
    align-items: center;
    flex-wrap: wrap;
}

.search-input-wrap {
    position: relative;
    flex: 1;
    min-width: 200px;
}

.search-input-wrap .search-icon {
    position: absolute;
    left: .75rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--abu);
    font-size: .9rem;
}

.search-input-wrap input {
    padding-left: 2.2rem;
}

/* ── Modal ────────────────────────────────────────────────── */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.5);
    z-index: 2000;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.modal-overlay.show { display: flex; }

.modal {
    background: white;
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 520px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
    animation: modalIn .2s ease;
}

@keyframes modalIn {
    from { opacity: 0; transform: scale(.95) translateY(-10px); }
    to   { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-header {
    padding: 1.1rem 1.25rem;
    border-bottom: 1px solid var(--abu-muda);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.modal-header h4 { font-size: 1rem; font-weight: 600; }

.modal-close {
    background: none; border: none; cursor: pointer;
    font-size: 1.3rem; color: var(--abu); line-height: 1;
}

.modal-body { padding: 1.25rem; }
.modal-footer {
    padding: 1rem 1.25rem;
    border-top: 1px solid var(--abu-muda);
    display: flex;
    justify-content: flex-end;
    gap: .5rem;
}

/* ── Public Pages ─────────────────────────────────────────── */
.public-header {
    background: linear-gradient(135deg, var(--hijau-tua) 0%, var(--hijau) 100%);
    color: white;
    padding: 0;
    box-shadow: var(--shadow);
    position: sticky;
    top: 0;
    z-index: 500;
}

.public-header .header-top {
    background: rgba(0,0,0,.2);
    padding: .4rem 2rem;
    font-size: .78rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.public-header .header-main {
    padding: 1rem 2rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.public-header .logo-area {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.public-header .logo-icon {
    width: 56px; height: 56px;
    background: rgba(255,255,255,.2);
    border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.8rem;
}

.public-header .logo-text h1 { font-size: 1.2rem; font-weight: 700; }
.public-header .logo-text p  { font-size: .78rem; opacity: .85; }

.public-nav { display: flex; align-items: center; gap: .25rem; }

.public-nav a {
    color: rgba(255,255,255,.9);
    padding: .5rem .9rem;
    border-radius: 6px;
    font-size: .88rem;
    transition: background var(--transition);
}

.public-nav a:hover,
.public-nav a.active { background: rgba(255,255,255,.2); color: white; }

.hero-section {
    background: linear-gradient(135deg, var(--hijau-tua) 0%, var(--hijau) 60%, var(--hijau-muda) 100%);
    color: white;
    padding: 5rem 2rem;
    text-align: center;
}

.hero-section h1 { font-size: 2.5rem; font-weight: 800; margin-bottom: .75rem; }
.hero-section p  { font-size: 1.1rem; opacity: .9; max-width: 600px; margin: 0 auto 2rem; }

.public-container { max-width: 1200px; margin: 0 auto; padding: 0 1.5rem; }

.section-title {
    text-align: center;
    margin-bottom: 2.5rem;
}

.section-title h2 {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--abu-gelap);
    margin-bottom: .5rem;
}

.section-title p { color: var(--abu); }

.section-title .title-line {
    width: 60px; height: 4px;
    background: var(--hijau);
    border-radius: 2px;
    margin: .75rem auto 0;
}

/* ── Layanan Cards (public) ───────────────────────────────── */
.layanan-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1.5rem;
}

.layanan-card {
    background: white;
    border-radius: var(--radius-lg);
    padding: 2rem 1.5rem;
    text-align: center;
    box-shadow: var(--shadow);
    transition: transform var(--transition), box-shadow var(--transition);
    border-top: 4px solid var(--hijau);
}

.layanan-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-lg); }

.layanan-card .layanan-icon {
    width: 64px; height: 64px;
    background: var(--hijau-pale);
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.8rem;
    margin: 0 auto 1rem;
}

.layanan-card h3 { font-size: 1rem; font-weight: 600; margin-bottom: .5rem; }
.layanan-card p  { font-size: .85rem; color: var(--abu); }

/* ── Pengumuman Cards (public) ────────────────────────────── */
.pengumuman-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1.5rem;
}

.pengumuman-card {
    background: white;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
    transition: transform var(--transition);
}

.pengumuman-card:hover { transform: translateY(-2px); }

.pengumuman-card .card-kategori {
    padding: .35rem .85rem;
    font-size: .75rem;
    font-weight: 600;
    background: var(--hijau-pale);
    color: var(--hijau-tua);
    display: inline-block;
    border-radius: 0 0 8px 0;
}

.pengumuman-card .card-content { padding: 1rem 1.25rem; }
.pengumuman-card h3 { font-size: .95rem; font-weight: 600; margin-bottom: .5rem; }
.pengumuman-card p  { font-size: .85rem; color: var(--abu); line-height: 1.6; }
.pengumuman-card .card-date { font-size: .78rem; color: var(--abu); margin-top: .75rem; }

/* ── Login Page ───────────────────────────────────────────── */
.login-page {
    min-height: 100vh;
    background: linear-gradient(135deg, var(--hijau-tua) 0%, var(--hijau) 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
}

.login-card {
    background: white;
    border-radius: var(--radius-lg);
    padding: 2.5rem;
    width: 100%;
    max-width: 420px;
    box-shadow: var(--shadow-lg);
}

.login-logo {
    text-align: center;
    margin-bottom: 2rem;
}

.login-logo .logo-circle {
    width: 72px; height: 72px;
    background: var(--hijau-pale);
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 2rem;
    margin: 0 auto .75rem;
}

.login-logo h2 { font-size: 1.2rem; font-weight: 700; color: var(--abu-gelap); }
.login-logo p  { font-size: .82rem; color: var(--abu); }

/* ── Statistik Charts ─────────────────────────────────────── */
.chart-bar-wrap { padding: .5rem 0; }

.chart-bar-item { margin-bottom: .85rem; }

.chart-bar-label {
    display: flex;
    justify-content: space-between;
    font-size: .82rem;
    margin-bottom: .3rem;
    color: var(--abu-gelap);
}

.chart-bar-track {
    height: 10px;
    background: var(--abu-muda);
    border-radius: 5px;
    overflow: hidden;
}

.chart-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--hijau), var(--hijau-muda));
    border-radius: 5px;
    transition: width .8s ease;
}

/* ── Donut Chart (CSS) ────────────────────────────────────── */
.donut-wrap {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    flex-wrap: wrap;
}

.donut-legend { flex: 1; min-width: 140px; }

.donut-legend-item {
    display: flex;
    align-items: center;
    gap: .5rem;
    font-size: .83rem;
    margin-bottom: .5rem;
}

.donut-legend-dot {
    width: 10px; height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

/* ── Responsive ───────────────────────────────────────────── */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .main-content {
        margin-left: 0;
    }

    .btn-toggle-sidebar { display: block; }

    .stats-grid { grid-template-columns: repeat(2, 1fr); }

    .hero-section h1 { font-size: 1.75rem; }

    .public-header .header-top { display: none; }

    .public-nav { display: none; }

    .form-row { grid-template-columns: 1fr; }
}

@media (max-width: 480px) {
    .stats-grid { grid-template-columns: 1fr; }
    .page-content { padding: 1rem; }
}

/* ── Print ────────────────────────────────────────────────── */
@media print {
    .sidebar, .topbar, .btn, .no-print { display: none !important; }
    .main-content { margin-left: 0; }
    .card { box-shadow: none; border: 1px solid #ddd; }
}

/* ── Utilities ────────────────────────────────────────────── */
.text-center { text-align: center; }
.text-right  { text-align: right; }
.text-muted  { color: var(--abu); }
.text-success { color: #155724; }
.text-danger  { color: var(--merah); }
.mt-1 { margin-top: .5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mb-1 { margin-bottom: .5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }
.d-flex { display: flex; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-1 { gap: .5rem; }
.gap-2 { gap: 1rem; }
.w-100 { width: 100%; }
.fw-bold { font-weight: 700; }
.fs-sm { font-size: .82rem; }
