/**
 * Enhanced Organization Chart Styles
 * Improved visual hierarchy and image handling
 */

/* Professional gradient backgrounds with better contrast */
.org-chart-wrapper {
    background: linear-gradient(145deg, #1e3c72 0%, #2a5298 50%, #667eea 100%);
    position: relative;
}

.org-chart-wrapper::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: 
        radial-gradient(ellipse at top left, rgba(255,255,255,0.1) 0%, transparent 50%),
        radial-gradient(ellipse at bottom right, rgba(255,255,255,0.05) 0%, transparent 50%);
    pointer-events: none;
    z-index: 1;
}

/* Enhanced node containers */
.org-level {
    position: relative;
    z-index: 2;
}

/* CEO level styling */
.ceo-level { 
    justify-content: center; 
    margin-bottom: 3rem;
}

/* Directors level styling */
.directors-level { 
    justify-content: space-around; 
    max-width: 600px; 
    margin: 0 auto 3rem; 
}

/* GM Level - Single horizontal row */
.gm-level { 
    justify-content: center;
    align-items: flex-start;
    gap: 1.2rem;
    flex-wrap: wrap;
    max-width: 1400px;
    margin: 0 auto;
}

/* Ensure all GM nodes including Staff Utama are same size */
.gm-level .org-node {
    flex: 0 0 auto;
    width: 220px;
    min-width: 220px;
    max-width: 220px;
}

