﻿@import url('open-iconic/font/css/open-iconic-bootstrap.min.css');

html, body {
    font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
}

h1:focus {
    outline: none;
}

a, .btn-link {
    color: #0071c1;
}

.btn-primary {
    color: #fff;
    background-color: #1b6ec2;
    border-color: #1861ac;
}

.content {
    padding-top: 1.1rem;
}

.valid.modified:not([type=checkbox]) {
    outline: 1px solid #26b050;
}

.invalid {
    outline: 1px solid red;
}

.validation-message {
    color: red;
}

#blazor-error-ui {
    background: lightyellow;
    bottom: 0;
    box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2);
    display: none;
    left: 0;
    padding: 0.6rem 1.25rem 0.7rem 1.25rem;
    position: fixed;
    width: 100%;
    z-index: 1000;
}

    #blazor-error-ui .dismiss {
        cursor: pointer;
        position: absolute;
        right: 0.75rem;
        top: 0.5rem;
    }

.blazor-error-boundary {
    background: url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNTYiIGhlaWdodD0iNDkiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiBvdmVyZmxvdz0iaGlkZGVuIj48ZGVmcz48Y2xpcFBhdGggaWQ9ImNsaXAwIj48cmVjdCB4PSIyMzUiIHk9IjUxIiB3aWR0aD0iNTYiIGhlaWdodD0iNDkiLz48L2NsaXBQYXRoPjwvZGVmcz48ZyBjbGlwLXBhdGg9InVybCgjY2xpcDApIiB0cmFuc2Zvcm09InRyYW5zbGF0ZSgtMjM1IC01MSkiPjxwYXRoIGQ9Ik0yNjMuNTA2IDUxQzI2NC43MTcgNTEgMjY1LjgxMyA1MS40ODM3IDI2Ni42MDYgNTIuMjY1OEwyNjcuMDUyIDUyLjc5ODcgMjY3LjUzOSA1My42MjgzIDI5MC4xODUgOTIuMTgzMSAyOTAuNTQ1IDkyLjc5NSAyOTAuNjU2IDkyLjk5NkMyOTAuODc3IDkzLjUxMyAyOTEgOTQuMDgxNSAyOTEgOTQuNjc4MiAyOTEgOTcuMDY1MSAyODkuMDM4IDk5IDI4Ni42MTcgOTlMMjQwLjM4MyA5OUMyMzcuOTYzIDk5IDIzNiA5Ny4wNjUxIDIzNiA5NC42NzgyIDIzNiA5NC4zNzk5IDIzNi4wMzEgOTQuMDg4NiAyMzYuMDg5IDkzLjgwNzJMMjM2LjMzOCA5My4wMTYyIDIzNi44NTggOTIuMTMxNCAyNTkuNDczIDUzLjYyOTQgMjU5Ljk2MSA1Mi43OTg1IDI2MC40MDcgNTIuMjY1OEMyNjEuMiA1MS40ODM3IDI2Mi4yOTYgNTEgMjYzLjUwNiA1MVpNMjYzLjU4NiA2Ni4wMTgzQzI2MC43MzcgNjYuMDE4MyAyNTkuMzEzIDY3LjEyNDUgMjU5LjMxMyA2OS4zMzcgMjU5LjMxMyA2OS42MTAyIDI1OS4zMzIgNjkuODYwOCAyNTkuMzcxIDcwLjA4ODdMMjYxLjc5NSA4NC4wMTYxIDI2NS4zOCA4NC4wMTYxIDI2Ny44MjEgNjkuNzQ3NUMyNjcuODYgNjkuNzMwOSAyNjcuODc5IDY5LjU4NzcgMjY3Ljg3OSA2OS4zMTc5IDI2Ny44NzkgNjcuMTE4MiAyNjYuNDQ4IDY2LjAxODMgMjYzLjU4NiA2Ni4wMTgzWk0yNjMuNTc2IDg2LjA1NDdDMjYxLjA0OSA4Ni4wNTQ3IDI1OS43ODYgODcuMzAwNSAyNTkuNzg2IDg5Ljc5MjEgMjU5Ljc4NiA5Mi4yODM3IDI2MS4wNDkgOTMuNTI5NSAyNjMuNTc2IDkzLjUyOTUgMjY2LjExNiA5My41Mjk1IDI2Ny4zODcgOTIuMjgzNyAyNjcuMzg3IDg5Ljc5MjEgMjY3LjM4NyA4Ny4zMDA1IDI2Ni4xMTYgODYuMDU0NyAyNjMuNTc2IDg2LjA1NDdaIiBmaWxsPSIjRkZFNTIwIiBmaWxsLXJ1bGU9ImV2ZW5vZGQiLz48L2c+PC9zdmc+) no-repeat 1rem/1.8rem, #b32121;
    padding: 1rem 1rem 1rem 3.7rem;
    color: white;
}

    .blazor-error-boundary::after {
        content: "An error has occurred."
    }

.status-bar-safe-area {
    display: none;
}

@supports (-webkit-touch-callout: none) {
    .status-bar-safe-area {
        display: flex;
        position: sticky;
        top: 0;
        height: env(safe-area-inset-top);
        background-color: #f7f7f7;
        width: 100%;
        z-index: 1;
    }

    .flex-column,
    .navbar-brand {
        padding-left: env(safe-area-inset-left);
    }
}

