/* ============================================
   Custom Chart Legend for Line Isolation Feature
   Created: 2025-11-19
   ============================================ */

.chart-legend-container {
    margin-top: 4px;
}

.chart-legend-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    cursor: pointer;
    transition: background 0.2s ease;
    border-radius: 8px;
}

.chart-legend-header:hover {
    background: #e0f2fe;
}

.chart-legend-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    font-weight: 600;
    color: #374151;
    flex: 1;
}

.chart-legend-title .toggle-icon {
    transition: transform 0.2s ease;
    color: #3b82f6;
    font-size: 20px;
}

.chart-legend-title .toggle-icon.expanded {
    transform: rotate(180deg);
}



.chart-legend-items {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 8px;
    max-height: 500px;
    overflow-y: auto;
    margin-top: 12px;
    transition: max-height 0.3s ease, opacity 0.3s ease;
    /* Hide scrollbar for Chrome, Safari and Opera */
    scrollbar-width: none; /* Firefox */
    -ms-overflow-style: none; /* IE and Edge */
}

.chart-legend-items::-webkit-scrollbar {
    display: none; /* Chrome, Safari, Opera */
}

.chart-legend-items.collapsed {
    display: none;
}

.chart-legend-item {
    display: flex;
    align-items: center;
    padding: 6px 10px;
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
    user-select: none;
}

.chart-legend-item:hover {
    background: #f3f4f6;
    border-color: #d1d5db;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.chart-legend-item.isolated {
    background: #dbeafe;
    border-color: #3b82f6;
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.1);
}

.chart-legend-item.hidden {
    opacity: 0.4;
    background: #f9fafb;
}

.chart-legend-item.hidden:hover {
    opacity: 0.6;
}

.legend-color-indicator {
    width: 12px;
    height: 12px;
    border-radius: 3px;
    margin-right: 8px;
    flex-shrink: 0;
    border: 1px solid rgba(0, 0, 0, 0.1);
}

.legend-domain-name {
    font-size: 13px;
    color: #374151;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
}

.chart-legend-item.hidden .legend-domain-name {
    color: #9ca3af;
}

/* Mobile responsive */
@media (max-width: 768px) {
    .chart-legend-items {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    }
    
    .legend-domain-name {
        font-size: 12px;
    }
    
    .chart-legend-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }
    
    .chart-legend-actions {
        width: 100%;
        justify-content: flex-end;
    }
}
