/* ============================================
   DASHBOARD.CSS - KHUSUS HALAMAN DASHBOARD
============================================ */

/* ===== LAYOUT ===== */
.app-layout { display: flex; min-height: 100vh; }

/* ===== SIDEBAR ===== */
.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-sidebar);
    border-right: 2px solid var(--border-color);
    padding: 20px 0;
    margin-top: 10px;
    flex-shrink: 0;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    transition: width 0.8s cubic-bezier(0.4, 0, 0.2, 1), padding 0.5s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 100;
}
.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-track { background: transparent; }
.sidebar::-webkit-scrollbar-thumb { background: var(--border-color); border-radius: 10px; }

.sidebar-logo {
    padding: 0 24px 28px 24px;
    display: flex;
    align-items: center;
    gap: 12px;
}
.sidebar-logo .logo-icon {
    width: 36px;
    height: 36px;
    background: var(--brand-orange);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 700;
    font-size: 18px;
    flex-shrink: 0;
}
.sidebar-logo h1 {
    font-family: 'Lora', serif;
    font-size: 18px;
    font-weight: 600;
    color: var(--brand-orange);
}
.sidebar-logo .sub {
    display: block;
    font-size: 10px;
    font-family: 'Inter', sans-serif;
    font-weight: 400;
    color: var(--text-secondary);
    letter-spacing: 0.5px;
}

.sidebar-menu {
    list-style: none;
    padding: 0 12px;
    margin-top: 30px;
    border-radius: 4px;
}
.sidebar-menu li {
    padding: 2px 4px;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-secondary);
    border-radius: 10px;
    font-size: 0.80rem;
    font-weight: 500;
    margin-bottom: 15px;
    background: transparent;
    border: 1px solid transparent;
    box-shadow: none;
    white-space: nowrap;
}
.sidebar-menu li:hover {
    background: var(--bg-highlight);
    color: var(--daun-tua);
    border-color: var(--daun-muda);
    transform: translateY(-2px);
    box-shadow: var(--shadow-hover);
}
.sidebar-menu li.active {
    background: var(--border-color);
    color: black;
    border-color: var(--daun-tua);
    box-shadow: 0 4px 12px rgba(46, 125, 50, 0.3);
}
.sidebar-menu li .icon {
    font-size: 1rem;
    width: 22px;
    text-align: center;
    flex-shrink: 0;
    line-height: 1;
}
.sidebar-menu .divider {
    height: 1px;
    background: var(--border-color);
    margin: 12px 16px;
}

/* ===== SIDEBAR RESIZER ===== */
.sidebar-resizer {
    position: absolute;
    right: -12px;
    top: 80%;
    transform: translateY(-50%);
    width: 40px;
    height: 90px;
    cursor: pointer;
    z-index: 10;
    background: var(--krem);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
    box-shadow: var(--shadow-card);
}
.sidebar-resizer:hover {
    border-color: var(--daun-muda);
    box-shadow: var(--shadow-hover);
}
.sidebar-resizer .resizer-icon {
    font-size: 25px;
    color: var(--text-secondary);
    transition: var(--transition);
    line-height: 1;
    letter-spacing: 2px;
}
.sidebar-resizer:hover .resizer-icon {
    color: var(--daun-tua);
}

/* ===== SIDEBAR COLLAPSED ===== */
.sidebar.collapsed {
    width: 64px;
    padding: 16px 0;
}
.sidebar.collapsed .sidebar-logo h1,
.sidebar.collapsed .sidebar-logo .sub,
.sidebar.collapsed .sidebar-menu li span:not(.icon) {
    display: none;
}
.sidebar.collapsed .sidebar-logo {
    padding: 0 12px 16px 12px;
    justify-content: center;
}
.sidebar.collapsed .sidebar-menu li {
    padding: 8px 4px;
    border-radius: 4px;
    justify-content: center;
    background: var(--krem);
}
.sidebar.collapsed .sidebar-menu li .icon {
    font-size: 20px;
    width: auto;
    text-align: center;
    flex-shrink: 2;
    line-height: 1;
}
.sidebar.collapsed .sidebar-menu .divider {
    margin: 8px 12px;
}
.sidebar.collapsed .sidebar-resizer {
    right: -6px;
    width: 19px;
}

/* ===== MAIN CONTENT ===== */
.main-content { flex: 1; padding: 24px 32px; min-width: 0; }

