body {
    overflow: auto;
    background-color: rgba(248, 247, 247, 1);
}

/* Family Tree Template 2 Enhanced Styles */
.family-tree-template2 {
    position: relative;
    padding: 3rem 2rem;
    border-radius: 20px;
    min-height: 600px;
    overflow: visible;
}

/* Level Styles */
.grandparents-level,
.parents-siblings-level,
.children-level,
.grandchildren-level,
.great-grandparents-level {
    display: flex;
    justify-content: center;
    align-items: flex-start;
    gap: 2rem;
    margin: 4rem 0;
    position: relative;
    flex-wrap: wrap;
    min-height: 120px;
}


/* Family Groups */
.family-group {
    display: inline-flex;
    align-items: center;
    gap: 0 !important;
    position: relative;
    margin: 0 1.5rem;
}

.family-group .tree-member {
    margin: 0 !important;
    position: relative;
}

/* للبطاقة الأولى في المجموعة (الأب عادة) */
.family-group .tree-member:first-child:not(:only-child) {
    border-radius: 0 8px 8px 0 !important;
    border-right-width: 1px !important;
    margin-right: -2px !important;
    z-index: 2;
}

/* للبطاقة الثانية في المجموعة (الأم عادة) */
.family-group .tree-member:nth-child(2) {
    border-radius: 8px 0 0 8px !important;
    border-left-width: 1px !important;
    z-index: 1;
}

/* خط الاتصال الصغير بين الأب والأم */
.family-group .tree-member:first-child:not(:only-child)::after {
    content: '';
    position: absolute;
    top: 35%;
    right: -15px;
    width: 30px;
    height: 2px;
    z-index: 3;
}

/* للبطاقة الوحيدة */
.family-group .tree-member:only-child {
    border-radius: 12px !important;
}

/* تأكد من عدم وجود فجوات */
.parents-siblings-level .family-group {
    display: inline-flex !important;
}

/* Member Cards */
.tree-member {
    background: white;
    border: 2px solid;
    border-radius: 12px;
    padding: 1rem 0.8rem;
    text-align: center;
    max-width: 230px !important;
    max-height: 270px !important;
    position: relative;
    transition: all 0.3s ease;
    cursor: pointer;
    z-index: 10;
}

.tree-member:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 11;
}

.tree-member.male {
    border-top: 10px solid rgba(59, 130, 246, 1);
    border-bottom-color: rgb(201, 200, 200);
    border-right-color: rgb(201, 200, 200);
    border-left-color: rgb(201, 200, 200);
    background: transparent;
}

.tree-member.male:hover {
    box-shadow: 0 4px 12px rgba(107, 166, 229, 0.3);
    border-color: #5B9BD5;
}

.tree-member.female {
    border-top: 10px solid rgba(236, 72, 153, 1);
    border-bottom-color: rgb(201, 200, 200);
    border-right-color: rgb(201, 200, 200);
    border-left-color: rgb(201, 200, 200);
    background: transparent;
}

.tree-member.female:hover {
    box-shadow: 0 4px 12px rgba(244, 163, 196, 0.3);
    border-color: #ED7D95;
}

/* Member Avatar */
.member-avatar-container {
    margin-bottom: 0.5rem;
}

.member-avatar {
    width: 90px !important;
    height: 90px !important;
    border-radius: 50%;
    object-fit: cover;
    transition: all 0.3s ease;
}

.tree-member:hover .member-avatar {
    transform: scale(1.05);
}

/* Member Info */
.member-name {
    font-size: 24px;
    font-weight: 700;
    color: rgba(0, 0, 0, 1);
    margin: 0.3rem 0 0.2rem;
}

.member-relation {
    font-size: 0.7rem;
    color: #7f8c8d;
    font-weight: 500;
    margin-bottom: 0.2rem;
}

.member-dates {
    font-size: 15px;
    color: rgba(102, 102, 102, 1);
    margin-top: 0.2rem;
}

