/* ============================================================
   Pendataan Warga Muna di Banggai - Clean White Theme
   ============================================================ */

:root {
    --primary: #0d6efd;
    --primary-light: #e8f4fd;
    --primary-dark: #0a58ca;
    --accent: #0288d1;
    --success: #198754;
    --warning: #ffc107;
    --danger: #dc3545;
    --gray-50: #f8f9fa;
    --gray-100: #f0f2f5;
    --gray-200: #e9ecef;
    --gray-300: #dee2e6;
    --gray-400: #ced4da;
    --gray-500: #adb5bd;
    --gray-600: #6c757d;
    --gray-700: #495057;
    --gray-800: #343a40;
    --gray-900: #212529;
    --white: #ffffff;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.08);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.1);
    --shadow-lg: 0 8px 24px rgba(0,0,0,0.12);
    --radius: 10px;
    --radius-sm: 6px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--gray-50);
    color: var(--gray-800);
    line-height: 1.6;
    min-height: 100vh;
}

/* ─── LOGIN ─────────────────────────────── */
.login-body {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: linear-gradient(135deg, #e8f4fd 0%, #f0f2f5 100%);
    padding: 20px;
}
.login-container {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    padding: 40px 36px;
    width: 100%;
    max-width: 400px;
    text-align: center;
}
.login-logo { margin-bottom: 16px; }
.logo-img { width: 80px; height: 80px; border-radius: 50%; object-fit: cover; border: 3px solid var(--primary-light); }
.login-title { font-size: 1.3rem; color: var(--gray-900); font-weight: 700; margin-bottom: 4px; }
.login-subtitle { font-size: 0.9rem; color: var(--gray-600); margin-bottom: 24px; }
.login-form { text-align: left; }
.login-footer { margin-top: 20px; font-size: 0.8rem; color: var(--gray-500); }

/* ─── ALERTS ────────────────────────────── */
.alert {
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    margin-bottom: 16px;
    font-size: 0.9rem;
}
.alert-error { background: #fef2f2; color: var(--danger); border: 1px solid #fecaca; }

/* ─── FORM ──────────────────────────────── */
.form-group { margin-bottom: 14px; }
.form-group label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--gray-700);
    margin-bottom: 4px;
}
.form-group input, .form-group select, .form-group textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1.5px solid var(--gray-300);
    border-radius: var(--radius-sm);
    font-size: 0.95rem;
    color: var(--gray-800);
    background: var(--white);
    transition: border-color 0.2s, box-shadow 0.2s;
    font-family: inherit;
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(13,110,253,0.12);
}
.form-group textarea { resize: vertical; min-height: 60px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }
.form-section-title {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--primary-dark);
    padding-bottom: 6px;
    border-bottom: 2px solid var(--primary-light);
    margin-bottom: 12px;
    margin-top: 16px;
}

/* ─── BUTTONS ───────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 20px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
    text-decoration: none;
}
.btn-primary { background: var(--primary); color: var(--white); }
.btn-primary:hover { background: var(--primary-dark); }
.btn-success { background: var(--success); color: var(--white); }
.btn-success:hover { background: #157347; }
.btn-warning { background: var(--warning); color: var(--gray-900); }
.btn-danger { background: var(--danger); color: var(--white); }
.btn-danger:hover { background: #b02a37; }
.btn-outline { background: transparent; color: var(--primary); border: 1.5px solid var(--primary); }
.btn-outline:hover { background: var(--primary-light); }
.btn-sm { padding: 6px 12px; font-size: 0.8rem; }
.btn-full { width: 100%; }

/* ─── HEADER / NAVBAR ──────────────────── */
.navbar {
    background: var(--white);
    border-bottom: 1px solid var(--gray-200);
    padding: 12px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: var(--shadow-sm);
    position: sticky;
    top: 0;
    z-index: 100;
}
.navbar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    color: var(--gray-900);
    font-weight: 700;
    font-size: 1.05rem;
}
.navbar-brand img { width: 36px; height: 36px; border-radius: 50%; object-fit: cover; }
.navbar-right { display: flex; align-items: center; gap: 12px; }
.navbar-user { font-size: 0.85rem; color: var(--gray-600); }
.navbar-kecamatan { font-size: 0.8rem; color: var(--primary); font-weight: 600; }