/* ===== HEADER ===== */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 0 20px 0;
    margin-bottom: 24px;
    border-bottom: 1px solid var(--border-color);
    flex-wrap: wrap;
    gap: 12px;
}
.header-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

/* ===== TOOLBAR ===== */
.toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    background: var(--bg-toolbar);
    padding: 0.5rem 0.8rem;
    border-radius: var(--radius-card);
    border: 1px solid var(--border-color);
    margin-bottom: 1.5rem;
    align-items: center;
    transition: var(--transition);
}
.toolbar .search-wrap {
    flex: 2;
    min-width: 140px;
    display: flex;
    align-items: center;
    gap: 0.3rem;
    background: var(--bg-input);
    border-radius: 10px;
    padding: 0 0.5rem;
    border: 1.5px solid var(--border-color);
    transition: var(--transition);
}
.toolbar .search-wrap:focus-within {
    border-color: var(--daun-muda);
    box-shadow: 0 0 0 3px rgba(139, 195, 74, 0.15);
}
.toolbar .search-wrap input {
    border: none;
    background: transparent;
    padding: 0.4rem 0.2rem;
    font-size: 0.85rem;
    font-family: inherit;
    width: 100%;
    outline: none;
    color: var(--text-primary);
}
.toolbar .search-wrap .search-icon {
    color: var(--text-secondary);
    font-size: 0.9rem;
}
.toolbar select {
    padding: 0.4rem 0.6rem;
    border: 1.5px solid var(--border-color);
    border-radius: 10px;
    font-size: 0.8rem;
    font-family: inherit;
    background: var(--bg-input);
    min-width: 110px;
    flex: 1;
    cursor: pointer;
    color: var(--text-primary);
}
.toolbar select:focus {
    outline: none;
    border-color: var(--daun-muda);
    box-shadow: 0 0 0 3px rgba(139, 195, 74, 0.15);
}
.toolbar .reset-btn {
    background: var(--bg-badge);
    border: 1px solid var(--border-color);
    padding: 0.35rem 0.8rem;
    border-radius: 40px;
    cursor: pointer;
    font-weight: 500;
    color: var(--text-secondary);
    transition: var(--transition);
    font-size: 0.75rem;
    white-space: nowrap;
}
.toolbar .reset-btn:hover {
    background: var(--border-color);
}
.real-time {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    font-size: 0.75rem;
    color: var(--text-secondary);
    white-space: nowrap;
}

/* ===== STATS ===== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 16px;
    margin-bottom: 28px;
}
.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-card);
    padding: 20px 24px;
    box-shadow: var(--shadow-card);
    transition: var(--transition);
}
.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-hover);
}
.stat-card .stat-icon {
    font-size: 20px;
    display: block;
    margin-bottom: 4px;
}
.stat-card .stat-number {
    font-size: 28px;
    font-weight: 700;
    color: var(--brand-orange);
    line-height: 1.2;
}
.stat-card .stat-label {
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 2px;
}

#visitorStatCard {
    grid-column: span 2;
}
#visitorStatCard canvas {
    width: 100% !important;
    height: 50px !important;
}

/* ============================================
   TABLE
============================================ */
.table-wrapper {
    position: relative;
	background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-card);
    box-shadow: var(--shadow-card);
    margin-top: 20px;
}
.table-scroll {
    overflow-x: auto;
    overflow-y: auto;
    padding: 0;
    -webkit-overflow-scrolling: touch;
    max-height: 600px;
}
table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
    min-width: 650px;
}
th {
    text-align: left;
    padding: 12px 16px;
    font-weight: 600;
    color: var(--text-secondary);
    background: var(--bg-hover);
    border-bottom: 1px solid var(--border-color);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    white-space: nowrap;
}
td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-primary);
    vertical-align: middle;
}
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--bg-hover); }

.table-header {
    padding: 16px 20px;
    border-bottom: 2px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
}
.table-header h3 {
    font-family: 'Lora', serif;
    font-size: 18px;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 8px;
}
.table-header .table-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ============================================
   TAB CONTENT
============================================ */
.tab-content {
    display: none;
}
.tab-content:first-of-type {
    display: block;
}