html,
body {
    margin: 0;
    padding: 0;
    font-family: Arial, Tahoma, sans-serif;
    background: #f5f7f6;
}

.app-shell {
    min-height: 100vh;
    background: #f5f7f6;
}

.app-header {
    height: 72px;
    background: #145c43;
    color: white;
    display: flex;
    align-items: center;
    padding: 0 18px;
    gap: 15px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.menu-button {
    border: none;
    background: transparent;
    color: white;
    font-size: 28px;
    cursor: pointer;
}

.app-title {
    display: flex;
    flex-direction: column;
}

.main-title {
    font-size: 21px;
    font-weight: bold;
}

.sub-title {
    font-size: 12px;
    opacity: 0.85;
}

.app-content {
    padding: 20px;
}

.home-page {
    max-width: 700px;
    margin: auto;
}

.welcome-section {
    text-align: center;
    padding: 28px 10px;
}

.family-logo {
    width: 90px;
    height: 90px;
    margin: 0 auto 15px;
    background: #e2eee8;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 45px;
}

.welcome-section h1 {
    margin: 0;
    font-size: 32px;
    color: #145c43;
}

.welcome-section p {
    margin-top: 8px;
    color: #666;
}

.home-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 14px;
}

.home-card {
    background: white;
    border-radius: 18px;
    padding: 22px 14px;
    text-decoration: none;
    color: #222;
    box-shadow: 0 3px 12px rgba(0, 0, 0, 0.08);
    text-align: center;
    transition: transform 0.15s ease;
}

    .home-card:active {
        transform: scale(0.97);
    }

.home-card-icon {
    font-size: 38px;
    margin-bottom: 10px;
}

.home-card-title {
    font-size: 18px;
    font-weight: bold;
    color: #145c43;
    margin-bottom: 6px;
}

.home-card-text {
    font-size: 13px;
    color: #777;
    line-height: 1.6;
}

.family-nav {
    display: flex;
    flex-direction: column;
}

.family-nav-link {
    padding: 12px;
    text-decoration: none;
}

@media (max-width: 450px) {
    .app-content {
        padding: 14px;
    }

    .home-grid {
        grid-template-columns: 1fr 1fr;
        gap: 10px;
    }

    .home-card {
        padding: 18px 10px;
    }

    .home-card-title {
        font-size: 16px;
    }

    .home-card-text {
        font-size: 12px;
    }
}


/* ===========================
   شجرة العائلة
   =========================== */

.tree-page {
    padding: 16px;
    max-width: 900px;
    margin: auto;
}

.tree-page-header {
    text-align: center;
    margin-bottom: 20px;
}

    .tree-page-header h2 {
        color: #145c43;
        margin-bottom: 4px;
    }

    .tree-page-header p {
        color: #777;
    }

.mobile-family-tree {
    background: white;
    border-radius: 18px;
    padding: 16px;
    box-shadow: 0 4px 16px rgba(0,0,0,.08);
    overflow-x: auto;
}

.mobile-tree-item {
    position: relative;
}

.mobile-tree-row {
    display: flex;
    align-items: center;
    gap: 7px;
    min-height: 38px;
}

.mobile-tree-toggle {
    width: 30px;
    height: 30px;
    border: 1px solid #ccd8d2;
    border-radius: 8px;
    background: #f5faf7;
    color: #145c43;
    font-size: 19px;
    font-weight: bold;
    flex-shrink: 0;
}

.mobile-tree-spacer {
    width: 30px;
}

.mobile-tree-person {
    border: 0;
    background: transparent;
    padding: 6px 10px;
    border-radius: 10px;
    font-size: 15px;
    text-align: right;
    color: #222;
    display: flex;
    align-items: center;
    gap: 9px;
}

    .mobile-tree-person.selected {
        background: #dcefe6;
        color: #145c43;
        font-weight: bold;
    }

.mobile-tree-children {
    margin-right: 22px;
    padding-right: 16px;
    border-right: 1px solid #cad8d1;
}

.deceased-mark {
    color: #777;
    font-size: 9px;
    margin-right: 5px;
}

.tree-message {
    text-align: center;
    padding: 30px;
    color: #666;
}

.tree-error {
    margin: 20px;
    padding: 14px;
    border-radius: 12px;
    background: #fff1f1;
    color: #a40000;
}

.tree-person-image {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid #e1e8e4;
    background: #ffffff;
    flex-shrink: 0;
}

.tree-loading {
    padding: 6px 42px;
    font-size: 13px;
    color: #666;
}


/* ===========================
   نافذة تفاصيل الشخص
   =========================== */

.person-details-overlay {
    position: fixed !important;
    top: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    left: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    background: rgba(0, 0, 0, 0.58) !important;
    z-index: 999999 !important;
    display: flex !important;
    justify-content: center !important;
    align-items: center !important;
    padding: 15px !important;
    box-sizing: border-box !important;
}

