/* =========================================
   1. الأساسيات والريست (Basics)
   ========================================= */
body {
    font-family: sans-serif;
    background: #f4f4f9;
    margin: 0;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

#tree-container {
    flex: 1;
    width: 100%;
}

/* =========================================
   2. الهيدر (Header)
   ========================================= */
.main-header {
    background-color: #1a252f;
    color: #ffffff;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    padding: 15px 30px;
    position: sticky;
    top: 0;
    z-index: 1000;
}

.header-content {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    max-width: 1400px;
    margin: 0 auto;
    gap: 15px;
}

.main-header h1 {
    margin: 0;
    color: #ffffff !important;
    font-size: 26px;
}

.hamburger {
    display: none;
    background: none;
    border: none;
    color: #fff;
    font-size: 28px;
    cursor: pointer;
    padding: 0;
}

.controls {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
}

#searchInput {
    padding: 10px 20px;
    font-size: 14px;
    border: 2px solid #e0e0e0;
    border-radius: 25px;
    outline: none;
    transition: all 0.3s ease;
    width: 250px;
    background-color: #f9f9f9;
}

#searchInput:focus {
    border-color: #34495e;
    background-color: #ffffff;
    box-shadow: 0 0 8px rgba(52, 73, 94, 0.2);
}

/* =========================================
   3. محرك الشجرة (Tree Structure)
   ========================================= */
.tree {
    width: 100%;
    overflow-x: auto;
    text-align: center;
    padding: 20px 0 180px 0;
}

.tree ul {
    padding-top: 20px;
    position: relative;
    display: inline-flex;
    justify-content: center;
    min-width: 100%;
    margin: 0 auto;
    padding-left: 0;
}

.tree li {
    list-style-type: none;
    position: relative;
    padding: 20px 5px 0 5px;
    text-align: center;
    flex: 1 1 auto;
}

.tree li::before,
.tree li::after {
    content: '';
    position: absolute;
    top: 0;
    right: 50%;
    border-top: 2px solid #aaa;
    width: 50%;
    height: 20px;
}

.tree li::after {
    right: auto;
    left: 50%;
    border-left: 2px solid #aaa;
}

.tree li:only-child::after,
.tree li:only-child::before {
    display: none;
}

.tree li:only-child {
    padding-top: 0;
}

.tree li:first-child::before,
.tree li:last-child::after {
    border: 0 none;
}

.tree li:last-child::before {
    border-right: 2px solid #aaa;
    border-radius: 0 5px 0 0;
}

.tree li:first-child::after {
    border-radius: 5px 0 0 0;
}

.tree ul ul::before {
    content: '';
    position: absolute;
    top: 0;
    left: 50%;
    border-left: 2px solid #aaa;
    width: 0;
    height: 20px;
    margin-left: -1px;
}

/* =========================================
   4. البوكس المدمج (Cards & Couples)
   ========================================= */
.couple-container {
    display: flex;
    flex-direction: column;
    background: white;
    border: 2px solid #ccc;
    border-radius: 10px;
    padding: 0;
    margin: 0 auto;
    width: 100%;
    max-width: 240px;
    min-width: 150px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    position: relative;
    overflow: visible;
    transition: all 0.3s ease;
}

#tree-root>li>.couple-container {
    box-shadow: 0 8px 25px rgba(230, 126, 34, 0.3);
    border: 2px solid #e67e22;
}

.spouse-connector {
    display: none !important;
}

.card {
    background: transparent !important;
    padding: 15px 10px 10px 10px;
    width: 100%;
    border: none !important;
    box-sizing: border-box;
    position: relative;
    margin: 0 !important;
}

.card:first-child {
    border-top-left-radius: 8px;
    border-top-right-radius: 8px;
}

.card:last-child {
    border-bottom-left-radius: 8px;
    border-bottom-right-radius: 8px;
}

.card:last-child:not(:first-child) {
    border-top: 1px dashed #ccc !important;
}

.card h3 {
    font-size: clamp(13px, 1.2vw, 15px);
    margin: 0 0 5px 0;
    color: #222;
}

.card p {
    font-size: clamp(11px, 1vw, 12px);
    color: #666;
    margin: 0 0 5px 0;
}

.spouse-card {
    background-color: #f3e5f5 !important;
    border: 1px solid #9b59b6 !important;
    box-shadow: inset 0 0 8px rgba(155, 89, 182, 0.2);
}

.spouse-card h3 {
    color: #4a148c;
}

.card-actions {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-top: 5px;
}