/* ============================================
   TAB VISITOR
============================================ */
#tabVisitor .table-scroll {
    max-height: 600px;
    overflow-y: auto;
	padding: 0 2px;  /* ← TAMBAH PADDING KECIL */
    scrollbar-width: thin;  /* ← TIPISKAN SCROLL */
    scrollbar-color: var(--border-color) transparent;
}
#tabVisitor table {
    table-layout: fixed;
    width: 100%;
    min-width: 800px;
}
#tabVisitor .table-scroll::-webkit-scrollbar {
    width: 6px;  /* ← TIPIS! */
    height: 6px;
}
#tabVisitor .table-scroll::-webkit-scrollbar-track {
    background: transparent;  /* ← TRANSPARAN! */
}
#tabVisitor .table-scroll::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 10px;
}
#tabVisitor .table-scroll::-webkit-scrollbar-thumb:hover {
    background: var(--text-secondary);
}

#tabVisitor th:nth-child(1) { width: 5%; }
#tabVisitor th:nth-child(2) { width: 7%; }
#tabVisitor th:nth-child(3) { width: 18%; }   /* ← 20% → 18% (dikurangi) */
#tabVisitor th:nth-child(4) { width: 8%; }    /* ← 10% → 8% (dikurangi) */
#tabVisitor th:nth-child(5) { width: 10%; }   /* ← 12% → 10% (dikurangi) */
#tabVisitor th:nth-child(6) { width: 20%; }   /* ← 14% → 20% (DIPERBESAR!) */
#tabVisitor th:nth-child(7) { width: 18%; }
#tabVisitor th:nth-child(8) { width: 14%; }
#tabVisitor td {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
#tabVisitor td:nth-child(5),
#tabVisitor td:nth-child(6) {
    font-size: 0.65rem;
}
/* 🔥 KHUSUS KOLOM IP (kolom ke-6) */
#tabVisitor td:nth-child(6) {
    font-size: 0.6rem;
    word-break: break-all;     /* ← BIAR IPv6 BISA WRAP KALO KEPANJANGAN */
    white-space: normal;       /* ← BIAR BISA TURUN BARIS */
    max-width: 100px;          /* ← BIAR GA KELUAR DARI TABEL */
}

#tabVisitor td:nth-child(5),
#tabVisitor td:nth-child(7) {
    font-size: 0.65rem;
}

/* ============================================
   TAB PENGUMUMAN
============================================ */
#tabPengumuman table {
    table-layout: fixed;
    width: 100%;
    min-width: 650px;
}
#tabPengumuman th:nth-child(1) { width: 5%; }
#tabPengumuman th:nth-child(2) { width: 25%; }
#tabPengumuman th:nth-child(3) { width: 15%; }
#tabPengumuman th:nth-child(4) { width: 15%; }
#tabPengumuman th:nth-child(5) { width: 15%; }
#tabPengumuman th:nth-child(6) { width: 20%; }

/* ============================================
   TAB PENGURUS
============================================ */
/* ============================================
   TAB PENGURUS
============================================ */
#tabPengurus table {
    table-layout: fixed;
    width: 100%;
    min-width: 800px;
}

/* 🔥 10 KOLOM (TOTAL 100%) */
#tabPengurus th:nth-child(1) { width: 4%; }   /* ID */
#tabPengurus th:nth-child(2) { width: 12%; }  /* Nama */
#tabPengurus th:nth-child(3) { width: 10%; }  /* Posisi */
#tabPengurus th:nth-child(4) { width: 10%; }  /* Role */
#tabPengurus th:nth-child(5) { width: 12%; }  /* Email */
#tabPengurus th:nth-child(6) { width: 5%; }   /* Foto */
#tabPengurus th:nth-child(7) { width: 10%; }  /* Nomor WA */
#tabPengurus th:nth-child(8) { width: 6%; }   /* Urutan */
#tabPengurus th:nth-child(9) { width: 8%; }   /* Status */
#tabPengurus th:nth-child(10) { width: 23%; } /* Aksi */

/* Tombol aksi di tabel pengurus */
#tabPengurus .action-group {
    display: flex;
    gap: 4px;
    flex-wrap: nowrap;
    justify-content: center;
    align-items: center;
}

#tabPengurus .action-group .btn {
    font-size: 9px;
    padding: 2px 8px;
    border-radius: 12px;
    white-space: nowrap;
    flex-shrink: 0;
}

