﻿/* =============================================
   family-tree.css
   ============================================= */

/* ===== عام ===== */
.family-page {
    padding: 20px;
    font-family: Tahoma, Arial, sans-serif;
    direction: rtl;
    background: #f5f2eb;
    min-height: 100vh;
}

/* ===== هيدر الصفحة ===== */
.family-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    gap: 10px;
    flex-wrap: wrap;
}

    .family-header h2 {
        margin: 0;
        font-size: 20px;
        font-weight: 600;
        color: #1a2e1e;
    }

/* ===== بحث ===== */
.ft-search-wrap {
    position: relative;
    flex: 1;
    max-width: 280px;
}

.ft-search {
    width: 100%;
    padding: 7px 32px 7px 10px;
    border: 0.5px solid #ccc;
    border-radius: 8px;
    font-family: Tahoma, Arial, sans-serif;
    font-size: 13px;
    background: #fff;
    direction: rtl;
    outline: none;
}

    .ft-search:focus {
        border-color: #1D9E75;
        box-shadow: 0 0 0 2px rgba(29,158,117,.13);
    }

.ft-search-icon {
    position: absolute;
    left: 9px;
    top: 50%;
    transform: translateY(-50%);
    color: #9ca3af;
    font-size: 15px;
    pointer-events: none;
}

.ft-search-results {
    position: absolute;
    top: calc(100% + 4px);
    right: 0;
    left: 0;
    background: #fff;
    border: 0.5px solid #d1d5db;
    border-radius: 8px;
    z-index: 200;
    max-height: 240px;
    overflow-y: auto;
    box-shadow: 0 4px 16px rgba(0,0,0,.1);
    display: none;
}

.ft-search-item {
    padding: 9px 12px;
    font-size: 12px;
    cursor: pointer;
    border-bottom: 0.5px solid #f3f4f6;
    color: #111827;
    line-height: 1.5;
}

    .ft-search-item:hover {
        background: #f0fdf8;
    }

    .ft-search-item:last-child {
        border-bottom: none;
    }

    .ft-search-item .hi {
        font-weight: 700;
        color: #0F6E56;
    }

/* ===== زر إضافة ===== */
.btn-save {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    background: #0f6e56;
    color: #e1f5ee;
    border: none;
    border-radius: 8px;
    font-size: 13px;
    font-family: Tahoma, Arial, sans-serif;
    cursor: pointer;
    text-decoration: none;
}

/* ===== لفافة الشجرة ===== */
.tree-scroll {
    overflow: auto;
    padding: 30px 20px;
    background: #edeadf;
    border-radius: 14px;
    min-height: 500px;
}

.tree-canvas {
    position: relative;
    direction: ltr; /* الـ left يحسب من اليسار كما في الـ JS */
    transition: width 320ms ease, height 320ms ease;
}

    .tree-canvas svg {
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        pointer-events: none;
        overflow: visible;
    }

/* ===== بطاقة الشخص ===== */
.ft-card {
    position: absolute;
    width: 100px;
    background: #fff;
    border-radius: 12px;
    border: 0.5px solid #d3d1c7;
    cursor: pointer;
    overflow: visible; /* مهم — يخلي زر الكولابس يظهر خارج البطاقة */
    will-change: left, top, opacity, transform;
}

    /* نغطي فقط منطقة الصورة والنص */
    .ft-card > .card-img,
    .ft-card > .card-name,
    .ft-card > .card-dead {
        overflow: hidden;
    }

    .ft-card > .card-img {
        border-radius: 11px 11px 0 0;
    }

    .ft-card.highlighted {
        border: 2.5px solid #E24B4A;
        box-shadow: 0 0 0 3px rgba(226,75,74,.2);
    }

.card-img {
    width: 100%;
    height: 133px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    position: relative;
    flex-shrink: 0;
}

    .card-img img {
        width: 100%;
        height: 100%;
        object-fit: cover;
        object-position: center top;
    }

    .card-img.has-photo {
        height: 133px;
    }

    .card-img.ph-m {
        background: #9FE1CB;
    }

        .card-img.ph-m i {
            font-size: 32px;
            color: #0F6E56;
        }

    .card-img.ph-f {
        background: #F4C0D1;
    }

        .card-img.ph-f i {
            font-size: 32px;
            color: #993556;
        }