.card-actions button {
    width: 100%;
    padding: 8px 5px;
    border: none;
    border-radius: 4px;
    font-size: 11px;
    font-weight: bold;
    cursor: pointer;
}

/* =========================================
   🔥 نظام الصلاحيات السري (RBAC) 🔥
   ========================================= */
/* إخفاء زر التعديل (الـ 3 نقط) عن أي زائر عادي */
.menu-dots-btn {
    display: none;
    position: absolute;
    top: 5px;
    right: 8px;
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
    color: #95a5a6;
    padding: 0 5px;
    z-index: 5;
    font-weight: bold;
    transition: color 0.2s ease;
}

.menu-dots-btn:hover {
    color: #2c3e50;
}

/* إظهار زر التعديل فقط لو المتصفح فيه كلاس الإدارة */
body.admin-mode .menu-dots-btn {
    display: block;
}

/* 🌟 إخفاء السن عن أي شخص ملوش صلاحية 🌟 */
.card p.relation,
.spouse-card p.relation {
    display: none !important;
}

/* 🌟 إظهار السن فقط للي معاه كلاس show-age (من الـ JS) 🌟 */
p.relation.show-age {
    display: block !important;
}

/* تصميم قائمة التعديلات */
.card-dropdown {
    display: none;
    position: absolute;
    top: 35px;
    right: 8px;
    background-color: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    min-width: 160px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
    z-index: 999;
    border-radius: 12px;
    flex-direction: column;
    border: 1px solid rgba(0, 0, 0, 0.05);
    padding: 6px;
}

.card-dropdown.show {
    display: flex;
    animation: slideInDrop 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes slideInDrop {
    from {
        opacity: 0;
        transform: translateY(-10px) scale(0.95);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.card-dropdown button {
    background: transparent;
    border: none;
    padding: 10px 12px;
    text-align: right;
    width: 100%;
    cursor: pointer;
    font-size: 12px;
    font-weight: 600;
    color: #2c3e50;
    border-radius: 8px;
    transition: all 0.2s ease;
    margin-bottom: 2px;
}

.card-dropdown button:last-child {
    margin-bottom: 0;
}

.card-dropdown button:hover {
    background-color: rgba(52, 152, 219, 0.1);
    color: #2980b9;
    transform: translateX(-4px);
}

.card-dropdown button.delete-text {
    color: #e74c3c;
}

.card-dropdown button.delete-text:hover {
    background-color: rgba(231, 76, 60, 0.1);
    color: #c0392b;
}

/* =========================================
   5. المودال (Modern Modal)
   ========================================= */
.modal,
#editModal,
#kinshipModal,
#loginModal {
    display: none;
    position: fixed;
    z-index: 9999;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(5px);
}

.modal-content {
    background-color: #ffffff;
    margin: 10vh auto;
    padding: 30px;
    border-radius: 16px;
    width: 90%;
    max-width: 380px;
    display: flex;
    flex-direction: column;
    gap: 15px;
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.2);
    animation: slideDown 0.3s ease-out;
}

@keyframes slideDown {
    from {
        transform: translateY(-20px);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

#modalTitle {
    margin: 0 0 5px 0;
    color: #2c3e50;
    font-size: 22px;
    text-align: center;
}

.modal-content label {
    font-size: 14px;
    color: #555;
    font-weight: bold;
    margin-bottom: -5px;
}

.modal-content input[type="text"],
.modal-content input[type="date"],
.modal-content input[type="email"],
.modal-content input[type="password"],
.modal-content select {
    padding: 12px 15px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 15px;
    outline: none;
    transition: all 0.3s ease;
    background-color: #f9f9f9;
    font-family: inherit;
    color: #2c3e50;
}

.modal-content input:focus,
.modal-content select:focus {
    border-color: #3498db;
    background-color: #fff;
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.1);
}

.modal-actions {
    display: flex;
    gap: 12px;
    margin-top: 10px;
}

.modal-save-btn,
.modal-cancel-btn {
    flex: 1;
    padding: 12px;
    border-radius: 8px;
    font-size: 15px;
    font-weight: bold;
    cursor: pointer;
    border: none;
    transition: background-color 0.2s, transform 0.1s;
}

.modal-save-btn {
    background-color: #2ecc71;
    color: white;
}

.modal-save-btn:hover {
    filter: brightness(0.9);
}

.modal-cancel-btn {
    background-color: #f1f2f6;
    color: #747d8c;
}

.modal-cancel-btn:hover {
    background-color: #dfe4ea;
    color: #2f3542;
}

.modal-save-btn:active,
.modal-cancel-btn:active {
    transform: scale(0.97);
}

/* =========================================
   6. الدارك مود (Full Dark Mode Fix)
   ========================================= */
body.dark-mode {
    background-color: #1a1a1a;
    color: #f0f0f0;
}

body.dark-mode .main-header {
    background-color: #2d2d2d;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

body.dark-mode .main-header h1 {
    color: #f0f0f0 !important;
}

body.dark-mode #searchInput {
    background-color: #444;
    color: #f0f0f0;
    border-color: #555;
}

body.dark-mode #searchInput:focus {
    border-color: #f39c12;
    background-color: #555;
}