/* ─── MAIN LAYOUT ──────────────────────── */
.container {
    max-width: 1100px;
    margin: 0 auto;
    padding: 20px 16px;
}

/* ─── STAT CARDS ───────────────────────── */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin-bottom: 24px; }
.stat-card {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    padding: 18px 16px;
    text-align: center;
    border: 1px solid var(--gray-200);
}
.stat-card .stat-value {
    font-size: 1.8rem;
    font-weight: 800;
    color: var(--primary);
    line-height: 1.2;
}
.stat-card .stat-label {
    font-size: 0.8rem;
    color: var(--gray-600);
    margin-top: 4px;
}

/* ─── TABS ──────────────────────────────── */
.tabs {
    display: flex;
    gap: 4px;
    background: var(--gray-100);
    padding: 4px;
    border-radius: var(--radius);
    margin-bottom: 20px;
    overflow-x: auto;
}
.tab-btn {
    padding: 8px 18px;
    border: none;
    background: transparent;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--gray-600);
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
    font-family: inherit;
}
.tab-btn.active {
    background: var(--white);
    color: var(--primary);
    box-shadow: var(--shadow-sm);
}
.tab-btn:hover:not(.active) { color: var(--gray-800); }
.tab-content { display: none; }
.tab-content.active { display: block; }

/* ─── CARDS ─────────────────────────────── */
.card {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    padding: 20px;
    margin-bottom: 16px;
    border: 1px solid var(--gray-200);
}
.card-title {
    font-size: 1rem;
    font-weight: 700;
    color: var(--gray-900);
    margin-bottom: 16px;
}

/* ─── INPUT KELUARGA ────────────────────── */
.input-group {
    display: flex;
    gap: 8px;
}
.input-group input, .input-group select { flex: 1; }
.input-group .btn { flex-shrink: 0; }

.keluarga-info {
    background: var(--primary-light);
    border-radius: var(--radius-sm);
    padding: 14px;
    margin-bottom: 12px;
    font-size: 0.9rem;
}
.keluarga-info strong { color: var(--primary-dark); }

/* ─── ANGGOTA LIST ──────────────────────── */
.anggota-list { margin-top: 12px; }
.anggota-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    background: var(--gray-50);
    border-radius: var(--radius-sm);
    margin-bottom: 6px;
    border-left: 3px solid var(--primary);
    font-size: 0.9rem;
}
.anggota-item .anggota-nama { font-weight: 600; }
.anggota-item .anggota-detail { font-size: 0.8rem; color: var(--gray-600); }
.anggota-item .badge {
    font-size: 0.7rem;
    padding: 2px 8px;
    border-radius: 12px;
    background: var(--primary-light);
    color: var(--primary-dark);
    font-weight: 600;
}

/* ─── TABEL ─────────────────────────────── */
.table-container { overflow-x: auto; }
table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}
table th {
    background: var(--gray-50);
    color: var(--gray-700);
    font-weight: 700;
    text-align: left;
    padding: 10px 12px;
    border-bottom: 2px solid var(--gray-200);
    white-space: nowrap;
}
table td {
    padding: 8px 12px;
    border-bottom: 1px solid var(--gray-100);
    vertical-align: top;
}
table tr:hover { background: var(--gray-50); }

/* ─── FILTER ────────────────────────────── */
.filter-bar {
    display: flex;
    gap: 10px;
    align-items: center;
    margin-bottom: 16px;
    flex-wrap: wrap;
}
.filter-bar select, .filter-bar input { padding: 8px 12px; border: 1.5px solid var(--gray-300); border-radius: var(--radius-sm); font-size: 0.9rem; }

/* ─── RESPONSIVE ────────────────────────── */
@media (max-width: 640px) {
    .form-row { grid-template-columns: 1fr; }
    .form-row-3 { grid-template-columns: 1fr; }
    .navbar { padding: 10px 14px; }
    .container { padding: 14px 10px; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .stat-card { padding: 14px; }
    .stat-card .stat-value { font-size: 1.4rem; }
    .filter-bar { flex-direction: column; }
    .filter-bar select, .filter-bar input { width: 100%; }
    .input-group { flex-direction: column; }
    .login-container { padding: 30px 20px; }
}

/* ─── UTILITY ───────────────────────────── */
.text-muted { color: var(--gray-600); }
.text-sm { font-size: 0.85rem; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; }
.mb-2 { margin-bottom: 8px; }
.mb-3 { margin-bottom: 12px; }
.flex { display: flex; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 8px; }
.flex-1 { flex: 1; }

/* Scrollbar */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--gray-100); }
::-webkit-scrollbar-thumb { background: var(--gray-400); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--gray-500); }