/* ============================================
   TAB KELUARGA (PERBAIKAN LEBAR KOLOM)
============================================ */
#tabKeluarga table {
    table-layout: fixed;
    width: 100%;
    min-width: 800px;
}
/* FORMULA BARU (TOTAL 100%) */
#tabKeluarga th:nth-child(1) { width: 3%; }   /* ID (lebih kecil) */
#tabKeluarga th:nth-child(2) { width: 14%; }  /* NAMA ANAK */
#tabKeluarga th:nth-child(3) { width: 6%; }   /* NIP ABSEN (lebih kecil) */
#tabKeluarga th:nth-child(4) { width: 13%; }  /* AYAH */
#tabKeluarga th:nth-child(5) { width: 13%; }  /* IBU */
#tabKeluarga th:nth-child(6) { width: 13%; }  /* NOMOR WA */
#tabKeluarga th:nth-child(7) { width: 8%; }   /* STATUS */
#tabKeluarga th:nth-child(8) { width: 12%; }  /* VERIFIKASI */
#tabKeluarga th:nth-child(9) { width: 18%; }  /* AKSI (DIPERBESAR!) */

/* Kolom aksi di tabel keluarga */
#tabKeluarga .action-group {
    display: flex;
    gap: 4px;
    flex-wrap: nowrap;      /* JANGAN TURUN BARIS */
    justify-content: center;
    align-items: center;
}

#tabKeluarga .action-group .btn {
    font-size: 9px;
    padding: 2px 8px;
    border-radius: 12px;
    white-space: nowrap;
    flex-shrink: 0;         /* JANGAN NYUSUT */
}

/* Responsif: kolom aksi tetap rapi di HP */
@media (max-width: 700px) {
    #tabKeluarga table {
        min-width: 650px;
    }
    #tabKeluarga th:nth-child(8) { width: 30%; }
    #tabKeluarga .action-group .btn {
        font-size: 8px;
        padding: 2px 6px;
    }
}

@media (max-width: 480px) {
    #tabKeluarga table {
        min-width: 550px;
    }
    #tabKeluarga th:nth-child(8) { width: 32%; }
    #tabKeluarga .action-group {
        gap: 2px;
    }
    #tabKeluarga .action-group .btn {
        font-size: 7px;
        padding: 1px 4px;
    }
}

/* ================================
   ACTION GROUP (TombolAksi diTabel
=================================== */
.action-group {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    justify-content: center;
}
.action-group .btn {
    font-size: 10px;
    padding: 3px 12px;
    border-radius: 20px;
    white-space: nowrap;
}

/* ============================================
   TEXT COLOR UTILITY (Buat Tombol Berwarna)
============================================ */
.text-warning { color: var(--brand-orange); }
.text-danger { color: var(--red); }
.text-info { color: var(--blue); }

/* ============================================
   BUTTONS tak pindahkestyle
============================================ */

/* ============================================
   MODAL
============================================ */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
}
.modal-overlay.active { display: flex !important; }

.modal-content {
    background: var(--bg-modal);
    max-width: 520px;
    width: 100%;
    border-radius: var(--radius-card);
    padding: 28px 32px;
    border: 1px solid var(--border-color);
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
    animation: modalIn 0.25s ease;
    box-shadow: 0 8px 32px rgba(0,0,0,0.2);
    scrollbar-width: thin;
    scrollbar-color: var(--border-color) transparent;
}
.modal-content::-webkit-scrollbar {
    width: 4px;
}
.modal-content::-webkit-scrollbar-track {
    background: transparent;
}
.modal-content::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 10px;
}
.modal-content::-webkit-scrollbar-thumb:hover {
    background: var(--text-secondary);
}

@keyframes modalIn {
    from { transform: scale(0.95) translateY(10px); opacity: 0; }
    to { transform: scale(1) translateY(0); opacity: 1; }
}

.modal-close {
    position: absolute;
    top: 12px;
    right: 16px;
    font-size: 24px;
    cursor: pointer;
    color: var(--text-secondary);
    background: none;
    border: none;
    transition: var(--transition);
    line-height: 1;
    z-index: 10;
}
.modal-close:hover {
    color: var(--text-primary);
    transform: rotate(90deg);
}