body.dark-mode .couple-container {
    background-color: #2d2d2d;
    border: 2px solid #444;
}

body.dark-mode #tree-root>li>.couple-container {
    box-shadow: 0 8px 25px rgba(243, 156, 18, 0.2);
    border: 2px solid #f39c12;
}

body.dark-mode .card,
body.dark-mode .spouse-card {
    background-color: #2d2d2d !important;
    border: none !important;
}

body.dark-mode .card:last-child:not(:first-child) {
    border-top: 1px dashed #555 !important;
    border-left: none;
}

body.dark-mode .spouse-card {
    background-color: #382444 !important;
    border-top: 1px dashed #7a3b91 !important;
}

body.dark-mode .card h3,
body.dark-mode .spouse-card h3 {
    color: #f0f0f0;
}

body.dark-mode .card p {
    color: #bbb;
}

body.dark-mode .menu-dots-btn {
    color: #bbb;
}

body.dark-mode .menu-dots-btn:hover {
    color: #f0f0f0;
}

body.dark-mode .card-dropdown {
    background-color: rgba(45, 45, 45, 0.95);
    border-color: rgba(255, 255, 255, 0.05);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}

body.dark-mode .card-dropdown button {
    color: #ecf0f1;
}

body.dark-mode .card-dropdown button:hover {
    background-color: rgba(255, 255, 255, 0.1);
    color: #f39c12;
}

body.dark-mode .card-dropdown button.delete-text {
    color: #ff7675;
}

body.dark-mode .card-dropdown button.delete-text:hover {
    background-color: rgba(255, 118, 117, 0.15);
    color: #ff7675;
}

body.dark-mode .tree ul ul::before {
    border-left-color: #555;
}

body.dark-mode .tree li::before,
body.dark-mode .tree li::after {
    border-top-color: #555;
}

body.dark-mode .tree li::after {
    border-left-color: #555;
}

body.dark-mode .modal-content {
    background-color: #2d2d2d;
    border: 1px solid #444;
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.5);
}

body.dark-mode #modalTitle {
    color: #f0f0f0;
}

body.dark-mode .modal-content label {
    color: #bbb;
}

body.dark-mode .modal-content input,
body.dark-mode .modal-content select {
    background-color: #333;
    color: #f0f0f0;
    border: 2px solid #555;
}

body.dark-mode .modal-content input:focus,
body.dark-mode .modal-content select:focus {
    border-color: #f39c12;
    background-color: #2d2d2d;
    box-shadow: 0 0 0 3px rgba(243, 156, 18, 0.1);
}

body.dark-mode .modal-cancel-btn {
    background-color: #444;
    color: #ccc;
}

body.dark-mode .modal-cancel-btn:hover {
    background-color: #555;
    color: #fff;
}

body.dark-mode .main-footer {
    background-color: #2d2d2d;
    color: #f0f0f0;
    border-top: 1px solid #444;
}

body.dark-mode .phone-link {
    color: #2ecc71;
}

body.dark-mode .zoom-btn {
    background-color: #444;
    color: #fff;
}

body.dark-mode .zoom-btn:hover {
    background-color: #666;
}

/* =========================================
   7. تنسيق الفوتر (Footer)
   ========================================= */
.main-footer {
    background-color: #ffffff;
    color: #2c3e50;
    text-align: center;
    padding: 15px 20px;
    border-top: 2px solid #e0e0e0;
    box-shadow: 0 -4px 10px rgba(0, 0, 0, 0.1);
    width: 100%;
    box-sizing: border-box;
    margin-top: auto;
}

.footer-content p {
    margin: 5px 0;
    font-weight: bold;
    font-size: 14px;
}

.phone-link {
    color: #27ae60;
    direction: ltr;
    display: inline-block;
}

