:root {
    --bg-color: #e6eef8;
    --text-color: #2d3436;
    --neo-light: #ffffff;
    --neo-shadow: #b8c6db;
    --glass-bg: rgba(255, 255, 255, 0.4);
    --accent: #4a90e2;
}

* { 
    margin: 0; 
    padding: 0; 
    box-sizing: border-box; 
}

/* =========================================
   PENGATURAN DASAR & VIEWER (index.html)
   ========================================= */
body {
    background-color: var(--bg-color);
    font-family: 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    color: var(--text-color);
    overflow: hidden; /* Mencegah scroll ganda di canvas */
}

/* =========================================
   PENGATURAN LAYOUT ADMIN (admin.html)
   ========================================= */
body.admin-mode {
    display: flex;
    justify-content: center;
    align-items: flex-start; /* Berubah jadi flex-start agar bisa di-scroll kalau panjang */
    min-height: 100vh;
    padding: 40px 20px;
    box-sizing: border-box;
    overflow-y: auto;
}

/* Kelas Utilitas Admin Panel 2 Kolom */
.admin-layout {
    display: flex;
    gap: 30px;
    justify-content: center;
    align-items: flex-start;
    flex-wrap: wrap; /* Jika layar kecil, kolom kanan akan turun ke bawah */
    width: 100%;
    max-width: 1100px;
}

.admin-card {
    position: relative !important; /* Mencegah bentrok dengan kartu di layar index.html */
    left: auto !important;
    top: auto !important;
    backdrop-filter: blur(15px);
    margin: 0;
    text-align: left;
}

.form-column {
    flex: 1 1 400px;
    max-width: 450px;
}

.list-column {
    flex: 2 1 450px;
    max-width: 600px;
}

.form-main-title {
    margin-bottom: 20px;
}

.admin-header-flex {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 25px;
}

.admin-title {
    margin: 0;
    color: #2d3748;
    font-size: 1.5rem;
}

.btn-small {
    padding: 8px 15px;
    font-size: 0.8rem;
    text-decoration: none;
    color: var(--accent);
}

.flex-row-gap {
    display: flex;
    gap: 15px;
}

.flex-1 {
    flex: 1;
}

.hidden-group {
    display: none;
}

.btn-submit {
    width: 100%;
    padding: 16px;
    font-size: 1.05rem;
    margin-top: 10px;
    letter-spacing: 0.5px;
}

.admin-subtitle {
    margin-top: 0;
    margin-bottom: 15px;
    color: #4a5568;
    font-size: 1.1rem;
}

.loading-text {
    text-align: center;
    color: #a0aec0;
    font-size: 0.9rem;
    margin-top: 20px;
}

/* =========================================
   KOMPONEN UMUM (M7 Neo & Glass)
   ========================================= */
.member-card {
    background: var(--glass-bg);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.5);
    border-radius: 24px;
    padding: 20px;
    width: 220px;
    text-align: center;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.05);
    position: absolute;
    transition: transform 0.3s ease;
    z-index: 2;
}

.neo-box {
    background: var(--bg-color);
    box-shadow: 8px 8px 16px var(--neo-shadow), 
               -8px -8px 16px var(--neo-light);
    border-radius: 15px;
    border: none;
}

.neo-button {
    padding: 12px 24px;
    background: var(--bg-color);
    box-shadow: 6px 6px 12px var(--neo-shadow), 
               -6px -6px 12px var(--neo-light);
    border-radius: 12px;
    border: none;
    cursor: pointer;
    font-weight: 600;
    transition: 0.2s;
    color: var(--accent);
}

.neo-button:active {
    box-shadow: inset 4px 4px 8px var(--neo-shadow), 
               inset -4px -4px 8px var(--neo-light);
}

/* =========================================
   KOMPONEN FORM ADMIN
   ========================================= */
.form-group { margin-bottom: 20px; display: flex; flex-direction: column; }

label { margin-bottom: 8px; font-weight: 600; font-size: 0.9rem; }

input, select { 
    width: 100%; padding: 12px; border: none; border-radius: 12px; 
    background: var(--bg-color); box-shadow: inset 4px 4px 8px #b8c6db, inset -4px -4px 8px #ffffff;
    outline: none;
}

input::placeholder { color: #a0aec0; }

input:focus, select:focus {
    box-shadow: inset 2px 2px 5px var(--neo-shadow), 
                inset -2px -2px 5px var(--neo-light);
}

/* Member List Container Inset */
.list-container {
    max-height: 500px; /* Tinggi maksimal dinaikkan agar pas di kolom kanan */
    overflow-y: auto; 
    padding: 15px; 
    border-radius: 16px;
    background: var(--bg-color);
    box-shadow: inset 4px 4px 8px var(--neo-shadow), inset -4px -4px 8px var(--neo-light);
}

/* Custom Scrollbar */
.list-container::-webkit-scrollbar { width: 6px; }
.list-container::-webkit-scrollbar-track { background: transparent; }
.list-container::-webkit-scrollbar-thumb { background: #cbd5e0; border-radius: 10px; }
.list-container::-webkit-scrollbar-thumb:hover { background: #a0aec0; }

/* =========================================
   KANVAS POHON SILSILAH
   ========================================= */
#canvas {
    width: 5000px;
    height: 5000px;
    position: relative;
    cursor: grab;
    transition: transform 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    transform-origin: 0 0;
}

#svg-layers {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    pointer-events: none;
}

/* =========================================
   M7 TOAST NOTIFICATIONS
   ========================================= */
#toast-container {
    position: fixed;
    top: 25px;
    right: 25px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 15px;
    pointer-events: none; /* Agar tidak mengganggu klik di elemen bawahnya */
}