/* Marriage Connector */
.marriage-connector {
    position: absolute;
    top: 35%;
    left: calc(50% - 25px);
    width: 50px;
    height: 2px;
    background: linear-gradient(to right, #5B9BD5, #ED7D95);
    transform: translateY(-50%);
    z-index: 8;
}

/* Marriage Line Horizontal */
.marriage-line-horizontal {
    position: absolute;
    top: 40%;
    right: -30px;
    width: 30px;
    height: 2px;
    background: linear-gradient(to right, #6BA6E5, #F4A3C4);
    z-index: 8;
    transform: translateY(-50%);
}

/* Parent-Children Connections Container */
.parent-children-connections {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 5;
}

.connection-line {
    position: absolute;
    background: #ddd;
    z-index: 1;
}

.horizontal-line {
    height: 2px;
}

.vertical-line {
    width: 2px;
}

/* Marriage Connection */
.marriage-line {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 80px;
    height: 3px;
    background: linear-gradient(90deg, #e24a90 0%, #ff6b9d 50%, #e24a90 100%);
    border-radius: 2px;
    z-index: 2;
    box-shadow: 0 2px 8px rgba(226, 74, 144, 0.3);
}

.marriage-line::after {
    content: '💕';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: white;
    color: #e24a90;
    font-size: 1.2rem;
    padding: 0.25rem 0.5rem;
    border-radius: 50%;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

/* Tree Levels with Connection Lines */
.great-grandparents-level {
    display: flex;
    justify-content: center;
    gap: 3rem;
    margin-bottom: 4rem;
    position: relative;
}

.grandparents-level {
    display: flex;
    justify-content: center;
    gap: 8rem;
    margin-bottom: 4rem;
    position: relative;
}

.parents-siblings-level {
    display: flex;
    justify-content: center;
    gap: 5rem;
    margin: 4rem 0;
    position: relative;
    flex-wrap: wrap;
}

.family-group {
    display: flex;
    gap: 1.5rem;
    position: relative;
    align-items: center;
}

.parents-level {
    display: flex;
    justify-content: center;
    gap: 3rem;
    margin: 4rem 0;
    position: relative;
}

.children-level {
    display: flex;
    justify-content: center;
    gap: 2rem;
    flex-wrap: wrap;
    margin: 4rem 0;
    position: relative;
}

.grandchildren-level {
    display: flex;
    justify-content: center;
    gap: 2rem;
    flex-wrap: wrap;
    margin-top: 4rem;
    position: relative;
}

/* Parent-Child Connection Lines */
.parent-children-connections {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
    z-index: 5;
}

.parent-line {
    box-shadow: 0 2px 4px rgba(74, 144, 226, 0.3);
}

.children-horizontal-line {
    box-shadow: 0 1px 3px rgba(74, 144, 226, 0.2);
}

.child-line {
    box-shadow: 0 2px 4px rgba(74, 144, 226, 0.3);
}

.child-arrow {
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
    transition: all 0.3s ease;
}

.child-arrow:hover {
    transform: translateX(-50%) scale(1.1);
    box-shadow: 0 3px 8px rgba(74, 144, 226, 0.4);
}

/* Connection Lines Between Levels */
.level-connector {
    position: absolute;
    bottom: -3rem;
    left: 50%;
    transform: translateX(-50%);
    width: 2px;
    height: 12rem;
    background: #ccc;
    z-index: 1;
}

.horizontal-connector {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    height: 2px;
    background: #ccc;
    z-index: 1;
}

/* Simplified Connection Lines */
.level-connector {
    position: absolute;
    bottom: -3rem;
    left: 50%;
    transform: translateX(-50%);
    width: 2px;
    height: 5rem;
    background: #ccc;
    z-index: 1;
}

/* Node Plus Button 2 */
.node-plus2 {
    background: white;
    border: 2px solid rgba(59, 130, 246, 0.1);
    border-radius: 50%;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 16px;
    font-weight: bold;
    color: rgba(59, 130, 246, 1);
    transition: all 0.3s ease;
}

.node-plus2:hover {
    background: white;
    border-color: rgba(59, 130, 246, 0.1);
    color: rgba(59, 130, 246, 1);
    transform: scale(1.1);
}

/* Responsive Design */
@media (max-width: 768px) {
    .family-tree-template2 {
        padding: 2rem 1rem;
        min-height: 600px;
    }

    .tree-member {
        min-width: 140px;
        max-width: 160px;
        padding: 1.25rem 0.75rem;
        margin: 0 0.5rem;
    }

    .member-avatar {
        width: 50px;
        height: 50px;
    }

    .member-name {
        font-size: 0.9rem;
    }

    .member-relation {
        font-size: 0.75rem;
    }

    .grandparents-level {
        gap: 4rem;
        margin-bottom: 3rem;
    }

    .parents-siblings-level {
        gap: 3rem;
        margin: 3rem 0;
    }

    .family-group {
        gap: 1rem;
    }

    .children-level {
        gap: 1.5rem;
        margin: 3rem 0;
    }

    .grandchildren-level {
        gap: 1.5rem;
        margin-top: 3rem;
    }

    .marriage-connector {
        width: 50px;
    }
}

@media (max-width: 480px) {
    .tree-member {
        min-width: 120px;
        max-width: 140px;
        padding: 1rem 0.5rem;
    }

    .member-avatar {
        width: 40px;
        height: 40px;
    }

    .grandparents-level {
        gap: 2rem;
    }

    .parents-siblings-level {
        gap: 2rem;
    }

    .children-level {
        gap: 1rem;
    }
}

@media (max-width: 480px) {
    .grandparents-level {
        gap: 3rem;
        flex-direction: column;
        align-items: center;
    }

    .parents-level {
        gap: 1rem;
    }

    .children-level {
        gap: 0.75rem;
    }

    .tree-member {
        min-width: 100px;
        max-width: 120px;
    }
}

/* Sidebar */
.sidebar {
    width: 300px;
    background-color: #fff;
    box-shadow: 0px 14px 10px rgba(8, 15, 52, 0.06);
    position: fixed;
    top: 0;
    bottom: 0;
    right: 0;
    z-index: 1000;
    transition: transform 0.3s ease-in-out;
    overflow-y: auto;
}

.sidebar .logo img {
    max-width: 152px;
    height: auto;
}

.sidebar ul {
    list-style: none;
    padding: 0;
}

.sidebar ul li {
    margin-bottom: 0.8rem;
}

.sidebar ul li a {
    color: rgba(39, 58, 65, 1);
    text-decoration: none;
    font-size: 16px;
    padding: .7rem;
}

.sidebar ul li.active a {
    color: #b7924f !important;
    font-weight: bold;
}

.sidebar ul li a:hover {
    color: #b7924f;
}

.sidebar .nav-link.active {
    color: #b7924f;
}

.sidebar .icon {
    width: 20px;
    height: 20px;
    transition: all 0.3s ease-in-out;
}

.sidebar ul li.active .icon,
.sidebar ul li:hover .icon {
    filter: brightness(0) saturate(100%) invert(64%) sepia(29%) saturate(343%) hue-rotate(8deg) brightness(95%) contrast(90%);
    transform: scale(1.05);
}

.sidebar .nav-item:hover {
    background-color: rgba(249, 248, 244, 1);
    border-radius: 8px;
}

.sidebar .nav-item.active {
    background-color: rgba(249, 248, 244, 1);
    border-radius: 8px;
}

/* Close Button */
.sidebar-close {
    display: none;
    position: absolute;
    top: 2%;
    left: 0;
    font-size: 2rem;
    color: black;
}


/* custom container */

.custom-container {
    padding: 0 20rem 0 0;
}

/* navbar */
.search-bar {
    padding-right: 1rem;
    width: 100%;
}

.search-bar input {
    background-color: rgba(39, 58, 65, 0.05) !important;
    border: none;
    padding: .7rem;
}

.search-bar input::placeholder {
    color: rgba(156, 156, 156, 1);
    font-size: 14px;
    padding: .5rem;
}

.search-bar input {
    background-color: #f7f7f7;
    border: none;
    padding-right: 2.5rem;
}

.search-bar input:focus {
    box-shadow: none;
    background-color: #f7f7f7;
}

.search-bar i {
    color: rgba(158, 158, 158, 1);
    font-size: 16px;
}

/* Content */
.content {
    margin-right: 270px;
    padding: 1rem 3rem;
    transition: margin-left 0.3s ease-in-out;
}


/* Content */
.content {
    margin-right: 270px;
    padding: 1rem 3rem;
    transition: margin-left 0.3s ease-in-out;
}

.img-member {
    width: 70px;
    height: 70px;
    object-fit: cover;
}

#loadingIndicator {
    transition: all 0.3s ease;
}

.spinner-border {
    width: 3rem;
    height: 3rem;
}

.table-container {
    transition: opacity 0.3s ease;
}

/* في ملف CSS الخاص بك */
#treeLoadingIndicator {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 1000;
}

.tree-container {
    position: relative;
    transition: opacity 0.3s ease;
}

.spinner-border {
    width: 3rem;
    height: 3rem;
}

.active-status p {
    background-color: rgba(23, 89, 65, 0.2);
    color: rgba(23, 89, 65, 1);
    border-radius: 16px;
    padding: .5rem;
}

#cover-loading {
    z-index: 1000;
    background-color: rgba(0, 0, 0, 0.5);
    padding: 20px;
    border-radius: 10px;
}

@media (max-width: 767.98px) {
    .header h1 {
        font-size: 1.5rem;
    }

    .programmes-table {
        font-size: 14px;
    }

    .pagination-controls select {
        width: 80px;
    }
}

/* Responsive Sidebar */
@media (max-width: 991.98px) {
    .sidebar {
        transform: translateX(100%);
    }

    .sidebar.show {
        transform: translateX(0%);
    }

    .sidebar-close {
        display: block;
    }

    .content {
        margin-right: 0 !important;
        padding: .5rem;
    }

    .custom-container {
        padding: 0;
    }

    .search-bar {
        width: 100%;
    }
}


/* content */

.btn-custom {
    background-color: rgba(211, 171, 85, 1);
    color: rgba(248, 247, 247, 1);
    border: none;
    padding: 15px 35px;
    width: 100%;
    border-radius: 50px;
}

.btn-custom:hover {
    background-color: rgb(211, 160, 51);
    color: rgba(248, 247, 247, 1);
}

.cover-container {
    width: 100%;
    height: auto;
    margin-top: .5rem;
    border-radius: 25px;
    overflow: hidden;
}

.cover-container img {
    width: 100%;
    height: auto;
    object-fit: cover;
}

.cover-actions {
    margin-top: .5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}


.family-name {
    font-size: 1.5rem;
    font-weight: bold;
}

@media (max-width: 767.98px) {
    .header h1 {
        font-size: 1.5rem;
    }

    .programmes-table {
        font-size: 14px;
    }

    .pagination-controls select {
        width: 80px;
    }
}


/* Ensure table cells don't wrap unnecessarily */
.table th,
.table td {
    white-space: nowrap;
}

.table td,
.table th {
    padding: 1.2rem;
}

.table th {
    color: rgba(63, 63, 63, 1);
    font-size: 10px;
}

.table {
    border-radius: 12px !important;
}


.btn i {
    font-size: 1.2rem;
}

.modal-body input::placeholder {
    color: rgba(123, 123, 123, 0.5);
    font-size: 16px;
    font-weight: 400;
    text-align: right;
}

.modal-body input[type="text"],
input[type="date"],
input[type="tel"],
select {
    padding: 1rem;
    border-radius: 10px;
}

.modal-body label {
    margin-bottom: 1rem;
}


.form-check-input:checked {
    background-color: rgb(211, 160, 51);
    border-color: rgba(211, 171, 85, 0.2);
    color: rgba(162, 124, 42, 1) !important;
}


#tree {
    width: 100%;
    height: 100%;
    border: none !important;
}