.person-details-card {
    position: relative !important;
    width: 100% !important;
    max-width: 430px !important;
    max-height: 90vh !important;
    overflow-y: auto !important;
    background: #ffffff !important;
    border-radius: 22px !important;
    padding: 20px 18px 18px !important;
    box-sizing: border-box !important;
    direction: rtl !important;
    box-shadow: 0 18px 60px rgba(0, 0, 0, 0.35) !important;
}

.person-details-close {
    position: absolute !important;
    top: 8px !important;
    left: 8px !important;
    width: 36px !important;
    height: 36px !important;
    border: none !important;
    border-radius: 50% !important;
    background: #f0f0f0 !important;
    color: #333 !important;
    font-size: 24px !important;
    font-weight: bold !important;
    cursor: pointer !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    z-index: 20 !important;
}

.person-details-photo-wrap {
    width: 100% !important;
    display: flex !important;
    justify-content: center !important;
    align-items: center !important;
    margin-top: 4px !important;
}

.person-details-photo {
    width: 150px !important;
    height: 150px !important;
    border-radius: 50% !important;
    object-fit: cover !important;
    border: 4px solid #e4eee8 !important;
    background: #ffffff !important;
    display: block !important;
}

.person-details-name {
    text-align: center !important;
    margin: 8px 0 2px !important;
    color: #145c43 !important;
    font-size: 24px !important;
    font-weight: bold !important;
}

.person-deceased {
    text-align: center !important;
    color: #777 !important;
    margin: 0 0 8px !important;
}

.person-details-list {
    width: 100% !important;
    margin-top: 8px !important;
}

.person-detail-row {
    display: flex !important;
    flex-direction: column !important;
    gap: 2px !important;
    padding: 7px 3px !important;
    border-bottom: 1px solid #eeeeee !important;
    text-align: right !important;
}

    .person-detail-row strong {
        color: #236b45 !important;
        font-size: 14px !important;
    }

    .person-detail-row span {
        color: #333 !important;
        font-size: 14px !important;
    }

    .person-detail-row a {
        color: #1565c0 !important;
        text-decoration: none !important;
        overflow-wrap: anywhere !important;
        font-size: 14px !important;
    }

.person-detail-notes {
    margin-top: 9px !important;
    padding: 11px !important;
    background: #f5f9f6 !important;
    border-radius: 12px !important;
    line-height: 1.6 !important;
    text-align: right !important;
}

    .person-detail-notes strong {
        color: #236b45 !important;
    }

    .person-detail-notes p {
        margin: 7px 0 0 !important;
    }


/* ===========================
   تحسين الموبايل
   =========================== */

@media (max-width: 480px) {

    .person-details-overlay {
        padding: 8px !important;
    }

    .person-details-card {
        max-height: 94vh !important;
        padding: 18px 14px 16px !important;
        border-radius: 18px !important;
    }

    .person-details-name {
        font-size: 21px !important;
        margin-top: 7px !important;
    }

    .person-detail-row {
        padding: 6px 2px !important;
    }
}

.search-page {
    max-width: 700px;
    margin: auto;
    padding: 16px;
}

.search-page-header {
    text-align: center;
    margin-bottom: 18px;
}

    .search-page-header h2 {
        color: #145c43;
        margin-bottom: 4px;
    }

    .search-page-header p {
        color: #777;
    }

.search-box {
    display: flex;
    gap: 8px;
    margin-bottom: 18px;
}

.search-input {
    flex: 1;
    border: 1px solid #ccd8d2;
    border-radius: 12px;
    padding: 12px 14px;
    font-size: 16px;
    outline: none;
}

    .search-input:focus {
        border-color: #145c43;
    }

.search-button {
    border: none;
    border-radius: 12px;
    background: #145c43;
    color: white;
    padding: 0 20px;
    font-size: 15px;
    cursor: pointer;
}

    .search-button:disabled {
        opacity: .6;
    }

.search-results {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.search-result-card {
    width: 100%;
    border: none;
    border-radius: 14px;
    background: white;
    text-align: right;
    padding: 14px;
    box-shadow: 0 3px 12px rgba(0,0,0,.07);
    cursor: pointer;
}

.search-result-name {
    font-size: 16px;
    font-weight: bold;
    color: #145c43;
}

.search-result-info {
    margin-top: 5px;
    font-size: 13px;
    color: #777;
}

.search-message {
    text-align: center;
    padding: 20px;
    color: #666;
}

.search-error {
    margin: 12px 0;
    padding: 12px;
    border-radius: 12px;
    background: #fff1f1;
    color: #a40000;
}


.search-results-count {
    margin-bottom: 10px;
    text-align: right;
    color: #666;
    font-size: 13px;
    font-weight: bold;
}

/* ==================================================
   إدارة الشجرة من تطبيق الهاتف
   ================================================== */

.person-manage-card {
    max-width: 470px !important;
}

.branch-status-box {
    margin: 10px 0;
    padding: 10px 12px;
    border-radius: 12px;
    background: #f5f9f6;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    flex-wrap: wrap;
    font-size: 13px;
}

.branch-open-badge,
.branch-locked-badge {
    border-radius: 999px;
    padding: 5px 9px;
    font-weight: 800;
    font-size: 12px;
}

.branch-open-badge {
    background: #dff4e8;
    color: #16623d;
}

.branch-locked-badge {
    background: #f1f1f1;
    color: #666;
}

.unlock-box {
    display: flex;
    gap: 8px;
    margin: 10px 0;
}

    .unlock-box input {
        flex: 1;
        min-width: 0;
        border: 1px solid #ccd8d2;
        border-radius: 11px;
        padding: 10px 12px;
        font-size: 15px;
    }

    .unlock-box button {
        border: 0;
        border-radius: 11px;
        padding: 0 14px;
        background: #145c43;
        color: white;
        font-weight: 800;
    }

.person-management-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    margin: 12px 0;
}

    .person-management-actions button,
    .small-dialog-actions button {
        border: 0;
        border-radius: 11px;
        padding: 10px 8px;
        font-weight: 800;
        cursor: pointer;
    }

