/* Tree Container */
.tree-container {
    position: relative;
    overflow: visible;
    padding: 20px 0;
}

/* User Nodes */
.user-node {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding-bottom: 30px;
}

.user {
    height: 100px;
    width: 100px;
    margin-left: auto;
    margin-right: auto;
    line-height: 120px;
    position: relative;
    border-radius: 50%;
    background-color: #ffffff;
    border: none;
    -webkit-appearance: initial!important;
    transition: all 0.3s ease;
    cursor: pointer;
}

.user img {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    object-fit: cover;
    position: relative;
    z-index: 99;
}

.user .user-name {
    line-height: 1.5;
    font-size: 14px;
    font-weight: 500;
    color: #777777;
    margin-top: 5px;
    text-align: center;
    width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.clickable-user:hover {
    transform: scale(1.05);
    box-shadow: 0 5px 15px rgba(0,0,0,0.1);
}

/* Tree Lines */
.line {
    width: 50%;
    margin-left: auto;
    margin-right: auto;
    height: 80px;
    display: inherit;
    border: 2px dotted #bbb;
    border-bottom: none;
    position: relative;
}

.line::before, .line::after {
    position: absolute;
    content: "\f107";
    font-family: "Line Awesome Free";
    font-weight: 600;
    font-size: 24px;
    color: #bbb;
    bottom: 0;
    width: 30px;
    text-align: center;
    background: #fff;
    z-index: 1;
    line-height: 20px;
    height: 20px;
}

.line::before {
    left: -15px;
}

.line::after {
    right: -15px;
}

.w-8 .line::before, .w-8 .line::after {
    display: none;
}

.llll:last-child .line {
    border: none;
}

/* Tree Levels */
.w-1, .w-2, .w-4, .w-8 {
    padding: inherit;
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.w-1 { width: 100%; }
.w-2 { width: 50%; }
.w-4 { width: 25%; }
.w-8 { width: 12.5%; padding-bottom: 50px;}

/* User Status Classes */
.paid-user {
    border: 5px solid #2ecc71;
}

.free-user {
    border: 5px solid #101536;
}

.no-user {
    border: 5px solid #ddd;
}

/* Tree dropdown styles */
.team-dropdown {
    position: absolute;
    top: calc(100% + 10px);
    left: 0;
    width: 100%; /* Prend toute la largeur du parent */
    background: white;
    border: 1px solid #ddd;
    border-radius: 8px;
    box-shadow: 0 5px 25px rgba(0,0,0,0.15);
    z-index: 1000;
    display: none;
    max-height: 500px;
    overflow-y: auto;
}

.dropdown-content {
    width: 100%;
    padding: 0;
}

.dropdown-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-radius: 8px 8px 0 0;
}

.dropdown-user-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.dropdown-user-img {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    object-fit: cover;
    border: 3px solid white;
    box-shadow: 0 3px 10px rgba(0,0,0,0.2);
}

.dropdown-user-details h6 {
    /*color: white;*/
    margin-bottom: 3px;
    font-weight: 600;
}

.dropdown-user-details small {
    color: rgba(255,255,255,0.8);
}

.close-dropdown {
    background: rgba(255,255,255,0.2);
    border: none;
    font-size: 18px;
    cursor: pointer;
    color: white;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.3s ease;
}

.close-dropdown:hover {
    background: rgba(255,255,255,0.3);
    transform: rotate(90deg);
}

.dropdown-body {
    padding: 20px;
    background: #f8f9fa;
}

/* Team tree styles */
.team-tree-container {
    background: white;
    border-radius: 8px;
    padding: 20px;
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.05);
}

.tree-level {
    /*margin-bottom: 10px;*/
}

.team-user-node {
    position: relative;
    padding: 15px;
    background: white;
    border-radius: 8px;
    border: 1px solid #e9ecef;
    margin-bottom: 10px;
    transition: all 0.3s ease;
    cursor: pointer;
}

.team-user-node:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
    border-color: #667eea;
}

.team-user-info {
    display: flex;
    align-items: center;
    flex-direction: column;
    text-align: center;
    gap: 12px;
}

.team-user-img {
    width: 45px;
    height: 45px;
    border-radius: 50%;
    object-fit: cover;
    border: 3px solid;
}

.team-user-img.paid-user {
    border-color: #2ecc71;
}

.team-user-img.free-user {
    border-color: #101536;
}

.team-user-details {
    flex: 1;
}

.team-user-name {
    font-weight: 600;
    color: #333;
    margin-bottom: 3px;
    font-size: 14px;
}

.team-user-username {
    color: #666;
    font-size: 12px;
    margin-bottom: 5px;
}

.team-user-status {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 15px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
}