/* ===============================
   رسائل التنبيه المحسنة
   =============================== */

.custom-alert {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 9999;
    min-width: 350px;
    max-width: 500px;
    padding: 20px 25px;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    font-family: 'AdorHairlineExtraBold', Arial, sans-serif;
    animation: slideInRight 0.4s ease-out;
    transform: translateX(0);
    opacity: 1;
    transition: all 0.3s ease;
}

.custom-alert.success {
    background: linear-gradient(135deg, rgba(76, 175, 80, 0.95) 0%, rgba(139, 195, 74, 0.95) 100%);
    color: white;
    border-left: 5px solid #4CAF50;
}

.custom-alert.error {
    background: linear-gradient(135deg, rgba(244, 67, 54, 0.95) 0%, rgba(233, 30, 99, 0.95) 100%);
    color: white;
    border-left: 5px solid #f44336;
}

.custom-alert.warning {
    background: linear-gradient(135deg, rgba(255, 193, 7, 0.95) 0%, rgba(255, 152, 0, 0.95) 100%);
    color: white;
    border-left: 5px solid #FF9800;
}

.custom-alert.info {
    background: linear-gradient(135deg, rgba(33, 150, 243, 0.95) 0%, rgba(3, 169, 244, 0.95) 100%);
    color: white;
    border-left: 5px solid #2196F3;
}

