/* =========================================================================
   Aplikasi Silsilah Keluarga Besar Nasab Khanuddin - Core Stylesheet
   ========================================================================= */

/* Google Fonts */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght=400;600;700&display=swap');

body { 
    font-family: 'Inter', sans-serif; 
    background: #f8fafc; 
    padding: 20px; 
    color: #1e293b;
}
/*TAMBAH DATA STYLE----------------------------------------------------------
/* Tambahan style spesifik untuk form agar rapi */
        .form-group {
            margin-bottom: 20px;
            display: flex;
            flex-direction: column;
            text-align: left;
        }
        .form-group label {
            font-weight: 600;
            font-size: 14px;
            color: #334155;
            margin-bottom: 8px;
        }
        .form-control {
            width: 100%;
            padding: 12px 16px;
            border: 1px solid #e2e8f0;
            border-radius: 10px;
            font-family: 'Inter', sans-serif;
            font-size: 14px;
            color: #1e293b;
            background: #f8fafc;
            box-sizing: border-box;
            transition: all 0.2s ease;
        }
        .form-control:focus {
            outline: none;
            border-color: #3b82f6;
            background: #ffffff;
            box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
        }
        .radio-group {
            display: flex;
            gap: 20px;
            margin-top: 5px;
        }
        .radio-label {
            display: flex;
            align-items: center;
            gap: 8px;
            font-size: 14px;
            font-weight: 500;
            cursor: pointer;
        }
        .btn-submit {
            width: 100%;
            padding: 14px;
            background: #3b82f6;
            color: #ffffff;
            border: none;
            border-radius: 12px;
            font-weight: 700;
            font-size: 15px;
            cursor: pointer;
            transition: all 0.2s ease;
            box-shadow: 0 4px 6px -1px rgba(59, 130, 246, 0.2);
        }
        .btn-submit:hover {
            background: #2563eb;
            transform: translateY(-1px);
        }
        @media (max-width: 768px) {
            .form-container {
                max-width: 100% !important;
                padding: 20px 15px !important;
            }
        }

/*ADMIN STYLE-------------------------------------------------------------------*/
.login-card {
            max-width: 400px;
            margin: 100px auto;
            padding: 30px;
            background: #ffffff;
            border-radius: 16px;
            border: 1px solid #e2e8f0;
            box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.05);
            text-align: center;
        }
        .form-group {
            margin-bottom: 20px;
            text-align: left;
        }
        .form-group label {
            font-weight: 600;
            font-size: 14px;
            color: #334155;
            display: block;
            margin-bottom: 8px;
        }
        .form-control {
            width: 100%;
            padding: 12px 16px;
            border: 1px solid #cbd5e1;
            border-radius: 10px;
            font-size: 14px;
            box-sizing: border-box;
        }
        .form-control:focus {
            outline: none;
            border-color: #3b82f6;
        }
        .btn-login {
            width: 100%;
            padding: 12px;
            background: #3b82f6;
            color: white;
            border: none;
            border-radius: 10px;
            font-weight: 700;
            cursor: pointer;
            font-size: 15px;
        }
        .btn-login:hover { background: #2563eb; }
        .alert-error {
            background: #fef2f2;
            color: #dc2626;
            padding: 12px;
            border-radius: 8px;
            font-size: 13px;
            margin-bottom: 20px;
            font-weight: 500;
            border: 1px solid #fecaca;
        }

/* -------------------------------------------------------------------------
   Container & Global Header
   ------------------------------------------------------------------------- */
.tree-container { 
    width: 95%;
    max-width: 1400px; 
    margin: 20px auto; 
    background: #ffffff; 
    padding: 40px 30px; 
    border-radius: 25px; 
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.05), 0 8px 10px -6px rgba(0, 0, 0, 0.05);
}

.tree-header {
    text-align: center;
    margin-bottom: 40px;
    border-bottom: 2px solid #f1f5f9;
    padding-bottom: 20px;
}

.tree-header h2 { 
    font-weight: 700; 
    color: #0f172a; 
    margin: 0; 
    text-transform: uppercase; 
    letter-spacing: 1px; 
}

/* Judul Khusus yang disembunyikan di layar browser biasa */
.print-only-header {
    display: none;
}

/* -------------------------------------------------------------------------
   Sistem Layout Legacy (List Bertingkat Samping)
   ------------------------------------------------------------------------- */
.tree ul { 
    padding-left: 25px; 
    list-style: none; 
    border-left: 2px solid #e2e8f0; 
    margin-left: 15px; 
}

.tree li { 
    position: relative; 
    margin: 15px 0; 
    padding-left: 25px; 
}

.tree li::before {
    content: "";
    position: absolute; 
    top: 22px; 
    left: -25px;
    width: 25px; 
    height: 2px;
    background: #e2e8f0;
}

/* -------------------------------------------------------------------------
   Sistem Tampilan Utama - DIAGRAM POHON VERTIKAL (FLOWCHART)
   ------------------------------------------------------------------------- */
.silsilah-tree-container {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px 0;
    width: 100%;
    overflow-x: auto;
}

.tree-branch {
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
    width: 100%;
}

.tree-node-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    position: relative;
}

/* Base Node Card */
.node-card {
    display: inline-flex; 
    flex-direction: column;
    justify-content: center;
    padding: 12px 20px; 
    background: #fff;
    border: 1px solid #e2e8f0; 
    border-radius: 12px;
    min-width: 220px;
    position: relative;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: pointer;
}

/* Animasi saat di-hover di Desktop */
.node-card:hover {
    transform: translateY(-4px) scale(1.02);
    box-shadow: 0 10px 25px -5px rgba(59, 130, 246, 0.15) !important;
    border-color: #3b82f6 !important;
}