.manage-primary,
.editor-save {
    background: #145c43;
    color: white;
}

.manage-secondary {
    background: #e8f1ec;
    color: #145c43;
}

.manage-danger {
    background: #b42318;
    color: white;
}

.manage-lock,
.editor-cancel {
    background: #ededed;
    color: #333;
}

.tree-no-children {
    margin: 3px 0 7px 38px;
    font-size: 12px;
    color: #999;
}

.small-dialog {
    width: 100%;
    max-width: 390px;
    background: white;
    border-radius: 18px;
    padding: 20px;
    box-sizing: border-box;
    box-shadow: 0 18px 55px rgba(0,0,0,.3);
}

    .small-dialog h3 {
        margin-top: 0;
        color: #145c43;
    }

    .small-dialog > input {
        width: 100%;
        box-sizing: border-box;
        border: 1px solid #ccd8d2;
        border-radius: 11px;
        padding: 11px 12px;
        font-size: 16px;
    }

.small-dialog-actions {
    display: flex;
    gap: 8px;
    margin-top: 14px;
}

    .small-dialog-actions button {
        flex: 1;
    }

.danger-note {
    color: #8a1c14;
    font-size: 13px;
}

/* محرر بيانات الشخص */
.person-editor-card {
    position: relative;
    width: 100%;
    max-width: 680px;
    max-height: 94vh;
    overflow-y: auto;
    background: white;
    border-radius: 20px;
    padding: 20px;
    box-sizing: border-box;
    box-shadow: 0 18px 60px rgba(0,0,0,.35);
}

.editor-title {
    margin: 0 0 12px;
    text-align: center;
    color: #145c43;
}

.editor-photo-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 14px;
    flex-wrap: wrap;
    margin-bottom: 16px;
}

.editor-upload-button {
    display: inline-block;
    background: #e8f1ec;
    color: #145c43;
    border-radius: 11px;
    padding: 9px 13px;
    font-weight: 800;
    cursor: pointer;
}

.editor-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 11px;
}