.modal-content h3 {
    font-family: 'Lora', serif;
    font-size: 20px;
    color: var(--text-primary);
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.modal-content .input-group {
    margin-bottom: 16px;
}
.modal-content .input-group label {
    display: block;
    font-weight: 500;
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 4px;
}
.modal-content .input-group input,
.modal-content .input-group textarea {
    width: 100%;
    padding: 8px 12px;
    border: 1.5px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: var(--bg-input);
    color: var(--text-primary);
    font-family: 'Inter', sans-serif;
    font-size: 14px;
    transition: var(--transition);
}
.modal-content .input-group input:focus,
.modal-content .input-group textarea:focus {
    outline: none;
    border-color: var(--brand-orange);
    box-shadow: 0 0 0 3px rgba(247,129,0,0.12);
}
.modal-content .input-group textarea {
    resize: vertical;
    min-height: 80px;
}

/* ===== FORM ACTIONS (Tombol di Modal) ===== */
.modal-content .form-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 8px;
}
.modal-content .form-actions .btn {
    flex: 1;
    min-width: 80px;
    justify-content: center;
}

/* ============================================
   RESPONSIVE
============================================ */
@media (max-width: 992px) {
    .main-content { padding: 16px; }
    .stats-grid { grid-template-columns: repeat(3, 1fr); }
    #visitorStatCard { grid-column: span 3; }
}

@media (max-width: 700px) {
    .app-layout { flex-direction: column; }
    .sidebar {
        width: 100% !important;
        height: auto;
        position: relative;
        padding: 12px;
        border-right: none;
        border-bottom: 2px solid var(--border-color);
        overflow-y: visible;
        margin-top: 0;
    }
    .sidebar.collapsed {
        width: 100% !important;
        padding: 8px 12px;
    }
    .sidebar.collapsed .sidebar-logo {
        justify-content: flex-start;
        padding: 0 12px 8px 12px;
    }
    .sidebar.collapsed .sidebar-logo h1,
    .sidebar.collapsed .sidebar-logo .sub {
        display: block;
    }
    .sidebar-logo { padding: 0 12px 16px 12px; }
    .sidebar-menu {
        display: flex;
        flex-wrap: wrap;
        gap: 6px;
        padding: 0 4px;
        margin-top: 8px;
    }
    .sidebar-menu li {
        padding: 6px 12px;
        margin-bottom: 0;
        font-size: 0.7rem;
        border: 1px solid var(--border-color);
        border-radius: 6px;
        flex: 0 1 auto;
        background: var(--bg-card);
    }
    .sidebar-menu li .icon { font-size: 0.8rem; width: 18px; }
    .sidebar-menu .divider { display: none; }
    .sidebar-resizer { display: none; }
    
    .main-content { padding: 12px; }
    .header {
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
    }
    .header-actions { flex-wrap: wrap; justify-content: center; }
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }
    #visitorStatCard { grid-column: span 2; }
    .stat-card { padding: 12px 16px; }
    .stat-card .stat-number { font-size: 20px; }
    
    .table-wrapper {
        margin-top: 12px;
        border-radius: 8px;
    }
    .table-header {
        padding: 12px 16px;
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
    }
    .table-header h3 { font-size: 16px; }
    .table-header .table-actions { justify-content: flex-start; }
    table { min-width: 600px; font-size: 11px; }
    th, td { padding: 8px 10px; }
    .table-scroll { max-height: 400px; }
    #tabPengumuman table { min-width: 500px; }
    #tabPengumuman th:nth-child(6) { width: 35%; }
    
    .modal-content {
        padding: 20px 16px;
        margin: 10px;
        max-height: 85vh;
    }
    .modal-content h3 {
        font-size: 18px;
    }
    .modal-content .form-actions .btn {
        font-size: 12px;
        padding: 8px 12px;
    }
    
    .toolbar {
        flex-direction: column;
        align-items: stretch;
        gap: 0.4rem;
        padding: 0.6rem;
    }
    .toolbar .search-wrap { min-width: unset; }
    .toolbar select { min-width: unset; width: 100%; }
    .real-time { justify-content: center; }
}

@media (max-width: 480px) {
    .stats-grid {
        grid-template-columns: 1fr 1fr;
        gap: 8px;
    }
    #visitorStatCard { grid-column: span 2; }
    .stat-card { padding: 10px 12px; }
    .stat-card .stat-number { font-size: 18px; }
    table { min-width: 500px; font-size: 10px; }
    th, td { padding: 6px 8px; }
    .action-group .btn { font-size: 9px; padding: 2px 6px; }
    
    .modal-content {
        padding: 16px 12px;
        margin: 8px;
        max-height: 80vh;
        border-radius: 12px;
    }
    .modal-content h3 {
        font-size: 16px;
    }
    .modal-content .form-actions {
        flex-direction: column;
    }
    .modal-content .form-actions .btn {
        width: 100%;
    }
}