/* =========================================
   8. وضع الموبايل (Smart Grid Fix & Glassmorphism Menu)
   ========================================= */
@media screen and (max-width: 768px) {
    .header-content {
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
        width: 100%;
        position: relative;
    }

    .hamburger {
        display: block;
    }

    .controls {
        display: none;
        flex-direction: column;
        width: 100%;
        gap: 12px;
        position: absolute;
        top: 100%;
        left: 0;
        background-color: rgba(26, 37, 47, 0.85);
        backdrop-filter: blur(12px);
        -webkit-backdrop-filter: blur(12px);
        padding: 20px;
        box-sizing: border-box;
        box-shadow: 0 10px 25px rgba(0, 0, 0, 0.3);
        border-radius: 0 0 15px 15px;
        z-index: 1000;
        margin-top: 0;
        border-top: 1px solid rgba(255, 255, 255, 0.1);
    }

    body.dark-mode .controls {
        background-color: rgba(30, 30, 30, 0.85);
        border-top: 1px solid rgba(255, 255, 255, 0.05);
    }

    .controls.show {
        display: flex;
        animation: slideDownMenu 0.3s ease-out forwards;
    }

    @keyframes slideDownMenu {
        from {
            opacity: 0;
            transform: translateY(-10px);
        }

        to {
            opacity: 1;
            transform: translateY(0);
        }
    }

    #searchInput {
        width: 100%;
        box-sizing: border-box;
    }

    .controls button {
        width: 100%;
        margin: 0 !important;
    }

    .tree {
        padding: 15px 10px 180px 10px;
        overflow-x: hidden;
        box-sizing: border-box !important;
    }

    .tree ul {
        display: flex !important;
        flex-wrap: wrap !important;
        flex-direction: row !important;
        justify-content: center !important;
        gap: 15px !important;
        padding-left: 0 !important;
        margin: 0 !important;
        width: 100% !important;
    }

    .tree li::before,
    .tree li::after,
    .tree ul ul::before {
        display: none !important;
    }

    .tree ul ul {
        display: flex !important;
        flex-wrap: wrap !important;
        flex-direction: row !important;
        justify-content: center !important;
        gap: 15px !important;
        width: 100% !important;
        margin-top: 20px !important;
    }

    .tree li {
        display: block !important;
        flex: 1 1 calc(50% - 15px) !important;
        min-width: 140px !important;
        max-width: 100% !important;
        padding: 0 !important;
        box-sizing: border-box !important;
    }

    #tree-root>li {
        flex: 1 1 100% !important;
        width: 100% !important;
    }

    #tree-root>li>.couple-container {
        display: flex !important;
        flex-direction: row !important;
        width: 100% !important;
        margin-bottom: 0 !important;
    }

    #tree-root>li>.couple-container>.card {
        width: 50% !important;
        flex: 1 1 50% !important;
        padding: 15px 10px !important;
    }

    #tree-root>li>.couple-container>.card:last-child:not(:first-child) {
        border-top: none !important;
        border-left: 1px dashed #ccc !important;
    }

    body.dark-mode #tree-root>li>.couple-container>.card:last-child:not(:first-child) {
        border-top: none !important;
        border-left: 1px dashed #555 !important;
    }

    .tree ul ul li .couple-container {
        display: flex !important;
        flex-direction: column !important;
        width: 100% !important;
    }

    .tree ul ul li .card {
        width: 100% !important;
        padding: 15px 10px !important;
    }

    .tree ul ul li .card:last-child:not(:first-child) {
        border-left: none !important;
        border-top: 1px dashed #ccc !important;
    }

    body.dark-mode .tree ul ul li .card:last-child:not(:first-child) {
        border-left: none !important;
        border-top: 1px dashed #555 !important;
    }

    #tree-root>li>.couple-container .card:last-child:not(:first-child) {
        border-top: none !important;
    }

    .card h3 {
        font-size: 13px !important;
        word-wrap: break-word !important;
        margin: 0 0 5px 0 !important;
        padding: 0 15px !important;
        line-height: 1.4 !important;
    }

    .card-actions {
        display: flex !important;
        flex-direction: column !important;
        gap: 8px !important;
        padding-top: 10px !important;
    }

    .main-footer {
        padding: 10px !important;
        margin-top: auto;
    }

    .go-up-btn {
        width: 90% !important;
        margin: 0 auto 20px auto !important;
        display: block !important;
        border-radius: 25px !important;
        text-align: center !important;
    }
}

ul.search-mode li::before,
ul.search-mode li::after {
    display: none !important;
}