.editor-field {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

    .editor-field span,
    .editor-check span {
        color: #145c43;
        font-size: 13px;
        font-weight: 800;
    }

    .editor-field input,
    .editor-field textarea,
    .advanced-mobile-search input,
    .advanced-mobile-search select {
        width: 100%;
        box-sizing: border-box;
        border: 1px solid #ccd8d2;
        border-radius: 10px;
        padding: 10px 11px;
        font-size: 15px;
        background: white;
    }

    .editor-field textarea {
        resize: vertical;
    }

.editor-wide {
    grid-column: 1 / -1;
}

.editor-check {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 9px;
    border-radius: 10px;
    background: #f7faf8;
}

.editor-actions {
    display: flex;
    gap: 9px;
    margin-top: 16px;
}

    .editor-actions button {
        flex: 1;
        border: 0;
        border-radius: 11px;
        padding: 11px;
        font-weight: 800;
    }

.editor-message {
    margin: 9px 0;
    padding: 9px 11px;
    border-radius: 10px;
    font-size: 13px;
    font-weight: 700;
}

.editor-success {
    background: #e5f6ec;
    color: #17643e;
}

.editor-error {
    background: #fff0ef;
    color: #a1261d;
}

/* البحث المتقدم */
.advanced-mobile-search {
    display: grid;
    grid-template-columns: 190px 1fr auto;
    gap: 10px;
    align-items: end;
    background: white;
    border-radius: 16px;
    padding: 14px;
    box-shadow: 0 3px 14px rgba(0,0,0,.07);
    margin-bottom: 16px;
}

    .advanced-mobile-search label {
        display: flex;
        flex-direction: column;
        gap: 5px;
    }

        .advanced-mobile-search label > span {
            color: #145c43;
            font-size: 13px;
            font-weight: 800;
        }

.search-button-wide {
    min-height: 42px;
}

.search-result-with-photo {
    display: flex;
    align-items: center;
    gap: 12px;
}

    .search-result-with-photo > img {
        width: 54px;
        height: 54px;
        border-radius: 50%;
        object-fit: cover;
        flex-shrink: 0;
        border: 2px solid #e1e8e4;
    }

@media (max-width: 600px) {
    .editor-grid {
        grid-template-columns: 1fr;
    }

    .editor-wide {
        grid-column: auto;
    }

    .advanced-mobile-search {
        grid-template-columns: 1fr;
    }

    .search-button-wide {
        min-height: 44px;
    }
}

/* =========================================================
   Tree UI refinement - compact, clear, mobile friendly
   ========================================================= */
.tree-page,
.mobile-family-tree,
.mobile-tree-item,
.mobile-tree-row,
.mobile-tree-person,
.tree-inline-stats,
.tree-mini-profile {
    font-family: Calibri, "Segoe UI", Tahoma, Arial, sans-serif;
}

.mobile-family-tree {
    font-size: 14px;
    line-height: 1.25;
}

.mobile-tree-row {
    min-height: 31px;
    gap: 5px;
    padding-block: 2px;
    position: relative;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
}

.mobile-tree-person {
    font-size: 14px;
    font-weight: 600;
    padding: 3px 6px;
    min-height: 28px;
    border-radius: 8px;
    gap: 5px;
}

    .mobile-tree-person .person-name {
        line-height: 1.15;
    }

.tree-person-image {
    width: 23px;
    height: 23px;
    border-radius: 50%;
    object-fit: cover;
}

.mobile-tree-toggle {
    width: 24px;
    height: 24px;
    min-width: 24px;
    padding: 0;
    font-size: 15px;
    border-radius: 7px;
}

.mobile-tree-children {
    margin-inline-start: 15px;
    padding-inline-start: 8px;
}

.tree-inline-stats {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    flex-wrap: nowrap;
    white-space: nowrap;
    font-size: 11.5px;
    direction: ltr;
}

.tree-stat {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    padding: 2px 5px;
    border-radius: 999px;
    font-weight: 700;
    border: 1px solid transparent;
}

.tree-stat-icon {
    font-size: 12px;
    line-height: 1;
}

.tree-stat-total {
    background: #e8f7f5;
    color: #087f70;
    border-color: #bfe9e2;
}

.tree-stat-male {
    background: #eaf3ff;
    color: #1d63ad;
    border-color: #c9def8;
}

.tree-stat-female {
    background: #f9eefd;
    color: #9a3ca7;
    border-color: #ebd0f0;
}

.tree-stat-death {
    background: #f4eeee;
    color: #8a3434;
    border-color: #e7cccc;
}

.tree-mini-profile {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    max-width: 330px;
    padding: 6px 7px;
    margin-inline-start: 7px;
    background: rgba(255,255,255,.98);
    border: 1px solid #d9e6e1;
    border-radius: 10px;
    box-shadow: 0 5px 16px rgba(21,70,55,.12);
    direction: rtl;
    font-size: 11.5px;
}

.tree-mini-profile-photo {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    object-fit: cover;
    flex: 0 0 38px;
}

.tree-mini-profile-body {
    display: flex;
    flex-direction: column;
    gap: 1px;
    min-width: 0;
}

    .tree-mini-profile-body strong {
        font-size: 12.5px;
        color: #124f3e;
    }

    .tree-mini-profile-body span {
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        color: #5e6b67;
    }

.tree-mini-profile-open {
    border: 0;
    border-radius: 8px;
    padding: 5px 7px;
    background: #146b50;
    color: white;
    font-size: 11px;
    white-space: nowrap;
}

.person-details-fullscreen-overlay {
    align-items: stretch !important;
    justify-content: stretch !important;
    padding: 0 !important;
}

.person-details-fullscreen-card {
    width: 100vw !important;
    max-width: none !important;
    height: 100vh !important;
    max-height: 100vh !important;
    border-radius: 0 !important;
    overflow-y: auto !important;
    padding: 22px 18px 36px !important;
}

@media (max-width: 720px) {
    .mobile-family-tree {
        font-size: 13.5px;
    }

    .mobile-tree-person {
        font-size: 13.5px;
    }

    .tree-inline-stats {
        font-size: 10.5px;
        gap: 3px;
    }

    .tree-stat {
        padding: 2px 4px;
    }

    .tree-mini-profile {
        max-width: 270px;
        width: min(270px, 86vw);
    }

    .person-details-fullscreen-card {
        padding: 18px 12px 30px !important;
    }
}

/* =========================================================
   Selected branch only: stats + side profile + inline unlock
   ========================================================= */
.mobile-tree-row {
    flex-wrap: nowrap;
    overflow: visible;
}

/* الإحصائيات لا تظهر إلا للعقدة المعلّمة لأن TreeNode يرسمها فقط عند IsSelected. */
.tree-inline-stats-selected {
    flex: 0 0 auto;
    animation: treeSelectedInfoIn .15s ease-out;
}

/* الصندوق يأتي بعد الإحصائية في صف RTL، أي إلى يسار الاسم مباشرة. */
.tree-mini-profile {
    flex: 0 0 auto;
    max-width: 430px;
    min-width: 300px;
    margin-inline-start: 8px;
    padding: 7px 8px;
    gap: 8px;
    z-index: 20;
    border-color: #cfe2da;
    box-shadow: 0 7px 20px rgba(21,70,55,.14);
}

.tree-mini-profile-actions {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 160px;
}

.tree-mini-branch-name {
    color: #146b50 !important;
    font-weight: 700;
}

.tree-mini-unlock-row {
    display: flex;
    align-items: center;
    gap: 4px;
    direction: rtl;
}

.tree-mini-password {
    width: 135px;
    min-width: 105px;
    height: 29px;
    padding: 3px 7px;
    border: 1px solid #c9dbd4;
    border-radius: 7px;
    outline: none;
    font-family: Calibri, "Segoe UI", Tahoma, Arial, sans-serif;
    font-size: 11.5px;
    background: #fff;
}

    .tree-mini-password:focus {
        border-color: #2a8a6c;
        box-shadow: 0 0 0 2px rgba(42,138,108,.10);
    }

.tree-mini-unlock-button {
    height: 29px;
    border: 0;
    border-radius: 7px;
    padding: 3px 8px;
    background: #146b50;
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    white-space: nowrap;
}

    .tree-mini-unlock-button:disabled {
        opacity: .55;
    }

.tree-mini-unlocked {
    display: inline-flex;
    align-items: center;
    width: fit-content;
    padding: 3px 7px;
    border-radius: 999px;
    background: #e6f6ee;
    color: #146b50;
    border: 1px solid #bde2cf;
    font-size: 11px;
    font-weight: 700;
}

.tree-mini-message {
    max-width: 220px;
    font-size: 10.5px;
    line-height: 1.2;
}

    .tree-mini-message.success {
        color: #146b50;
    }

    .tree-mini-message.error {
        color: #a33434;
    }

@keyframes treeSelectedInfoIn {
    from {
        opacity: 0;
        transform: translateX(4px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@media (max-width: 900px) {
    .mobile-tree-row {
        flex-wrap: wrap;
    }

    .tree-mini-profile {
        min-width: 0;
        width: min(410px, 88vw);
        max-width: 88vw;
        margin-inline-start: 31px;
    }
}

@media (max-width: 560px) {
    .tree-mini-profile {
        width: min(330px, 88vw);
        align-items: flex-start;
        flex-wrap: wrap;
    }

    .tree-mini-profile-actions {
        width: 100%;
        min-width: 0;
    }

    .tree-mini-unlock-row {
        width: 100%;
    }

    .tree-mini-password {
        flex: 1 1 auto;
        width: auto;
    }
}



/* =========================================================
   Selected-person inline management controls
   تظهر بجانب الشخص المعلَّم فقط بعد فتح فرعه
   ========================================================= */
.tree-inline-actions {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    margin-inline: 5px 3px;
    direction: rtl;
    vertical-align: middle;
    flex-wrap: nowrap;
}



.tree-action-btn {
    width: 27px;
    height: 27px;
    min-width: 27px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    border: 1px solid #cfded8;
    background: #ffffff;
    color: #17684f;
    font-family: Calibri, "Segoe UI", Tahoma, Arial, sans-serif;
    font-size: 16px;
    font-weight: 700;
    line-height: 1;
    cursor: pointer;
    box-shadow: 0 1px 2px rgba(0,0,0,.04);
}



    .tree-action-btn:hover:not(:disabled) {
        transform: translateY(-1px);
        box-shadow: 0 2px 5px rgba(0,0,0,.09);
    }



    .tree-action-btn:disabled {
        opacity: .45;
        cursor: default;
    }



.tree-action-edit {
    background: #eef8f4;
    color: #126548;
    border-color: #c9e6da;
}


.tree-action-add {
    background: #e8f7ef;
    color: #087443;
    border-color: #bfe5d1;
    font-size: 20px;
}


.tree-action-up,
.tree-action-down {
    background: #f0f6fb;
    color: #26638f;
    border-color: #cfdfeb;
    font-size: 17px;
}


.tree-action-delete {
    background: #fff0ef;
    color: #b42318;
    border-color: #f3cac6;
    font-size: 14px;
}



/* Keep selected row readable: name + actions + statistics on one organized line. */
.mobile-tree-row {
    align-items: center;
}



.mobile-tree-person.selected {
    box-shadow: 0 0 0 2px rgba(24, 116, 87, .12);
}



@media (max-width: 700px) {

    .tree-inline-actions {
        gap: 3px;
        margin-inline: 3px 2px;
    }


    .tree-action-btn {
        width: 25px;
        height: 25px;
        min-width: 25px;
        border-radius: 7px;
        font-size: 15px;
    }


    .tree-action-add {
        font-size: 19px;
    }
}



/* =========================================================
   Compact selected-person action cluster
   عمود أسهم + عمود إضافة/حذف + زر تعديل بجانبهما
   ========================================================= */
.tree-inline-actions-compact {
    display: inline-grid;
    grid-template-columns: 24px 24px 29px;
    grid-template-rows: 22px 22px;
    gap: 3px;
    align-items: stretch;
    margin-inline: 5px 4px;
    direction: rtl;
    vertical-align: middle;
}

    .tree-inline-actions-compact .tree-action-stack {
        display: contents;
    }

    /* RTL: العمود الأول يمين المجموعة للأسهم، الثاني للإضافة/الحذف، والثالث للتعديل. */
    .tree-inline-actions-compact .tree-action-up {
        grid-column: 1;
        grid-row: 1;
    }

    .tree-inline-actions-compact .tree-action-down {
        grid-column: 1;
        grid-row: 2;
    }

    .tree-inline-actions-compact .tree-action-add {
        grid-column: 2;
        grid-row: 1;
    }

    .tree-inline-actions-compact .tree-action-delete {
        grid-column: 2;
        grid-row: 2;
    }

    .tree-inline-actions-compact .tree-action-edit-tall {
        grid-column: 3;
        grid-row: 1 / span 2;
        width: 29px;
        min-width: 29px;
        height: 47px;
        font-size: 16px;
    }

    .tree-inline-actions-compact .tree-action-btn {
        width: 24px;
        min-width: 24px;
        height: 22px;
        border-radius: 6px;
        font-size: 13px;
        padding: 0;
    }

    .tree-inline-actions-compact .tree-action-add {
        font-size: 17px;
    }

    .tree-inline-actions-compact .tree-action-delete {
        font-size: 12px;
    }

@media (max-width: 700px) {
    .tree-inline-actions-compact {
        grid-template-columns: 22px 22px 27px;
        grid-template-rows: 21px 21px;
        gap: 2px;
    }

        .tree-inline-actions-compact .tree-action-btn {
            width: 22px;
            min-width: 22px;
            height: 21px;
            font-size: 12px;
        }

        .tree-inline-actions-compact .tree-action-edit-tall {
            width: 27px;
            min-width: 27px;
            height: 44px;
        }
}

/* =========================================================
   Dayraban - selected person inline card + 2-2-1 controls
   2026-09-16
   ========================================================= */

/* Keep every selected row on one horizontal line.
   The tree itself can scroll horizontally on narrow screens. */
.mobile-family-tree {
    overflow-x: auto !important;
}

.mobile-tree-row {
    display: flex !important;
    align-items: center !important;
    flex-wrap: nowrap !important;
    gap: 7px !important;
    overflow: visible !important;
    width: max-content;
    min-width: 100%;
}

/* Name + compact information card:
   in RTL the card is rendered to the visual left of the name. */
.tree-person-card-wrap {
    display: inline-flex !important;
    align-items: center !important;
    flex-direction: row !important;
    direction: rtl !important;
    gap: 14px !important;
    flex: 0 0 auto !important;
}

.tree-selected-person-card {
    display: inline-flex !important;
    align-items: center !important;
    gap: 10px !important;
    width: 275px !important;
    min-width: 275px !important;
    padding: 9px 11px !important;
    margin: 0 !important;
    background: #ffffff !important;
    border: 1px solid #cfe0d8 !important;
    border-radius: 14px !important;
    box-shadow: 0 7px 20px rgba(21, 70, 55, .14) !important;
    direction: rtl !important;
    box-sizing: border-box !important;
    animation: treeSelectedInfoIn .15s ease-out;
}

.tree-selected-person-photo {
    width: 74px !important;
    height: 74px !important;
    min-width: 74px !important;
    flex: 0 0 74px !important;
    border-radius: 12px !important;
    object-fit: cover !important;
    border: 2px solid #e1ece6 !important;
    background: #f3f5f4 !important;
}

.tree-selected-person-content {
    min-width: 0 !important;
    flex: 1 1 auto !important;
    display: flex !important;
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 3px !important;
    text-align: right !important;
}

.tree-selected-person-name {
    color: #145c43 !important;
    font-size: 14px !important;
    font-weight: 800 !important;
    line-height: 1.25 !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    white-space: nowrap !important;
}

.tree-selected-person-deceased {
    color: #7a6464 !important;
    font-size: 10.5px !important;
    font-weight: 700 !important;
}

.tree-selected-person-line {
    display: flex !important;
    align-items: baseline !important;
    gap: 4px !important;
    min-width: 0 !important;
    color: #4f5d58 !important;
    font-size: 11px !important;
    line-height: 1.2 !important;
    white-space: nowrap !important;
}

    .tree-selected-person-line strong {
        color: #236b45 !important;
        font-weight: 800 !important;
        flex: 0 0 auto !important;
    }

    .tree-selected-person-line span {
        overflow: hidden !important;
        text-overflow: ellipsis !important;
        white-space: nowrap !important;
    }

.tree-selected-person-details {
    align-self: flex-start !important;
    margin-top: 3px !important;
    border: 0 !important;
    border-radius: 8px !important;
    padding: 4px 9px !important;
    background: #eaf4ef !important;
    color: #145c43 !important;
    font-size: 10.5px !important;
    font-weight: 800 !important;
    cursor: pointer !important;
}

/* Password stays separate from the information card.
   It only appears from degree 3 downward while the branch is locked. */
.tree-password-only-box {
    display: inline-flex !important;
    align-items: center !important;
    gap: 5px !important;
    flex: 0 0 auto !important;
    padding: 5px 6px !important;
    border: 1px solid #d6e2dc !important;
    border-radius: 10px !important;
    background: #fbfdfc !important;
    direction: rtl !important;
}

    .tree-password-only-box .tree-mini-password {
        width: 118px !important;
        min-width: 118px !important;
        height: 28px !important;
        box-sizing: border-box !important;
    }

    .tree-password-only-box .tree-mini-unlock-button {
        height: 28px !important;
        padding-inline: 9px !important;
    }

    .tree-password-only-box .tree-mini-message {
        max-width: 150px !important;
        white-space: nowrap !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
    }

/* 2 - 2 - 1 management controls.
   Visual order from the person's name toward the left:
   arrows | delete/add | edit. */
.tree-inline-actions-compact {
    display: inline-grid !important;
    grid-template-columns: 24px 24px 30px !important;
    grid-template-rows: 23px 23px !important;
    gap: 3px !important;
    direction: rtl !important;
    align-items: stretch !important;
    flex: 0 0 auto !important;
    margin: 0 3px !important;
}

    .tree-inline-actions-compact .tree-action-stack {
        display: contents !important;
    }

    .tree-inline-actions-compact .tree-action-up {
        grid-column: 1 !important;
        grid-row: 1 !important;
    }

    .tree-inline-actions-compact .tree-action-down {
        grid-column: 1 !important;
        grid-row: 2 !important;
    }

    .tree-inline-actions-compact .tree-action-delete {
        grid-column: 2 !important;
        grid-row: 1 !important;
    }

    .tree-inline-actions-compact .tree-action-add {
        grid-column: 2 !important;
        grid-row: 2 !important;
    }

    .tree-inline-actions-compact .tree-action-edit-tall {
        grid-column: 3 !important;
        grid-row: 1 / span 2 !important;
        width: 30px !important;
        min-width: 30px !important;
        height: 49px !important;
    }

    .tree-inline-actions-compact .tree-action-btn {
        width: 24px !important;
        min-width: 24px !important;
        height: 23px !important;
        padding: 0 !important;
        border-radius: 6px !important;
        display: inline-flex !important;
        align-items: center !important;
        justify-content: center !important;
        line-height: 1 !important;
    }

    .tree-inline-actions-compact .tree-action-add {
        font-size: 17px !important;
    }

    .tree-inline-actions-compact .tree-action-delete {
        font-size: 12px !important;
    }

/* Do NOT push the card below the name on phones.
   Horizontal scrolling is preferable for the tree view. */
@media (max-width: 900px) {
    .mobile-tree-row {
        flex-wrap: nowrap !important;
    }

    .tree-person-card-wrap {
        gap: 10px !important;
    }

    .tree-selected-person-card {
        width: 245px !important;
        min-width: 245px !important;
        padding: 8px 9px !important;
    }

    .tree-selected-person-photo {
        width: 64px !important;
        height: 64px !important;
        min-width: 64px !important;
        flex-basis: 64px !important;
    }
}

/* =========================================================
   V3: بطاقة الشخص فوق أدوات الإدارة + نافذة تفاصيل جانبية
   ========================================================= */
.mobile-tree-row {
    display: flex !important;
    align-items: flex-start !important;
    flex-wrap: nowrap !important;
    gap: 10px !important;
    overflow: visible !important;
}

.tree-selected-inline-panel {
    display: inline-flex !important;
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 8px !important;
    width: 295px !important;
    min-width: 295px !important;
    flex: 0 0 295px !important;
    animation: treeSelectedInfoIn .15s ease-out;
}

.tree-selected-inline-bottom {
    display: flex !important;
    align-items: flex-start !important;
    gap: 8px !important;
    flex-wrap: wrap !important;
}

.tree-selected-person-card {
    width: 100% !important;
    min-width: 0 !important;
    box-sizing: border-box !important;
}

.tree-password-only-box {
    display: inline-flex !important;
    align-items: center !important;
    gap: 5px !important;
    padding: 7px 8px !important;
    background: #ffffff !important;
    border: 1px solid #d8e4de !important;
    border-radius: 12px !important;
    box-shadow: 0 4px 12px rgba(21,70,55,.08) !important;
}

.tree-selected-inline-message {
    padding: 8px 10px !important;
    border-radius: 10px !important;
    font-size: 12px !important;
    line-height: 1.35 !important;
    width: 100% !important;
    box-sizing: border-box !important;
}

    .tree-selected-inline-message.success {
        background: #edf8f1 !important;
        color: #156046 !important;
    }

    .tree-selected-inline-message.error {
        background: #fff1f1 !important;
        color: #b03d3d !important;
    }

.person-details-fullscreen-overlay {
    align-items: stretch !important;
    justify-content: flex-start !important;
    padding: 0 !important;
    background: transparent !important;
}

.person-details-fullscreen-card {
    width: min(440px, 92vw) !important;
    max-width: min(440px, 92vw) !important;
    height: 100vh !important;
    max-height: 100vh !important;
    border-radius: 0 18px 18px 0 !important;
    overflow-y: auto !important;
    padding: 22px 18px 34px !important;
    margin: 0 !important;
    box-shadow: 0 0 28px rgba(0,0,0,.18) !important;
}

@media (max-width: 980px) {
    .mobile-tree-row {
        flex-wrap: wrap !important;
    }

    .tree-selected-inline-panel {
        width: min(310px, calc(100vw - 90px)) !important;
        min-width: 0 !important;
        flex-basis: auto !important;
        margin-right: 34px !important;
    }
}

@media (max-width: 700px) {
    .person-details-fullscreen-card {
        width: 100vw !important;
        max-width: 100vw !important;
        border-radius: 0 !important;
    }
}