.dead-ov {
    position: absolute;
    inset: 0;
    background: repeating-linear-gradient( -45deg, transparent, transparent 8px, rgba(150,0,0,.07) 8px, rgba(150,0,0,.07) 10px );
    pointer-events: none;
}

.card-name {
    font-size: 11px;
    font-weight: 600;
    color: #111827;
    text-align: center;
    padding: 6px 4px 7px;
    line-height: 1.3;
    cursor: pointer;
}

    .card-name:hover {
        color: #0F6E56;
    }

.card-dead {
    font-size: 9px;
    color: #A32D2D;
    text-align: center;
    padding-bottom: 5px;
    margin-top: -4px;
}

/* ===== زر كولابس ===== */
.col-btn {
    position: absolute;
    top: -13px;
    right: -13px;
    z-index: 20;
    width: 28px;
    height: 28px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.13s ease;
    box-shadow: 0 2px 6px rgba(0,0,0,0.22);
}

    /* مفتوح — أخضر مملوء، أيقونة ضغط */
    .col-btn.col-open {
        background: #0F6E56;
        border: none;
        color: #fff;
    }

    /* مغلق — برتقالي/أصفر، أيقونة توسيع */
    .col-btn.col-closed {
        background: #854F0B;
        border: none;
        color: #fff;
    }

    .col-btn:active {
        transform: scale(0.80) !important;
    }

/* ===== شاشة فارغة ===== */
.empty-tree {
    background: #fff;
    padding: 30px;
    border-radius: 16px;
    text-align: center;
    color: #6b7280;
}

/* =============================================
   المودالات
   ============================================= */
.family-modal {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0);
    z-index: 9999;
    align-items: center;
    justify-content: center;
    padding: 16px;
    transition: background 0.22s ease;
}

    .family-modal.show {
        display: flex;
        background: rgba(15, 23, 42, 0.42);
        animation: backdropIn 0.22s ease both;
    }

@keyframes backdropIn {
    from {
        background: rgba(15,23,42,0);
    }

    to {
        background: rgba(15,23,42,0.42);
    }
}

.family-modal-inner {
    background: #fff;
    border-radius: 16px;
    width: 340px;
    max-width: 100%;
    direction: rtl;
    max-height: 92vh;
    overflow-y: auto;
    animation: modalSlideIn 0.25s cubic-bezier(0.34,1.2,0.64,1) both;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(20px) scale(0.97);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* هيدر المودال */
.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-bottom: 0.5px solid #e5e7eb;
    position: sticky;
    top: 0;
    background: #fff;
    z-index: 2;
    flex-shrink: 0;
}

.modal-header-title {
    display: flex;
    align-items: center;
    gap: 7px;
    font-size: 15px;
    font-weight: 600;
    color: #111827;
}

    .modal-header-title i {
        color: #0F6E56;
        font-size: 17px;
    }

.modal-close-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: #9ca3af;
    font-size: 20px;
    padding: 2px;
    font-family: inherit;
}

/* صورة البروفايل */
.modal-photo {
    width: 100%;
    background: #e8e4d8;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    flex-shrink: 0;
    min-height: 120px;
}

    .modal-photo img {
        width: 100%;
        height: auto;
        display: block;
        object-fit: contain;
    }

    .modal-photo i {
        font-size: 56px;
        color: #b4b2a9;
        padding: 40px 0;
    }

/* معلومات البروفايل */
.modal-info {
    padding: 14px 16px;
    border-bottom: 0.5px solid #e5e7eb;
}

.modal-fullname {
    font-size: 13px;
    font-weight: 600;
    color: #111827;
    line-height: 1.9;
    margin-bottom: 8px;
}

    .modal-fullname .first-name {
        color: #0F6E56;
        font-size: 15px;
    }

