/* ============================================================
   SISTEM RT — Global Theme CSS
   Panggil di layout utama: <link rel="stylesheet" href="<?php echo base_url('assets/css/theme.css'); ?>">
   ============================================================ */

/* ===== LINKS ===== */
a {
    color: #0d9488;
    text-decoration: none;
    transition: color .15s;
}
a:hover {
    color: #0f766e;
    text-decoration: underline;
}
a.text-muted { color: #9ca3af !important; }
a.text-muted:hover { color: #6b7280 !important; }

/* Link di dalam tabel */
.rt-table a,
.section-card a {
    color: #0d9488;
    font-weight: 600;
}
.rt-table a:hover,
.section-card a:hover {
    color: #0f766e;
    text-decoration: underline;
}

/* Back link di form header */
.back-link {
    color: rgba(255,255,255,.8) !important;
    text-decoration: none;
    font-size: .78rem;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    margin-bottom: 4px;
}
.back-link:hover {
    color: #fff !important;
    text-decoration: none;
}

/* Btn-like links (action buttons) — override anchor blue */
.btn-act,
.btn-act:visited,
.btn-primary-teal,
.btn-primary-teal:visited,
.btn-cancel,
.btn-cancel:visited,
.btn-submit,
.btn-submit:visited {
    text-decoration: none;
}
.btn-act:hover { text-decoration: none; }

/* KK number link in table */
a.kk-link {
    color: #0d9488;
    font-weight: 700;
    font-family: monospace;
    font-size: .83rem;
}
a.kk-link:hover { color: #0f766e; text-decoration: underline; }

/* ===== RESET & BASE ===== */
.btn:focus,
.form-control:focus,
.form-select:focus,
textarea.form-control:focus {
    box-shadow: none;
}
.form-control:focus,
.form-select:focus,
textarea.form-control:focus {
    border-color: #20c997;
    box-shadow: 0 0 0 3px rgba(32, 201, 151, .12);
}
.form-control,
.form-select,
textarea.form-control {
    border-radius: 8px;
    border: 1.5px solid #e5e7eb;
    font-size: .88rem;
    padding: 9px 12px;
    color: #374151;
}
.form-control-sm,
.form-select-sm {
    font-size: .8rem !important;
    padding: 6px 8px !important;
    border-radius: 7px !important;
}
.form-label {
    font-size: .8rem;
    font-weight: 700;
    color: #374151;
    margin-bottom: 4px;
}


/* ============================================================
   SIDEBAR
   ============================================================ */
.sidebar {
    width: 220px;
    min-height: 100vh;
    background: linear-gradient(135deg, #0d9488 0%, #115e59 100%);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    z-index: 1000;
    overflow-y: auto;
    overflow-x: hidden;
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,.15) transparent;
}
.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-track { background: transparent; }
.sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,.15); border-radius: 4px; }

.sidebar-brand {
    padding: 20px 16px 16px;
    text-align: center;
    border-bottom: 1px solid rgba(255,255,255,.1);
    flex-shrink: 0;
}
.sidebar-brand .brand-icon {
    width: 42px; height: 42px;
    background: rgba(255,255,255,.18);
    border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    margin: 0 auto 8px;
}
.sidebar-brand .brand-icon i { font-size: 1.2rem; color: #fff; }
.sidebar-brand h4 {
    font-size: .9rem; font-weight: 800; color: #fff;
    margin: 0; letter-spacing: .06em; text-transform: uppercase;
}
.sidebar-brand small {
    font-size: .68rem; color: rgba(255,255,255,.55); font-weight: 500;
}

.sidebar-menu { padding: 8px 0 16px; flex: 1; }

.sidebar .nav-item { margin: 1px 8px; }
.sidebar .nav-link {
    display: flex; align-items: center; gap: 9px;
    padding: 8px 12px; border-radius: 8px;
    color: rgba(255,255,255,.75);
    font-size: .82rem; font-weight: 500;
    text-decoration: none;
    transition: all .15s ease;
    position: relative; white-space: nowrap;
}
.sidebar .nav-link i {
    font-size: .95rem; width: 18px;
    text-align: center; flex-shrink: 0; opacity: .85;
}
.sidebar .nav-link span { flex: 1; overflow: hidden; text-overflow: ellipsis; }
.sidebar .nav-link:hover { background: rgba(255,255,255,.1); color: #fff; }
.sidebar .nav-link:hover i { opacity: 1; }
.sidebar .nav-link.active { background: rgba(255,255,255,.18); color: #fff; font-weight: 700; }
.sidebar .nav-link.active i { opacity: 1; }
.sidebar .nav-link.active::before {
    content: '';
    position: absolute; left: 0; top: 50%; transform: translateY(-50%);
    width: 3px; height: 60%;
    background: #a7f3d0; border-radius: 0 2px 2px 0;
}
.sidebar .nav-link.logout-link { color: rgba(255,120,120,.8); margin-top: 4px; }
.sidebar .nav-link.logout-link:hover { background: rgba(239,68,68,.15); color: #fca5a5; }

.sidebar .nav-link .sb-badge {
    font-size: .62rem; font-weight: 700; padding: 2px 6px;
    border-radius: 999px; line-height: 1.2; flex-shrink: 0;
}
.sb-badge-danger { background: #ef4444; color: #fff; }
.sb-badge-info   { background: rgba(255,255,255,.2); color: rgba(255,255,255,.7); }

.sidebar .collapse .nav { padding: 2px 0 4px; }
.sidebar .collapse .nav-item { margin: 1px 0 1px 10px; }
.sidebar .collapse .nav-link { font-size: .79rem; padding: 6px 10px; border-radius: 7px; }
.sidebar .collapse .nav-link::before { display: none; }

.sidebar .nav-link .chevron {
    font-size: .65rem; color: rgba(255,255,255,.45);
    margin-left: auto; flex-shrink: 0;
    transition: transform .2s;
}
.sidebar .nav-link[aria-expanded="true"] .chevron { transform: rotate(180deg); }

/* Main content offset */
.main-content { margin-left: 220px; }


/* ============================================================
   STAT CARDS (dashboard & halaman lain)
   ============================================================ */
.stat-card-teal {
    border-radius: 10px; border: none;
    box-shadow: 0 1px 4px rgba(0,0,0,.08);
    background: linear-gradient(135deg, #1abc9c 0%, #16a085 100%);
    transition: transform .15s, box-shadow .15s;
}
.stat-card-teal:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(26,188,156,.25);
}
.stat-card-teal .card-body {
    padding: 14px 16px;
    display: flex; align-items: center; justify-content: space-between; gap: 10px;
}
.stat-card-icon {
    width: 40px; height: 40px; border-radius: 8px;
    background: rgba(255,255,255,.22);
    display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.stat-card-icon i { font-size: 1.2rem; color: #fff; }
.stat-card-label {
    font-size: .74rem; font-weight: 600; opacity: .88;
    color: #fff; margin-bottom: 2px; white-space: nowrap;
}
.stat-card-value {
    font-size: 1.35rem; font-weight: 800;
    color: #fff; line-height: 1.1; white-space: nowrap;
}

/* Mini stat card (for warga pages) */
.stat-card-mini {
    border-radius: 10px; border: none;
    box-shadow: 0 1px 4px rgba(0,0,0,.08);
}
.stat-card-mini .card-body {
    padding: 11px 14px;
    display: flex; align-items: center; gap: 10px;
}
.stat-card-mini-icon {
    width: 38px; height: 38px; border-radius: 8px;
    display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.stat-card-mini-icon i { font-size: 1.1rem; }


/* ============================================================
   SECTION CARD (tabel, list, konten utama)
   ============================================================ */
.section-card {
    border-radius: 14px; border: 1.5px solid #e5e7eb;
    box-shadow: 0 1px 5px rgba(0,0,0,.06);
    overflow: hidden; background: #fff; margin-bottom: 16px;
}
.section-card-header {
    padding: 12px 20px;
    display: flex; align-items: center; justify-content: space-between;
    border-bottom: 1px solid #f1f3f5; background: #fff;
}
.section-card-header .title {
    font-size: .85rem; font-weight: 700; color: #374151;
    display: flex; align-items: center; gap: 6px;
}
.section-card-header .title i { color: #20c997; }

/* Form block (untuk tambah/edit form) */
.form-block {
    border-radius: 10px; border: 1.5px solid #e5e7eb;
    background: #fff; margin-bottom: 20px; overflow: hidden;
}
.form-block-header {
    padding: 10px 16px;
    display: flex; align-items: center; justify-content: space-between;
    border-bottom: 1px solid #f1f3f5; background: #f8fffe;
}
.form-block-header .label {
    font-size: .8rem; font-weight: 700; color: #374151;
    display: flex; align-items: center; gap: 6px;
}
.form-block-header .label i { color: #20c997; }
.form-block-body { padding: 16px; }


/* ============================================================
   TABLES
   ============================================================ */
.rt-table th {
    font-size: .72rem; text-transform: uppercase; letter-spacing: .04em;
    color: #6b7280; font-weight: 700; padding: 10px 14px;
    background: #f8fffe; border-bottom: 1.5px solid #e5e7eb; white-space: nowrap;
}
.rt-table td {
    padding: 10px 14px; vertical-align: middle;
    font-size: .84rem; border-bottom: 1px solid #f3f4f6;
}
.rt-table tbody tr:last-child td { border-bottom: none; }
.rt-table tbody tr:hover { background: #f8fffe; }

/* Compact table (for forms) */
.rt-table-sm th {
    font-size: .69rem; text-transform: uppercase; letter-spacing: .04em;
    color: #6b7280; font-weight: 700; padding: 8px 10px;
    background: #f8fffe; border-bottom: 1.5px solid #e5e7eb; white-space: nowrap;
}
.rt-table-sm td {
    padding: 6px 6px; vertical-align: middle;
    border-bottom: 1px solid #f3f4f6; font-size: .82rem;
}
.rt-table-sm tbody tr:last-child td { border-bottom: none; }
.rt-table-sm tbody tr:hover { background: #f8fffe; }


/* ============================================================
   STATUS BADGES
   ============================================================ */
.status-badge {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 3px 9px; border-radius: 999px;
    font-size: .72rem; font-weight: 600; white-space: nowrap;
}

/* Iuran */
.sb-lunas      { background:#dcfce7; color:#166534; border:1px solid #bbf7d0; }
.sb-verifikasi { background:#fef9c3; color:#854d0e; border:1px solid #fde68a; }
.sb-pending    { background:#fee2e2; color:#991b1b; border:1px solid #fecaca; }

/* Surat */
.sb-diproses   { background:#dbeafe; color:#1e40af; border:1px solid #bfdbfe; }
.sb-selesai    { background:#dcfce7; color:#166534; border:1px solid #bbf7d0; }
.sb-ditolak    { background:#fee2e2; color:#991b1b; border:1px solid #fecaca; }

/* Hubungan */
.sb-kepala     { background:#dbeafe; color:#1e40af; border:1px solid #93c5fd; }
.sb-istri      { background:#cffafe; color:#155e75; border:1px solid #a5f3fc; }
.sb-anak       { background:#dcfce7; color:#166534; border:1px solid #bbf7d0; }
.sb-secondary  { background:#f3f4f6; color:#6b7280; border:1px solid #e5e7eb; }
.sb-warning    { background:#fef3c7; color:#92400e; border:1px solid #fde68a; }

/* Domisili */
.dom-tetap     { background:#dcfce7; color:#166534; border:1px solid #bbf7d0; }
.dom-kost      { background:#fef3c7; color:#92400e; border:1px solid #fde68a; }
.dom-kontrak   { background:#cffafe; color:#155e75; border:1px solid #a5f3fc; }
.dom-pendatang { background:#fee2e2; color:#991b1b; border:1px solid #fecaca; }
.dom-sementara { background:#f3f4f6; color:#6b7280; border:1px solid #e5e7eb; }

/* General */
.sb-other      { background:#f3f4f6; color:#6b7280; border:1px solid #e5e7eb; }
.badge-kk      { background:#dbeafe; color:#1e40af; border:1px solid #93c5fd; border-radius:6px; font-size:.68rem; font-weight:700; padding:2px 7px; }


/* ============================================================
   ACTION BUTTONS
   ============================================================ */
.btn-act {
    font-size: .78rem; padding: 5px 9px; border-radius: 7px;
    font-weight: 600; white-space: nowrap;
    display: inline-flex; align-items: center; gap: 3px;
    cursor: pointer; text-decoration: none;
}
.btn-act-view   { background:#dbeafe; border:1px solid #93c5fd;  color:#1e40af; }
.btn-act-view:hover  { background:#bfdbfe; color:#1e3a8a; }
.btn-act-ok     { background:#dcfce7; border:1px solid #6ee7b7;  color:#065f46; }
.btn-act-ok:hover    { background:#bbf7d0; color:#064e3b; }
.btn-act-edit   { background:#fef3c7; border:1px solid #fde68a;  color:#92400e; }
.btn-act-edit:hover  { background:#fde68a; color:#78350f; }
.btn-act-delete { background:#fee2e2; border:1px solid #fecaca;  color:#991b1b; }
.btn-act-delete:hover { background:#fecaca; color:#7f1d1d; }
.btn-act-add    { background:#dcfce7; border:1px solid #6ee7b7;  color:#065f46; }
.btn-act-add:hover   { background:#bbf7d0; }
.btn-act-print  { background:#ede9fe; border:1px solid #c4b5fd;  color:#5b21b6; }
.btn-act-print:hover { background:#ddd6fe; }
.btn-act-warn   { background:#fef3c7; border:1px solid #fde68a;  color:#92400e; }
.btn-act-warn:hover  { background:#fde68a; }


/* ============================================================
   PAGE HEADER BUTTONS
   ============================================================ */
.page-header-btns { display: flex; gap: 8px; flex-wrap: wrap; }
.page-header-btns .btn {
    font-size: .82rem; padding: 7px 14px;
    border-radius: 8px; font-weight: 600; white-space: nowrap;
}
.btn-primary-teal {
    background: #20c997; color: #fff; border: none;
    border-radius: 8px; font-size: .84rem; font-weight: 700;
    padding: 8px 16px; display: inline-flex; align-items: center; gap: 6px;
    cursor: pointer; text-decoration: none; transition: background .15s;
}
.btn-primary-teal:hover { background: #17a589; color: #fff; }


/* ============================================================
   FORM CARD (edit / tambah halaman penuh)
   ============================================================ */
.rt-form-card {
    border-radius: 14px; border: 1.5px solid #e5e7eb;
    box-shadow: 0 1px 6px rgba(0,0,0,.07); overflow: hidden; background: #fff;
}
.rt-form-card-header {
    background: linear-gradient(135deg, #1abc9c 0%, #16a085 100%);
    padding: 15px 24px;
}
.rt-form-card-header .back-link {
    font-size: .78rem; color: rgba(255,255,255,.8); text-decoration: none;
    display: inline-flex; align-items: center; gap: 4px; margin-bottom: 4px;
}
.rt-form-card-header .back-link:hover { color: #fff; }
.rt-form-card-header h5 { font-size: .98rem; font-weight: 800; color: #fff; margin: 0; }
.rt-form-card-body { padding: 24px; }

.form-footer {
    display: flex; justify-content: space-between; align-items: center;
    border-top: 1.5px solid #f1f3f5; padding-top: 18px; margin-top: 4px;
}
.btn-cancel {
    font-size: .84rem; font-weight: 600; padding: 8px 18px;
    border-radius: 8px; border: 1.5px solid #e5e7eb;
    color: #6b7280; background: #fff; text-decoration: none;
    display: inline-flex; align-items: center; gap: 5px; transition: background .15s;
}
.btn-cancel:hover { background: #f3f4f6; color: #374151; }
.btn-submit {
    font-size: .84rem; font-weight: 700; padding: 9px 24px;
    border-radius: 8px; border: none; background: #20c997; color: #fff;
    display: inline-flex; align-items: center; gap: 6px;
    cursor: pointer; transition: background .15s;
}
.btn-submit:hover { background: #17a589; color: #fff; }
.btn-tambah-baris {
    font-size: .78rem; font-weight: 700; padding: 6px 12px;
    border-radius: 8px; border: 1.5px solid #6ee7b7;
    color: #065f46; background: #d1fae5; cursor: pointer;
    display: inline-flex; align-items: center; gap: 4px; transition: background .15s;
}
.btn-tambah-baris:hover { background: #a7f3d0; }


/* ============================================================
   INFO BOXES
   ============================================================ */
.info-box-teal {
    background: #f0fdf4; border: 1.5px solid #6ee7b7;
    border-radius: 8px; padding: 9px 14px;
    font-size: .78rem; color: #065f46;
    display: flex; align-items: flex-start; gap: 8px;
}
.info-box-blue {
    background: #eff6ff; border: 1.5px solid #bfdbfe;
    border-radius: 12px; padding: 12px 16px;
    font-size: .82rem; color: #1e40af;
    display: flex; align-items: flex-start; gap: 10px;
}
.info-box-yellow {
    background: #fffbeb; border: 1.5px solid #fde68a;
    border-radius: 8px; padding: 10px 14px;
    font-size: .78rem; color: #92400e;
    display: flex; align-items: flex-start; gap: 8px;
}


/* ============================================================
   FLASH MESSAGES
   ============================================================ */
.flash-success {
    border-radius: 10px; font-size: .83rem;
    border: 1.5px solid #6ee7b7; background: #f0fdf4; color: #065f46;
    padding: 10px 14px; margin-bottom: 12px;
    display: flex; align-items: center; gap: 8px;
}
.flash-error {
    border-radius: 10px; font-size: .83rem;
    border: 1.5px solid #fecaca; background: #fee2e2; color: #991b1b;
    padding: 10px 14px; margin-bottom: 12px;
    display: flex; align-items: center; gap: 8px;
}
.flash-warning {
    border-radius: 10px; font-size: .83rem;
    border: 1.5px solid #fde68a; background: #fffbeb; color: #92400e;
    padding: 10px 14px; margin-bottom: 12px;
    display: flex; align-items: center; gap: 8px;
}
.alert-danger-custom {
    border-radius: 10px; font-size: .83rem;
    border: 1.5px solid #fecaca; background: #fee2e2; color: #991b1b;
    padding: 10px 14px; margin-bottom: 16px;
    display: flex; align-items: center; gap: 8px;
}


/* ============================================================
   FILTER CARD
   ============================================================ */
.filter-card {
    border-radius: 12px; border: 1.5px solid #e5e7eb;
    box-shadow: none; margin-bottom: 16px; background: #fff;
}
.filter-card .card-body { padding: 14px 18px; }


/* ============================================================
   MODAL
   ============================================================ */
.modal-content {
    border-radius: 14px; border: none;
    box-shadow: 0 8px 32px rgba(0,0,0,.12);
}
.modal-header { padding: 15px 20px; border-bottom: 1px solid #f1f3f5; }
.modal-body   { padding: 20px; }
.modal-footer { padding: 13px 20px; border-top: 1px solid #f1f3f5; }
.modal-header-teal {
    background: linear-gradient(135deg, #1abc9c, #16a085);
}
.modal-header-yellow {
    background: #fffbeb; border-bottom: 1.5px solid #fde68a !important;
}
.modal-header-red {
    background: #fee2e2; border-bottom: 1.5px solid #fecaca !important;
}


/* ============================================================
   KK INFO CARD
   ============================================================ */
.kk-info-card {
    border-radius: 14px; border: 1.5px solid #e5e7eb;
    box-shadow: 0 1px 5px rgba(0,0,0,.06); background: #fff; margin-bottom: 16px; overflow: hidden;
}
.kk-info-header {
    background: linear-gradient(135deg, #1abc9c 0%, #16a085 100%);
    padding: 14px 20px; display: flex; align-items: center; gap: 10px;
}
.kk-info-header .kk-no  { font-size:.78rem; font-weight:700; color:rgba(255,255,255,.85); letter-spacing:.03em; text-transform:uppercase; margin-bottom:2px; }
.kk-info-header .kk-kepala { font-size:1rem; font-weight:800; color:#fff; }
.kk-info-badge { background:rgba(255,255,255,.22); border-radius:8px; padding:6px 12px; color:#fff; font-size:.78rem; font-weight:700; white-space:nowrap; flex-shrink:0; }
.kk-info-body  { padding:14px 20px; display:flex; flex-wrap:wrap; gap:16px; }
.kk-info-item .lbl { font-size:.72rem; color:#9ca3af; font-weight:600; text-transform:uppercase; letter-spacing:.04em; margin-bottom:2px; }
.kk-info-item .val { font-size:.85rem; font-weight:600; color:#374151; }

/* Avatar */
.kk-avatar {
    width: 32px; height: 32px; border-radius: 8px;
    background: linear-gradient(135deg, #1abc9c, #16a085);
    color: #fff; font-size: .78rem; font-weight: 800;
    display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}

/* Verif alert */
.verif-alert {
    background: #fffbeb; border: 1.5px solid #fde68a;
    border-radius: 12px; padding: 13px 18px; margin-bottom: 16px;
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.verif-alert .va-text { font-size: .85rem; font-weight: 600; color: #92400e; }
.btn-verif-now {
    background: #f59e0b; border: none; color: #fff;
    border-radius: 8px; padding: 6px 14px; font-size: .8rem; font-weight: 700; white-space: nowrap;
}
.btn-verif-now:hover { background: #d97706; color: #fff; }

/* NIK input */
.nik-input.is-invalid { border-color: #ef4444; background: #fff5f5; }


/* ============================================================
   MOBILE TOGGLE (desktop table vs mobile card list)
   ============================================================ */
.desktop-table    { display: block; }
.mobile-card-list { display: none; }


/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 991.98px) {
    .sidebar { transform: translateX(-100%); transition: transform .25s ease; }
    .sidebar.show { transform: translateX(0); box-shadow: 4px 0 24px rgba(0,0,0,.18); }
    .main-content { margin-left: 0 !important; }
}

@media (max-width: 767.98px) {
    .container-fluid { padding-left: 12px !important; padding-right: 12px !important; }

    /* Page headers */
    .page-header { flex-direction: column !important; align-items: flex-start !important; gap: 10px; }
    .page-header-btns { display: grid; grid-template-columns: 1fr 1fr; width: 100%; }
    .page-header-btns .btn,
    .page-header-btns .btn-primary-teal { justify-content: center; }
    .btn-primary-teal.full-mobile { width: 100%; justify-content: center; }

    /* Stat cards 2 col */
    .stat-row > [class*='col-'] { flex: 0 0 50% !important; max-width: 50% !important; }

    /* Form card */
    .rt-form-card-body { padding: 14px; }
    .rt-form-card-header { padding: 12px 16px; }
    .form-block-body { padding: 12px; }
    .form-footer { flex-direction: column-reverse; gap: 8px; }
    .form-footer .btn-cancel,
    .form-footer .btn-submit { width: 100%; justify-content: center; }

    /* KK info */
    .kk-info-header { flex-wrap: wrap; gap: 8px; }
    .kk-info-item { min-width: calc(50% - 8px); flex: none; }

    /* Verif alert */
    .verif-alert { flex-direction: column; align-items: flex-start; }
    .btn-verif-now { width: 100%; text-align: center; }

    /* Table -> card list switch */
    .desktop-table    { display: none !important; }
    .mobile-card-list { display: flex !important; flex-direction: column; gap: 8px; padding: 10px; }

    /* Horizontal scroll for form tables */
    .table-scroll-mobile { overflow-x: auto; -webkit-overflow-scrolling: touch; }
    .table-scroll-mobile table { min-width: 700px; }

    /* Charts full width */
    .chart-row > [class*='col-'] { flex: 0 0 100% !important; max-width: 100% !important; }
    .top5-row  > [class*='col-'] { flex: 0 0 100% !important; max-width: 100% !important; }
}