.neo-toast {
    min-width: 280px;
    padding: 16px 20px;
    background: rgba(255, 255, 255, 0.65);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-left: 6px solid var(--accent); /* Warna biru untuk sukses */
    border-radius: 16px;
    box-shadow: 8px 8px 16px rgba(163, 177, 198, 0.4), 
               -8px -8px 16px rgba(255, 255, 255, 0.8);
    color: var(--text-color);
    font-weight: 600;
    font-size: 0.95rem;
    display: flex;
    align-items: center;
    gap: 12px;
    /* Animasi masuk dari kanan, lalu memudar setelah 3 detik */
    animation: slideInRight 0.4s cubic-bezier(0.25, 1, 0.5, 1) forwards, 
               fadeOut 0.4s ease 3s forwards;
}

/* Varian Error/Hapus */
.neo-toast.error {
    border-left-color: #ff4757;
}

@keyframes slideInRight {
    from { transform: translateX(120%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

@keyframes fadeOut {
    from { opacity: 1; transform: translateY(0); }
    to { opacity: 0; transform: translateY(-20px); }
}

/* =========================================
   NAVIGASI MELAYANG (index.html)
   ========================================= */
.main-title-container { transition: all 0.3s ease; }
.main-title { margin: 0; font-size: 1.8rem; color: #1a202c; letter-spacing: 3px; font-weight: 800; text-transform: uppercase; }
.main-subtitle { margin: 5px 0 0 0; font-size: 0.9rem; color: #4a5568; font-weight: 600; letter-spacing: 1px; }

.admin-btn-floating {
    position: fixed; top: 30px; left: 30px; z-index: 100; padding: 12px 20px;
    display: flex; align-items: center; gap: 10px; text-decoration: none; border-radius: 20px; font-weight: bold;
}

.top-right-controls {
    position: fixed; top: 30px; right: 30px; z-index: 100; display: flex; gap: 15px; align-items: center;
}
.search-box {
    background: rgba(255, 255, 255, 0.65); backdrop-filter: blur(15px);
    padding: 12px 20px; border-radius: 20px; display: flex; align-items: center; gap: 10px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.08); border: 1px solid rgba(255, 255, 255, 0.5);
}
.search-box input { border: none; background: transparent; outline: none; font-size: 0.95rem; width: 200px; color: #2d3748; font-weight: 600; transition: width 0.3s ease; }
.search-box input::placeholder { color: #a0aec0; font-weight: 400; }

.btn-logout { 
    background-color: #ff4757 !important; color: white !important; 
    padding: 12px 20px !important; border-radius: 20px !important; 
    display: flex; align-items: center; gap: 8px;
}
.logout-icon { display: none; }

.control-panel {
    position: fixed; bottom: 40px; right: 40px; z-index: 100; display: flex; gap: 15px;
    background: rgba(255, 255, 255, 0.5); backdrop-filter: blur(10px); padding: 12px 20px;
    border-radius: 20px; box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1); border: 1px solid rgba(255, 255, 255, 0.6);
}
.control-panel .neo-button { padding: 10px 10px; font-size: 0.95rem; display: flex; align-items: center; border-radius: 28px; }
.btn-print { background-color: #4a90e2 !important; color: white !important; box-shadow: 4px 4px 10px rgba(74, 144, 226, 0.3), -4px -4px 10px rgba(255, 255, 255, 0.8) !important; }


/* =========================================
   SISTEM RESPONSIVITAS CERDAS (MEDIA QUERIES)
   ========================================= */

/* LAYAR LAPTOP & TABLET LEBAR (Max 1024px) */
@media (max-width: 1024px) {
    .main-title-container { top: 20px; padding: 12px 30px; }
    .main-title { font-size: 1.4rem; letter-spacing: 2px; }
    .search-box input { width: 140px; }
    .admin-btn-floating { top: 20px; left: 20px; padding: 10px 15px; }
    .top-right-controls { top: 20px; right: 20px; }
}

/* LAYAR TABLET (Max 850px) */
@media (max-width: 850px) {
    .main-title-container { top: 85px; width: max-content; padding: 10px 25px; }
    .main-title { font-size: 1.3rem; letter-spacing: 1px; }
    .main-subtitle { font-size: 0.8rem; margin-top: 2px; }
    .admin-btn-floating { top: 20px; left: 20px; padding: 10px 16px; font-size: 0.9rem; }
    .top-right-controls { top: 20px; right: 20px; gap: 10px; }
    .search-box { padding: 10px 15px; }
    .btn-logout { padding: 10px 16px !important; font-size: 0.9rem; }
}

/* LAYAR SMARTPHONE (Max 600px) - PERBAIKAN TOTAL */
@media (max-width: 600px) {
    .hide-mobile { display: none !important; }
    .logout-icon { display: block !important; margin: 0 !important; }
    
    /* 1. Tombol Ikon Kiri & Kanan */
    .admin-btn-floating, .btn-logout { 
        padding: 8px !important; 
        border-radius: 50% !important; 
        width: 42px !important; height: 42px !important; 
        justify-content: center; 
    }
    .admin-btn-floating { top: 15px !important; left: 15px !important; }
    .admin-btn-floating svg, .btn-logout svg { margin: 0; width: 18px; height: 18px; }

    /* 2. Kontainer Kanan ditarik ke kiri agar memenuhi sisa layar */
    .top-right-controls { 
        top: 15px !important; 
        right: 15px !important; 
        left: 70px !important; /* Ditarik sampai ke sebelah tombol kiri */
        gap: 8px !important; 
        justify-content: flex-end; /* Memastikan tombol Keluar tetap di ujung kanan */
    }

    /* 3. Kotak Pencarian mengisi sisa ruang secara proporsional */
    .search-box { 
        padding: 8px 12px !important; 
        border-radius: 15px !important; 
        flex-grow: 1; /* KUNCI RAHASIA: Otomatis melebar mengisi kekosongan */
        max-width: 100%;
    }
    .search-box input { 
        width: 100% !important; 
        max-width: none !important; /* Hapus batasan */
        font-size: 0.85rem !important; 
    }
    .search-box svg { width: 16px; height: 16px; min-width: 16px; }

    /* 4. Memperbaiki Judul "SILSILAH KELUARGA" */
    .diagram-title { 
        top: 75px !important; 
        width: 90% !important; 
        left: 50% !important; 
        transform: translateX(-50%) !important; 
    }
    .diagram-title h1 { 
        font-size: 1.3rem !important; 
        letter-spacing: 0.5px !important; 
        white-space: normal; 
        line-height: 1.2;
    }
    .diagram-title { 
        top: 100px !important; /* Proporsional untuk layar kecil */
        width: 90% !important; 
        left: 50% !important; 
        transform: translateX(-50%) !important; 
    }

    /* 5. Memperbaiki Layout Admin Panel */
    .admin-layout { 
        flex-direction: column; 
        margin-top: 70px !important; 
        gap: 20px !important; 
        padding: 0 10px;
    }
    .form-column, .list-column { 
        max-width: 100% !important; 
        width: 100% !important; 
    }
    .flex-row-gap { 
        flex-direction: column; 
        gap: 10px !important; 
    }

    /* 6. Menyesuaikan Tombol Zoom & Cetak */
    .control-panel {
        bottom: 15px !important; right: 15px !important; padding: 8px !important; gap: 6px !important; border-radius: 12px !important;
    }
    .control-panel .neo-button { padding: 8px !important; border-radius: 8px !important; width: 36px; height: 36px; display:flex; justify-content:center; }
    .btn-print { border-radius: 50% !important; width: 36px !important; height: 36px !important; }
}

/* LAYAR SANGAT KECIL (< 400px) */
@media (max-width: 400px) {
    /* Kita tidak perlu lagi membatasi lebar search box karena otomatis diatur oleh flex-grow di atas */
    .diagram-title h1 { font-size: 1.15rem !important; }
}

/* =========================================
   PENGATURAN CETAK (PRINT) - CLEAN VERSION
   ========================================= */
@media print {
    /* Sembunyikan elemen UI agar tidak ikut tercetak */
    .main-title-container, 
    .admin-btn-floating, 
    .control-panel, 
    .top-right-controls,
    #biodataModal { 
        display: none !important; 
    }

    /* Hilangkan background glassmorphism agar kartu terlihat jelas di kertas */
    .member-card { 
        background: #ffffff !important; 
        border: 2px solid #cbd5e0 !important; 
        box-shadow: none !important;
        backdrop-filter: none !important;
    }

    /* Pastikan warna & garis muncul */
    * { 
        -webkit-print-color-adjust: exact !important; 
        print-color-adjust: exact !important; 
    }

    @page {
        size: landscape;
        margin: 0;
    }
}

/* Menyesuaikan style Choices.js agar tetap bertema Neumorphism */
.choices__inner {
    background: var(--bg-color) !important;
    border: none !important;
    border-radius: 12px !important;
    box-shadow: inset 4px 4px 8px #b8c6db, inset -4px -4px 8px #ffffff !important;
    padding: 5px 10px !important;
}
.choices__list--dropdown {
    background: var(--bg-color) !important;
    border-radius: 12px !important;
    box-shadow: 8px 8px 16px var(--neo-shadow) !important;
    border: 1px solid rgba(255,255,255,0.5) !important;
}
.choices__item--selectable.is-highlighted {
    background-color: var(--accent) !important;
    color: white !important;
}