/**
 * Organizational Chart - Hierarchical Tree Styles
 * KEITATA GLOBAL LOGISTICS
 * Version: 3.0.0 - Structure optimisée et moderne
 */

/* ===== CONTAINER ===== */
.tree-container {
    overflow-x: auto;
    overflow-y: visible;
    padding: 60px 20px;
    background: linear-gradient(135deg, #f8fafc 0%, #e2e8f0 100%);
    border-radius: 16px;
    margin: 0 auto;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.08);
}

/* ===== TREE STRUCTURE ===== */
.tree {
    display: table;
    margin: 0 auto;
    padding: 0;
    list-style: none;
    width: 100%;
}

.tree ul {
    padding-top: 30px;
    position: relative;
    display: table;
    margin: 0 auto;
    list-style: none;
    width: 100%;
}

.tree li {
    display: table-cell;
    text-align: center;
    list-style-type: none;
    position: relative;
    padding: 25px 15px 0 15px;
    vertical-align: top;
}

/* ===== LIGNES DE CONNEXION AMÉLIORÉES ===== */

/* Ligne verticale descendante du parent vers la ligne horizontale */
.tree li::before {
    content: '';
    position: absolute;
    top: 0;
    left: 50%;
    border-left: 3px solid #3b82f6;
    width: 0;
    height: 25px;
    margin-left: -1.5px;
    box-shadow: 0 2px 4px rgba(59, 130, 246, 0.2);
}

/* Ligne horizontale reliant les enfants */
.tree li::after {
    content: '';
    position: absolute;
    top: 0;
    right: 50%;
    border-top: 3px solid #3b82f6;
    width: 50%;
    height: 25px;
    box-shadow: 0 2px 4px rgba(59, 130, 246, 0.2);
}

/* Premier enfant - ligne depuis le centre vers la droite */
.tree li:first-child::after {
    border: none;
    border-right: 3px solid #3b82f6;
    border-top: 3px solid #3b82f6;
    border-radius: 0 8px 0 0;
}

/* Dernier enfant - ligne depuis la gauche vers le centre */
.tree li:last-child::after {
    border: none;
    border-left: 3px solid #3b82f6;
    border-top: 3px solid #3b82f6;
    border-radius: 8px 0 0 0;
}

/* Enfant unique - pas de ligne horizontale */
.tree li:only-child::after {
    display: none;
}

/* Enfant unique - ligne verticale simple centrée */
.tree li:only-child::before {
    left: 50%;
    margin-left: -1.5px;
}

/* Pas de ligne avant pour le premier niveau (racine) */
.tree > li::before,
.tree > li::after {
    border: 0 !important;
}

/* Ligne verticale depuis le parent vers ses enfants */
.tree li:not(:only-child)::before {
    content: '';
}

/* ===== CARTES DES MEMBRES AMÉLIORÉES ===== */
.tree li .org-card {
    border: 3px solid #e5e7eb;
    padding: 20px;
    text-align: center;
    border-radius: 16px;
    display: inline-block;
    background: #ffffff;
    position: relative;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    min-width: 220px;
    max-width: 280px;
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.08);
    margin-top: 25px;
    overflow: hidden;
}

/* Effet de surbrillance au survol */
.tree li .org-card::after {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.4), transparent);
    transition: left 0.5s ease;
}

.tree li .org-card:hover::after {
    left: 100%;
}

.tree li .org-card:hover {
    transform: translateY(-8px) scale(1.02);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.18);
    border-color: #3b82f6;
    z-index: 10;
}

/* Ligne verticale depuis la carte vers le haut */
.tree li .org-card::before {
    content: '';
    position: absolute;
    top: -25px;
    left: 50%;
    border-left: 3px solid #3b82f6;
    width: 0;
    height: 25px;
    margin-left: -1.5px;
    box-shadow: 0 2px 4px rgba(59, 130, 246, 0.2);
    z-index: -1;
}

/* Pas de ligne pour le niveau racine */
.tree > li > .org-card::before {
    display: none;
}

/* ===== STYLES PAR NIVEAU HIÉRARCHIQUE AMÉLIORÉS ===== */