.profile-meta {
    font-size: 12px;
    color: #6b7280;
    display: flex;
    align-items: flex-start;
    gap: 6px;
    margin-bottom: 5px;
}

    .profile-meta i {
        font-size: 14px;
        margin-top: 2px;
        flex-shrink: 0;
        color: #9ca3af;
    }

/* أزرار الأكشن */
.modal-actions {
    padding: 12px 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.profile-action-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 11px;
    border-radius: 10px;
    border: none;
    font-family: Tahoma, Arial, sans-serif;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    width: 100%;
    background: #1D9E75;
    color: #fff;
}

    .profile-action-btn.blue {
        background: #185FA5;
        color: #E6F1FB;
    }

    .profile-action-btn.gray {
        background: #e8e4d8;
        color: #374151;
        border: 0.5px solid #c9c5b8;
    }

    .profile-action-btn.red {
        background: #FCEBEB;
        color: #A32D2D;
        border: 0.5px solid #F09595;
    }

    .profile-action-btn.orange {
        background: #FAEEDA;
        color: #854F0B;
        border: 0.5px solid #FAC775;
    }

    .profile-action-btn.purple {
        background: #F1E9FB;
        color: #5B2D9E;
        border: 0.5px solid #C9AEEC;
    }

    .profile-action-btn.teal {
        background: #DEF4F1;
        color: #0B6B5B;
        border: 0.5px solid #7BD0C4;
    }

/* ===== صف التاريخ + تبديل التقويم ===== */
.date-row {
    display: flex;
    gap: 8px;
    align-items: center;
}

    .date-row input {
        flex: 1;
        min-width: 0;
    }

.cal-toggle {
    flex-shrink: 0;
    white-space: nowrap;
    padding: 9px 12px;
    border-radius: 9px;
    border: 0.5px solid #c9c5b8;
    background: #e8e4d8;
    color: #374151;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
}

    .cal-toggle.hijri-on {
        background: #1D9E75;
        border-color: #1D9E75;
        color: #fff;
    }

/* منتقي التاريخ الهجري (يوم/شهر/سنة) */
.hijri-picker {
    flex: 1;
    min-width: 0;
    display: flex;
    gap: 6px;
    align-items: center;
}

.hijri-sel {
    flex: 1;
    min-width: 0;
    padding: 9px 6px;
    border-radius: 9px;
    border: 1px solid #d8d4c6;
    background: #fff;
    font-size: 13px;
    color: #2c2a24;
}

    .hijri-sel:focus {
        border-color: #1D9E75;
        box-shadow: 0 0 0 3px rgba(29,158,117,.12);
        outline: none;
    }

.hijri-tag {
    flex-shrink: 0;
    font-size: 12px;
    font-weight: 700;
    color: #1D9E75;
}

/* ===== شارة رقم الأم على بطاقة الابن (زاوية البطاقة — بارزة) ===== */
.ft-card .wife-num {
    position: absolute;
    top: 6px;
    left: 6px;
    min-width: 26px;
    height: 26px;
    padding: 0 5px;
    border-radius: 13px;
    background: #0F6E56;
    color: #fff;
    font-size: 15px;
    font-weight: 800;
    line-height: 26px;
    text-align: center;
    box-shadow: 0 0 0 2.5px #fff, 0 2px 5px rgba(0,0,0,.28);
    z-index: 5;
    pointer-events: none;
}

/* ===== زوجات الشخص في البروفايل ===== */
#modalWives {
    margin-top: 12px;
    width: 100%;
}

.modal-wives-title {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    font-weight: 700;
    color: #0F6E56;
    margin-bottom: 6px;
}

.modal-wives-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.mw-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    color: #2c2a24;
}

.mw-num {
    flex-shrink: 0;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: #0F6E56;
    color: #fff;
    font-size: 12px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
}

.mw-link {
    color: #185FA5;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

    .mw-link:hover { text-decoration: underline; }

.mw-link i { font-size: 13px; }

.mw-div {
    font-size: 11px;
    padding: 1px 7px;
    border-radius: 8px;
    background: #FAE3E3;
    color: #9A2D2D;
    font-weight: 600;
}

/* ===== قائمة الزوجات ===== */
.wives-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 4px;
}