.status-paid {
    background: #d4edda;
    color: #155724;
}

.status-free {
    background: #f8d7da;
    color: #721c24;
}

/* Tree connections */
.tree-connections {
    position: relative;
    padding-left: 25px;
    margin-top: 10px;
}

.tree-connections::before {
    content: '';
    position: absolute;
    left: 20px;
    top: -10px;
    bottom: -10px;
    width: 2px;
    background: #dee2e6;
}

.child-node {
    position: relative;
    padding: 12px;
    margin: 8px 0;
    background: #f8f9fa;
    border-radius: 6px;
    border-left: 3px solid #667eea;
}

.child-node::before {
    content: '';
    position: absolute;
    left: -15px;
    top: 50%;
    width: 15px;
    height: 2px;
    background: #dee2e6;
}

/* Expand/collapse button */
.expand-team-btn {
    background: #667eea;
    color: white;
    border: none;
    padding: 5px 15px;
    border-radius: 20px;
    font-size: 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 5px;
    margin-top: 10px;
    transition: all 0.3s ease;
}

.expand-team-btn:hover {
    background: #5a67d8;
    transform: scale(1.05);
}

/* No team members */
.no-team-members {
    text-align: center;
    padding: 40px 20px;
    color: #6c757d;
}

.no-team-members i {
    font-size: 48px;
    margin-bottom: 15px;
    opacity: 0.5;
}

/* Loading animation */
.loading-spinner {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px;
    color: #6c757d;
}

/* Arrow for dropdown */
.dropdown-arrow {
    position: absolute;
    top: -10px;
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 0;
    border-left: 10px solid transparent;
    border-right: 10px solid transparent;
    border-bottom: 10px solid white;
    filter: drop-shadow(0 -2px 1px rgba(0,0,0,0.1));
}

/* Responsive adjustments */
@media (max-width: 767px) {
    .team-dropdown {
        position: fixed;
        top: 50% !important;
        left: 50% !important;
        transform: translate(-50%, -50%) !important;
        width: 95% !important;
        max-width: 400px;
        max-height: 80vh;
        z-index: 1050;
    }
    
    .dropdown-arrow {
        display: none;
    }
    
    .team-tree-container {
        padding: 15px;
    }
    
    .team-user-node {
        padding: 12px;
    }
}

.dropdown-arrow {
    position: absolute;
    top: -10px;
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 0;
    border-left: 10px solid transparent;
    border-right: 10px solid transparent;
    border-bottom: 10px solid white;
    filter: drop-shadow(0 -2px 1px rgba(0,0,0,0.1));
}

.dropdown-content {
    padding: 0;
    border-radius: 8px;
    overflow: hidden;
}

.dropdown-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px;
    background: #f8f9fa;
    border-bottom: 1px solid #eee;
}

.dropdown-user-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.dropdown-user-img {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    object-fit: cover;
    border: 3px solid #2ecc71;
}

.dropdown-body {
    max-height: 300px;
    overflow-y: auto;
    padding: 15px;
}

.loading-spinner {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 30px;
    color: #666;
}

/* Indicateur pour les utilisateurs avec dropdown */
.has-dropdown::after {
    content: "▼";
    position: absolute;
    bottom: -20px;
    left: 50%;
    transform: translateX(-50%);
    color: #2ecc71;
    font-size: 12px;
    opacity: 0.7;
}

/* Overlay pour mobile */
.overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 1040;
    display: none;
}

.overlay.show {
    display: block;
}

/* Responsive Design */
@media (max-width: 767px) {
    .user {
        line-height: 0;
        position: relative;
        z-index: 2;
    }

    .w-4 .line::before, .w-4 .line::after {
        display: none;
    }

    .user img {
        border-width: 3px;
    }
    
    .line {
        transform: translateY(-10px);
    }
    
    .w-1 .user {
        width: 80px;
        height: 80px;
    }
    
    .w-1 .user img {
        width: 80px;
        height: 80px;
    }
    
    .user::before {
        display: none;
    }
    
    .w-1 .line {
        height: 50px;
    }
    
    .w-2 .user {
        width: 70px;
        height: 70px;
    }
    
    .w-2 .user img {
        width: 70px;
        height: 70px;
    }
    
    .w-2 .line {
        height: 50px;
    }
    
    .w-4 .user {
        width: 60px;
        height: 60px;
    }
    
    .w-4 .user img {
        width: 60px;
        height: 60px;
    }
    
    .w-4 .line {
        height: 40px;
        margin-top: 17px;
        width: 60%;
        transform: translate(-8px,-20px);
        z-index: 0;
    }
    
    .w-8 {
        transform: translateY(-30px);
    }
    
    .w-8 .user {
        width: 50px;
        height: 50px;
    }
    
    .w-8 .user img {
        width: 50px;
        height: 50px;
    }
    
    .w-8 .line {
        height: 0;
    }
    
    .user .user-name {
        display: none;
    }
    
    /* Dropdown mobile */
    .team-dropdown {
        position: fixed;
        top: 50% !important;
        left: 50% !important;
        transform: translate(-50%, -50%) !important;
        width: 90%;
        max-width: 300px;
        z-index: 1050;
    }
    
    .dropdown-arrow {
        display: none;
    }
}