/* Logo Elegant Styling */
.navbar-brand img {
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    padding: 2px;
    background: white;
    transition: transform 0.2s, box-shadow 0.2s;
}
.navbar-brand img:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 16px rgba(13,110,253,0.15);
}
.login-logo img {
    border-radius: 16px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.1);
    padding: 4px;
    background: white;
    width: 140px;
    height: 140px;
    object-fit: contain;
}


/* ─── FILTER BUILDER ────────────────────── */
.filter-builder {
    background:#f8f9fc;
    border:1px solid #e0e0e0;
    border-radius:10px;
    padding:16px;
    margin-top:10px;
    margin-bottom:16px;
}
.filter-row {
    display:flex;
    gap:8px;
    align-items:center;
    margin-bottom:8px;
    flex-wrap:wrap;
}
.filter-row select, .filter-row input {
    padding:7px 10px;
    border:1px solid #ddd;
    border-radius:6px;
    font-size:0.85rem;
    font-family:inherit;
}
.filter-row .field-select { width:180px; }
.filter-row .op-select { width:140px; }
.filter-row .val-input { width:140px; }
.filter-row .val-input-sm { width:80px; }
.filter-row .btn-remove-filter {
    background:#fee;
    color:#c62828;
    border:1px solid #fcc;
    border-radius:6px;
    padding:4px 10px;
    cursor:pointer;
    font-weight:700;
    font-size:0.9rem;
    line-height:1;
}
.filter-row .btn-remove-filter:hover { background:#fcc; }
.filter-chips {
    display:flex;
    gap:6px;
    flex-wrap:wrap;
    margin:10px 0;
}
.filter-chip {
    background:#e8eaf6;
    color:#1a237e;
    padding:4px 10px;
    border-radius:16px;
    font-size:0.78rem;
    display:inline-flex;
    align-items:center;
    gap:4px;
}
.filter-chip .remove-chip {
    cursor:pointer;
    font-weight:700;
    color:#c62828;
    margin-left:4px;
}
.filter-chip .remove-chip:hover { color:#b71c1c; }
.filter-actions {
    display:flex;
    gap:10px;
    margin-top:10px;
    flex-wrap:wrap;
}

/* 🎯 Filter Builder - Mobile Responsive */
@media (max-width: 768px) {
    .filter-builder {
        padding: 12px;
        margin-left: -4px;
        margin-right: -4px;
        border-radius: 8px;
    }
    .filter-row {
        flex-direction: column;
        align-items: stretch;
        gap: 6px;
        padding: 10px;
        background: #f0f2f8;
        border-radius: 8px;
        margin-bottom: 8px;
    }
    .filter-row .field-select,
    .filter-row .op-select,
    .filter-row .val-input {
        width: 100% !important;
        min-width: 0;
    }
    .filter-row .val-input-sm {
        width: 45% !important;
        min-width: 0;
    }
    .filter-row .btn-remove-filter {
        align-self: flex-end;
        width: 100%;
        text-align: center;
        padding: 6px 10px;
    }
    .filter-actions {
        flex-direction: column;
        gap: 6px;
    }
    .filter-actions .btn {
        width: 100%;
        justify-content: center;
        padding: 10px 14px;
        font-size: 0.85rem;
    }
    .filter-chip {
        font-size: 0.72rem;
        padding: 3px 8px;
    }
    .filter-bar {
        flex-direction: column;
        gap: 8px;
        align-items: stretch !important;
    }
    .filter-bar input,
    .filter-bar select,
    .filter-bar button {
        width: 100%;
    }
    .filter-bar .text-muted {
        text-align: center;
    }
}
@media (max-width: 480px) {
    .filter-row {
        padding: 8px;
    }
    .filter-row select, .filter-row input {
        font-size: 0.8rem;
        padding: 8px 10px;
    }
}
