.gp-tree-wrapper {
    position: relative;
    width: 100%;
}

#giapha-tree-container {
    width: 100%;
    height: 665px;
    background-image: url('images/bg-gia-pha.jpg');
    background-size: cover;
    background-position: top center;
    background-repeat: no-repeat;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    position: relative;
}

/* Trạng thái Fullscreen chuẩn cho cả Desktop và Mobile */
#giapha-tree-container.gp-fullscreen-mode {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    height: 100dvh !important; /* Tối ưu tuyệt đối cho mobile */
    z-index: 2147483646 !important;
    border: none !important;
    border-radius: 0 !important;
}

#gpFullscreenBtn, #gpCenterBtn {
	position: absolute;
	top: 10px;
	right: 10px;
	left: auto;
	z-index: 2147483647 !important;
	background: #2563eb;
	color: #ffffff;
	border: none;
	border-radius: 6px;
	width: 38px;
	height: 38px;
	padding: 0;
	justify-content: center;
	font-size: 16px;
	font-weight: 600;
	cursor: pointer;
	box-shadow: 0 4px 6px rgba(0, 0, 0, 0.15);
	display: flex;
	align-items: center;
	gap: 6px;
	pointer-events: auto !important;
	margin: 0;
}

#gpCenterBtn { right: 56px; background: #b91c1c; }
#gpFullscreenBtn .gp-compress-icon { display: none; }
#gpFullscreenBtn.gp-is-fullscreen .gp-expand-icon { display: none; }
#gpFullscreenBtn.gp-is-fullscreen .gp-compress-icon { display: inline-flex; }
.gp-sr-only {
    position: absolute !important;
    width: 1px; height: 1px; padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0, 0, 0, 0);
    white-space: nowrap; border: 0;
}
.gp-zoom-control {
    position: absolute;
    right: 12px;
    bottom: 12px;
    z-index: 2147483647;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 8px 11px;
    border-radius: 7px;
    background: rgba(255,255,255,.94);
    color: #333;
    box-shadow: 0 2px 10px rgba(0,0,0,.22);
    font: 600 17px/1 Arial, sans-serif;
}
.gp-zoom-control input {
    width: 22px;
    height: 140px;
    margin: 0;
    writing-mode: vertical-lr;
    direction: rtl;
    accent-color: #b91c1c;
    cursor: pointer;
}
.gp-tree-wrapper:has(#giapha-tree-container.gp-fullscreen-mode) #gpCenterBtn,
.gp-tree-wrapper:has(#giapha-tree-container.gp-fullscreen-mode) .gp-zoom-control { position: fixed !important; }
@media (max-width: 600px) {
    #gpCenterBtn { right: 56px; top: 10px; }
    .gp-zoom-control input { height: 110px; }
}

/* Khi phóng to toàn màn hình, nút tự chuyển sang fixed để ghim đúng góc màn hình */
#giapha-tree-container.gp-fullscreen-mode ~ #gpFullscreenBtn,
.gp-tree-wrapper:has(#giapha-tree-container.gp-fullscreen-mode) #gpFullscreenBtn {
    position: fixed !important;
}

/* Đảm bảo Popup thông tin và Menu chuột phải luôn nổi lên trên cùng ngay cả khi đang Fullscreen */
.gp-modal-overlay {
    z-index: 2147483648 !important;
}

.gp-custom-menu-popup {
    z-index: 2147483648 !important;
}
@media (max-width: 768px) {
    #giapha-tree-container {
        height: 500px;
    }
}

#giapha-tree-container [data-l-id] path,
#giapha-tree-container path.link,
#giapha-tree-container .bft-link {
    stroke: #94a3b8 !important;
    stroke-width: 2.5px !important;
    stroke-linecap: round !important;
    stroke-linejoin: round !important;
    transition: stroke 0.2s ease, stroke-width 0.2s ease;
}

#giapha-tree-container .gp-member-card {
    filter: drop-shadow(0 3px 4px rgba(64, 35, 20, .25));
    transition: filter .18s ease;
}
#giapha-tree-container [data-n-id]:hover .gp-member-card {
    filter: drop-shadow(0 5px 7px rgba(64, 35, 20, .32));
}

#giapha-tree-container [data-l-id]:hover path,
#giapha-tree-container path.link:hover {
    stroke: #3b82f6 !important;
    stroke-width: 3px !important;
}

#giapha-tree-container [data-n-id],
#giapha-tree-container [data-n-id] *,
#giapha-tree-container .node,
#giapha-tree-container .node * {
    cursor: pointer !important;
    user-select: none;
}

.bft-search label,
.bft-search-box label {
    display: none !important;
}

/* FamilyTreeJS đặt ô tìm kiếm ở bên phải theo mặc định. */
#giapha-tree-container .bft-search,
#giapha-tree-container .bft-search-box {
    left: 10px !important;
    right: auto !important;
    top: 10px !important;
    width: min(320px, calc(100% - 115px)) !important;
    max-width: none !important;
}
#giapha-tree-container .bft-search input,
#giapha-tree-container .bft-search-box input {
    width: 100% !important;
    box-sizing: border-box;
}
#giapha-tree-container .bft-search-result {
    left: 0 !important;
    right: auto !important;
    max-width: min(440px, calc(100vw - 20px)) !important;
}

.bft-search input,
.bft-search-box input {
    padding-top: 6px !important;
    height: 38px !important;
    line-height: 24px !important;
}