.wives-empty {
    color: #8a8675;
    font-size: 13px;
    text-align: center;
    padding: 10px 0;
}

.wife-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-radius: 10px;
    border: 1px solid #e3dfd2;
    background: #faf8f2;
}

.wife-num-chip {
    flex-shrink: 0;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: #0F6E56;
    color: #fff;
    font-size: 13px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
}

    .wife-num-chip.sm {
        width: 20px;
        height: 20px;
        font-size: 11px;
    }

.wife-main {
    flex: 1;
    min-width: 0;
}

.wife-label {
    font-size: 14px;
    color: #2c2a24;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.wife-tags {
    display: flex;
    gap: 5px;
    margin-top: 3px;
    flex-wrap: wrap;
}

.wife-tag {
    font-size: 11px;
    padding: 1px 7px;
    border-radius: 8px;
    font-weight: 600;
}

    .wife-tag.fam { background: #E3F1EC; color: #0B6B5B; }
    .wife-tag.ext { background: #eee9dd; color: #6b6450; }
    .wife-tag.cur { background: #DEF0DC; color: #2C6B2C; }
    .wife-tag.div { background: #FAE3E3; color: #9A2D2D; }

.spouse-kids {
    font-size: 12px;
    color: #6b6450;
    margin-top: 3px;
}

.wife-actions {
    display: flex;
    gap: 4px;
    flex-shrink: 0;
}

.wife-mini {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    border: 0.5px solid #c9c5b8;
    background: #fff;
    color: #374151;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

    .wife-mini.del { color: #A32D2D; border-color: #e7b9b9; background: #fbeaea; }

/* ===== صندوق إضافة زوجة ===== */
.add-wife-box {
    border-top: 1px dashed #d8d4c6;
    padding-top: 12px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.add-wife-title {
    font-size: 13px;
    font-weight: 700;
    color: #374151;
}

.wife-src-row {
    display: flex;
    gap: 8px;
}

.wife-src-opt {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 10px;
    border-radius: 9px;
    border: 1px solid #d8d4c6;
    font-size: 13px;
    cursor: pointer;
}

.wife-search-results {
    position: absolute;
    top: 100%;
    right: 0;
    left: 0;
    z-index: 20;
    max-height: 220px;
    overflow-y: auto;
}

.wife-selected {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    border-radius: 9px;
    background: #E3F1EC;
    color: #0B6B5B;
    font-size: 13px;
    font-weight: 600;
}

    .wife-selected .wife-clear-sel {
        margin-right: auto;
        border: none;
        background: transparent;
        color: #0B6B5B;
        cursor: pointer;
    }

/* ===== تحديد أبناء الزوجة ===== */
.assign-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.assign-row {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 9px 10px;
    border-radius: 9px;
    border: 1px solid #e3dfd2;
    background: #faf8f2;
    cursor: pointer;
}

    .assign-row input { width: 17px; height: 17px; }

.assign-name {
    flex: 1;
    font-size: 14px;
    color: #2c2a24;
}

.assign-other {
    font-size: 11px;
    padding: 1px 7px;
    border-radius: 8px;
    background: #eee9dd;
    color: #6b6450;
    font-weight: 600;
}

/* ===== ترتيب الأبناء ===== */
.reorder-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.reorder-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    border-radius: 9px;
    border: 1px solid #e3dfd2;
    background: #faf8f2;
}

.reorder-dot {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    flex-shrink: 0;
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
}

.reorder-name {
    flex: 1;
    font-size: 14px;
    color: #2c2a24;
}

.reorder-handles {
    display: flex;
    gap: 4px;
}

    .reorder-handles button {
        width: 30px;
        height: 30px;
        border-radius: 8px;
        border: 0.5px solid #c9c5b8;
        background: #fff;
        color: #374151;
        cursor: pointer;
        display: flex;
        align-items: center;
        justify-content: center;
    }

/* ===== شاشة التعديل ===== */
.edit-body {
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    overflow-y: auto;
    flex: 1;
}

.field-group {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

    .field-group label {
        font-size: 12px;
        color: #6b7280;
        font-weight: 500;
    }

    .field-group input,
    .field-group select,
    .field-group textarea {
        width: 100%;
        padding: 9px 11px;
        border: 0.5px solid #d1d5db;
        border-radius: 9px;
        font-family: Tahoma, Arial, sans-serif;
        font-size: 13px;
        color: #111827;
        background: #fafafa;
        outline: none;
        direction: rtl;
    }

        .field-group input:focus,
        .field-group select:focus,
        .field-group textarea:focus {
            border-color: #1D9E75;
            box-shadow: 0 0 0 3px rgba(29,158,117,.12);
            background: #fff;
        }

    .field-group textarea {
        resize: vertical;
        min-height: 70px;
    }

/* سويتش */
.switch-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 4px 0;
}

    .switch-row > span {
        font-size: 13px;
        color: #374151;
    }

.toggle-switch {
    position: relative;
    width: 42px;
    height: 24px;
}

    .toggle-switch input {
        opacity: 0;
        width: 0;
        height: 0;
    }

.toggle-slider {
    position: absolute;
    inset: 0;
    background: #d1d5db;
    border-radius: 24px;
    cursor: pointer;
    transition: background 0.2s;
}

    .toggle-slider::before {
        content: '';
        position: absolute;
        width: 18px;
        height: 18px;
        border-radius: 50%;
        background: #fff;
        top: 3px;
        right: 3px;
        transition: transform 0.2s;
    }

.toggle-switch input:checked + .toggle-slider {
    background: #1D9E75;
}

    .toggle-switch input:checked + .toggle-slider::before {
        transform: translateX(-18px);
    }

/* فوتر التعديل */
.edit-footer {
    padding: 12px 16px;
    border-top: 0.5px solid #e5e7eb;
    display: flex;
    gap: 8px;
    position: sticky;
    bottom: 0;
    background: #fff;
    flex-shrink: 0;
}

.edit-save-btn {
    flex: 1;
    padding: 11px;
    border: none;
    border-radius: 10px;
    background: #1D9E75;
    color: #fff;
    font-family: Tahoma, Arial, sans-serif;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.edit-cancel-btn {
    padding: 11px 16px;
    border: 0.5px solid #d1d5db;
    border-radius: 10px;
    background: #f3f4f6;
    color: #374151;
    font-family: Tahoma, Arial, sans-serif;
    font-size: 13px;
    cursor: pointer;
}

/* hint box */
.hint-box {
    background: #f5f3df;
    border-radius: 10px;
    padding: 10px 14px;
    font-size: 11px;
    color: #444;
    line-height: 1.9;
    margin-bottom: 4px;
}

    .hint-box ul {
        margin: 0;
        padding-right: 14px;
    }

/* confirm box */
.confirm-box {
    padding: 20px 16px;
    text-align: center;
}

    .confirm-box p {
        font-size: 14px;
        color: #374151;
        line-height: 1.7;
        margin-bottom: 16px;
    }

/* Crop Overlay */
.crop-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(10,15,30,.85);
    z-index: 10000;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 14px;
    padding: 16px;
}

    .crop-overlay.show {
        display: flex;
    }

.crop-title {
    color: #fff;
    font-size: 15px;
    font-weight: 500;
    font-family: Tahoma, Arial, sans-serif;
}

.crop-hint {
    color: #9ca3af;
    font-size: 12px;
    font-family: Tahoma, Arial, sans-serif;
}

.crop-container {
    position: relative;
    background: #111;
    border-radius: 10px;
    overflow: hidden;
    max-width: min(480px,90vw);
    max-height: 52vh;
    cursor: crosshair;
    user-select: none;
    touch-action: none;
}

    .crop-container img {
        display: block;
        max-width: 100%;
        max-height: 52vh;
        object-fit: contain;
    }

.crop-frame {
    position: absolute;
    border: 2px solid #fff;
    box-shadow: 0 0 0 9999px rgba(0,0,0,0.5);
    border-radius: 4px;
    cursor: move;
}

.crop-handle {
    position: absolute;
    width: 12px;
    height: 12px;
    background: #fff;
    border-radius: 2px;
}

    .crop-handle.tl {
        top: -6px;
        left: -6px;
        cursor: nwse-resize;
    }

    .crop-handle.tr {
        top: -6px;
        right: -6px;
        cursor: nesw-resize;
    }

    .crop-handle.bl {
        bottom: -6px;
        left: -6px;
        cursor: nesw-resize;
    }

    .crop-handle.br {
        bottom: -6px;
        right: -6px;
        cursor: nwse-resize;
    }

.crop-actions {
    display: flex;
    gap: 10px;
}

.crop-btn {
    padding: 9px 22px;
    border-radius: 9px;
    border: none;
    font-family: Tahoma, Arial, sans-serif;
    font-size: 13px;
    cursor: pointer;
}

    .crop-btn.confirm {
        background: #1D9E75;
        color: #fff;
    }

    .crop-btn.cancel {
        background: #374151;
        color: #fff;
    }

/* ===== أزرار تحكم الشجرة (طي / فتح الكل) ===== */
.tree-controls {
    display: flex;
    gap: 8px;
    align-items: center;
}

.tree-ctrl-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 7px 13px;
    border: none;
    border-radius: 8px;
    font-family: Tahoma, Arial, sans-serif;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.15s;
}

    .tree-ctrl-btn:first-child {
        background: #854F0B;
        color: #fff;
    }

    .tree-ctrl-btn:last-child {
        background: #0F6E56;
        color: #fff;
    }

    .tree-ctrl-btn:hover {
        opacity: 0.88;
    }

    .tree-ctrl-btn i {
        font-size: 14px;
    }

/* ===== Crop Overlay ===== */
.crop-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(8, 12, 24, 0.92);
    z-index: 10000;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 16px;
    animation: fadeIn 0.18s ease both;
}

    .crop-overlay.show {
        display: flex;
    }

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

.crop-title {
    color: #fff;
    font-size: 15px;
    font-weight: 600;
    font-family: Tahoma, Arial, sans-serif;
}

.crop-hint {
    color: #9ca3af;
    font-size: 12px;
    font-family: Tahoma, Arial, sans-serif;
}

.crop-container {
    position: relative;
    background: #111;
    border-radius: 10px;
    overflow: hidden;
    max-width: min(420px, 90vw);
    max-height: 55vh;
    cursor: crosshair;
    user-select: none;
    touch-action: none;
}

    .crop-container img {
        display: block;
        max-width: 100%;
        object-fit: contain;
        pointer-events: none;
    }

.crop-frame {
    position: absolute;
    border: 2px solid #fff;
    box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.52);
    border-radius: 2px;
    cursor: move;
    box-sizing: border-box;
}

.crop-handle {
    position: absolute;
    width: 14px;
    height: 14px;
    background: #fff;
    border-radius: 3px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.4);
}

    .crop-handle.tl {
        top: -7px;
        left: -7px;
        cursor: nwse-resize;
    }

    .crop-handle.tr {
        top: -7px;
        right: -7px;
        cursor: nesw-resize;
    }

    .crop-handle.bl {
        bottom: -7px;
        left: -7px;
        cursor: nesw-resize;
    }

    .crop-handle.br {
        bottom: -7px;
        right: -7px;
        cursor: nwse-resize;
    }

.crop-actions {
    display: flex;
    gap: 10px;
    margin-top: 4px;
}

.crop-btn {
    padding: 10px 28px;
    border-radius: 9px;
    border: none;
    font-family: Tahoma, Arial, sans-serif;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.15s;
}

    .crop-btn:hover {
        opacity: 0.88;
    }

    .crop-btn.confirm {
        background: #1D9E75;
        color: #fff;
    }

    .crop-btn.cancel {
        background: #374151;
        color: #fff;
    }