/* CEO node enhanced styling */
.ceo-node {
    background: linear-gradient(145deg, #1a202c 0%, #2d3748 50%, #4a5568 100%);
    border: none;
    box-shadow: 
        0 25px 50px rgba(0,0,0,0.3),
        0 0 0 1px rgba(255,255,255,0.1) inset,
        0 0 100px rgba(72, 187, 120, 0.2);
    transform: translateZ(0);
}

.ceo-node::before {
    content: '';
    position: absolute;
    top: -2px;
    left: -2px;
    right: -2px;
    bottom: -2px;
    background: linear-gradient(145deg, #48bb78, #38a169, #2f855a);
    border-radius: inherit;
    z-index: -1;
    opacity: 0.8;
}

/* Director nodes styling */
.director-node {
    background: linear-gradient(145deg, #ed8936 0%, #dd6b20 50%, #c05621 100%);
    box-shadow: 
        0 20px 40px rgba(237, 137, 54, 0.3),
        0 0 0 1px rgba(255,255,255,0.1) inset;
}

/* GM nodes styling */
.gm-node {
    background: linear-gradient(145deg, #3182ce 0%, #2b77cb 50%, #2c5aa0 100%);
    box-shadow: 
        0 15px 35px rgba(49, 130, 206, 0.25),
        0 0 0 1px rgba(255,255,255,0.1) inset;
}

/* Special staff styling - now consistent with other GMs */
.staff-utama {
    background: linear-gradient(145deg, #38a169 0%, #2f855a 50%, #276749 100%);
    box-shadow: 
        0 15px 35px rgba(56, 161, 105, 0.25),
        0 0 0 1px rgba(255,255,255,0.1) inset;
    border-top: 5px solid #48bb78;
}

/* Ensure Staff Utama is same height as other GM nodes */
.staff-utama .node-content {
    min-height: auto;
}

.staff-utama .node-info h5 {
    font-size: 1rem;
    font-weight: 600;
}

.staff-utama .node-info p {
    font-size: 0.9rem;
    opacity: 0.95;
}

/* Enhanced avatar styling */
.node-avatar {
    position: relative;
    margin-bottom: 1.5rem;
}

.node-avatar img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
    border: 4px solid rgba(255,255,255,0.9);
    box-shadow: 
        0 10px 30px rgba(0,0,0,0.2),
        0 0 0 2px rgba(255,255,255,0.1);
    transition: all 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    background: linear-gradient(145deg, #f7fafc, #edf2f7);
}

/* Hover effects for avatars */
.org-node:hover .node-avatar img {
    transform: scale(1.1) rotate(2deg);
    border-color: rgba(255,255,255,1);
    box-shadow: 
        0 20px 50px rgba(0,0,0,0.3),
        0 0 0 4px rgba(255,255,255,0.2),
        0 0 50px rgba(72, 187, 120, 0.4);
}

/* Enhanced status indicator */
.status-indicator {
    background: linear-gradient(145deg, #48bb78, #38a169);
    box-shadow: 
        0 4px 8px rgba(72, 187, 120, 0.3),
        0 0 0 3px rgba(255,255,255,0.9);
    animation: statusPulse 3s ease-in-out infinite;
}

@keyframes statusPulse {
    0%, 100% { 
        transform: scale(1);
        box-shadow: 
            0 4px 8px rgba(72, 187, 120, 0.3),
            0 0 0 3px rgba(255,255,255,0.9),
            0 0 0 0 rgba(72, 187, 120, 0.7);
    }
    50% { 
        transform: scale(1.1);
        box-shadow: 
            0 4px 8px rgba(72, 187, 120, 0.4),
            0 0 0 3px rgba(255,255,255,1),
            0 0 0 8px rgba(72, 187, 120, 0.3);
    }
}

/* Better text rendering */
.node-name {
    text-shadow: 0 2px 4px rgba(0,0,0,0.1);
    font-weight: 700;
    letter-spacing: 0.5px;
}

.node-title {
    text-shadow: 0 1px 2px rgba(0,0,0,0.1);
    font-weight: 500;
    opacity: 0.95;
}

/* Enhanced team section styling */
.team-details-section {
    background: linear-gradient(145deg, #ffffff 0%, #f8fafc 100%);
    border: 1px solid rgba(0,0,0,0.05);
}

.team-card {
    border: 1px solid rgba(0,0,0,0.08);
    background: linear-gradient(145deg, #ffffff 0%, #f9fafb 100%);
    transition: all 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.team-card:hover {
    border-color: rgba(66, 153, 225, 0.3);
    background: linear-gradient(145deg, #ffffff 0%, #f7fafc 100%);
    box-shadow: 
        0 20px 40px rgba(0,0,0,0.1),
        0 0 0 1px rgba(66, 153, 225, 0.1) inset;
}

/* Member items enhancement */
.member-item {
    transition: all 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    border: 1px solid rgba(0,0,0,0.05);
}

.member-item:hover {
    background: linear-gradient(145deg, #f8fafc 0%, #edf2f7 100%);
    border-color: rgba(66, 153, 225, 0.2);
    box-shadow: 
        0 8px 25px rgba(0,0,0,0.08),
        0 0 0 1px rgba(66, 153, 225, 0.1) inset;
}

.member-item img {
    border: 2px solid rgba(0,0,0,0.08);
    transition: all 0.3s ease;
    background: linear-gradient(145deg, #f7fafc, #edf2f7);
}

.member-item:hover img {
    border-color: rgba(66, 153, 225, 0.4);
    box-shadow: 0 4px 15px rgba(66, 153, 225, 0.2);
}

/* Connection lines enhancement */
.connection-line-dynamic {
    background: linear-gradient(90deg, 
        rgba(255,255,255,0.9) 0%,
        rgba(255,255,255,0.7) 50%,
        rgba(255,255,255,0.9) 100%);
    box-shadow: 0 0 10px rgba(255,255,255,0.3);
    opacity: 0.8;
    transition: opacity 0.3s ease;
}

.connection-line-dynamic.dashed {
    background: none;
    border-top: 2px dashed rgba(255,255,255,0.8);
    border-image: linear-gradient(90deg, 
        rgba(255,255,255,0.9),
        rgba(255,255,255,0.6),
        rgba(255,255,255,0.9)) 1;
}

/* Improved responsive behavior */
@media (max-width: 1400px) {
    .gm-level {
        justify-content: center;
        gap: 1rem;
    }
    
    .gm-level .org-node {
        width: 200px;
        min-width: 200px;
        max-width: 200px;
    }
}

@media (max-width: 1200px) {
    .directors-level {
        flex-direction: column;
        align-items: center;
        gap: 2rem;
    }
    
    .gm-level {
        justify-content: center;
        gap: 1.5rem;
    }
    
    .gm-level .org-node {
        width: 190px;
        min-width: 190px;
        max-width: 190px;
    }
}

@media (max-width: 992px) {
    .org-chart-wrapper {
        padding: 3rem 2rem;
    }
    
    .gm-level {
        flex-direction: column;
        align-items: center;
        gap: 2rem;
    }
    
    .gm-level .org-node {
        width: 100%;
        max-width: 280px;
        min-width: auto;
    }
}

@media (max-width: 768px) {
    .org-chart-wrapper {
        padding: 2rem 1rem;
        background: linear-gradient(145deg, #2a5298 0%, #667eea 100%);
    }
    
    .org-node {
        padding: 1.5rem;
        min-width: 180px;
        max-width: 240px;
    }
    
    .node-avatar {
        width: 80px;
        height: 80px;
        margin-bottom: 1rem;
    }
    
    .node-name {
        font-size: 0.95rem;
    }
    
    .node-title {
        font-size: 0.85rem;
    }
}

/* Loading states for images */
.node-avatar img[data-loading="true"] {
    opacity: 0.5;
    filter: blur(2px);
}

.node-avatar img[data-loaded="true"] {
    opacity: 1;
    filter: none;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .org-node {
        border: 2px solid currentColor;
    }
    
    .node-avatar img {
        border-width: 3px;
    }
    
    .connection-line-dynamic {
        background: currentColor;
        opacity: 1;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    .org-node,
    .member-item,
    .team-card,
    .node-avatar img {
        transition: none;
    }
    
    .status-indicator {
        animation: none;
    }
    
    .org-level {
        animation: none;
    }
}