@media (max-width: 575px) {
    .user {
        line-height: 0;
        position: relative;
        z-index: 2;
    }
    
    .line {
        transform: translateY(-10px);
    }
    
    .w-1 .user {
        width: 70px;
        height: 70px;
    }
    
    .w-1 .user img {
        width: 70px;
        height: 70px;
    }
    
    .w-1 .line {
        height: 50px;
    }
    
    .w-2 .user {
        width: 60px;
        height: 60px;
    }
    
    .w-2 .user img {
        width: 60px;
        height: 60px;
    }
    
    .w-2 .line {
        height: 50px;
    }
    
    .w-4 .user {
        width: 55px;
        height: 55px;
    }
    
    .w-4 .user img {
        width: 55px;
        height: 55px;
    }
    
    .w-4 .line {
        height: 40px;
        margin-top: 18px;
        width: 70%;
        transform: translate(-1px,-20px);
        z-index: 0;
    }
    
    .w-8 {
        transform: translateY(-30px);
    }
    
    .w-8 .user {
        width: 45px;
        height: 45px;
    }
    
    .w-8 .user img {
        width: 45px;
        height: 45px;
    }
    
    .w-8 .line {
        height: 0;
    }
    
    .user img {
        border-width: 2px;
    }
}

@media (max-width: 400px) {
    .user {
        line-height: 0;
        position: relative;
        z-index: 2;
    }
    
    .line {
        transform: translateY(-10px);
    }
    
    .w-1 .user {
        width: 70px;
        height: 70px;
    }
    
    .w-1 .user img {
        width: 70px;
        height: 70px;
    }
    
    .w-1 .line {
        height: 50px;
    }
    
    .w-2 .user {
        width: 60px;
        height: 60px;
    }
    
    .w-2 .user img {
        width: 60px;
        height: 60px;
    }
    
    .w-2 .line {
        height: 50px;
    }
    
    .w-4 .user {
        width: 50px;
        height: 50px;
    }
    
    .w-4 .user img {
        width: 50px;
        height: 50px;
    }
    
    .w-4 .line {
        height: 50px;
        margin-top: 17px;
        width: 49%;
        transform: translate(-2px,-19px);
        z-index: 0;
    }
    
    .w-8 {
        transform: translateY(-30px);
    }
    
    .w-8 .user {
        width: 35px;
        height: 35px;
    }
    
    .w-8 .user img {
        width: 35px;
        height: 35px;
    }
    
    .w-8 .line {
        height: 0;
    }
    
    .card {
        padding: 30px;
        margin: 0 -30px;
    }
}

/* Pseudo-element pour le fond des cercles */
.user::before {
    position: absolute;
    content: '';
    top: 7px;
    left: -4px;
    width: 110px;
    height: 110px;
    border-radius: 50%;
    background-color: #ffffff;
    z-index: 2;
}

/* Dark mode overrides */
.theme-dark .user {
    background-color: #0e0e0e;
}

.theme-dark .user::before {
    background-color: #0e0e0e;
}

.theme-dark .user .user-name {
    color: #bebebe;
}

.theme-dark .line {
    border-color: #404040;
}

.theme-dark .line::before,
.theme-dark .line::after {
    color: #404040;
    background: #0e0e0e;
}

.theme-dark .team-tree-container {
    background: #121212;
}

.theme-dark .team-user-node {
    background: #121212;
    border-color: #404040;
}

.theme-dark .team-user-name {
    color: #e8e8e8;
}

.theme-dark .team-user-username {
    color: #bebebe;
}

.theme-dark .child-node {
    background: #1a1a1a;
    border-left-color: #667eea;
}

.theme-dark .team-dropdown {
    background: #121212;
    border-color: #404040;
}

.theme-dark .dropdown-header {
    background: #202020;
    border-bottom-color: #404040;
}

.theme-dark .dropdown-body {
    background: #0e0e0e;
}

.theme-dark .dropdown-arrow {
    border-bottom-color: #121212;
}

.theme-dark .tree-connections::before {
    background: #404040;
}

.theme-dark .child-node::before {
    background: #404040;
}