/* Niveau 0 - CEO / Direction Générale */
.tree > li > .org-card {
    border-color: #f59e0b;
    background: linear-gradient(135deg, #fffbeb 0%, #ffffff 50%, #fef3c7 100%);
    border-width: 4px;
    min-width: 280px;
    padding: 25px;
    box-shadow: 0 10px 25px rgba(245, 158, 11, 0.25);
}

.tree > li > .org-card:hover {
    border-color: #d97706;
    box-shadow: 0 25px 50px rgba(245, 158, 11, 0.35);
    transform: translateY(-10px) scale(1.03);
}

/* Badge spécial pour CEO */
.tree > li > .org-card .badge {
    background: linear-gradient(135deg, #f59e0b, #d97706) !important;
    color: white !important;
    font-weight: 600;
    padding: 8px 16px !important;
    font-size: 12px !important;
}

/* Niveau 1 - Directeurs */
.tree > li > ul > li > .org-card {
    border-color: #3b82f6;
    background: linear-gradient(135deg, #eff6ff 0%, #ffffff 50%, #dbeafe 100%);
    box-shadow: 0 8px 20px rgba(59, 130, 246, 0.2);
}

.tree > li > ul > li > .org-card:hover {
    border-color: #2563eb;
    box-shadow: 0 20px 40px rgba(59, 130, 246, 0.3);
}

.tree > li > ul > li > .org-card .badge {
    background: linear-gradient(135deg, #3b82f6, #2563eb) !important;
    color: white !important;
}

/* Niveau 2 - Managers */
.tree > li > ul > li > ul > li > .org-card {
    border-color: #10b981;
    background: linear-gradient(135deg, #f0fdf4 0%, #ffffff 50%, #dcfce7 100%);
    box-shadow: 0 8px 20px rgba(16, 185, 129, 0.2);
}

.tree > li > ul > li > ul > li > .org-card:hover {
    border-color: #059669;
    box-shadow: 0 20px 40px rgba(16, 185, 129, 0.3);
}

.tree > li > ul > li > ul > li > .org-card .badge {
    background: linear-gradient(135deg, #10b981, #059669) !important;
    color: white !important;
}

/* Niveau 3 - Équipes */
.tree > li > ul > li > ul > li > ul > li > .org-card {
    border-color: #8b5cf6;
    background: linear-gradient(135deg, #f5f3ff 0%, #ffffff 50%, #ede9fe 100%);
    box-shadow: 0 8px 20px rgba(139, 92, 246, 0.2);
}

.tree > li > ul > li > ul > li > ul > li > .org-card:hover {
    border-color: #7c3aed;
    box-shadow: 0 20px 40px rgba(139, 92, 246, 0.3);
}

.tree > li > ul > li > ul > li > ul > li > .org-card .badge {
    background: linear-gradient(135deg, #8b5cf6, #7c3aed) !important;
    color: white !important;
}

/* Niveau 4+ - Autres niveaux */
.tree > li > ul > li > ul > li > ul > li > ul > li > .org-card {
    border-color: #ec4899;
    background: linear-gradient(135deg, #fdf2f8 0%, #ffffff 50%, #fce7f3 100%);
    box-shadow: 0 8px 20px rgba(236, 72, 153, 0.2);
}

.tree > li > ul > li > ul > li > ul > li > ul > li > .org-card:hover {
    border-color: #db2777;
    box-shadow: 0 20px 40px rgba(236, 72, 153, 0.3);
}

.tree > li > ul > li > ul > li > ul > li > ul > li > .org-card .badge {
    background: linear-gradient(135deg, #ec4899, #db2777) !important;
    color: white !important;
}

/* ===== CONTENU DES CARTES AMÉLIORÉ ===== */

/* Avatar avec effet 3D */
.org-card .symbol {
    margin: 0 auto 15px;
    position: relative;
}

.org-card .symbol::before {
    content: '';
    position: absolute;
    top: -5px;
    left: -5px;
    right: -5px;
    bottom: -5px;
    background: linear-gradient(135deg, #3b82f6, #8b5cf6);
    border-radius: 50%;
    opacity: 0;
    transition: opacity 0.3s ease;
    z-index: -1;
}

.org-card:hover .symbol::before {
    opacity: 0.3;
}

.org-card .symbol img {
    border: 4px solid #ffffff;
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.15);
    object-fit: cover;
    transition: transform 0.3s ease;
}

.org-card:hover .symbol img {
    transform: scale(1.1);
}

/* Nom avec effet */
.org-card a {
    text-decoration: none;
    color: #1f2937;
    font-weight: 700;
    font-size: 15px;
    display: block;
    margin-bottom: 10px;
    transition: all 0.3s ease;
    line-height: 1.5;
    position: relative;
}

.org-card a::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 50%;
    width: 0;
    height: 2px;
    background: #3b82f6;
    transition: all 0.3s ease;
    transform: translateX(-50%);
}

.org-card a:hover {
    color: #3b82f6;
}

.org-card a:hover::after {
    width: 80%;
}

/* Badge de poste modernisé */
.org-card .badge {
    font-size: 12px;
    padding: 6px 14px;
    font-weight: 600;
    display: inline-block;
    margin-bottom: 10px;
    border-radius: 20px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
}

.org-card:hover .badge {
    transform: scale(1.05);
}

/* Département */
.org-card .text-gray-600 {
    font-size: 13px;
    color: #6b7280;
    margin-bottom: 10px;
    font-weight: 500;
}

/* Nombre de subordonnés avec icône */
.org-card .text-gray-500 {
    font-size: 12px;
    color: #9ca3af;
    margin-top: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    font-weight: 500;
    padding-top: 10px;
    border-top: 1px solid #e5e7eb;
}

.org-card .text-gray-500 i {
    color: #3b82f6;
}

/* ===== ANIMATIONS AMÉLIORÉES ===== */

/* Animation d'entrée fluide */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(40px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.tree li {
    animation: fadeInUp 0.7s cubic-bezier(0.4, 0, 0.2, 1) backwards;
}

.tree > li {
    animation-delay: 0.1s;
}

.tree > li > ul > li {
    animation-delay: 0.2s;
}

.tree > li > ul > li > ul > li {
    animation-delay: 0.3s;
}

.tree > li > ul > li > ul > li > ul > li {
    animation-delay: 0.4s;
}

.tree > li > ul > li > ul > li > ul > li > ul > li {
    animation-delay: 0.5s;
}

/* Animation de pulsation pour les cartes importantes */
@keyframes pulse {
    0%, 100% {
        box-shadow: 0 10px 25px rgba(245, 158, 11, 0.25);
    }
    50% {
        box-shadow: 0 15px 35px rgba(245, 158, 11, 0.4);
    }
}

.tree > li > .org-card {
    animation: pulse 4s ease-in-out infinite;
}

/* Animation de brillance pour les lignes */
@keyframes lineGlow {
    0%, 100% {
        box-shadow: 0 2px 4px rgba(59, 130, 246, 0.2);
    }
    50% {
        box-shadow: 0 2px 8px rgba(59, 130, 246, 0.4);
    }
}

.tree li::before,
.tree li::after {
    animation: lineGlow 3s ease-in-out infinite;
}

/* ===== RESPONSIVE DESIGN OPTIMISÉ ===== */

/* Grands écrans */
@media (min-width: 1400px) {
    .tree-container {
        padding: 80px 40px;
    }

    .org-card {
        min-width: 240px !important;
        max-width: 300px !important;
    }
}

/* Tablettes */
@media (max-width: 1200px) {
    .tree li {
        padding: 20px 12px 0 12px;
    }

    .org-card {
        min-width: 200px !important;
        max-width: 240px !important;
        padding: 16px !important;
    }

    .tree > li > .org-card {
        min-width: 240px !important;
    }
}

/* Tablettes moyennes */
@media (max-width: 992px) {
    .tree,
    .tree ul {
        display: block;
        width: 100%;
    }

    .tree li {
        display: block;
        padding: 20px 0;
        margin: 0 auto;
    }

    /* Suppression des lignes de connexion sur mobile */
    .tree li::before,
    .tree li::after,
    .tree li .org-card::before {
        display: none !important;
    }

    .tree-container {
        padding: 30px 15px;
        background: linear-gradient(135deg, #f8fafc 0%, #ffffff 100%);
    }

    .org-card {
        min-width: 240px !important;
        max-width: 320px !important;
        margin: 0 auto 20px !important;
    }

    .tree > li > .org-card {
        min-width: 260px !important;
    }

    /* Alignement vertical des cartes sur mobile */
    .tree li .org-card {
        display: block;
        margin-left: auto;
        margin-right: auto;
    }
}

/* Petits mobiles */
@media (max-width: 576px) {
    .tree-container {
        padding: 20px 10px;
    }

    .org-card {
        min-width: 180px !important;
        max-width: 300px !important;
        padding: 14px !important;
    }

    .tree > li > .org-card {
        min-width: 220px !important;
        padding: 18px !important;
    }

    .org-card a {
        font-size: 14px;
    }

    .org-card .badge {
        font-size: 11px;
        padding: 5px 10px;
    }

    .org-card .text-gray-600,
    .org-card .text-gray-500 {
        font-size: 12px;
    }

    .org-card .symbol {
        width: 50px !important;
        height: 50px !important;
    }

    .org-card .symbol img {
        border-width: 3px;
    }
}

/* ===== UTILITAIRES AMÉLIORÉS ===== */

/* Scrollbar personnalisée pour le container */
.tree-container::-webkit-scrollbar {
    height: 12px;
}

.tree-container::-webkit-scrollbar-track {
    background: linear-gradient(135deg, #f1f5f9, #e2e8f0);
    border-radius: 6px;
}

.tree-container::-webkit-scrollbar-thumb {
    background: linear-gradient(135deg, #3b82f6, #2563eb);
    border-radius: 6px;
    border: 2px solid #f1f5f9;
}

.tree-container::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(135deg, #2563eb, #1d4ed8);
}

/* Mode impression optimisé */
@media print {
    .tree-container {
        overflow: visible;
        background: white;
        padding: 20px;
        box-shadow: none;
    }

    .tree li .org-card {
        box-shadow: none;
        border: 2px solid #000;
        page-break-inside: avoid;
        background: white !important;
    }

    .tree li .org-card:hover {
        transform: none;
        box-shadow: none;
    }

    .tree li {
        animation: none;
    }

    .tree > li > .org-card {
        animation: none;
    }

    .tree li::before,
    .tree li::after {
        animation: none;
        border-color: #000 !important;
    }

    /* Suppression des effets de survol en impression */
    .tree li .org-card::after,
    .tree li .org-card .symbol::before,
    .org-card a::after {
        display: none;
    }
}

/* ===== ACCESSIBILITÉ AMÉLIORÉE ===== */

/* Focus pour la navigation au clavier */
.org-card a:focus {
    outline: 4px solid #3b82f6;
    outline-offset: 4px;
    border-radius: 6px;
}

.org-card a:focus-visible {
    outline: 4px solid #3b82f6;
    outline-offset: 4px;
}

/* Amélioration du contraste pour l'accessibilité */
@media (prefers-contrast: high) {
    .org-card {
        border-width: 4px;
    }

    .org-card a {
        font-weight: 800;
    }

    .tree li::before,
    .tree li::after,
    .tree li .org-card::before {
        border-width: 4px;
    }
}

/* Réduction des animations pour les utilisateurs qui préfèrent */
@media (prefers-reduced-motion: reduce) {
    .tree li {
        animation: none;
    }

    .tree li .org-card {
        transition: none;
    }

    .tree > li > .org-card {
        animation: none;
    }

    .tree li::before,
    .tree li::after {
        animation: none;
    }

    .org-card .symbol img {
        transition: none;
    }

    .org-card a::after {
        transition: none;
    }

    .org-card .badge {
        transition: none;
    }

    .org-card::after {
        display: none;
    }
}

/* Mode sombre automatique */
@media (prefers-color-scheme: dark) {
    .tree-container {
        background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
    }

    .org-card {
        background: #1e293b !important;
        border-color: #334155 !important;
        color: #f1f5f9;
    }

    .org-card a {
        color: #f1f5f9;
    }

    .org-card .text-gray-600 {
        color: #cbd5e1;
    }

    .org-card .text-gray-500 {
        color: #94a3b8;
        border-top-color: #334155;
    }

    .tree li::before,
    .tree li::after,
    .tree li .org-card::before {
        border-color: #3b82f6;
    }
}

/* ===== BACKDROP BLUR (pour le hero) ===== */
.backdrop-blur {
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

/* ===== MEMBER CARD HOVER (pour les cartes de présentation) ===== */
.member-card-hover {
    transition: all 0.3s ease;
}

.member-card-hover:hover {
    transform: translateY(-10px);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1) !important;
}