/* Pembeda Desain Gender */
.L { border-left: 6px solid #3b82f6; background: linear-gradient(to right, #eff6ff, #ffffff); }
.P { border-left: 6px solid #ef4444; background: linear-gradient(to right, #fef2f2, #ffffff); }

.nama { 
    font-weight: 700; 
    font-size: 15px; 
    color: #334155; 
    margin-bottom: 2px; 
}

.ket { 
    font-size: 12px; 
    color: #64748b; 
    font-weight: 500; 
    display: flex; 
    align-items: center; 
}

.ket::before { 
    content: "•"; 
    margin-right: 5px; 
    color: #94a3b8; 
}

/* Garis Alur Vertikal */
.tree-line {
    width: 2px;
    height: 40px;
    background: linear-gradient(to bottom, #3b82f6, #cbd5e1);
    position: relative;
    z-index: 1;
}

.tree-line::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    border-left: 4px solid transparent;
    border-right: 4px solid transparent;
    border-top: 6px solid #64748b;
}

/* -------------------------------------------------------------------------
   Komponen Navigasi, Tombol & Footer
   ------------------------------------------------------------------------- */
.nav-wrapper { 
    display: flex; 
    gap: 10px; 
    margin-bottom: 25px; 
    flex-wrap: wrap; 
    justify-content: center; 
}

.btn-back {
    display: inline-block;
    color: #64748b;
    text-decoration: none;
    font-weight: 600;
    font-size: 14px;
    transition: color 0.2s;
}

.btn-back:hover { 
    color: #0f172a; 
}

.btn-nav {
    display: inline-flex; 
    align-items: center; 
    padding: 8px 16px; 
    background: #ffffff;
    border: 1px solid #e2e8f0; 
    border-radius: 8px; 
    color: #64748b; 
    text-decoration: none;
    font-size: 13px; 
    font-weight: 600; 
    transition: all 0.2s ease; 
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}

.btn-nav:hover { 
    background: #f1f5f9; 
    color: #0f172a; 
    border-color: #cbd5e1; 
    transform: translateY(-1px); 
}

.btn-nav-primary { 
    background: #f8fafc; 
    border-style: dashed; 
}

.nav-sep { 
    color: #cbd5e1; 
    align-self: center; 
    font-weight: bold; 
}

.tree-item a:hover {
    background: #3b82f6 !important; 
    color: white !important; 
    border-color: #3b82f6 !important;
    transform: translateY(-2px); 
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

.tree-footer {
    margin-top: 50px; 
    padding-top: 20px; 
    border-top: 2px solid #f1f5f9; 
    text-align: center;
}

/* =========================================================================
   MEDIA QUERY: OPTIMASI VIEW HANDPHONE (RESPONSIVE SCREEN)
   ========================================================================= */
@media (max-width: 768px) {
    body {
        padding: 10px;
    }

    .tree-container {
        padding: 20px 15px;
    }

    .silsilah-tree-container {
        padding: 10px !important;
        overflow-x: hidden !important; 
        width: 100% !important;
        box-sizing: border-box;
    }

    .tree-branch, .tree-node-wrapper {
        width: 100% !important;
        padding: 0 !important;
    }

    /* Set ukuran card agar pas mantap di layar HP */
    .node-card {
        width: 100% !important;
        max-width: 280px !important; 
        padding: 10px 14px !important; 
        margin: 0 auto !important;
        min-width: unset !important;
    }

    .node-card .nama {
        font-size: 13px !important; 
    }

    .node-card .badge {
        font-size: 8px !important;
        padding: 1px 6px !important;
    }

    .node-card .avatar {
        width: 30px !important;
        height: 30px !important;
        font-size: 11px !important;
        margin-left: 6px !important;
    }

    .tree-line {
        height: 30px !important;
    }
}

/* =========================================================================
   MEDIA QUERY: ATURAN KHUSUS CETAK / PRINT MODE (Ctrl + P)
   ========================================================================= */
@media print {
    /* 1. Kelola visibilitas elemen penunjang */
    .nav-header, .btn-back, form, .btn-nav, .tree-footer, footer, .branch-nav-wrapper, .tree-header {
        display: none !important;
    }

    /* 2. Tampilkan judul khusus cetak di posisi paling atas */
    .print-only-header {
        display: block !important;
        text-align: center;
        margin-bottom: 30px;
    }
    .print-only-header h1 {
        font-size: 22px;
        font-weight: 800;
        margin: 0 0 4px 0;
        color: #0f172a;
    }
    .print-only-header h2 {
        font-size: 18px;
        font-weight: 700;
        margin: 0 0 6px 0;
        color: #1e293b;
    }
    .print-only-header h3 {
        font-size: 13px;
        font-weight: 600;
        color: #64748b;
        letter-spacing: 2px;
        margin: 0 0 15px 0;
    }
    .print-separator {
        width: 120px;
        height: 2px;
        background-color: #3b82f6 !important;
        margin: 0 auto;
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }
    
    /* 3. Maksimalkan area kertas cetak */
    body {
        background: #ffffff !important;
        padding: 0 !important;
        margin: 0 !important;
    }
    
    .tree-container, .silsilah-tree-container, .tree-branch, .tree-node-wrapper {
        box-shadow: none !important;
        padding: 0 !important;
        margin: 0 !important;
        width: 100% !important;
        max-width: 100% !important;
        overflow: visible !important;
        height: auto !important;
        display: block !important;
    }

    .silsilah-tree-container {
        page-break-inside: avoid;
    }
    
    /* 4. Amankan rendering warna padat untuk garis dan background card */
    .node-card, .tree-item, [style*="background"] {
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }

    .tree-line {
        background: #3b82f6 !important;
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }
    
    @page {
        size: auto;
        margin: 15mm;
    }
}