/* =========================================
   9. شاشة الاستعراض الأفقية والزووم (Horizontal Tree Preview)
   ========================================= */
.full-tree-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: #f4f4f9;
    z-index: 10000;
    flex-direction: column;
    overflow: hidden;
}

body.dark-mode .full-tree-overlay {
    background-color: #1a1a1a;
}

.full-tree-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 30px;
    background-color: #1a252f;
    color: white;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    z-index: 10;
}

body.dark-mode .full-tree-header {
    background-color: #2d2d2d;
}

.full-tree-header h2 {
    margin: 0;
    font-size: 20px;
}

.full-tree-actions {
    display: flex;
    align-items: center;
    gap: 15px;
}

.zoom-controls {
    display: flex;
    gap: 5px;
    background: rgba(255, 255, 255, 0.1);
    padding: 5px;
    border-radius: 8px;
}

.zoom-btn {
    background-color: transparent;
    border: none;
    color: white;
    font-size: 16px;
    cursor: pointer;
    padding: 5px 10px;
    border-radius: 5px;
    transition: 0.2s;
}

.zoom-btn:hover {
    background-color: rgba(255, 255, 255, 0.2);
}

.main-actions button {
    padding: 10px 15px;
    margin-left: 5px;
    border: none;
    border-radius: 8px;
    font-weight: bold;
    cursor: pointer;
    transition: 0.2s;
    font-size: 14px;
}

.download-tree-btn {
    background-color: #2ecc71;
    color: white;
}

.download-tree-btn:hover {
    background-color: #27ae60;
}

.close-tree-btn {
    background-color: #e74c3c;
    color: white;
}

.close-tree-btn:hover {
    background-color: #c0392b;
}

.tree-content-wrapper {
    flex: 1;
    overflow: auto;
    padding: 40px;
    direction: rtl;
    display: flex;
    align-items: center;
    justify-content: flex-start;
}

.hz-tree {
    display: flex;
    min-height: min-content;
    min-width: min-content;
    margin: auto 0;
    transform-origin: right center;
    transition: transform 0.2s ease-out;
}

.hz-tree ul {
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding-right: 40px;
    position: relative;
    margin: 0;
    list-style: none;
}

.hz-tree li {
    display: flex;
    flex-direction: row;
    align-items: center;
    padding: 15px 40px 15px 0;
    position: relative;
}

.hz-tree ul::before {
    content: '';
    position: absolute;
    right: 0;
    top: 50%;
    width: 40px;
    border-top: 2px solid #aaa;
}

.hz-tree li::before {
    content: '';
    position: absolute;
    right: 0;
    top: 50%;
    width: 40px;
    border-top: 2px solid #aaa;
}

.hz-tree li::after {
    content: '';
    position: absolute;
    right: 0;
    top: 0;
    bottom: 0;
    border-right: 2px solid #aaa;
}

.hz-tree li:first-child::after {
    top: 50%;
}

.hz-tree li:last-child::after {
    bottom: 50%;
}

.hz-tree li:only-child::after {
    display: none;
}

#readOnlyTreeRoot {
    padding-right: 0;
}

#readOnlyTreeRoot::before {
    display: none;
}

#readOnlyTreeRoot>li {
    padding-right: 0;
}

#readOnlyTreeRoot>li::before,
#readOnlyTreeRoot>li::after {
    display: none;
}

body.dark-mode .hz-tree ul::before,
body.dark-mode .hz-tree li::before {
    border-top-color: #555;
}

body.dark-mode .hz-tree li::after {
    border-right-color: #555;
}

.hz-tree .couple-container {
    flex-direction: column !important;
    min-width: 220px;
    margin: 0;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.08);
    border: 2px solid #ccc;
    background: white;
    border-radius: 10px;
    overflow: hidden;
}

body.dark-mode .hz-tree .couple-container {
    border-color: #444;
    background: #2d2d2d;
}

#readOnlyTreeRoot>li>.couple-container {
    border-color: #e67e22;
    box-shadow: 0 5px 25px rgba(230, 126, 34, 0.2);
}

.hz-tree .card {
    padding: 15px !important;
    width: 100% !important;
    text-align: right;
    background: transparent !important;
    border: none !important;
}

.hz-tree .spouse-card {
    background-color: #f3e5f5 !important;
}

body.dark-mode .hz-tree .spouse-card {
    background-color: #382444 !important;
}

.hz-tree .card h3 {
    font-size: 15px !important;
    margin-bottom: 5px !important;
    color: #222;
}