.bft-search-result {
    width: 440px !important;
    max-width: 90vw !important;
    border-radius: 8px !important;
    overflow: hidden !important;
    box-shadow: 0 10px 25px rgba(0,0,0,0.12) !important;
}

.bft-search [data-search-item-id] {
    padding: 10px 14px !important;
    height: auto !important;
    border-bottom: 1px solid #f1f5f9 !important;
    transition: background 0.15s ease !important;
}

.bft-search [data-search-item-id]:hover {
    background: #f8fafc !important;
}

.bft-search [data-search-item-id] td:first-child {
    width: 58px !important;
    min-width: 58px !important;
    padding: 0 12px 0 0 !important;
    margin: 0 !important;
    border-right: none !important;
    vertical-align: middle !important;
    text-align: center !important;
}

.bft-search [data-search-item-id] td:first-child img {
    width: 46px !important;
    height: 46px !important;
    min-width: 46px !important;
    min-height: 46px !important;
    border-radius: 50% !important;
    object-fit: cover !important;
    border: 2px solid #e2e8f0 !important;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08) !important;
    display: block !important;
    margin: 0 auto !important;
}
.bft-search .bft-search-photo {
    margin: 7px 7px 0 0;
}
div.bft-search [data-search-item-id] td:first-child, div.bft-search-result td:first-child {
    padding: 0 8px !important;
}

.gp-search-item-box {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    text-align: left;
    padding: 2px 0;
    justify-content: center;
    min-width: 0;
}

.gp-search-name {
    display: block;
    width: 100%;
    font-weight: 700;
    font-size: 15px;
    color: #0f172a;
    line-height: 1.35;
}

.gp-search-meta {
    display: block;
    width: 100%;
    font-size: 13px;
    color: #64748b;
    line-height: 1.35;
    margin-top: 3px;
    white-space: normal;
    font-weight: 400;
}

.gp-modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(15, 23, 42, 0.6);
    z-index: 999999;
    align-items: center;
    justify-content: center;
}

.gp-modal-box {
    background: #ffffff;
    width: 90%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    border-radius: 10px;
    padding: 24px;
    box-shadow: 0 20px 25px -5px rgba(0,0,0,0.3);
    position: relative;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

.gp-modal-close {
    position: absolute;
    top: 12px;
    right: 14px;
    font-size: 24px;
    font-weight: bold;
    border: none;
    background: transparent;
    cursor: pointer;
    color: #64748b;
}

.gp-modal-header {
    display: flex;
    gap: 16px;
    align-items: center;
    margin-bottom: 16px;
    border-bottom: 1px solid #f1f5f9;
    padding-bottom: 14px;
}

.gp-modal-avatar {
    width: 70px;
    height: 70px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid #cbd5e1;
}

.gp-modal-title {
    margin: 0;
    font-size: 20px;
    font-weight: 700;
    color: #0f172a;
}

.gp-modal-gen {
    font-size: 13px;
    color: #2563eb;
    font-weight: 600;
    margin-top: 4px;
}

.gp-info-row {
    font-size: 14px;
    margin-bottom: 9px;
    display: flex;
    align-items: flex-start;
}

.gp-info-label {
    width: 110px;
    font-weight: 600;
    color: #475569;
    flex-shrink: 0;
}

.gp-info-val {
    flex: 1;
    color: #1e293b;
}

.gp-position-highlight {
    color: #dc2626 !important;
    font-weight: 700 !important;
}

.gp-rel-link {
    color: #2563eb;
    text-decoration: none;
    cursor: pointer;
    margin-right: 8px;
    display: inline-block;
}

.gp-rel-link:hover {
    text-decoration: underline;
}

.gp-actions {
    margin-top: 16px;
    display: flex;
}

.gp-btn-edit {
    width: 100%;
    text-align: center;
    padding: 10px 14px;
    font-size: 13px;
    font-weight: 600;
    border-radius: 6px;
    text-decoration: none !important;
    background: #2563eb !important;
    color: #ffffff !important;
    display: inline-block;
    transition: background 0.2s ease, color 0.2s ease;
}

.gp-btn-edit:hover,
.gp-btn-edit:focus,
.gp-btn-edit:active {
    background: #1d4ed8 !important;
    color: #ffffff !important;
    text-decoration: none !important;
}

.gp-form-row {
    margin-bottom: 12px;
    display: flex;
    flex-direction: column;
}

.gp-form-row label {
    font-size: 13px;
    font-weight: 600;
    color: #334155;
    margin-bottom: 4px;
}

.gp-form-row input,
.gp-form-row select,
.gp-form-row textarea {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    font-size: 14px;
    box-sizing: border-box;
    font-family: inherit;
}

.gp-form-row input:focus,
.gp-form-row select:focus,
.gp-form-row textarea:focus {
    outline: none;
    border-color: #2563eb;
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.2);
}

.gp-form-actions {
    display: flex;
    gap: 10px;
    margin-top: 18px;
}

.gp-btn-submit {
    flex: 1;
    background: #2563eb;
    color: #ffffff;
    border: none;
    padding: 10px;
    border-radius: 6px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

.gp-btn-submit:hover {
    background: #1d4ed8;
}

.gp-btn-cancel {
    background: #f1f5f9;
    color: #475569;
    border: 1px solid #cbd5e1;
    padding: 10px 16px;
    border-radius: 6px;
    font-weight: 600;
    cursor: pointer;
}

.gp-btn-cancel:hover {
    background: #e2e8f0;
}
div.bft-light .bft-search [data-search-item-id] td {
    border-top: none !important;
}