.alert-header {
    display: flex;
    align-items: center;
    margin-bottom: 10px;
    gap: 12px;
}

.alert-icon {
    font-size: 24px;
    min-width: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.alert-title {
    font-size: 18px;
    font-weight: bold;
    margin: 0;
    flex: 1;
}

.alert-close {
    background: none;
    border: none;
    color: white;
    font-size: 20px;
    cursor: pointer;
    padding: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background-color 0.2s ease;
}

.alert-close:hover {
    background-color: rgba(255, 255, 255, 0.2);
}

.alert-message {
    font-size: 16px;
    line-height: 1.5;
    margin: 0;
    opacity: 0.95;
}

.alert-progress {
    position: absolute;
    bottom: 0;
    left: 0;
    height: 3px;
    background-color: rgba(255, 255, 255, 0.3);
    border-radius: 0 0 12px 12px;
    animation: progressBar 4s linear;
}

/* الأنيميشن */
@keyframes slideInRight {
    from {
        transform: translateX(100%);
        opacity: 0;
    }

    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes slideOutRight {
    from {
        transform: translateX(0);
        opacity: 1;
    }

    to {
        transform: translateX(100%);
        opacity: 0;
    }
}

@keyframes progressBar {
    from {
        width: 100%;
    }

    to {
        width: 0%;
    }
}

.custom-alert.hiding {
    animation: slideOutRight 0.3s ease-in forwards;
}

/* تأثيرات إضافية */
.custom-alert::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    border-radius: 12px;
    padding: 1px;
    background: linear-gradient(45deg, rgba(255, 255, 255, 0.3), transparent, rgba(255, 255, 255, 0.3));
    mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    mask-composite: exclude;
    pointer-events: none;
}

/* أزرار التأكيد في نافذة الحذف */
.alert-buttons {
    display: flex;
    gap: 10px;
    justify-content: center;
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px solid rgba(255, 255, 255, 0.2);
}

.alert-buttons .btn {
    padding: 8px 20px;
    border-radius: 8px;
    font-weight: 600;
    font-size: 14px;
    border: none;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 120px;
    justify-content: center;
}

.alert-buttons .btn-danger {
    background: linear-gradient(135deg, #dc3545 0%, #c82333 100%);
    color: white;
    box-shadow: 0 4px 15px rgba(220, 53, 69, 0.3);
}

.alert-buttons .btn-danger:hover {
    background: linear-gradient(135deg, #c82333 0%, #a71e2a 100%);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(220, 53, 69, 0.4);
}

.alert-buttons .btn-secondary {
    background: linear-gradient(135deg, #6c757d 0%, #5a6268 100%);
    color: white;
    box-shadow: 0 4px 15px rgba(108, 117, 125, 0.3);
}

.alert-buttons .btn-secondary:hover {
    background: linear-gradient(135deg, #5a6268 0%, #495057 100%);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(108, 117, 125, 0.4);
}

.alert-buttons .btn:active {
    transform: translateY(0);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
}

/* تحسين مظهر الأزرار المعطلة */
.btn.disabled,
.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none !important;
    box-shadow: none !important;
}

.btn .fas.fa-spinner {
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

/* تجاوب مع الشاشات الصغيرة */
@media (max-width: 768px) {
    .custom-alert {
        right: 10px;
        left: 10px;
        min-width: auto;
        max-width: none;
        top: 10px;
    }

    .alert-title {
        font-size: 16px;
    }

    .alert-message {
        font-size: 14px;
    }
}


.logo-container {
    position: relative;
    width: 120px; /* حجم الشعار */
    height: 120px; /* حجم الشعار */
}

.family-logo-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
    border: 4px solid white; /* يضيف إطار أبيض جميل */
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

.edit-logo-button {
    position: absolute;
    bottom: 5px; /* المسافة من الأسفل */
    right: 5px; /* المسافة من اليمين */
    width: 35px; /* حجم الزر */
    height: 35px; /* حجم الزر */
    padding: 0;
    border: none;
    background: none;
    cursor: pointer;
    transition: transform 0.2s ease;
}

.edit-logo-button:hover {
    transform: scale(1.1);
}

.edit-logo-button img {
    width: 100%;
    height: 100%;
}

.family-name {
    font-size: 2rem; /* تكبير الخط قليلاً */
    font-weight: bold;
    color: #273A41;
    margin-bottom: 0.5rem; /* إضافة هامش سفلي */
}