body.dark-mode .hz-tree .card h3 {
    color: #f0f0f0;
}

.hz-tree .card p {
    margin: 0 !important;
    font-size: 13px !important;
    color: #666;
}

body.dark-mode .hz-tree .card p {
    color: #bbb;
}

.hz-tree .card:last-child:not(:first-child) {
    border-left: none !important;
    border-top: 1px dashed #ccc !important;
}

body.dark-mode .hz-tree .card:last-child:not(:first-child) {
    border-top: 1px dashed #555 !important;
}

@media screen and (max-width: 768px) {
    .full-tree-header {
        flex-direction: column;
        gap: 15px;
        padding: 15px;
        text-align: center;
    }

    .full-tree-actions {
        flex-direction: column;
        width: 100%;
        gap: 10px;
    }

    .zoom-controls {
        width: 100%;
        justify-content: center;
    }

    .main-actions {
        display: flex;
        width: 100%;
        gap: 10px;
    }

    .main-actions button {
        flex: 1;
        margin: 0;
        padding: 12px 10px;
    }
}

/* =========================================
   10. القائمة المنسدلة الذكية للبحث (Custom Autocomplete)
   ========================================= */
.autocomplete-container {
    position: relative;
    width: 100%;
}

.custom-dropdown {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    width: 100%;
    max-height: 160px;
    overflow-y: auto;
    background-color: #fff;
    border: 2px solid #3498db;
    border-radius: 0 0 8px 8px;
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.2);
    z-index: 10001;
    margin-top: -2px;
}

.custom-dropdown div {
    padding: 12px 15px;
    cursor: pointer;
    border-bottom: 1px solid #eee;
    font-size: 14px;
    color: #2c3e50;
    text-align: right;
    font-weight: bold;
}

.custom-dropdown div:last-child {
    border-bottom: none;
}

.custom-dropdown div:hover {
    background-color: #f0f8ff;
    color: #3498db;
}

body.dark-mode .custom-dropdown {
    background-color: #2d2d2d;
    border-color: #f39c12;
}

body.dark-mode .custom-dropdown div {
    color: #f0f0f0;
    border-bottom: 1px solid #444;
}

body.dark-mode .custom-dropdown div:hover {
    background-color: #444;
    color: #f39c12;
}

/* =========================================
   11. علامة التبني (Adopted Badge)
   ========================================= */
.adopted-badge {
    position: absolute;
    top: -12px;
    left: -12px;
    background-color: #ff3b30;
    color: white;
    font-size: 11px;
    font-weight: bold;
    padding: 4px 10px;
    border-radius: 20px;
    box-shadow: 0 4px 8px rgba(255, 59, 48, 0.4);
    z-index: 10;
    border: 2px solid white;
    pointer-events: none;
}

body.dark-mode .adopted-badge {
    border-color: #2d2d2d;
}

/* =========================================
   12. شاشة القفل (بوابة الدخول)
   ========================================= */
.lock-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #1a252f, #2c3e50);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9000;
    flex-direction: column;
    color: white;
    text-align: center;
}

.lock-content {
    background: rgba(255, 255, 255, 0.1);
    padding: 40px;
    border-radius: 16px;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.1);
    max-width: 400px;
    width: 90%;
}

.lock-icon {
    font-size: 60px;
    margin-bottom: 15px;
}

.lock-screen h1 {
    font-size: 24px;
    margin-bottom: 10px;
    color: #fff;
}

.lock-screen p {
    font-size: 15px;
    color: #ddd;
    margin-bottom: 25px;
    line-height: 1.6;
}

.lock-login-btn {
    background-color: #e74c3c;
    color: white;
    border: none;
    padding: 12px 30px;
    font-size: 16px;
    font-weight: bold;
    border-radius: 8px;
    cursor: pointer;
    transition: 0.3s;
    width: 100%;
    margin-bottom: 20px;
}

.lock-login-btn:hover {
    background-color: #c0392b;
    transform: translateY(-2px);
}

.contact-info {
    font-size: 14px;
    color: #ccc;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    padding-top: 15px;
}

.contact-info a {
    color: #2ecc71;
    text-decoration: none;
    font-weight: bold;
    font-size: 20px;
    display: inline-block;
    margin-top: 8px;
    letter-spacing: 1px;
}

/* إخفاء التطبيق بالكامل أثناء القفل */
body.is-locked .main-header,
body.is-locked #tree-container,
body.is-locked .main-footer {
    display: none !important;
}